3 test_description
='test exclude_patterns functionality in main ref store'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK
=true
11 for_each_ref__exclude
() {
12 GIT_TRACE2_PERF
=1 test-tool ref-store main \
13 for-each-ref--exclude
"$@" >actual.raw
14 cut
-d ' ' -f 2 actual.raw
18 git for-each-ref
--format='%(refname)' "$@"
25 case "$GIT_DEFAULT_REF_FORMAT" in
27 grep -q "name:jumps_made value:$nr$" $trace;;
29 grep -q "name:reseeks_made value:$nr$" $trace;;
31 BUG
"unhandled ref format $GIT_DEFAULT_REF_FORMAT";;
36 ! assert_jumps
".*" "$1"
39 test_expect_success
'setup' '
40 test_commit --no-tag base &&
41 base="$(git rev-parse HEAD)" &&
43 for name in foo bar baz quux
47 echo "create refs/heads/$name/$i $base" || return 1
50 echo "delete refs/heads/main" >>in &&
52 git update-ref --stdin <in &&
56 test_expect_success
'excluded region in middle' '
57 for_each_ref__exclude refs/heads refs/heads/foo >actual 2>perf &&
58 for_each_ref refs/heads/bar refs/heads/baz refs/heads/quux >expect &&
60 test_cmp expect actual &&
64 test_expect_success
'excluded region at beginning' '
65 for_each_ref__exclude refs/heads refs/heads/bar >actual 2>perf &&
66 for_each_ref refs/heads/baz refs/heads/foo refs/heads/quux >expect &&
68 test_cmp expect actual &&
72 test_expect_success
'excluded region at end' '
73 for_each_ref__exclude refs/heads refs/heads/quux >actual 2>perf &&
74 for_each_ref refs/heads/foo refs/heads/bar refs/heads/baz >expect &&
76 test_cmp expect actual &&
80 test_expect_success
'disjoint excluded regions' '
81 for_each_ref__exclude refs/heads refs/heads/bar refs/heads/quux >actual 2>perf &&
82 for_each_ref refs/heads/baz refs/heads/foo >expect &&
84 test_cmp expect actual &&
88 test_expect_success
'adjacent, non-overlapping excluded regions' '
89 for_each_ref__exclude refs/heads refs/heads/bar refs/heads/baz >actual 2>perf &&
90 for_each_ref refs/heads/foo refs/heads/quux >expect &&
92 test_cmp expect actual &&
93 case "$GIT_DEFAULT_REF_FORMAT" in
99 BUG "unhandled ref format $GIT_DEFAULT_REF_FORMAT";;
103 test_expect_success
'overlapping excluded regions' '
104 for_each_ref__exclude refs/heads refs/heads/ba refs/heads/baz >actual 2>perf &&
105 for_each_ref refs/heads/foo refs/heads/quux >expect &&
107 test_cmp expect actual &&
111 test_expect_success
'several overlapping excluded regions' '
112 for_each_ref__exclude refs/heads \
113 refs/heads/bar refs/heads/baz refs/heads/foo >actual 2>perf &&
114 for_each_ref refs/heads/quux >expect &&
116 test_cmp expect actual &&
117 case "$GIT_DEFAULT_REF_FORMAT" in
119 assert_jumps 1 perf;;
121 assert_jumps 3 perf;;
123 BUG "unhandled ref format $GIT_DEFAULT_REF_FORMAT";;
127 test_expect_success
'unordered excludes' '
128 for_each_ref__exclude refs/heads \
129 refs/heads/foo refs/heads/baz >actual 2>perf &&
130 for_each_ref refs/heads/bar refs/heads/quux >expect &&
132 test_cmp expect actual &&
133 case "$GIT_DEFAULT_REF_FORMAT" in
135 assert_jumps 1 perf;;
137 assert_jumps 2 perf;;
139 BUG "unhandled ref format $GIT_DEFAULT_REF_FORMAT";;
143 test_expect_success
'non-matching excluded section' '
144 for_each_ref__exclude refs/heads refs/heads/does/not/exist >actual 2>perf &&
145 for_each_ref >expect &&
147 test_cmp expect actual &&
151 test_expect_success
'meta-characters are discarded' '
152 for_each_ref__exclude refs/heads "refs/heads/ba*" >actual 2>perf &&
153 for_each_ref >expect &&
155 test_cmp expect actual &&