3 test_description='for-each-ref errors for broken refs'
8 MISSING=abababababababababababababababababababab
10 test_expect_success setup '
11 git commit --allow-empty -m "Initial" &&
13 git for-each-ref >full-list &&
14 git for-each-ref --format="%(objectname) %(refname)" >brief-list
17 test_expect_success 'Broken refs are reported correctly' '
20 test_when_finished "rm -f .git/$r" &&
21 echo "warning: ignoring broken ref $r" >broken-err &&
22 git for-each-ref >out 2>err &&
23 test_cmp full-list out &&
24 test_cmp broken-err err
27 test_expect_success 'NULL_SHA1 refs are reported correctly' '
29 echo $ZEROS >.git/$r &&
30 test_when_finished "rm -f .git/$r" &&
31 echo "warning: ignoring broken ref $r" >zeros-err &&
32 git for-each-ref >out 2>err &&
33 test_cmp full-list out &&
34 test_cmp zeros-err err &&
35 git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
36 test_cmp brief-list brief-out &&
37 test_cmp zeros-err brief-err
40 test_expect_success 'Missing objects are reported correctly' '
41 r=refs/heads/missing &&
42 echo $MISSING >.git/$r &&
43 test_when_finished "rm -f .git/$r" &&
44 echo "fatal: missing object $MISSING for $r" >missing-err &&
45 test_must_fail git for-each-ref 2>err &&
46 test_cmp missing-err err &&
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