aboutsummaryrefslogtreecommitdiffstats
path: root/t/t3420-rebase-autostash.sh
diff options
context:
space:
mode:
authorPhillip Wood <phillip.wood@dunelm.org.uk>2024-02-09 16:19:39 +0000
committerJunio C Hamano <gitster@pobox.com>2024-02-09 10:04:59 -0800
commitbc7f5db896f59275fb0e4093dfd6891bfcece63d (patch)
tree9d04ee4f4c389ad03893a4409084d88c0d3d2628 /t/t3420-rebase-autostash.sh
parent3526e67d917bcd03f317a058208fa02737654637 (diff)
downloadgit-bc7f5db896f59275fb0e4093dfd6891bfcece63d.tar.gz
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>
Diffstat (limited to 't/t3420-rebase-autostash.sh')
-rwxr-xr-xt/t3420-rebase-autostash.sh10
1 files changed, 10 insertions, 0 deletions
diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh
index 693934ee8b..1a820f1481 100755
--- a/t/t3420-rebase-autostash.sh
+++ b/t/t3420-rebase-autostash.sh
@@ -333,4 +333,14 @@ test_expect_success 'never change active branch' '
test_cmp_rev not-the-feature-branch unrelated-onto-branch
'
+test_expect_success 'autostash commit is marked as reachable' '
+ echo changed >file0 &&
+ git rebase --autostash --exec "git prune --expire=now" \
+ feature-branch^ feature-branch &&
+ # git rebase succeeds if the stash cannot be applied so we need to check
+ # the contents of file0
+ echo changed >expect &&
+ test_cmp expect file0
+'
+
test_done