From patchwork Wed Nov 7 14:00:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruce Perry via GitGitGadget X-Patchwork-Id: 10672415 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20AFE14E2 for ; Wed, 7 Nov 2018 14:00:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 10C762BEB6 for ; Wed, 7 Nov 2018 14:00:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0559B2BF1F; Wed, 7 Nov 2018 14:00:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E6832BF1B for ; Wed, 7 Nov 2018 14:00:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730411AbeKGXbU (ORCPT ); Wed, 7 Nov 2018 18:31:20 -0500 Received: from mail-pg1-f172.google.com ([209.85.215.172]:37617 "EHLO mail-pg1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727806AbeKGXbU (ORCPT ); Wed, 7 Nov 2018 18:31:20 -0500 Received: by mail-pg1-f172.google.com with SMTP id c10-v6so7362632pgq.4 for ; Wed, 07 Nov 2018 06:00:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:mime-version :content-transfer-encoding:fcc:content-transfer-encoding :mime-version:to:cc; bh=pPe3QFXLwiUATG9i5FlPZ06i+iTzhOwOq/j+QoXFZ3c=; b=PJsdiFZCFW27VLXHXWP7zO2QZxqbx62oG4S9OPf+9DW03qPKq9XMvqlK7NfIWAAYZf 7qdMC1xB/dTKWbhHxwFUGUZ2hMWbWP6nKePEPEEMAa5rfyhd1c4YJmJQlJdE6521TvqG 2l/YoeA6EBTyRFR79fPLLo4nujJRG5cq7zojPHIej9Cl/1E3UkvkuPM/IIDMoaWW7sDj BOu3kvIwjUEFi6s2e2FDWrFxnbmWqrvB2Jizji0b1LB6O4NEL2nE4LxkuGrP23I0+uGI eooRCeD/+sNwT5uguqle2PM4oqACqQdDeAqt/i8VwWg8K2QuqA6Ln/NchbP4uoz1jtyd iXsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:mime-version:content-transfer-encoding:fcc :content-transfer-encoding:mime-version:to:cc; bh=pPe3QFXLwiUATG9i5FlPZ06i+iTzhOwOq/j+QoXFZ3c=; b=dSGk7CKyDflq7NqxCB05iKiyRU+P85Kr+xAtcieUf/WgZ+HQb0CYxHrTqUe4AcYP7T T4tUhB13SBS/Umy15cOV2vDZD3qWCMk4EYrVMQcNatM+Akpkgmdt6CUeYpDmHnOAHpK3 AEGpBv9nuuiA98BxmWbsnQOZhivhDkieBs3LtQ9E/dc2iPynr8XwUswTfQUu8fFyZsAv BQfxCYmgF4RJrXyRoOql5VwkOUzgq3l/vEZqrh1r6/Tn3TRkiwou7kXX93UIn80/RwCr SxkIfGQ1mhtgn/GbRislKvmQJ7E9CVKAC53bQf2h9KV68MewotBef1vv4sAV6oMY2bGN kR9w== X-Gm-Message-State: AGRZ1gLyrrKwjnQhbd6P1yZu4mAzTIYYS0kWBCmHmHyfPE1SVKMLt/PJ dqQhC1uphmpEBmIKxJmW8J1U2YP1gDQ= X-Google-Smtp-Source: AJdET5fy1snoegzINBZ2E03Q6sEKwkzaB+R+cMQ9J065U2Oc+n/rCQsCbxd7EW3QDq5RJ8BWOFUc5w== X-Received: by 2002:a63:6ac5:: with SMTP id f188mr263737pgc.165.1541599249430; Wed, 07 Nov 2018 06:00:49 -0800 (PST) Received: from [127.0.0.1] ([40.112.139.188]) by smtp.gmail.com with ESMTPSA id b69-v6sm778369pfc.150.2018.11.07.06.00.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 06:00:48 -0800 (PST) Date: Wed, 07 Nov 2018 06:00:48 -0800 (PST) X-Google-Original-Date: Wed, 07 Nov 2018 14:00:44 GMT Message-Id: <9a5237b13bb22e192cbe5777e6338d78e0773bad.1541599246.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH 1/2] built-in rebase: demonstrate regression with --autostash MIME-Version: 1.0 Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: AEvar , Pratik Karki , Jeff King , Junio C Hamano , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Schindelin An unnamed colleague of Ævar Arnfjörð Bjarmason reported a breakage where a `pull --rebase` (which did not really need to do anything but stash, see that nothing was changed, and apply the stash again) also detached the HEAD. This patch adds a minimal reproducer for this regression. Signed-off-by: Johannes Schindelin --- t/t3420-rebase-autostash.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh index f355c6825a..d4e2520bcb 100755 --- a/t/t3420-rebase-autostash.sh +++ b/t/t3420-rebase-autostash.sh @@ -361,4 +361,12 @@ test_expect_success 'autostash with dirty submodules' ' git rebase -i --autostash HEAD ' +test_expect_failure 'branch is left alone when possible' ' + git checkout -b unchanged-branch && + echo changed >file0 && + git rebase --autostash unchanged-branch && + test changed = "$(cat file0)" && + test unchanged-branch = "$(git rev-parse --abbrev-ref HEAD)" +' + test_done From patchwork Wed Nov 7 14:00:50 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Perry via GitGitGadget X-Patchwork-Id: 10672417 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1CB2014E2 for ; Wed, 7 Nov 2018 14:00:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BE372B9F2 for ; Wed, 7 Nov 2018 14:00:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 005BA2BEA7; Wed, 7 Nov 2018 14:00:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 74D6C2BEDD for ; Wed, 7 Nov 2018 14:00:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730493AbeKGXbW (ORCPT ); Wed, 7 Nov 2018 18:31:22 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:33795 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726688AbeKGXbW (ORCPT ); Wed, 7 Nov 2018 18:31:22 -0500 Received: by mail-pg1-f195.google.com with SMTP id k1-v6so7372002pgq.1 for ; Wed, 07 Nov 2018 06:00:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:in-reply-to:references:from:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=3n37fdwQJY2PTiBX4BBFgZdZfHKUVkXknVo2L4enXIM=; b=brM16oO/MAtv9kcPSBrlzdvOsnVym+ZZ1wJr+8Kup6mHUFiCxgM/s5ss9uIVj8Ggqt sFrFhMau09rnwX7v7zpLD2mmkrMF2IosfXiZaOQ47mgn/Dl+C1QqGSZd1M1FPwCtGlIm 2k9gZZE46i5iqWpHNpGpDyaF9fxP3+QB72X8GDCNMEcJMgzqTxUd/sVaqNVyQaJq/kKZ 5P5aKA3Wx6zJalE+VboolzSx3vK+tG7H4+N+NKgHBJH7v6SCprSSt4dWysmd7YFwjDGa sHh2wZHMQG/2A7bMRYf7xOEvfakTV8wNvmtiHsH702deKlQM8kMYowCwk65MjrOiy5ga HaiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:in-reply-to:references:from :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=3n37fdwQJY2PTiBX4BBFgZdZfHKUVkXknVo2L4enXIM=; b=EMH7mf9oCbha7RPvPpK3g+k7zEHU3C19nNM451C0J/blA+DV8RVcslxYUEZ11F8Ipd qUMCF00qTYo0PP00k6WDvQZOtV2nArgTSpfAfbUKE3D+RRs+zOUq49gO3h2cSuA9p/sy DjhDz+OKjJyiEovAef8BAri6ma+baRfNTqwPPzg+tZKO/oaBkhK2FUtpZt7GaeazOXje 9DdtsaISbs4i5bUo8ClthHchr+cpwVOXsly6h0W5bR1X0WMF6s0t0y4OfAqVSwuDgM2h AjQbsco7e8I366tx0W9mxPwuDd2LdgxUCNJw9ie7gmR2JlUE/IqVlTziOFT8HoSGmws0 MGCQ== X-Gm-Message-State: AGRZ1gLx0J9s9j0CrjvqNXMKHcllwQbONRXUnInBhhOY2AjKFevZ3AMk HkKLSG+1aJ5i2Ero0m7lUF/yqdkGdhA= X-Google-Smtp-Source: AJdET5eGf7CoAUc9/QCF+Fn9l9qQHgF2lYCDEEqVwF3rBaNxJ1C+Pq+xDDSJjY02QUB3lZs8OW39Vw== X-Received: by 2002:a63:585c:: with SMTP id i28mr285112pgm.178.1541599250614; Wed, 07 Nov 2018 06:00:50 -0800 (PST) Received: from [127.0.0.1] ([40.112.139.188]) by smtp.gmail.com with ESMTPSA id e70-v6sm722313pfb.113.2018.11.07.06.00.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 06:00:50 -0800 (PST) Date: Wed, 07 Nov 2018 06:00:50 -0800 (PST) X-Google-Original-Date: Wed, 07 Nov 2018 14:00:45 GMT Message-Id: In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH 2/2] built-in rebase --autostash: leave the current branch alone if possible Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: AEvar , Pratik Karki , Jeff King , Junio C Hamano , Johannes Schindelin Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Schindelin 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 --- builtin/rebase.c | 3 ++- t/t3420-rebase-autostash.sh | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 0ee06aa363..4a608d0a78 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -613,7 +613,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); diff --git a/t/t3420-rebase-autostash.sh b/t/t3420-rebase-autostash.sh index d4e2520bcb..4c7494cc8f 100755 --- a/t/t3420-rebase-autostash.sh +++ b/t/t3420-rebase-autostash.sh @@ -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 &&