3 test_description
='git rev-list --exclude-hidden test'
5 TEST_PASSES_SANITIZE_LEAK
=true
8 test_expect_success
'setup' '
9 test_commit_bulk --id=commit --ref=refs/heads/branch 1 &&
10 COMMIT=$(git rev-parse refs/heads/branch) &&
11 test_commit_bulk --id=tag --ref=refs/tags/lightweight 1 &&
12 TAG=$(git rev-parse refs/tags/lightweight) &&
13 test_commit_bulk --id=hidden --ref=refs/hidden/commit 1 &&
14 HIDDEN=$(git rev-parse refs/hidden/commit) &&
15 test_commit_bulk --id=namespace --ref=refs/namespaces/namespace/refs/namespaced/commit 1 &&
16 NAMESPACE=$(git rev-parse refs/namespaces/namespace/refs/namespaced/commit)
19 test_expect_success
'invalid section' '
20 echo "fatal: unsupported section for hidden refs: unsupported" >expected &&
21 test_must_fail git rev-list --exclude-hidden=unsupported 2>err &&
25 for section
in fetch receive uploadpack
27 test_expect_success
"$section: passed multiple times" '
28 echo "fatal: --exclude-hidden= passed more than once" >expected &&
29 test_must_fail git rev-list --exclude-hidden=$section --exclude-hidden=$section 2>err &&
33 test_expect_success
"$section: without hiddenRefs" '
34 git rev-list --exclude-hidden=$section --all >out &&
35 cat >expected <<-EOF &&
44 test_expect_success
"$section: hidden via transfer.hideRefs" '
45 git -c transfer.hideRefs=refs/hidden/ rev-list --exclude-hidden=$section --all >out &&
46 cat >expected <<-EOF &&
54 test_expect_success
"$section: hidden via $section.hideRefs" '
55 git -c $section.hideRefs=refs/hidden/ rev-list --exclude-hidden=$section --all >out &&
56 cat >expected <<-EOF &&
64 test_expect_success
"$section: respects both transfer.hideRefs and $section.hideRefs" '
65 git -c transfer.hideRefs=refs/tags/ -c $section.hideRefs=refs/hidden/ rev-list --exclude-hidden=$section --all >out &&
66 cat >expected <<-EOF &&
73 test_expect_success
"$section: negation without hidden refs marks everything as uninteresting" '
74 git rev-list --all --exclude-hidden=$section --not --all >out &&
75 test_must_be_empty out
78 test_expect_success
"$section: negation with hidden refs marks them as interesting" '
79 git -c transfer.hideRefs=refs/hidden/ rev-list --all --exclude-hidden=$section --not --all >out &&
80 cat >expected <<-EOF &&
86 test_expect_success
"$section: hidden refs and excludes work together" '
87 git -c transfer.hideRefs=refs/hidden/ rev-list --exclude=refs/tags/* --exclude-hidden=$section --all >out &&
88 cat >expected <<-EOF &&
95 test_expect_success
"$section: excluded hidden refs get reset" '
96 git -c transfer.hideRefs=refs/ rev-list --exclude-hidden=$section --all --all >out &&
97 cat >expected <<-EOF &&
103 test_cmp expected out
106 test_expect_success
"$section: excluded hidden refs can be used with multiple pseudo-refs" '
107 git -c transfer.hideRefs=refs/ rev-list --exclude-hidden=$section --all --exclude-hidden=$section --all >out &&
108 test_must_be_empty out
111 test_expect_success
"$section: works with --glob" '
112 git -c transfer.hideRefs=refs/hidden/ rev-list --exclude-hidden=$section --glob=refs/h* >out &&
113 cat >expected <<-EOF &&
116 test_cmp expected out
119 test_expect_success
"$section: operates on stripped refs by default" '
120 GIT_NAMESPACE=namespace git -c transfer.hideRefs=refs/namespaced/ rev-list --exclude-hidden=$section --all >out &&
121 cat >expected <<-EOF &&
126 test_cmp expected out
129 test_expect_success
"$section: does not hide namespace by default" '
130 GIT_NAMESPACE=namespace git -c transfer.hideRefs=refs/namespaces/namespace/ rev-list --exclude-hidden=$section --all >out &&
131 cat >expected <<-EOF &&
137 test_cmp expected out
140 test_expect_success
"$section: can operate on unstripped refs" '
141 GIT_NAMESPACE=namespace git -c transfer.hideRefs=^refs/namespaces/namespace/ rev-list --exclude-hidden=$section --all >out &&
142 cat >expected <<-EOF &&
147 test_cmp expected out
150 for pseudoopt
in remotes branches tags
152 test_expect_success
"$section: fails with --$pseudoopt" '
153 test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt 2>err &&
154 test_grep "error: --exclude-hidden cannot be used together with --$pseudoopt" err
157 test_expect_success
"$section: fails with --$pseudoopt=pattern" '
158 test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt=pattern 2>err &&
159 test_grep "error: --exclude-hidden cannot be used together with --$pseudoopt" err