From e6405461122d9ab2454b8397d1a1076a4fcf9a6a Mon Sep 17 00:00:00 2001 From: Michael Lohmann Date: Tue, 16 Jan 2024 22:45:22 +0100 Subject: [PATCH] redeem-nuggit: inline commit_nuggit function This is done to make reverse engineering a bit harder --- src/redeem-nuggit.sh | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/redeem-nuggit.sh b/src/redeem-nuggit.sh index bf0aedf..ccc1727 100755 --- a/src/redeem-nuggit.sh +++ b/src/redeem-nuggit.sh @@ -63,20 +63,18 @@ git cat-file -p "NUGGIT_DESCRIPTION_TREE:$(echo "$nuggit" | git hash-object --st exit 1 } -commit_nuggit() { # Manage our own little "branch" manually - local tree - # get the tree object from the last commit in nuggits - tree="$(git rev-parse "nuggits^{tree}")" - # get the description from our "nuggit tree object" from the folder with - # the hash of the nuggit and inside of that the description file - description="$(git cat-file -p "NUGGIT_DESCRIPTION_TREE:$(echo "$1" | git hash-object --stdin)/description")" - # add an empty commit with the parent being nuggits and "reset nuggits to that new commit" - git commit-tree "$tree" -p "$(cat .git/nuggits)" -m "$(printf "%s\n\n" "$nuggit" "$description")" > .git/nuggits.bak - # We can't directly pipe it into the file, because it will empty it before we read it... - # Therefore write it into a backup file and then replace it - mv .git/nuggits.bak .git/nuggits -} -commit_nuggit "$nuggit" +# Manage our own little "branch" manually + +# get the tree object from the last commit in nuggits +tree="$(git rev-parse "nuggits^{tree}")" +# get the description from our "nuggit tree object" from the folder with +# the hash of the nuggit and inside of that the description file +description="$(git cat-file -p "NUGGIT_DESCRIPTION_TREE:$(echo "$nuggit" | git hash-object --stdin)/description")" +# add an empty commit with the parent being nuggits and "reset nuggits to that new commit" +git commit-tree "$tree" -p "$(cat .git/nuggits)" -m "$(printf "%s\n\n" "$nuggit" "$description")" > .git/nuggits.bak +# We can't directly pipe it into the file, because it will empty it before we read it... +# Therefore write it into a backup file and then replace it +mv .git/nuggits.bak .git/nuggits # update our "branch" # Print some stats for the player, so they know if they still need to look for other nuggits echo "Number of redeemed nuggits: $redeemed_nuggits of NUMBER_OF_NUGGITS"