Merge branch 'jc/ci-upload-artifact-and-linux32'
[git/gitster.git] / t / t6021-rev-list-exclude-hidden.sh
blob51df02105d7b83c3b0b1c85f95d419ac9a4bbfe1
1 #!/bin/sh
3 test_description='git rev-list --exclude-hidden test'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
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 &&
22 test_cmp expected 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 &&
30 test_cmp expected err
33 test_expect_success "$section: without hiddenRefs" '
34 git rev-list --exclude-hidden=$section --all >out &&
35 cat >expected <<-EOF &&
36 $NAMESPACE
37 $HIDDEN
38 $TAG
39 $COMMIT
40 EOF
41 test_cmp expected out
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 &&
47 $NAMESPACE
48 $TAG
49 $COMMIT
50 EOF
51 test_cmp expected out
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 &&
57 $NAMESPACE
58 $TAG
59 $COMMIT
60 EOF
61 test_cmp expected out
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 &&
67 $NAMESPACE
68 $COMMIT
69 EOF
70 test_cmp expected out
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 &&
81 $HIDDEN
82 EOF
83 test_cmp expected out
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 &&
89 $NAMESPACE
90 $COMMIT
91 EOF
92 test_cmp expected out
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 &&
98 $NAMESPACE
99 $HIDDEN
100 $TAG
101 $COMMIT
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 &&
114 $COMMIT
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 &&
122 $HIDDEN
123 $TAG
124 $COMMIT
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 &&
132 $NAMESPACE
133 $HIDDEN
134 $TAG
135 $COMMIT
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 &&
143 $HIDDEN
144 $TAG
145 $COMMIT
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: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" 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: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err
161 done
162 done
164 test_done