built-in rebase --autostash: leave the current branch alone if possible
When we converted a `git reset --hard` call in the original Unix shell script to built-in code, we asked to reset the worktree and the index and explicitly *not* to detach the HEAD. By mistake, though, we still did. Let's fix this. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Nov 7, 2018 at 06:00 UTC
176f5d965ba128f79a51d6c8d1620506672403e1
2 files changed
+3
-2
builtin/rebase.c
+2
-1
@@ -612,7 +612,8 @@ static int reset_head(struct object_id *oid, const char *action,
612
reflog_head = msg.buf;
613
}
614
if (!switch_to_branch)
615
- ret = update_ref(reflog_head, "HEAD", oid, orig, REF_NO_DEREF,
615
+ ret = update_ref(reflog_head, "HEAD", oid, orig,
616
+ detach_head ? REF_NO_DEREF : 0,
617
UPDATE_REFS_MSG_ON_ERR);
618
else {
619
ret = create_symref("HEAD", switch_to_branch, msg.buf);
t/t3420-rebase-autostash.sh
+1
-1
@@ -361,7 +361,7 @@ test_expect_success 'autostash with dirty submodules' '
361
git rebase -i --autostash HEAD
362
'
363
364
-test_expect_failure 'branch is left alone when possible' '
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 &&