From patchwork Sun Mar 3 17:11:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koji Nakamaru via GitGitGadget X-Patchwork-Id: 10837111 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 640A3180E for ; Sun, 3 Mar 2019 17:11:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4884E29D4F for ; Sun, 3 Mar 2019 17:11:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A8DC29D51; Sun, 3 Mar 2019 17:11:57 +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 D545529D59 for ; Sun, 3 Mar 2019 17:11:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726473AbfCCRLz (ORCPT ); Sun, 3 Mar 2019 12:11:55 -0500 Received: from mail-ed1-f41.google.com ([209.85.208.41]:42422 "EHLO mail-ed1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726442AbfCCRLz (ORCPT ); Sun, 3 Mar 2019 12:11:55 -0500 Received: by mail-ed1-f41.google.com with SMTP id j89so2303704edb.9 for ; Sun, 03 Mar 2019 09:11:54 -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=VhMuAOmT4Y8clpe8vVOcle2S0EZOj49AJg42GB+xp4s=; b=eBxgrxeNkLsPbMTW6VSv82uGUaU5raMwRt1quQ/PufAhL4iRRy+K6MGYmgX3ZQ12l/ 4zblmqAxNmzJsbt6lBEiUcUtHFW9hbKegDRU/ASHQ/dz8IWhSvQ5ZiR3dq/wPm9UCBMb z6kXoDgwWfvogSnETxA3Tarc4DgX9A9N4l2JW6hITH7IWbQCzyn/544vN0K0yj8bSTTc GQcqONgytsiVSJGZmnPE4JEIH/2YV8E2PAy+UTPQ+oTmDVq/qeDKJKH7XzG62FrtmVll lsJSB+EJSQfvFhwRghLHBoTQ8QDScpzFGAJl0W4sprS+k9hL+K3/VpiPXQ3P5esCuagP v68A== 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=VhMuAOmT4Y8clpe8vVOcle2S0EZOj49AJg42GB+xp4s=; b=SftjZ3NsxAVZd/32W9KEcb/C0wnCAOPP87SGKfnHCEUPRmpEhdRGszfnWVzG3t+Qyv 4pPguawDl72zUtHH61D9x+U0yyuvbuIgttd10AixNoHB3nN839oY7tS/echy+9rA37js xYIKJhi31DhCQGy0vNiCTC8q+n+fcpbFQqwsvgzUaeedZzXVNzqwzf8FhQxba7Lct6cG 8XHobmJUQKa8Vcpkc1LJjQO3g6AvyV99ZE/Fwc0xbKYaz2ZskI1XUmKSlwkAwyxv7t7N jcRTuB4NqYsi3xZgYvafXCE0wtH0y8hiF1h+aq+c6sOctFCQEHDE+ImqlVQcvZz3PmFx t1CA== X-Gm-Message-State: APjAAAVm7iKgjoe7VEoWKpKAEfYRFSJvFPZS0zBUcKClD4zJ8/zb8Pi/ 41PBbg+YVr2ZTTk1DTca/ziJS+L8 X-Google-Smtp-Source: APXvYqwMvaAaQCXk5FPg6TVVz01Pqym6rdcnwePFAx7VG71Sqk2xsWFlP6lnE6tdw+U39StsJlfCMQ== X-Received: by 2002:a05:6402:171a:: with SMTP id y26mr12533403edu.72.1551633113753; Sun, 03 Mar 2019 09:11:53 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b29sm1366151eda.48.2019.03.03.09.11.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:11:53 -0800 (PST) Date: Sun, 03 Mar 2019 09:11:53 -0800 (PST) X-Google-Original-Date: Sun, 03 Mar 2019 17:11:49 GMT Message-Id: <59c3266ed523be6f92e7cb991436be3dac96a81f.1551633112.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH v2 1/4] built-in rebase: no need to check out `onto` twice Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Nazri Ramliy , Phillip Wood , 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 In the case that the rebase boils down to a fast-forward, the built-in rebase reset the working tree twice: once to start the rebase at `onto`, then realizing that the original (pre-rebase) HEAD was an ancestor and we basically already fast-forwarded to the post-rebase HEAD, `reset_head()` was called to update the original ref and to point HEAD back to it. That second `reset_head()` call does not need to touch the working tree, though, as it does not change the actual tip commit (and therefore the working tree should stay unchanged anyway): only the ref needs to be updated (because the rebase detached the HEAD, and we want to go back to the branch on which the rebase was started). But that second `reset_head()` was called without the flag to leave the working tree alone (the reason: when that call was introduced, that flag was not yet even thought of). Let's avoid that unnecessary work by passing that flag. Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 08ec4d52c7..813ec284ca 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1740,8 +1740,8 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) strbuf_addf(&msg, "rebase finished: %s onto %s", options.head_name ? options.head_name : "detached HEAD", oid_to_hex(&options.onto->object.oid)); - reset_head(NULL, "Fast-forwarded", options.head_name, 0, - "HEAD", msg.buf); + reset_head(NULL, "Fast-forwarded", options.head_name, + RESET_HEAD_REFS_ONLY, "HEAD", msg.buf); strbuf_release(&msg); ret = !!finish_rebase(&options); goto cleanup; From patchwork Sun Mar 3 17:11:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koji Nakamaru via GitGitGadget X-Patchwork-Id: 10837115 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 00C06180E for ; Sun, 3 Mar 2019 17:11:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA86F29D4F for ; Sun, 3 Mar 2019 17:11:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CEDB029D55; Sun, 3 Mar 2019 17:11:58 +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 8543F29D4F for ; Sun, 3 Mar 2019 17:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726491AbfCCRL5 (ORCPT ); Sun, 3 Mar 2019 12:11:57 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:46449 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbfCCRL4 (ORCPT ); Sun, 3 Mar 2019 12:11:56 -0500 Received: by mail-ed1-f65.google.com with SMTP id f2so2294955edy.13 for ; Sun, 03 Mar 2019 09:11:55 -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=qeKfQwcLlkFWz4gPjlZ2UmNVoHDBzu39T3HJbs1zShg=; b=LZ7A3+8ZZDN/QlYmFepD1oOLKhyHl0JeM09/Cj4jXzsJmqt15kmiCxq7sn68jx7V54 GrsU4Qx/iESUur9jib8fRkOn2QMzNl9wlmxd0wJNAoM4/n5yBKh5T2yYG6eFBkp7QGXx kjxIZTJMm2A69bBa3NiNutE4QzRTtTZWf0jEIPWMg78ggmbKC5fsc+q1MrZjMwMyDJ7F cvqml+FlEkLwtXQKISrfnWw8Lh1TERsi9oADMNebtDcPnRqOuT2YJgiZDlpEwkIukAng gydDpRe64qGqlBO7xyU5gtQ4DRkWAFe0tpzrOZNJhWIk3UgUgyO6Jmd51dH8z0gbna0O Hqsg== 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=qeKfQwcLlkFWz4gPjlZ2UmNVoHDBzu39T3HJbs1zShg=; b=C4yXD3zSVmggIvv9D/xVExLTE3htduOn6P0t9RW4C1o5zpw8GYW9Hx0NzhRNUxcAg2 UEQspj9kOPQI5pkONkjKfoH4V0i36b/rEEud2wMrMtajrgV6sqK15DHA07eIwgvxEqRh 60PyZRwomwVKoUV8JBmE6j2Q6tknrq2KeZKZptDlkyxWmuSgQkchIv6JMK1+X5NEvIr+ YuIhgbOiBBZNRgMu5jLRdSY2BZvtfW7qneVHQwlQc4FYru2AylNepXhqR5zZJqDQJ57t dZMPFpTRoAAeHcCOVFZeUNd9T6zrAlN1oMK8wXP/wS7Y5zSu7dRiua4oiLRfXFXbY8QS NWeg== X-Gm-Message-State: APjAAAXElrPzAdkuZCM1WgvIue6eRYOgKFomQT2KMlU92k+Avjx0abYJ tM0D6CuO2oNLAOJLQAj2fVz5fYAW X-Google-Smtp-Source: APXvYqyCx4kYx2xOe/+97yXrvuJSzUNmQYfe3/Ai2Nqlew3SbcI/MmMmUuoUDZl7Ta4Txe71/hKF5Q== X-Received: by 2002:a17:906:6a82:: with SMTP id p2mr10058107ejr.212.1551633114477; Sun, 03 Mar 2019 09:11:54 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w31sm1367115edc.46.2019.03.03.09.11.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:11:54 -0800 (PST) Date: Sun, 03 Mar 2019 09:11:54 -0800 (PST) X-Google-Original-Date: Sun, 03 Mar 2019 17:11:50 GMT Message-Id: <67e41c032a744096bf7e63c30a570bac01e2f656.1551633112.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH v2 2/4] built-in rebase: use the correct reflog when switching branches Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Nazri Ramliy , Phillip Wood , 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 By mistake, we used the reflog intended for ORIG_HEAD. Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 813ec284ca..aa469ec964 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -475,7 +475,7 @@ static int reset_head(struct object_id *oid, const char *action, detach_head ? REF_NO_DEREF : 0, UPDATE_REFS_MSG_ON_ERR); else { - ret = update_ref(reflog_orig_head, switch_to_branch, oid, + ret = update_ref(reflog_head, switch_to_branch, oid, NULL, 0, UPDATE_REFS_MSG_ON_ERR); if (!ret) ret = create_symref("HEAD", switch_to_branch, From patchwork Sun Mar 3 17:11:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koji Nakamaru via GitGitGadget X-Patchwork-Id: 10837117 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 6C30C139A for ; Sun, 3 Mar 2019 17:12:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 51CC429D4F for ; Sun, 3 Mar 2019 17:12:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 463AD29D55; Sun, 3 Mar 2019 17:12:00 +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 ECB6D29D4F for ; Sun, 3 Mar 2019 17:11:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726498AbfCCRL6 (ORCPT ); Sun, 3 Mar 2019 12:11:58 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:46451 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726476AbfCCRL5 (ORCPT ); Sun, 3 Mar 2019 12:11:57 -0500 Received: by mail-ed1-f66.google.com with SMTP id f2so2294972edy.13 for ; Sun, 03 Mar 2019 09:11:55 -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=w9D51nzePpOyGIwULQ/4KBCN7t8Dy6bXd4Z3X/qKuvQ=; b=nyxkNf/MIIfi+7RTSb6jJAx+6xX/gpkFv+3XvD4N3Ul9ujvRO5juzVWbpM/ShoQha0 MI74TSZDQs994Uqq5ltoXTwI85OPSni80VUyTGyQW3ZaJhdMmuO8o2kKB5vxryMQqPBI 7IuqfLe1qj3E7p9CGSOPm7uljdy2agoabev+x0DRAhKNTdcFGaWcBBWDxVlknwwlrqrZ KL2b+PC6cXTGkptLI6c5qRFkVFMtDPmcozpekYn/ofxi9UlsyOaH90F9cKH0wRkVDsLt Vhp37+qektQaSCTMODUcW6mEG3hKR6F2H1tH6sFOhOopN42Sf5AeKZHTZDmXOt1ryjnz kSfQ== 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=w9D51nzePpOyGIwULQ/4KBCN7t8Dy6bXd4Z3X/qKuvQ=; b=MaLjBDPgvyJiSxAJmsW5JvX+LAXNsx0FC2AK7QXgdCOMgOrt/e/NY6n/D4e9dgzO4L 4FsezLU4Pr2ViIeoDuS3XdZx8rcBGBm6w+FyFyp8n34wT/8WFon3GM8Jnw+2dQJOReQx vXI6WmEuHGdg8wh6O1p8Cd6iVnX46ZPQnxTp2iicGDS/P0kOc7mWIbtNM/MV9zPi+vfV GKARXbvKgnIILIC21O/asywU5SRR6dHNJrvfCuFwVVaQkQfA3jmG/jYBDSkREqXFtB8a uR3ZofRQZVXWr58GCrgjFc0m84fWUudY+1OkgvGrh8K0yTBkYKzE4yPGwhebHSZEj2SQ uuuA== X-Gm-Message-State: APjAAAUhIH81T0Cj95n94Gdt7tvwBpClg9XIMOIj1VfJsJrnaQfikbwn jh3GXpb4Dq63FItdTLFc2SPsslyr X-Google-Smtp-Source: APXvYqwblECrXC3BaHc5NY8C5RcTMWAy5ZT/1W/mbR9qSgj82DtCkzCGOQzQ3OLWy9+c0M1KcWwikA== X-Received: by 2002:aa7:db04:: with SMTP id t4mr12040083eds.173.1551633115199; Sun, 03 Mar 2019 09:11:55 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h22sm741700ejj.43.2019.03.03.09.11.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:11:54 -0800 (PST) Date: Sun, 03 Mar 2019 09:11:54 -0800 (PST) X-Google-Original-Date: Sun, 03 Mar 2019 17:11:51 GMT Message-Id: <17737998f45ed8b4e38fa58ff82309231230fc81.1551633112.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH v2 3/4] built-in rebase: demonstrate that ORIG_HEAD is not set correctly Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Nazri Ramliy , Phillip Wood , 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 The ORIG_HEAD pseudo ref is supposed to refer to the original, pre-rebase state after a successful rebase. Let's add a regression test to prove that this regressed: With GIT_TEST_REBASE_USE_BUILTIN=false, this test case passes, with GIT_TEST_REBASE_USE_BUILTIN=true (or unset), it fails. Reported by Nazri Ramliy. Signed-off-by: Johannes Schindelin --- t/t3400-rebase.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 3e73f7584c..7e8d5bb200 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -59,6 +59,14 @@ test_expect_success 'rebase against master' ' git rebase master ' +test_expect_failure 'rebase sets ORIG_HEAD to pre-rebase state' ' + git checkout -b orig-head topic && + pre="$(git rev-parse --verify HEAD)" && + git rebase master && + test_cmp_rev "$pre" ORIG_HEAD && + ! test_cmp_rev "$pre" HEAD +' + test_expect_success 'rebase, with and specified as :/quuxery' ' test_when_finished "git branch -D torebase" && git checkout -b torebase my-topic-branch^ && From patchwork Sun Mar 3 17:11:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Koji Nakamaru via GitGitGadget X-Patchwork-Id: 10837119 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 F1E1414DE for ; Sun, 3 Mar 2019 17:12:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D336029D55 for ; Sun, 3 Mar 2019 17:12:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4FDD29D66; Sun, 3 Mar 2019 17:12:03 +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 9CFF029D55 for ; Sun, 3 Mar 2019 17:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726506AbfCCRMA (ORCPT ); Sun, 3 Mar 2019 12:12:00 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:42210 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726442AbfCCRL5 (ORCPT ); Sun, 3 Mar 2019 12:11:57 -0500 Received: by mail-ed1-f67.google.com with SMTP id j89so2303754edb.9 for ; Sun, 03 Mar 2019 09:11:56 -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=g+pGs+pPQS4yupX4F+r6Rl4wu7svmR1go94XtrRFlIY=; b=MPBvQxg1koAEFAjys1DbBbxUYzgBGVUxmamnznFezsN2g87lSfp/WcXEZhUVTHKa90 aFbatdUPG4RPeR0TP/0aHVM1evU/JfHZb4OBNaePvBJV/F/UcWN/sU6uuFX7f3vKdfTw 9QSmjBs8eveLru7Y22FSURskENAeHFPZMhr2Wj9BsQr/2g5QPyxA+cIJEphAqnWzzcsC /WGiBYPYJ3a03hbLBrjyWsklMliDJ/581xcBtdjqKMi9vOcA7mGCdr5ha0CTWPXuzUBc YSSojjc2aK5o7qXUTan2E6+qhqA2XzRS7Y2g5utWsy4ZVuvyynRPMCEdHuqIuwTrUpzQ TbqQ== 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=g+pGs+pPQS4yupX4F+r6Rl4wu7svmR1go94XtrRFlIY=; b=jmPi425OKBXTC1SlmCAuJnk6wmWdeGc7w5yCnwSxLydf3Stlz8X7BDouoyiWR54pOz LlAcoWc8u7So6W05i5xZLDwVIu326R3wZVTH6QxyTk41xABuUMffI4N2yFLcKBM4bGe4 mm3lIJZcz5lfSNZ1r30kTAx45ddfKE6Oy1zylTM6b/PGsKImkvLv5v5sS1p89RKc1D9C 2XAfau76x8yd1l/7kQ84zULGNl6ak4pRZ0rdAiMlE5t8qYk5nIA5o87gaLQdE62XvU8s GDYxGDY8m+j2YVOH9h8mRX8sFi1LGyyEif9QJTqBEfrabph+WvxykPlOEzy94a40uZMz AA5Q== X-Gm-Message-State: APjAAAUMTr7lh8tzs0hGb57oMeIpj1TpIrK5IeQW7QlfSKDiPIkjFizy PBseycDRlIjOEC6TjzWIncKK1PoL X-Google-Smtp-Source: APXvYqyDagq1jLzhv8plq8r8pXR6d5PJaLcl34KBGc/mSZKWzsIw/vjX//HMIE5G8P25qz2cVW572Q== X-Received: by 2002:a50:b1b7:: with SMTP id m52mr12507900edd.18.1551633115875; Sun, 03 Mar 2019 09:11:55 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z39sm1365338edc.96.2019.03.03.09.11.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 03 Mar 2019 09:11:55 -0800 (PST) Date: Sun, 03 Mar 2019 09:11:55 -0800 (PST) X-Google-Original-Date: Sun, 03 Mar 2019 17:11:52 GMT Message-Id: <7891c05f51583e2391c74753c0377ed416314b8c.1551633112.git.gitgitgadget@gmail.com> In-Reply-To: References: From: "Johannes Schindelin via GitGitGadget" Subject: [PATCH v2 4/4] built-in rebase: set ORIG_HEAD just once, before the rebase Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Nazri Ramliy , Phillip Wood , 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 Technically, the scripted version set ORIG_HEAD only in two spots (which really could have been one, because it called `git checkout $onto^0` to start the rebase and also if it could take a shortcut, and in both cases it called `git update-ref $orig_head`). Practically, it *implicitly* reset ORIG_HEAD whenever `git reset --hard` was called. However, what we really want is that it is set exactly once, at the beginning of the rebase. So let's do that. Signed-off-by: Johannes Schindelin --- builtin/rebase.c | 31 ++++++++++++++++++------------- t/t3400-rebase.sh | 2 +- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index aa469ec964..0f4e1ead49 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -369,6 +369,7 @@ static void add_var(struct strbuf *buf, const char *name, const char *value) #define RESET_HEAD_DETACH (1<<0) #define RESET_HEAD_HARD (1<<1) #define RESET_HEAD_REFS_ONLY (1<<2) +#define RESET_ORIG_HEAD (1<<3) static int reset_head(struct object_id *oid, const char *action, const char *switch_to_branch, unsigned flags, @@ -377,6 +378,7 @@ static int reset_head(struct object_id *oid, const char *action, unsigned detach_head = flags & RESET_HEAD_DETACH; unsigned reset_hard = flags & RESET_HEAD_HARD; unsigned refs_only = flags & RESET_HEAD_REFS_ONLY; + unsigned update_orig_head = flags & RESET_ORIG_HEAD; struct object_id head_oid; struct tree_desc desc[2] = { { NULL }, { NULL } }; struct lock_file lock = LOCK_INIT; @@ -453,18 +455,21 @@ static int reset_head(struct object_id *oid, const char *action, strbuf_addf(&msg, "%s: ", reflog_action ? reflog_action : "rebase"); prefix_len = msg.len; - if (!get_oid("ORIG_HEAD", &oid_old_orig)) - old_orig = &oid_old_orig; - if (!get_oid("HEAD", &oid_orig)) { - orig = &oid_orig; - if (!reflog_orig_head) { - strbuf_addstr(&msg, "updating ORIG_HEAD"); - reflog_orig_head = msg.buf; - } - update_ref(reflog_orig_head, "ORIG_HEAD", orig, old_orig, 0, - UPDATE_REFS_MSG_ON_ERR); - } else if (old_orig) - delete_ref(NULL, "ORIG_HEAD", old_orig, 0); + if (update_orig_head) { + if (!get_oid("ORIG_HEAD", &oid_old_orig)) + old_orig = &oid_old_orig; + if (!get_oid("HEAD", &oid_orig)) { + orig = &oid_orig; + if (!reflog_orig_head) { + strbuf_addstr(&msg, "updating ORIG_HEAD"); + reflog_orig_head = msg.buf; + } + update_ref(reflog_orig_head, "ORIG_HEAD", orig, + old_orig, 0, UPDATE_REFS_MSG_ON_ERR); + } else if (old_orig) + delete_ref(NULL, "ORIG_HEAD", old_orig, 0); + } + if (!reflog_head) { strbuf_setlen(&msg, prefix_len); strbuf_addstr(&msg, "updating HEAD"); @@ -1725,7 +1730,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) strbuf_addf(&msg, "%s: checkout %s", getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name); if (reset_head(&options.onto->object.oid, "checkout", NULL, - RESET_HEAD_DETACH, NULL, msg.buf)) + RESET_HEAD_DETACH | RESET_ORIG_HEAD, NULL, msg.buf)) die(_("Could not detach HEAD")); strbuf_release(&msg); diff --git a/t/t3400-rebase.sh b/t/t3400-rebase.sh index 7e8d5bb200..460d0523be 100755 --- a/t/t3400-rebase.sh +++ b/t/t3400-rebase.sh @@ -59,7 +59,7 @@ test_expect_success 'rebase against master' ' git rebase master ' -test_expect_failure 'rebase sets ORIG_HEAD to pre-rebase state' ' +test_expect_success 'rebase sets ORIG_HEAD to pre-rebase state' ' git checkout -b orig-head topic && pre="$(git rev-parse --verify HEAD)" && git rebase master &&