mirror of
https://github.com/git/git.git
synced 2024-06-19 13:39:04 +02:00
Merge branch 'js/reflog-expire-stale-fix' into next
"git reflog expire --stale-fix" can be used to repair the reflog by removing entries that refer to objects that have been pruned away, but was not careful to tolerate missing objects. * js/reflog-expire-stale-fix: reflog expire --stale-fix: be generous about missing objects
This commit is contained in:
commit
899034efca
|
@ -602,6 +602,9 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
|
||||||
*/
|
*/
|
||||||
if (cb.cmd.stalefix) {
|
if (cb.cmd.stalefix) {
|
||||||
repo_init_revisions(the_repository, &cb.cmd.revs, prefix);
|
repo_init_revisions(the_repository, &cb.cmd.revs, prefix);
|
||||||
|
cb.cmd.revs.do_not_die_on_missing_tree = 1;
|
||||||
|
cb.cmd.revs.ignore_missing = 1;
|
||||||
|
cb.cmd.revs.ignore_missing_links = 1;
|
||||||
if (flags & EXPIRE_REFLOGS_VERBOSE)
|
if (flags & EXPIRE_REFLOGS_VERBOSE)
|
||||||
printf(_("Marking reachable objects..."));
|
printf(_("Marking reachable objects..."));
|
||||||
mark_reachable_objects(&cb.cmd.revs, 0, 0, NULL);
|
mark_reachable_objects(&cb.cmd.revs, 0, 0, NULL);
|
||||||
|
|
|
@ -158,6 +158,32 @@ test_expect_success 'reflog expire' '
|
||||||
check_fsck "dangling commit $K"
|
check_fsck "dangling commit $K"
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success '--stale-fix handles missing objects generously' '
|
||||||
|
git -c core.logAllRefUpdates=false fast-import --date-format=now <<-EOS &&
|
||||||
|
commit refs/heads/stale-fix
|
||||||
|
mark :1
|
||||||
|
committer Author <a@uth.or> now
|
||||||
|
data <<EOF
|
||||||
|
start stale fix
|
||||||
|
EOF
|
||||||
|
M 100644 inline file
|
||||||
|
data <<EOF
|
||||||
|
contents
|
||||||
|
EOF
|
||||||
|
commit refs/heads/stale-fix
|
||||||
|
committer Author <a@uth.or> now
|
||||||
|
data <<EOF
|
||||||
|
stale fix branch tip
|
||||||
|
EOF
|
||||||
|
from :1
|
||||||
|
EOS
|
||||||
|
|
||||||
|
parent_oid=$(git rev-parse stale-fix^) &&
|
||||||
|
test_when_finished "recover $parent_oid" &&
|
||||||
|
corrupt $parent_oid &&
|
||||||
|
git reflog expire --stale-fix
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'prune and fsck' '
|
test_expect_success 'prune and fsck' '
|
||||||
|
|
||||||
git prune &&
|
git prune &&
|
||||||
|
|
Loading…
Reference in New Issue