github.com/saracen/git-lfs@v2.5.2+incompatible/t/t-malformed-pointers.sh (about) 1 #!/usr/bin/env bash 2 3 . "$(dirname "$0")/testlib.sh" 4 5 begin_test "malformed pointers" 6 ( 7 set -e 8 9 reponame="malformed-pointers" 10 setup_remote_repo "$reponame" 11 clone_repo "$reponame" "$reponame" 12 13 git lfs track "*.dat" 14 git add .gitattributes 15 git commit -m "initial commit" 16 17 base64 /dev/urandom | head -c 1023 > malformed_small.dat 18 base64 /dev/urandom | head -c 1024 > malformed_exact.dat 19 base64 /dev/urandom | head -c 1025 > malformed_large.dat 20 base64 /dev/urandom | head -c 1048576 > malformed_xxl.dat 21 22 git \ 23 -c "filter.lfs.process=" \ 24 -c "filter.lfs.clean=cat" \ 25 -c "filter.lfs.required=false" \ 26 add *.dat 27 git commit -m "add malformed pointer" 28 29 git push origin master 30 31 pushd .. >/dev/null 32 clone_repo "$reponame" "$reponame-assert" 33 34 grep "malformed_small.dat" clone.log 35 grep "malformed_exact.dat" clone.log 36 grep "malformed_large.dat" clone.log 37 grep "malformed_xxl.dat" clone.log 38 39 expected_small="$(cat ../$reponame/malformed_small.dat)" 40 expected_exact="$(cat ../$reponame/malformed_exact.dat)" 41 expected_large="$(cat ../$reponame/malformed_large.dat)" 42 expected_xxl="$(cat ../$reponame/malformed_xxl.dat)" 43 44 actual_small="$(cat malformed_small.dat)" 45 actual_exact="$(cat malformed_exact.dat)" 46 actual_large="$(cat malformed_large.dat)" 47 actual_xxl="$(cat malformed_xxl.dat)" 48 49 [ "$expected_small" = "$actual_small" ] 50 [ "$expected_exact" = "$actual_exact" ] 51 [ "$expected_large" = "$actual_large" ] 52 [ "$expected_xxl" = "$actual_xxl" ] 53 popd >/dev/null 54 ) 55 end_test 56 57 begin_test "empty pointers" 58 ( 59 set -e 60 61 reponame="empty-pointers" 62 setup_remote_repo "$reponame" 63 clone_repo "$reponame" "$reponame" 64 65 git lfs track "*.dat" 66 git add .gitattributes 67 git commit -m "initial commit" 68 69 touch empty.dat 70 71 git \ 72 -c "filter.lfs.process=" \ 73 -c "filter.lfs.clean=cat" \ 74 -c "filter.lfs.required=false" \ 75 add empty.dat 76 git commit -m "add empty pointer" 77 78 [ "0" -eq "$(git cat-file -p :empty.dat | wc -c)" ] 79 [ "0" -eq "$(wc -c < empty.dat)" ] 80 81 git push origin master 82 83 pushd .. >/dev/null 84 clone_repo "$reponame" "$reponame-assert" 85 86 [ "0" -eq "$(grep -c "empty.dat" clone.log)" ] 87 88 [ "0" -eq "$(git cat-file -p :empty.dat | wc -c)" ] 89 [ "0" -eq "$(wc -c < empty.dat)" ] 90 popd >/dev/null 91 ) 92 end_test