t1404: demonstrate a bug resolving references

Add some tests checking that it is possible to work with a reference even if there is an empty directory where the loose ref would be stored. One of the new tests demonstrates a bug that has been with us since at least 2.5.0--single reference lookup gives up when it sees the directory, even if the reference exists as a packed ref. This probably hasn't been reported before because Git usually cleans up empty directories when packing references. This bug will be fixed shortly. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>

Michael Haggerty committed May 5, 2016 at 13:22 UTC 19dd7d06e5d2c58895dd101025c013404025e192
1 file changed +75 -1
t/t1404-update-ref-df-conflicts.sh
+75 -1
@@ -28,7 +28,9 @@ Q="'"
28 test_expect_success 'setup' '
29
30 git commit --allow-empty -m Initial &&
31 - C=$(git rev-parse HEAD)
31 + C=$(git rev-parse HEAD) &&
32 + git commit --allow-empty -m Second &&
33 + D=$(git rev-parse HEAD)
34
35 '
36
@@ -104,4 +106,76 @@ test_expect_success 'one new ref is a simple prefix of another' '
106
107 '
108
109 +test_expect_failure 'empty directory should not fool rev-parse' '
110 + prefix=refs/e-rev-parse &&
111 + git update-ref $prefix/foo $C &&
112 + git pack-refs --all &&
113 + mkdir -p .git/$prefix/foo/bar/baz &&
114 + echo "$C" >expected &&
115 + git rev-parse $prefix/foo >actual &&
116 + test_cmp expected actual
117 +'
118 +
119 +test_expect_success 'empty directory should not fool for-each-ref' '
120 + prefix=refs/e-for-each-ref &&
121 + git update-ref $prefix/foo $C &&
122 + git for-each-ref $prefix >expected &&
123 + git pack-refs --all &&
124 + mkdir -p .git/$prefix/foo/bar/baz &&
125 + git for-each-ref $prefix >actual &&
126 + test_cmp expected actual
127 +'
128 +
129 +test_expect_success 'empty directory should not fool create' '
130 + prefix=refs/e-create &&
131 + mkdir -p .git/$prefix/foo/bar/baz &&
132 + printf "create %s $C\n" $prefix/foo |
133 + git update-ref --stdin
134 +'
135 +
136 +test_expect_success 'empty directory should not fool verify' '
137 + prefix=refs/e-verify &&
138 + git update-ref $prefix/foo $C &&
139 + git pack-refs --all &&
140 + mkdir -p .git/$prefix/foo/bar/baz &&
141 + printf "verify %s $C\n" $prefix/foo |
142 + git update-ref --stdin
143 +'
144 +
145 +test_expect_success 'empty directory should not fool 1-arg update' '
146 + prefix=refs/e-update-1 &&
147 + git update-ref $prefix/foo $C &&
148 + git pack-refs --all &&
149 + mkdir -p .git/$prefix/foo/bar/baz &&
150 + printf "update %s $D\n" $prefix/foo |
151 + git update-ref --stdin
152 +'
153 +
154 +test_expect_success 'empty directory should not fool 2-arg update' '
155 + prefix=refs/e-update-2 &&
156 + git update-ref $prefix/foo $C &&
157 + git pack-refs --all &&
158 + mkdir -p .git/$prefix/foo/bar/baz &&
159 + printf "update %s $D $C\n" $prefix/foo |
160 + git update-ref --stdin
161 +'
162 +
163 +test_expect_success 'empty directory should not fool 0-arg delete' '
164 + prefix=refs/e-delete-0 &&
165 + git update-ref $prefix/foo $C &&
166 + git pack-refs --all &&
167 + mkdir -p .git/$prefix/foo/bar/baz &&
168 + printf "delete %s\n" $prefix/foo |
169 + git update-ref --stdin
170 +'
171 +
172 +test_expect_success 'empty directory should not fool 1-arg delete' '
173 + prefix=refs/e-delete-1 &&
174 + git update-ref $prefix/foo $C &&
175 + git pack-refs --all &&
176 + mkdir -p .git/$prefix/foo/bar/baz &&
177 + printf "delete %s $C\n" $prefix/foo |
178 + git update-ref --stdin
179 +'
180 +
181 test_done