mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
prune: turn on ref_paranoia flag
Prune should know about broken objects at the tips of refs, so that we can feed them to our traversal rather than ignoring them. It's better for us to abort the operation on the broken object than it is to start deleting objects with an incomplete view of the reachability namespace. Note that for missing objects, aborting is the best we can do. For a badly-named ref, we technically could use its sha1 as a reachability tip. However, the iteration code just feeds us a null sha1, so there would be a reasonable amount of code involved to pass down our wishes. It's not really worth trying to do better, because this is a case that should happen extremely rarely, and the message we provide: fatal: unable to parse object: refs/heads/bogus:name is probably enough to point the user in the right direction. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
49672f26d9
commit
ff4056bbc3
|
@ -115,6 +115,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
|
||||||
expire = ULONG_MAX;
|
expire = ULONG_MAX;
|
||||||
save_commit_buffer = 0;
|
save_commit_buffer = 0;
|
||||||
check_replace_refs = 0;
|
check_replace_refs = 0;
|
||||||
|
ref_paranoia = 1;
|
||||||
init_revisions(&revs, prefix);
|
init_revisions(&revs, prefix);
|
||||||
|
|
||||||
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
|
argc = parse_options(argc, argv, prefix, options, prune_usage, 0);
|
||||||
|
|
|
@ -25,7 +25,7 @@ test_expect_success 'create history reachable only from a bogus-named ref' '
|
||||||
git reset --hard HEAD^
|
git reset --hard HEAD^
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_failure 'pruning does not drop bogus object' '
|
test_expect_success 'pruning does not drop bogus object' '
|
||||||
test_when_finished "git hash-object -w -t commit saved" &&
|
test_when_finished "git hash-object -w -t commit saved" &&
|
||||||
test_might_fail git prune --expire=now &&
|
test_might_fail git prune --expire=now &&
|
||||||
verbose git cat-file -e $bogus
|
verbose git cat-file -e $bogus
|
||||||
|
@ -72,7 +72,7 @@ test_expect_success 'create history with missing tip commit' '
|
||||||
test_must_fail git cat-file -e $missing
|
test_must_fail git cat-file -e $missing
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_failure 'pruning with a corrupted tip does not drop history' '
|
test_expect_success 'pruning with a corrupted tip does not drop history' '
|
||||||
test_when_finished "git hash-object -w -t commit saved" &&
|
test_when_finished "git hash-object -w -t commit saved" &&
|
||||||
test_might_fail git prune --expire=now &&
|
test_might_fail git prune --expire=now &&
|
||||||
verbose git cat-file -e $recoverable
|
verbose git cat-file -e $recoverable
|
||||||
|
|
Loading…
Reference in a new issue