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 8809597920e2d797811e2e62b6786c87a0a586ad
parent 728fdeb511ffa931e4938bbadd741ffe40a92128
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Sun, 26 May 2024 20:59:12 +0200

Optimization of the status subcommand

Complete rewrite of the internal function that lists the git hashes of
WAD blobs. Not only is it more elegant, it's also more concise and
efficient, reducing its execution time by up to 60 times and the total
time of the status subcommand by more than 3.5 times.

Diffstat:
Mgit-wad | 22+++++++---------------
1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/git-wad b/git-wad @@ -73,23 +73,15 @@ encode() # digest, size wad_hashes() { # Regular expression of a WAD - wad_re="^${GIT_WAD_HEADER} [0-9a-z]\{64\} [0-9]\{1,\}$" + wad_re="${GIT_WAD_HEADER} [0-9a-z]\{64\} [0-9]\{1,\}" # The following command line can be translated as follows: - # Print the IDs of all objects in HEAD - # | Get their hash - # | Print object information of these hashes - # | Keep only objects that are blobs - # | Get their hash - # | Keep only the hash of blob objects that are WADs - git rev-list --objects HEAD -1 \ - | cut -d' ' -f1 \ - | git cat-file --batch-check \ - | sed -n "/[a-z0-9]\{40\} blob [0-9]\{1,\}/p" \ - | cut -d' ' -f1 \ - | xargs -I{} sh -c \ - " git cat-file blob {} \ - | sed -e '/${wad_re}/!d' -e 's/^.\{1,\}$/{}\n/'" + # Print the hash (aka objectname) of all blobs in HEAD + # | Print blob content preceeded by its hash + # | Print the blob hash if the following line indicates a WAD + git rev-list --objects --no-object-names --filter=object:type=blob HEAD -1 \ + | git cat-file --batch='%(objectname)' \ + | sed -n "/^[0-9a-z]\{40\}$/{N;s/^\([0-9a-z]\{40\}\)\n${wad_re}$/\1/p}" } # List paths of WAD file from the current commit