]>
Commit | Line | Data |
---|---|---|
8c1bc2a7 PS |
1 | #!/bin/sh |
2 | ||
3 | test_description='git rev-list --exclude-hidden test' | |
4 | ||
b2e5d75d | 5 | TEST_PASSES_SANITIZE_LEAK=true |
8c1bc2a7 PS |
6 | . ./test-lib.sh |
7 | ||
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) | |
17 | ' | |
18 | ||
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 | |
23 | ' | |
24 | ||
c6ce27ab | 25 | for section in fetch receive uploadpack |
8c1bc2a7 PS |
26 | do |
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 | |
31 | ' | |
32 | ||
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 | |
42 | ' | |
43 | ||
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 | |
52 | ' | |
53 | ||
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 | |
62 | ' | |
63 | ||
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 | |
71 | ' | |
72 | ||
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 | |
76 | ' | |
77 | ||
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 | |
84 | ' | |
85 | ||
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 | |
93 | ' | |
94 | ||
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 | |
102 | EOF | |
103 | test_cmp expected out | |
104 | ' | |
105 | ||
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 | |
109 | ' | |
110 | ||
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 | |
115 | EOF | |
116 | test_cmp expected out | |
117 | ' | |
118 | ||
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 | |
125 | EOF | |
126 | test_cmp expected out | |
127 | ' | |
128 | ||
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 | |
136 | EOF | |
137 | test_cmp expected out | |
138 | ' | |
139 | ||
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 | |
146 | EOF | |
147 | test_cmp expected out | |
148 | ' | |
149 | ||
150 | for pseudoopt in remotes branches tags | |
151 | do | |
152 | test_expect_success "$section: fails with --$pseudoopt" ' | |
153 | test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt 2>err && | |
81fb70f5 | 154 | test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err |
8c1bc2a7 PS |
155 | ' |
156 | ||
157 | test_expect_success "$section: fails with --$pseudoopt=pattern" ' | |
158 | test_must_fail git rev-list --exclude-hidden=$section --$pseudoopt=pattern 2>err && | |
81fb70f5 | 159 | test_grep "error: options .--exclude-hidden. and .--$pseudoopt. cannot be used together" err |
8c1bc2a7 PS |
160 | ' |
161 | done | |
162 | done | |
163 | ||
164 | test_done |