commit 58e181816513e740f21b579b450ac14c77aaa2c4
parent bcbf37f5f3db5397fdef89a5b51e5e8fd558fe77
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Sun, 23 Jun 2024 15:27:36 +0200
Complete rewriting of the wad_objects subcommand
It lists the digest WAD objects of the current workong tree. This
reimplementation makes it more elegant and concise by using the right
git rev-list options, thus avoiding several now unnecessary
post-processings of its output.
Diffstat:
1 file changed, 5 insertions(+), 15 deletions(-)
diff --git a/git-wad b/git-wad
@@ -118,23 +118,13 @@ wad_objects() # [-1a]
done
# The following command line can be translated as follows:
- # Print the IDs of all objects in "${rev}" (i.e. HEAD or --all)
- # | Get their hash
- # | Print object information of these hashes
- # | Keep only objects that are blobs
- # | Get their hash
- # | Print information _and_ contents of these hashes
- # | Keep only the contents of objects corresponding to WAD files
- # | And finally, extract the corresponding WAD object digest
+ # Print the hash (aka objectname) of all blobs in HEAD
+ # | Print blob content
+ # | Extract and print only the digest of WAD objects
# shellcheck disable=SC2086 # ${rev} can have several arguments
- git rev-list --objects ${rev} \
- | cut -d' ' -f1 \
- | git cat-file --batch-check \
- | sed -n "/^[a-z0-9]\{40\} blob [0-9]\{1,\}$/p" \
- | cut -d' ' -f1 \
+ git rev-list --objects --no-object-names --filter=object:type=blob ${rev} \
| git cat-file --batch \
- | sed -n "/^${GIT_WAD_HEADER} [0-9a-z]\{64\} [0-9]\{1,\}$/p" \
- | sed "s/^${GIT_WAD_HEADER} \([0-9a-z]\{64\}\) [0-9]\{1,\}$/\1/"
+ | sed -n "s/^${GIT_WAD_HEADER} \([0-9a-z]\{64\}\) [0-9]\{1,\}$/\1/p"
}
# List all stored WAD objects of the working tree. These may be WAD