reftable/stack: expose option to disable auto-compaction
[git.git] / t / t6301-for-each-ref-errors.sh
blob83b8a19d94176dcf66d2aca1d8a4b9519ee020fe
1 #!/bin/sh
3 test_description='for-each-ref errors for broken refs'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 ZEROS=$ZERO_OID
10 test_expect_success setup '
11 MISSING=$(test_oid deadbeef) &&
12 git commit --allow-empty -m "Initial" &&
13 git tag testtag &&
14 git for-each-ref >full-list &&
15 git for-each-ref --format="%(objectname) %(refname)" >brief-list
18 test_expect_success REFFILES 'Broken refs are reported correctly' '
19 r=refs/heads/bogus &&
20 : >.git/$r &&
21 test_when_finished "rm -f .git/$r" &&
22 echo "warning: ignoring broken ref $r" >broken-err &&
23 git for-each-ref >out 2>err &&
24 test_cmp full-list out &&
25 test_cmp broken-err err
28 test_expect_success REFFILES 'NULL_SHA1 refs are reported correctly' '
29 r=refs/heads/zeros &&
30 echo $ZEROS >.git/$r &&
31 test_when_finished "rm -f .git/$r" &&
32 echo "warning: ignoring broken ref $r" >zeros-err &&
33 git for-each-ref >out 2>err &&
34 test_cmp full-list out &&
35 test_cmp zeros-err err &&
36 git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
37 test_cmp brief-list brief-out &&
38 test_cmp zeros-err brief-err
41 test_expect_success 'Missing objects are reported correctly' '
42 test_when_finished "git update-ref -d refs/heads/missing" &&
43 test-tool ref-store main update-ref msg refs/heads/missing "$MISSING" "$ZERO_OID" REF_SKIP_OID_VERIFICATION &&
44 echo "fatal: missing object $MISSING for refs/heads/missing" >missing-err &&
45 test_must_fail git for-each-ref 2>err &&
46 test_cmp missing-err err &&
48 cat brief-list &&
49 echo "$MISSING refs/heads/missing"
50 ) | sort -k 2 >missing-brief-expected &&
51 git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
52 test_cmp missing-brief-expected brief-out &&
53 test_must_be_empty brief-err
56 test_expect_success 'ahead-behind requires an argument' '
57 test_must_fail git for-each-ref \
58 --format="%(ahead-behind)" 2>err &&
59 echo "fatal: expected format: %(ahead-behind:<committish>)" >expect &&
60 test_cmp expect err
63 test_expect_success 'missing ahead-behind base' '
64 test_must_fail git for-each-ref \
65 --format="%(ahead-behind:refs/heads/missing)" 2>err &&
66 echo "fatal: failed to find '\''refs/heads/missing'\''" >expect &&
67 test_cmp expect err
70 test_done