git-wad

Manage files via git but not their content
git clone git://git.meso-star.fr/git-wad.git
Log | Files | Refs | README | LICENSE

commit 950ad9e21b18129bfdea2fc9cf6a30778469b2b4
parent 77e2c79067ced674f82ea703df3da74e645965cf
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sat, 25 Nov 2023 19:19:13 +0100

Deletion of the decoding help function

The function returned a string containing the digest and size of the WAD
object, unless the submitted stream was not a WAD file. In the latter
case, it printed the input stream as is and returned an error. The
caller then had to detect this error so as not to interpret the result
as WAD content. This was particularly horrendous, as in this situation,
the string returned contained the entire file, which then had to be
printed by the caller. To avoid this unnecessary intermediate copy, we
perform the check directly in the smudge filters, and in so doing render
the decoding function useless that is thus remove by this commit.

Diffstat:
Mgit-wad | 20++++----------------
1 file changed, 4 insertions(+), 16 deletions(-)

diff --git a/git-wad b/git-wad @@ -48,21 +48,9 @@ encode() # digest, size printf "%s %s %d" "${GIT_WAD_HEADER}" "$1" "$2" } -decode() # stdin -{ - header_size="$(sizeof_header)" - header="$(dd ibs=1 count="${header_size}" 2> /dev/null)" - - if [ "${header}" = "${GIT_WAD_HEADER}" ]; then - # Remove the space after the header and before the digest - cat - | sed "1s/^ //d" - - else # It is not a WAD - printf "%s" "${header}" - cat - - fi -} - +######################################################################## +# Git filters +######################################################################## clean() # stdin { tmpfile="$(mktemp -p "${GIT_WAD_OBJDIR}")" @@ -95,7 +83,7 @@ clean() # stdin encode "${digest}" "${size}" } -smudge() +smudge() # stdin { header_size="$(sizeof_header)" header="$(dd ibs=1 count="${header_size}")"