File tree Expand file tree Collapse file tree 2 files changed +30
-26
lines changed Expand file tree Collapse file tree 2 files changed +30
-26
lines changed Original file line number Diff line number Diff line change @@ -328,4 +328,34 @@ test_expect_success 'refs/worktree must not be packed' '
328328 test_path_is_file .git/worktrees/wt2/refs/worktree/foo
329329'
330330
331+ # we do not want to count on running pack-refs to
332+ # actually pack it, as it is perfectly reasonable to
333+ # skip processing a broken ref
334+ test_expect_success ' create packed-refs file with broken ref' '
335+ test_tick && git commit --allow-empty -m one &&
336+ recoverable=$(git rev-parse HEAD) &&
337+ test_tick && git commit --allow-empty -m two &&
338+ missing=$(git rev-parse HEAD) &&
339+ rm -f .git/refs/heads/main &&
340+ cat >.git/packed-refs <<-EOF &&
341+ $missing refs/heads/main
342+ $recoverable refs/heads/other
343+ EOF
344+ echo $missing >expect &&
345+ git rev-parse refs/heads/main >actual &&
346+ test_cmp expect actual
347+ '
348+
349+ test_expect_success ' pack-refs does not silently delete broken packed ref' '
350+ git pack-refs --all --prune &&
351+ git rev-parse refs/heads/main >actual &&
352+ test_cmp expect actual
353+ '
354+
355+ test_expect_success ' pack-refs does not drop broken refs during deletion' '
356+ git update-ref -d refs/heads/other &&
357+ git rev-parse refs/heads/main >actual &&
358+ test_cmp expect actual
359+ '
360+
331361test_done
Original file line number Diff line number Diff line change @@ -111,30 +111,4 @@ test_expect_success 'pack-refs does not silently delete broken loose ref' '
111111 test_cmp expect actual
112112'
113113
114- # we do not want to count on running pack-refs to
115- # actually pack it, as it is perfectly reasonable to
116- # skip processing a broken ref
117- test_expect_success REFFILES ' create packed-refs file with broken ref' '
118- rm -f .git/refs/heads/main &&
119- cat >.git/packed-refs <<-EOF &&
120- $missing refs/heads/main
121- $recoverable refs/heads/other
122- EOF
123- echo $missing >expect &&
124- git rev-parse refs/heads/main >actual &&
125- test_cmp expect actual
126- '
127-
128- test_expect_success REFFILES ' pack-refs does not silently delete broken packed ref' '
129- git pack-refs --all --prune &&
130- git rev-parse refs/heads/main >actual &&
131- test_cmp expect actual
132- '
133-
134- test_expect_success REFFILES ' pack-refs does not drop broken refs during deletion' '
135- git update-ref -d refs/heads/other &&
136- git rev-parse refs/heads/main >actual &&
137- test_cmp expect actual
138- '
139-
140114test_done
You can’t perform that action at this time.
0 commit comments