summaryrefslogtreecommitdiff
path: root/t/t3210-pack-refs.sh
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2017-07-01 18:31:07 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-07-03 17:01:57 (GMT)
commit02a1a42056bd2e34f872d61e2ec7aa00dd43422b (patch)
tree7fdc493d61e15d3fbb68749642ef1835af3d1085 /t/t3210-pack-refs.sh
parente5cc7d7d2bf2fbb3dfba81fe0c0c2981607fbc84 (diff)
downloadgit-02a1a42056bd2e34f872d61e2ec7aa00dd43422b.zip
git-02a1a42056bd2e34f872d61e2ec7aa00dd43422b.tar.gz
git-02a1a42056bd2e34f872d61e2ec7aa00dd43422b.tar.bz2
t3210: add some tests of bogus packed-refs file contents
If `packed-refs` contains indecipherable lines, we should emit an error and quit rather than just skipping the lines. Unfortunately, we currently do the latter. Add some failing tests demonstrating the problem. This will be fixed in the next commit. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t3210-pack-refs.sh')
-rwxr-xr-xt/t3210-pack-refs.sh27
1 files changed, 27 insertions, 0 deletions
diff --git a/t/t3210-pack-refs.sh b/t/t3210-pack-refs.sh
index 9b182a0..4b65836 100755
--- a/t/t3210-pack-refs.sh
+++ b/t/t3210-pack-refs.sh
@@ -194,6 +194,33 @@ test_expect_success 'notice d/f conflict with existing ref' '
test_must_fail git branch foo/bar/baz/lots/of/extra/components
'
+test_expect_failure 'reject packed-refs with unterminated line' '
+ cp .git/packed-refs .git/packed-refs.bak &&
+ test_when_finished "mv .git/packed-refs.bak .git/packed-refs" &&
+ printf "%s" "$HEAD refs/zzzzz" >>.git/packed-refs &&
+ echo "fatal: unterminated line in .git/packed-refs: $HEAD refs/zzzzz" >expected_err &&
+ test_must_fail git for-each-ref >out 2>err &&
+ test_cmp expected_err err
+'
+
+test_expect_failure 'reject packed-refs containing junk' '
+ cp .git/packed-refs .git/packed-refs.bak &&
+ test_when_finished "mv .git/packed-refs.bak .git/packed-refs" &&
+ printf "%s\n" "bogus content" >>.git/packed-refs &&
+ echo "fatal: unexpected line in .git/packed-refs: bogus content" >expected_err &&
+ test_must_fail git for-each-ref >out 2>err &&
+ test_cmp expected_err err
+'
+
+test_expect_failure 'reject packed-refs with a short SHA-1' '
+ cp .git/packed-refs .git/packed-refs.bak &&
+ test_when_finished "mv .git/packed-refs.bak .git/packed-refs" &&
+ printf "%.7s %s\n" $HEAD refs/zzzzz >>.git/packed-refs &&
+ printf "fatal: unexpected line in .git/packed-refs: %.7s %s\n" $HEAD refs/zzzzz >expected_err &&
+ test_must_fail git for-each-ref >out 2>err &&
+ test_cmp expected_err err
+'
+
test_expect_success 'timeout if packed-refs.lock exists' '
LOCK=.git/packed-refs.lock &&
>"$LOCK" &&