Skip to content

Commit a083b88

Browse files
committed
Merge branch 'js/rebase-autostash-detach-fix'
2 parents 1f35a91 + bd78e1c commit a083b88

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

builtin/rebase.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,8 @@ static int reset_head(struct object_id *oid, const char *action,
615615
reflog_head = msg.buf;
616616
}
617617
if (!switch_to_branch)
618-
ret = update_ref(reflog_head, "HEAD", oid, orig, REF_NO_DEREF,
618+
ret = update_ref(reflog_head, "HEAD", oid, orig,
619+
detach_head ? REF_NO_DEREF : 0,
619620
UPDATE_REFS_MSG_ON_ERR);
620621
else {
621622
ret = create_symref("HEAD", switch_to_branch, msg.buf);

t/t3420-rebase-autostash.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,4 +361,12 @@ test_expect_success 'autostash with dirty submodules' '
361361
git rebase -i --autostash HEAD
362362
'
363363

364+
test_expect_success 'branch is left alone when possible' '
365+
git checkout -b unchanged-branch &&
366+
echo changed >file0 &&
367+
git rebase --autostash unchanged-branch &&
368+
test changed = "$(cat file0)" &&
369+
test unchanged-branch = "$(git rev-parse --abbrev-ref HEAD)"
370+
'
371+
364372
test_done

0 commit comments

Comments
 (0)