]> git.ipfire.org Git - thirdparty/git.git/commitdiff
built-in rebase --autostash: leave the current branch alone if possible
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Wed, 7 Nov 2018 14:00:50 +0000 (06:00 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Nov 2018 01:16:38 +0000 (10:16 +0900)
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>
builtin/rebase.c
t/t3420-rebase-autostash.sh

index bc92c9b5299de3d72378f67371e0d42990385ea7..d7239763c8096c88801ac03fb6250e7cd0517a12 100644 (file)
@@ -612,7 +612,8 @@ static int reset_head(struct object_id *oid, const char *action,
                reflog_head = msg.buf;
        }
        if (!switch_to_branch)
-               ret = update_ref(reflog_head, "HEAD", oid, orig, REF_NO_DEREF,
+               ret = update_ref(reflog_head, "HEAD", oid, orig,
+                                detach_head ? REF_NO_DEREF : 0,
                                 UPDATE_REFS_MSG_ON_ERR);
        else {
                ret = create_symref("HEAD", switch_to_branch, msg.buf);
index cc6149d53f220f46a9311275b4fc096b41f7a74d..4e3d362d37b92177d31b71749f1cca4ddb5ad572 100755 (executable)
@@ -361,7 +361,7 @@ test_expect_success 'autostash with dirty submodules' '
        git rebase -i --autostash HEAD
 '
 
-test_expect_failure 'branch is left alone when possible' '
+test_expect_success 'branch is left alone when possible' '
        git checkout -b unchanged-branch &&
        echo changed >file0 &&
        git rebase --autostash unchanged-branch &&