git-merge-tree.txt: replace spurious HTML entity
[git.git] / t / t6021-rev-list-exclude-hidden.sh
blob32b2b09413898f400e19de2e536532027556a310
1 #!/bin/sh
3 test_description='git rev-list --exclude-hidden test'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 test_commit_bulk --id=commit --ref=refs/heads/branch 1 &&
9 COMMIT=$(git rev-parse refs/heads/branch) &&
10 test_commit_bulk --id=tag --ref=refs/tags/lightweight 1 &&
11 TAG=$(git rev-parse refs/tags/lightweight) &&
12 test_commit_bulk --id=hidden --ref=refs/hidden/commit 1 &&
13 HIDDEN=$(git rev-parse refs/hidden/commit) &&
14 test_commit_bulk --id=namespace --ref=refs/namespaces/namespace/refs/namespaced/commit 1 &&
15 NAMESPACE=$(git rev-parse refs/namespaces/namespace/refs/namespaced/commit)
18 test_expect_success 'invalid section' '
19 echo "fatal: unsupported section for hidden refs: unsupported" >expected &&
20 test_must_fail git rev-list --exclude-hidden=unsupported 2>err &&
21 test_cmp expected err
24 for section in receive uploadpack
26 test_expect_success "$section: passed multiple times" '
27 echo "fatal: --exclude-hidden= passed more than once" >expected &&
28 test_must_fail git rev-list --exclude-hidden=$section --exclude-hidden=$section 2>err &&
29 test_cmp expected err
32 test_expect_success "$section: without hiddenRefs" '
33 git rev-list --exclude-hidden=$section --all >out &&
34 cat >expected <<-EOF &&
35 $NAMESPACE
36 $HIDDEN
37 $TAG
38 $COMMIT
39 EOF
40 test_cmp expected out
43 test_expect_success "$section: hidden via transfer.hideRefs" '
44 git -c transfer.hideRefs=refs/hidden/ rev-list --exclude-hidden=$section --all >out &&
45 cat >expected <<-EOF &&
46 $NAMESPACE
47 $TAG
48 $COMMIT
49 EOF
50 test_cmp expected out
53 test_expect_success "$section: hidden via $section.hideRefs" '
54 git -c $section.hideRefs=refs/hidden/ rev-list --exclude-hidden=$section --all >out &&
55 cat >expected <<-EOF &&
56 $NAMESPACE
57 $TAG
58 $COMMIT
59 EOF
60 test_cmp expected out
63 test_expect_success "$section: respects both transfer.hideRefs and $section.hideRefs" '
64 git -c transfer.hideRefs=refs/tags/ -c $section.hideRefs=refs/hidden/ rev-list --exclude-hidden=$section --all >out &&
65 cat >expected <<-EOF &&
66 $NAMESPACE
67 $COMMIT
68 EOF
69 test_cmp expected out
72 test_expect_success "$section: negation without hidden refs marks everything as uninteresting" '
73 git rev-list --all --exclude-hidden=$section --not --all >out &&
74 test_must_be_empty out
77 test_expect_success "$section: negation with hidden refs marks them as interesting" '
78 git -c transfer.hideRefs=refs/hidden/ rev-list --all --exclude-hidden=$section --not --all >out &&
79 cat >expected <<-EOF &&
80 $HIDDEN
81 EOF
82 test_cmp expected out
85 test_expect_success "$section: hidden refs and excludes work together" '
86 git -c transfer.hideRefs=refs/hidden/ rev-list --exclude=refs/tags/* --exclude-hidden=$section --all >out &&
87 cat >expected <<-EOF &&
88 $NAMESPACE
89 $COMMIT
90 EOF
91 test_cmp expected out
94 test_expect_success "$section: excluded hidden refs get reset" '
95 git -c transfer.hideRefs=refs/ rev-list --exclude-hidden=$section --all --all >out &&
96 cat >expected <<-EOF &&
97 $NAMESPACE
98 $HIDDEN
99 $TAG
100 $COMMIT
102 test_cmp expected out
105 test_expect_success "$section: excluded hidden refs can be used with multiple pseudo-refs" '
106 git -c transfer.hideRefs=refs/ rev-list --exclude-hidden=$section --all --exclude-hidden=$section --all >out &&
107 test_must_be_empty out
110 test_expect_success "$section: works with --glob" '
111 git -c transfer.hideRefs=refs/hidden/ rev-list --exclude-hidden=$section --glob=refs/h* >out &&
112 cat >expected <<-EOF &&
113 $COMMIT
115 test_cmp expected out
118 test_expect_success "$section: operates on stripped refs by default" '
119 GIT_NAMESPACE=namespace git -c transfer.hideRefs=refs/namespaced/ rev-list --exclude-hidden=$section --all >out &&
120 cat >expected <<-EOF &&
121 $HIDDEN
122 $TAG
123 $COMMIT
125 test_cmp expected out
128 test_expect_success "$section: does not hide namespace by default" '
129 GIT_NAMESPACE=namespace git -c transfer.hideRefs=refs/namespaces/namespace/ rev-list --exclude-hidden=$section --all >out &&
130 cat >expected <<-EOF &&
131 $NAMESPACE
132 $HIDDEN
133 $TAG
134 $COMMIT
136 test_cmp expected out
139 test_expect_success "$section: can operate on unstripped refs" '
140 GIT_NAMESPACE=namespace git -c transfer.hideRefs=^refs/namespaces/namespace/ rev-list --exclude-hidden=$section --all >out &&
141 cat >expected <<-EOF &&
142 $HIDDEN
143 $TAG
144 $COMMIT
146 test_cmp expected out
149 for pseudoopt in remotes branches tags
151 test_expect_success "$section: fails with --$pseudoopt" '
152 test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt 2>err &&
153 test_i18ngrep "error: --exclude-hidden cannot be used together with --$pseudoopt" err
156 test_expect_success "$section: fails with --$pseudoopt=pattern" '
157 test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt=pattern 2>err &&
158 test_i18ngrep "error: --exclude-hidden cannot be used together with --$pseudoopt" err
160 done
161 done
163 test_done