prune: mark rebase autostash and orig-head as reachable
commitbc7f5db896f59275fb0e4093dfd6891bfcece63d
authorPhillip Wood <phillip.wood@dunelm.org.uk>
Fri, 9 Feb 2024 16:19:39 +0000 (9 16:19 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 9 Feb 2024 18:04:59 +0000 (9 10:04 -0800)
tree9d04ee4f4c389ad03893a4409084d88c0d3d2628
parent3526e67d917bcd03f317a058208fa02737654637
prune: mark rebase autostash and orig-head as reachable

Rebase records the oid of HEAD before rebasing and the commit created by
"--autostash" in files in the rebase state directory. This means that
the autostash commit is never reachable from any ref or reflog and when
rebasing a detached HEAD the original HEAD can become unreachable if the
user expires HEAD's the reflog while the rebase is running. Fix this by
reading the relevant files when marking reachable commits.

Note that it is possible for the commit recorded in
.git/rebase-merge/amend to be unreachable but pruning that object does
not affect the operation of "git rebase --continue" as we're only
interested in the object id, not in the object itself.

Reported-by: Orgad Shaneh <orgads@gmail.com>
Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
reachable.c
t/t3407-rebase-abort.sh
t/t3420-rebase-autostash.sh