]> git.ipfire.org Git - thirdparty/git.git/blame - t/t6301-for-each-ref-errors.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t6301-for-each-ref-errors.sh
CommitLineData
c3e23dc1
MH
1#!/bin/sh
2
3test_description='for-each-ref errors for broken refs'
4
5. ./test-lib.sh
6
8125a58b 7ZEROS=$ZERO_OID
c3e23dc1
MH
8MISSING=abababababababababababababababababababab
9
10test_expect_success setup '
11 git commit --allow-empty -m "Initial" &&
12 git tag testtag &&
13 git for-each-ref >full-list &&
14 git for-each-ref --format="%(objectname) %(refname)" >brief-list
15'
16
8afc493d 17test_expect_success 'Broken refs are reported correctly' '
c3e23dc1
MH
18 r=refs/heads/bogus &&
19 : >.git/$r &&
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 &&
1edbaac3
VA
23 test_i18ncmp full-list out &&
24 test_i18ncmp broken-err err
c3e23dc1
MH
25'
26
501cf47c 27test_expect_success 'NULL_SHA1 refs are reported correctly' '
c3e23dc1
MH
28 r=refs/heads/zeros &&
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 &&
1edbaac3 34 test_i18ncmp zeros-err err &&
c3e23dc1
MH
35 git for-each-ref --format="%(objectname) %(refname)" >brief-out 2>brief-err &&
36 test_cmp brief-list brief-out &&
1edbaac3 37 test_i18ncmp zeros-err brief-err
c3e23dc1
MH
38'
39
40test_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 &&
1edbaac3 46 test_i18ncmp missing-err err &&
c3e23dc1
MH
47 (
48 cat brief-list &&
49 echo "$MISSING $r"
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
54'
55
56test_done