summaryrefslogtreecommitdiff
path: root/test.sh
diff options
context:
space:
mode:
authorJames Murty <james@murty.co>2014-05-24 21:34:01 +0100
committerJames Murty <james@murty.co>2014-05-24 21:34:01 +0100
commit6ca25da37333bbffe10cbb837c0002fd250931b1 (patch)
tree3dd6604749b99eac3a778724db114362230cfcd5 /test.sh
parent456d22cb3c7ba60e15d5d0f7de771c2acf573481 (diff)
downloadgit-fat-6ca25da37333bbffe10cbb837c0002fd250931b1.tar.gz
Add `verify` command to check git-fat object data matches hash filename.
While experimenting with using the --partial option with rsync I managed to corrupt one of my git-fat objects by truncating it. This caused some behaviour in git-fat which seemed odd until I worked out what had happened: it would check out the truncated data but git would see the file as modified and show the changed hash in a diff, while a re-checkout did not reset the file to its original data/hash. This commit adds a `verify` command that cross-checks git-fat object file names (the original SHA1) against the SHA1 of the object's actual data and prints any mismatches. So you can quickly find any dubious objects and decide what to do about them. A better solution might be to calcuate and verify objects' data hash during filter-smudge/checkout though this would likely hurt performance.
Diffstat (limited to 'test.sh')
-rwxr-xr-xtest.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/test.sh b/test.sh
index e9c9163..92f2db4 100755
--- a/test.sh
+++ b/test.sh
@@ -38,3 +38,11 @@ git commit -m'add d with normal content'
rm d
git fat pull
+# Check verify command finds corrupt object
+mv .git/fat/objects/6ecec2e21d3033e7ba53e2db63f69dbd3a011fa8 \
+ .git/fat/objects/6ecec2e21d3033e7ba53e2db63f69dbd3a011fa8.bak
+echo "Not the right data" > .git/fat/objects/6ecec2e21d3033e7ba53e2db63f69dbd3a011fa8
+git fat verify && true
+if [ $? -eq 0 ]; then echo "Verify did not detect invalid object"; exit 1; fi
+mv .git/fat/objects/6ecec2e21d3033e7ba53e2db63f69dbd3a011fa8.bak \
+ .git/fat/objects/6ecec2e21d3033e7ba53e2db63f69dbd3a011fa8