repack: point out a bug handling stale shallow info
A `git fetch --prune` can turn previously-reachable objects unreachable, even commits that are in the `shallow` list. A subsequent `git repack -ad` will then unceremoniously drop those unreachable commits, and the `shallow` list will become stale. This means that when we try to fetch with a larger `--depth` the next time, we may end up with: fatal: error in object: unshallow <commit-hash> Reported by Alejandro Pauly. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Oct 24, 2018 at 08:56 UTC
328a43518244b970e1765eca78060bfeb265a584
1 file changed
+27
t/t5537-fetch-shallow.sh
+27
@@ -186,6 +186,33 @@ EOF
186
test_cmp expect actual
187
'
188
189
+test_expect_failure '.git/shallow is edited by repack' '
190
+ git init shallow-server &&
191
+ test_commit -C shallow-server A &&
192
+ test_commit -C shallow-server B &&
193
+ git -C shallow-server checkout -b branch &&
194
+ test_commit -C shallow-server C &&
195
+ test_commit -C shallow-server E &&
196
+ test_commit -C shallow-server D &&
197
+ d="$(git -C shallow-server rev-parse --verify D^0)" &&
198
+ git -C shallow-server checkout master &&
199
+
200
+ git clone --depth=1 --no-tags --no-single-branch \
201
+ "file://$PWD/shallow-server" shallow-client &&
202
+
203
+ : now remove the branch and fetch with prune &&
204
+ git -C shallow-server branch -D branch &&
205
+ git -C shallow-client fetch --prune --depth=1 \
206
+ origin "+refs/heads/*:refs/remotes/origin/*" &&
207
+ git -C shallow-client repack -adfl &&
208
+ test_must_fail git -C shallow-client rev-parse --verify $d^0 &&
209
+ ! grep $d shallow-client/.git/shallow &&
210
+
211
+ git -C shallow-server branch branch-orig $d &&
212
+ git -C shallow-client fetch --prune --depth=2 \
213
+ origin "+refs/heads/*:refs/remotes/origin/*"
214
+'
215
+
216
. "$TEST_DIRECTORY"/lib-httpd.sh
217
start_httpd
218