From b53a9b1c56d8c300685c6512f2ea351ba8fd8620 Mon Sep 17 00:00:00 2001 From: Michael Lohmann Date: Tue, 16 Jan 2024 16:34:06 +0100 Subject: [PATCH] store credits in tree object This makes sure that the text does not show up directly when running git fsck --dangling | cut -d " " -f3 | xargs -n 1 git cat-file -p --- build.sh | 6 ++++-- src/redeem-nuggit.sh | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index c8dd95d..26e8ee9 100755 --- a/build.sh +++ b/build.sh @@ -57,10 +57,12 @@ Have a free nuggit!" > .git/nuggits . "$DOCDIR/store_nuggits.sh" # register the nuggits in our "git database" (aka some loose objects) ALMOST_CREDITS_HASH="$(git hash-object -w "$DOCDIR/almost_credits.txt")" # for the final credits do a little rot13, just to make life a bit harder if anyone e.g. greps through the loose objects... -CREDITS_HASH="$(tr 'A-Za-z' 'N-ZA-Mn-za-m' < "$DOCDIR/credits.txt" | git hash-object -w --stdin)" +FINAL_CREDITS_HASH="$(tr 'A-Za-z' 'N-ZA-Mn-za-m' < "$DOCDIR/credits.txt" | git hash-object -w --stdin)" +CREDITS_TREE="$(printf "100644 blob %s almost\n100644 blob %s final\n" "$ALMOST_CREDITS_HASH" "$FINAL_CREDITS_HASH" | git mktree)" + NUMBER_OF_NUGGITS="$(wc -l <"$DOCDIR/nuggits")" -replace NUMBER_OF_NUGGITS ALMOST_CREDITS_HASH CREDITS_HASH NUGGIT_DESCRIPTION_TREE "$DOCDIR/redeem-nuggit.sh" > ./.git/redeem.nuggit +replace NUMBER_OF_NUGGITS CREDITS_TREE NUGGIT_DESCRIPTION_TREE "$DOCDIR/redeem-nuggit.sh" > ./.git/redeem.nuggit chmod a=rx ./.git/redeem.nuggit # ------------------------------------------------------------------------------------------- # diff --git a/src/redeem-nuggit.sh b/src/redeem-nuggit.sh index ea5c9c6..543f90e 100755 --- a/src/redeem-nuggit.sh +++ b/src/redeem-nuggit.sh @@ -27,11 +27,11 @@ git cat-file -e "$(already_redeemed "$nuggit" | git hash-object --stdin)" 2>/dev redeemed_nuggits="$(git rev-list --count nuggits)" redeemed_nuggits=$((redeemed_nuggits - already_redeemed)) -[ "$redeemed_nuggits" -ne $((NUMBER_OF_NUGGITS - 1 )) ] || git cat-file -p ALMOST_CREDITS_HASH; +[ "$redeemed_nuggits" -ne $((NUMBER_OF_NUGGITS - 1 )) ] || git cat-file -p CREDITS_TREE:almost; [ "$redeemed_nuggits" -ne $(( NUMBER_OF_NUGGITS + 0 )) ] || { git cat-file -e "$(git hash-object --stdin <<< "$((NUMBER_OF_NUGGITS - 1))" | git hash-object --stdin)" 2>/dev/null || { echo Noughty boy!; exit 1; } - git cat-file -p CREDITS_HASH | tr 'A-Za-z' 'N-ZA-Mn-za-m'; + git cat-file -p CREDITS_TREE:final | tr 'A-Za-z' 'N-ZA-Mn-za-m'; } git cat-file -p "$(already_redeemed "$nuggit" | git hash-object --stdin)" 2>/dev/null && exit