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 grep -q "name:jumps_made value:$nr$" $trace
29 ! assert_jumps
".*" "$1"
32 test_expect_success
'setup' '
33 test_commit --no-tag base &&
34 base="$(git rev-parse HEAD)" &&
36 for name in foo bar baz quux
40 echo "create refs/heads/$name/$i $base" || return 1
43 echo "delete refs/heads/main" >>in &&
45 git update-ref --stdin <in &&
49 test_expect_success
'excluded region in middle' '
50 for_each_ref__exclude refs/heads refs/heads/foo >actual 2>perf &&
51 for_each_ref refs/heads/bar refs/heads/baz refs/heads/quux >expect &&
53 test_cmp expect actual &&
57 test_expect_success
'excluded region at beginning' '
58 for_each_ref__exclude refs/heads refs/heads/bar >actual 2>perf &&
59 for_each_ref refs/heads/baz refs/heads/foo refs/heads/quux >expect &&
61 test_cmp expect actual &&
65 test_expect_success
'excluded region at end' '
66 for_each_ref__exclude refs/heads refs/heads/quux >actual 2>perf &&
67 for_each_ref refs/heads/foo refs/heads/bar refs/heads/baz >expect &&
69 test_cmp expect actual &&
73 test_expect_success
'disjoint excluded regions' '
74 for_each_ref__exclude refs/heads refs/heads/bar refs/heads/quux >actual 2>perf &&
75 for_each_ref refs/heads/baz refs/heads/foo >expect &&
77 test_cmp expect actual &&
81 test_expect_success
'adjacent, non-overlapping excluded regions' '
82 for_each_ref__exclude refs/heads refs/heads/bar refs/heads/baz >actual 2>perf &&
83 for_each_ref refs/heads/foo refs/heads/quux >expect &&
85 test_cmp expect actual &&
89 test_expect_success
'overlapping excluded regions' '
90 for_each_ref__exclude refs/heads refs/heads/ba refs/heads/baz >actual 2>perf &&
91 for_each_ref refs/heads/foo refs/heads/quux >expect &&
93 test_cmp expect actual &&
97 test_expect_success
'several overlapping excluded regions' '
98 for_each_ref__exclude refs/heads \
99 refs/heads/bar refs/heads/baz refs/heads/foo >actual 2>perf &&
100 for_each_ref refs/heads/quux >expect &&
102 test_cmp expect actual &&
106 test_expect_success
'non-matching excluded section' '
107 for_each_ref__exclude refs/heads refs/heads/does/not/exist >actual 2>perf &&
108 for_each_ref >expect &&
110 test_cmp expect actual &&
114 test_expect_success
'meta-characters are discarded' '
115 for_each_ref__exclude refs/heads "refs/heads/ba*" >actual 2>perf &&
116 for_each_ref >expect &&
118 test_cmp expect actual &&