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 if test_have_prereq
!REFFILES
13 skip_all
='skipping `git for-each-ref --exclude` tests; need files backend'
17 for_each_ref__exclude
() {
18 GIT_TRACE2_PERF
=1 test-tool ref-store main \
19 for-each-ref--exclude
"$@" >actual.raw
20 cut
-d ' ' -f 2 actual.raw
24 git for-each-ref
--format='%(refname)' "$@"
31 grep -q "name:jumps_made value:$nr$" $trace
35 ! assert_jumps
".*" "$1"
38 test_expect_success
'setup' '
39 test_commit --no-tag base &&
40 base="$(git rev-parse HEAD)" &&
42 for name in foo bar baz quux
46 echo "create refs/heads/$name/$i $base" || return 1
49 echo "delete refs/heads/main" >>in &&
51 git update-ref --stdin <in &&
55 test_expect_success
'excluded region in middle' '
56 for_each_ref__exclude refs/heads refs/heads/foo >actual 2>perf &&
57 for_each_ref refs/heads/bar refs/heads/baz refs/heads/quux >expect &&
59 test_cmp expect actual &&
63 test_expect_success
'excluded region at beginning' '
64 for_each_ref__exclude refs/heads refs/heads/bar >actual 2>perf &&
65 for_each_ref refs/heads/baz refs/heads/foo refs/heads/quux >expect &&
67 test_cmp expect actual &&
71 test_expect_success
'excluded region at end' '
72 for_each_ref__exclude refs/heads refs/heads/quux >actual 2>perf &&
73 for_each_ref refs/heads/foo refs/heads/bar refs/heads/baz >expect &&
75 test_cmp expect actual &&
79 test_expect_success
'disjoint excluded regions' '
80 for_each_ref__exclude refs/heads refs/heads/bar refs/heads/quux >actual 2>perf &&
81 for_each_ref refs/heads/baz refs/heads/foo >expect &&
83 test_cmp expect actual &&
87 test_expect_success
'adjacent, non-overlapping excluded regions' '
88 for_each_ref__exclude refs/heads refs/heads/bar refs/heads/baz >actual 2>perf &&
89 for_each_ref refs/heads/foo refs/heads/quux >expect &&
91 test_cmp expect actual &&
95 test_expect_success
'overlapping excluded regions' '
96 for_each_ref__exclude refs/heads refs/heads/ba refs/heads/baz >actual 2>perf &&
97 for_each_ref refs/heads/foo refs/heads/quux >expect &&
99 test_cmp expect actual &&
103 test_expect_success
'several overlapping excluded regions' '
104 for_each_ref__exclude refs/heads \
105 refs/heads/bar refs/heads/baz refs/heads/foo >actual 2>perf &&
106 for_each_ref refs/heads/quux >expect &&
108 test_cmp expect actual &&
112 test_expect_success
'non-matching excluded section' '
113 for_each_ref__exclude refs/heads refs/heads/does/not/exist >actual 2>perf &&
114 for_each_ref >expect &&
116 test_cmp expect actual &&
120 test_expect_success
'meta-characters are discarded' '
121 for_each_ref__exclude refs/heads "refs/heads/ba*" >actual 2>perf &&
122 for_each_ref >expect &&
124 test_cmp expect actual &&