From patchwork Wed Apr 20 09:56:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12819996 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 15AA6C433EF for ; Wed, 20 Apr 2022 09:57:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377367AbiDTJ7s (ORCPT ); Wed, 20 Apr 2022 05:59:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377358AbiDTJ7n (ORCPT ); Wed, 20 Apr 2022 05:59:43 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 08AA438BF0 for ; Wed, 20 Apr 2022 02:56:57 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id r4-20020a05600c35c400b0039295dc1fc3so868482wmq.3 for ; Wed, 20 Apr 2022 02:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=Mc2YEAu3ezPc3vqrdQbG+5AlHxptS5xsMenkYldx7js=; b=Cxi4GznrAMCVUJB+Z5bTM4hd6AtOeRvSu6fmPQk1YK3DyoTOKEq7lhAht9IoFMRphr Bvta+8AK3oKCSc8r/ofrwcBjV3DsBO2wV8YCynuW1Qqe5RPyzs1B5QPAXlB1/d7NCvxf tSSj91NjCroAfc1rmfR3w2QobNHnAb0BzQQ0R/HO/WQIq2OS5sbDh0Qeutku5Yu/DxWy 7aNYOnUbLTvfM+0s+F7etQD3di7Ljhb88Z5LaDLCUlu40i4pQVjEbTWvLcwtSV8kYCZe 4NF8j2lHt9jmQD/52e3DLqSKAbcug937EvV3GPeYlqPFhqnlxzGVUp/ll+/edJLXPoKs HUiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=Mc2YEAu3ezPc3vqrdQbG+5AlHxptS5xsMenkYldx7js=; b=UJSAoBv/G6ljOEbKHX146IoDalC8Ck7PmL1Y/FtAPGFkqqAeM5/jlRaEFzP0BwQlJK ddeFrJq+PrQL8PB3Hpqqj1hzyw02SgkZryCBIZe2nz+0p6Okr1xrowQl+eED3xS7aV6M 9K4gPh4B5ONr2IrHwrOQgbiWyVc0MJPCAX2HSj1/F531F+F6RlwWOgyyWk1cJdv6ARSn 5X9gGdzllEwGRpJP+r/0LoxZq/3fqPCBg8CVRU7CNAlKdthro32/RTBueaodiCwe83Vk k/MUjyrPOopmdWmzUL4rGXZpjysCsZ7ojybRgRSVw0GGQPCY7qx8r54we5THliAQvQoY MbpQ== X-Gm-Message-State: AOAM531kdIB6EykAYfWdbkTf3AkLg+MnXwQKNJXQ1ppEbJxCtJl/Htw4 lQI2/gRdOE4XPuy4O+IPWB62+idj/eY= X-Google-Smtp-Source: ABdhPJwN65a4F6bNFwdQvX0+R4ldXY1wsGRTFsq6QkyC38tL+dBb4fkO7U610L2LODA7tmoBXnxloA== X-Received: by 2002:a05:600c:211:b0:38e:d0f2:8a3f with SMTP id 17-20020a05600c021100b0038ed0f28a3fmr2837960wmi.8.1650448615192; Wed, 20 Apr 2022 02:56:55 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o13-20020a05600c4fcd00b00392951086efsm9462700wmq.34.2022.04.20.02.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 02:56:54 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 20 Apr 2022 09:56:44 +0000 Subject: [PATCH v2 1/8] rebase --apply: remove duplicated code Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Christian Couder , Elijah Newren , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood When we are reattaching HEAD after a fast-forward we can use move_to_original_branch() rather than open coding a copy of that code. The old code appears to handle the case where the rebase is started from a detached HEAD but in fact in that case there is nothing to do as we have already updated HEAD. Note that the removal of "strbuf_release(&msg)" is safe as there is an identical call just above this hunk which can be seen by viewing the diff with -U6. Signed-off-by: Phillip Wood --- builtin/rebase.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index e942c300f8c..4832f16e675 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1782,19 +1782,10 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) * If the onto is a proper descendant of the tip of the branch, then * we just fast-forwarded. */ - strbuf_reset(&msg); if (oideq(&merge_base, &options.orig_head)) { printf(_("Fast-forwarded %s to %s.\n"), branch_name, options.onto_name); - strbuf_addf(&msg, "rebase finished: %s onto %s", - options.head_name ? options.head_name : "detached HEAD", - oid_to_hex(&options.onto->object.oid)); - memset(&ropts, 0, sizeof(ropts)); - ropts.branch = options.head_name; - ropts.flags = RESET_HEAD_REFS_ONLY; - ropts.head_msg = msg.buf; - reset_head(the_repository, &ropts); - strbuf_release(&msg); + move_to_original_branch(&options); ret = finish_rebase(&options); goto cleanup; } From patchwork Wed Apr 20 09:56:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12819995 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3ECEC433F5 for ; Wed, 20 Apr 2022 09:57:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377364AbiDTJ7r (ORCPT ); Wed, 20 Apr 2022 05:59:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377359AbiDTJ7o (ORCPT ); Wed, 20 Apr 2022 05:59:44 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 612C63298E for ; Wed, 20 Apr 2022 02:56:58 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id m15-20020a7bca4f000000b0038fdc1394b1so3298092wml.2 for ; Wed, 20 Apr 2022 02:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=vz48/RSPFOJlzJ3tJY1CkSjfI97YkEq4vzNOy46Tkig=; b=qgtOvxYNbWDz86XicSu6LrRIReywLTa2Ku5erT/kdJdHn9CqZzAOLDT9F/Od1pfiEJ p5E3tSLzfRy181JJzSV95XkmXSfIJIuHqVqMaph56fzUf9mAz4u8RSau1L9g4gQH0T3I L5+QL4KrJu0vnR/DOpPYVhrcMEDPpSUGBMA7/Z4o6By5YUPJ9ZsMYY84B53GTJWBiUyl hgQ0zJiU5kqr61RjZOpt4prWAuTwzTnJj9J9luo+gKxfyGtmpTZWMGL5zVZvOPjw4VsA 4UmyZe2BeWGssLWxURYY5U1NJ/o3N57la0gGvcKos16dTu95P7xPh9+Lv/qdZj7o5yr9 +pzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=vz48/RSPFOJlzJ3tJY1CkSjfI97YkEq4vzNOy46Tkig=; b=naGaq3BWtjYZkfJwKonbXTh2ekLywm/SyFkmBJYO04eqtGQXdSu+0DBODyIcgy2rbP rkYnDV04XRL27BoxDKoLGH5AmeN4+84I+yv2F9isZBM3x1dV3uuPRgsKydea78oTrsxb oS5reHv3ScWdgMOUtJXT9UoS0DPy7gE0E28xixQoN6b8B0FuqxKrWkGEJhBgEQ46nDqn If2XkfbY0DOfnuK40085kqkhu94oG8NSoXX2Nr2iHS4/z3izHC3ivk6j8Ctz0QqVJTAR pfrUaaWfhzkha7+W65i01p678rJnPmopqbduxnBXtWECEAIuBdb7qICyUEjRmZdtYcg/ 7lAw== X-Gm-Message-State: AOAM5320NaqC9lvN19vQcaeGumY5vnGBfGmvKAr9NpHj61kieTqWNzvQ aAOqkOQZQg/fgRsc/eareeRHT930eRs= X-Google-Smtp-Source: ABdhPJyEclfp3cbUS+1PafXH62p/DRVz7R2G/FaGIzSsf+exT8f6BC0W8YD8QQwm4+XmTTCmHGkSmA== X-Received: by 2002:a05:600c:3493:b0:38e:bbbb:26f7 with SMTP id a19-20020a05600c349300b0038ebbbb26f7mr2808564wmq.114.1650448616607; Wed, 20 Apr 2022 02:56:56 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id p2-20020a1c7402000000b0038159076d30sm21161311wmc.22.2022.04.20.02.56.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 02:56:55 -0700 (PDT) Message-Id: <0904b50a377ce3ac242f9594a635f9ae7cffc687.1650448612.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 20 Apr 2022 09:56:45 +0000 Subject: [PATCH v2 2/8] t3406: rework rebase reflog tests Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Christian Couder , Elijah Newren , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood Refactor the tests in preparation for adding more tests in the next few commits. The reworked tests use the same function for testing both the "merge" and "apply" backends. The test coverage for the "apply" backend now includes setting GIT_REFLOG_ACTION. Note that rebasing the "conflicts" branch does not create any conflicts yet. A commit to do that will be added in the next commit and the diff ends up smaller if we have don't rename the branch when it is added. Signed-off-by: Phillip Wood --- t/t3406-rebase-message.sh | 115 +++++++++++++++++++++++++------------- 1 file changed, 76 insertions(+), 39 deletions(-) diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index d17b450e811..5253dd1551d 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -10,10 +10,15 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME test_expect_success 'setup' ' test_commit O fileO && test_commit X fileX && + git branch fast-forward && test_commit A fileA && test_commit B fileB && test_commit Y fileY && + git checkout -b conflicts O && + test_commit P && + test_commit Q && + git checkout -b topic O && git cherry-pick A B && test_commit Z fileZ && @@ -79,54 +84,86 @@ test_expect_success 'error out early upon -C or --whitespace=' ' test_i18ngrep "Invalid whitespace option" err ' -test_expect_success 'GIT_REFLOG_ACTION' ' - git checkout start && - test_commit reflog-onto && - git checkout -b reflog-topic start && - test_commit reflog-to-rebase && - - git rebase reflog-onto && - git log -g --format=%gs -3 >actual && - cat >expect <<-\EOF && - rebase (finish): returning to refs/heads/reflog-topic - rebase (pick): reflog-to-rebase - rebase (start): checkout reflog-onto +write_reflog_expect () { + if test $mode = --apply + then + sed 's/.*(finish)/rebase finished/; s/ ([^)]*)//' + else + cat + fi >expect +} + +test_reflog () { + mode=$1 + reflog_action="$2" + + test_expect_success "rebase $mode reflog${reflog_action:+ GIT_REFLOG_ACTION=$reflog_action}" ' + git checkout conflicts && + test_when_finished "git reset --hard Q" && + + ( + if test -n "$reflog_action" + then + GIT_REFLOG_ACTION="$reflog_action" && + export GIT_REFLOG_ACTION + fi && + git rebase $mode main + ) && + + git log -g --format=%gs -4 >actual && + write_reflog_expect <<-EOF && + ${reflog_action:-rebase} (finish): returning to refs/heads/conflicts + ${reflog_action:-rebase} (pick): Q + ${reflog_action:-rebase} (pick): P + ${reflog_action:-rebase} (start): checkout main EOF test_cmp expect actual && - git checkout -b reflog-prefix reflog-to-rebase && - GIT_REFLOG_ACTION=change-the-reflog git rebase reflog-onto && - git log -g --format=%gs -3 >actual && - cat >expect <<-\EOF && - change-the-reflog (finish): returning to refs/heads/reflog-prefix - change-the-reflog (pick): reflog-to-rebase - change-the-reflog (start): checkout reflog-onto + git log -g --format=%gs -1 conflicts >actual && + write_reflog_expect <<-EOF && + ${reflog_action:-rebase} (finish): refs/heads/conflicts onto $(git rev-parse main) EOF - test_cmp expect actual -' - -test_expect_success 'rebase --apply reflog' ' - git checkout -b reflog-apply start && - old_head_reflog="$(git log -g --format=%gs -1 HEAD)" && - - git rebase --apply Y && + test_cmp expect actual && - git log -g --format=%gs -4 HEAD >actual && - cat >expect <<-EOF && - rebase finished: returning to refs/heads/reflog-apply - rebase: Z - rebase: checkout Y - $old_head_reflog + # check there is only one new entry in the branch reflog + test_cmp_rev conflicts@{1} Q + ' + + test_expect_success "rebase $mode fast-forward reflog${reflog_action:+ GIT_REFLOG_ACTION=$reflog_action}" ' + git checkout fast-forward && + test_when_finished "git reset --hard X" && + + ( + if test -n "$reflog_action" + then + GIT_REFLOG_ACTION="$reflog_action" && + export GIT_REFLOG_ACTION + fi && + git rebase $mode main + ) && + + git log -g --format=%gs -2 >actual && + write_reflog_expect <<-EOF && + ${reflog_action:-rebase} (finish): returning to refs/heads/fast-forward + ${reflog_action:-rebase} (start): checkout main EOF test_cmp expect actual && - git log -g --format=%gs -2 reflog-apply >actual && - cat >expect <<-EOF && - rebase finished: refs/heads/reflog-apply onto $(git rev-parse Y) - branch: Created from start + git log -g --format=%gs -1 fast-forward >actual && + write_reflog_expect <<-EOF && + ${reflog_action:-rebase} (finish): refs/heads/fast-forward onto $(git rev-parse main) EOF - test_cmp expect actual -' + test_cmp expect actual && + + # check there is only one new entry in the branch reflog + test_cmp_rev fast-forward@{1} X + ' +} + +test_reflog --merge +test_reflog --merge my-reflog-action +test_reflog --apply +test_reflog --apply my-reflog-action test_expect_success 'rebase -i onto unrelated history' ' git init unrelated && From patchwork Wed Apr 20 09:56:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12819998 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 128A2C433FE for ; Wed, 20 Apr 2022 09:57:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377376AbiDTJ7y (ORCPT ); Wed, 20 Apr 2022 05:59:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377361AbiDTJ7p (ORCPT ); Wed, 20 Apr 2022 05:59:45 -0400 Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 93A753969C for ; Wed, 20 Apr 2022 02:56:59 -0700 (PDT) Received: by mail-wm1-x333.google.com with SMTP id r4-20020a05600c35c400b0039295dc1fc3so868570wmq.3 for ; Wed, 20 Apr 2022 02:56:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=O5kvl/S52pJhaRUSJnaztjWAmJ26/3AUh80dthgKV3Y=; b=kYBHiItCT4NuNK01QxY/vPDc5LxjpGD4ECq0GVk+fT2QnM/ZUgfKyOPbJEfHp6tB3Y IQv8xjIlHNNCq62no9pxZOaDvWaRK6Ss4lMR6M9Z5FW/Ba//7uGfCOy70cBLcmWN22wq hR4hoAJK/TWdbREr6XjZI4Lu4wXA3mn8LqR9CnPqAr1q3pKuCTOqcGIWIUeWcvtF4L7I OGbN8r4xYDsb1brSvfKYQ9Cb/D4JxfR5aHnTU7h2MaqAn3SE5y/To2UpdooWb3mEGhQA BToGXDYXaep7/cZ0fYgc6aGPA+b3DRWi6jmhxWNAwRPt3kZ6yTmPPhsNHboXQDq60rlY 2piw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=O5kvl/S52pJhaRUSJnaztjWAmJ26/3AUh80dthgKV3Y=; b=nJMrTAkcNUkX4boaWe8YcdRB3Q97cwZyKQx+M7tN7NuNQW+qNo8r67cHgScEkamscm UmqpOiM8x3z6ZEQeydfUPrcqKkq3Qh4iWP6EIk2M9IjPGronD4wLhk92nwtseD6tgqOl 2+l4BEfmrMY6uvmQdJZeAu7i1tJWLdu0S2KK5krSzxGqAvyd6drZGSpKrZ7/o0Xo/Md9 fPyhMrpEAKiV/WDIMA57wLQHJHzWoPcPtCWMFIN2YODaVXqGU4SbLuylgumyD3yc8If9 TSTQGAq/w69xvdtD1ZlRFYI4kkcCUX0LJ0WNWdcQ8d+MSgfe2n5fF3kE8D5xKmSUF0Yz //HA== X-Gm-Message-State: AOAM532LqGpPI8TUpnfXLsyww2aYAa1u7NhaT57K02nHv+rTwn048a8W I5k3N0AUPn+4tuYt4Qk5j91aV9T2MFs= X-Google-Smtp-Source: ABdhPJxzAAg6JEMgdDaa4LVUPFZMcAznVGjjGdTsJEWM5LdK0fS/9fg4mjmNzDnMkgMluwaXfgpSdg== X-Received: by 2002:a05:600c:19c6:b0:392:926e:5023 with SMTP id u6-20020a05600c19c600b00392926e5023mr2811849wmq.110.1650448617813; Wed, 20 Apr 2022 02:56:57 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t16-20020a5d5350000000b0020a99bc986bsm6418475wrv.28.2022.04.20.02.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 02:56:57 -0700 (PDT) Message-Id: <6c15f00e17064a356ceb2b638e89ee7ea21aff24.1650448612.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 20 Apr 2022 09:56:46 +0000 Subject: [PATCH v2 3/8] rebase --merge: fix reflog when continuing Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Christian Couder , Elijah Newren , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood The reflog message for a conflict resolution committed by "rebase --continue" looks like rebase (continue): commit subject line Unfortunately the reflog message each subsequent pick look like rebase (continue) (pick): commit subject line Fix this by setting the reflog message for "rebase --continue" in sequencer_continue() so it does not affect subsequent commits. This introduces a memory leak similar to the one leaking GIT_REFLOG_ACTION in pick_commits(). Both of these will be fixed in a future series that stops the sequencer calling setenv(). Signed-off-by: Phillip Wood --- builtin/rebase.c | 2 -- sequencer.c | 5 +++++ t/t3406-rebase-message.sh | 9 +++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 4832f16e675..cd9a4f3e2f1 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1247,8 +1247,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) int fd; options.action = "continue"; - set_reflog_action(&options); - /* Sanity check */ if (get_oid("HEAD", &head)) die(_("Cannot read HEAD")); diff --git a/sequencer.c b/sequencer.c index bdd66b4b67a..3634ad5baa9 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4777,6 +4777,8 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) if (read_populate_opts(opts)) return -1; if (is_rebase_i(opts)) { + char *previous_reflog_action; + if ((res = read_populate_todo(r, &todo_list, opts))) goto release_todo_list; @@ -4787,10 +4789,13 @@ int sequencer_continue(struct repository *r, struct replay_opts *opts) unlink(rebase_path_dropped()); } + previous_reflog_action = xstrdup(getenv(GIT_REFLOG_ACTION)); + setenv(GIT_REFLOG_ACTION, reflog_message(opts, "continue", NULL), 1); if (commit_staged_changes(r, opts, &todo_list)) { res = -1; goto release_todo_list; } + setenv(GIT_REFLOG_ACTION, previous_reflog_action, 1); } else if (!file_exists(get_todo_path(opts))) return continue_single_pick(r, opts); else if ((res = read_populate_todo(r, &todo_list, opts))) diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index 5253dd1551d..3ca2fbb0d59 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -17,6 +17,7 @@ test_expect_success 'setup' ' git checkout -b conflicts O && test_commit P && + test_commit conflict-X fileX && test_commit Q && git checkout -b topic O && @@ -107,13 +108,17 @@ test_reflog () { GIT_REFLOG_ACTION="$reflog_action" && export GIT_REFLOG_ACTION fi && - git rebase $mode main + test_must_fail git rebase $mode main && + echo resolved >fileX && + git add fileX && + git rebase --continue ) && - git log -g --format=%gs -4 >actual && + git log -g --format=%gs -5 >actual && write_reflog_expect <<-EOF && ${reflog_action:-rebase} (finish): returning to refs/heads/conflicts ${reflog_action:-rebase} (pick): Q + ${reflog_action:-rebase} (continue): conflict-X ${reflog_action:-rebase} (pick): P ${reflog_action:-rebase} (start): checkout main EOF From patchwork Wed Apr 20 09:56:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12819999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D59D8C433F5 for ; Wed, 20 Apr 2022 09:57:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377378AbiDTJ75 (ORCPT ); Wed, 20 Apr 2022 05:59:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377363AbiDTJ7q (ORCPT ); Wed, 20 Apr 2022 05:59:46 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3E8330F75 for ; Wed, 20 Apr 2022 02:57:00 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id x18so1538580wrc.0 for ; Wed, 20 Apr 2022 02:57:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=iqaxVSiB12UtAol0ouxrRdYyVpj3Yne/p84KirKNfjA=; b=egPTduhGnlXLUYDrCVBIU/HnVZmvzXqHjl2julFwHyz0ybN1bd8blmAUurQhglzLBr mEJndrs7uDHjlB+NsWkLPF0sPS0EWAhtAGVE9lne6bzZQvuWQ6htDLYdIRha5+vjTfIQ gsvRa2O94AX4yYaeTc/vg1TAmDRa2cJ7C3ZJkgMkm91ykLEfohcWq8nel3zTOB0+ApwS QL7s91j0DI43aF/L+cxS7S8Ai43LZM1i7QWC2iqJALoUl8Bekd99QS2rjFKSasQmri/e peNG3JOc//n2jyTEmPCg7x5VdY2fMYACFNkW8oharakRB1ZXaGna6n5HVTwMAKYqz+hP 20mA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=iqaxVSiB12UtAol0ouxrRdYyVpj3Yne/p84KirKNfjA=; b=lxaIorC3faJfVkMzffpSLxTx/HtIWzprVEJoZYYxPE2/X50hh8fxZhuzuxha/Ju5Zk +d6xiTRBMeZXRU7Y+kWqd3bKqHKHXfQb5KJ9i7WQuH2NUWAAy9HKYdlYb6ibUQxJdS5E WIZ9W/DItbKGwXOq0VpYB9xMM8y5gFLILMxH4czHWqW0Hvyb7pLg+Hp/scHuwm0fk+q5 m5IGwN0gUkz076dgrO2L2gzoAqpGvYjlOPBce2fO7ZrbkPlYBbVVcZfXW2xGAXayni2w ZbggXQnNYuYnJh8KFXJ0ACIVfV8HW+mFbTUVj7LNURcVbC0f7lgmqU3C/77KImn7jEaI Wv3w== X-Gm-Message-State: AOAM530SHcmRZ4KZTtPAI9kvULsvXK5QcXQBwyNLXBX9mKUE2qIWPK3A 5Vm/7RoAKRbXiBq/hlv/qK6pkIeVMhY= X-Google-Smtp-Source: ABdhPJxpjX8n64CNpynsV7rXLgvhqlBapjm6BJpjFtDA+acvlRFOkEqws7aNe93GzskC0mJwd9lU+A== X-Received: by 2002:adf:db8b:0:b0:207:9a90:3819 with SMTP id u11-20020adfdb8b000000b002079a903819mr15505369wri.617.1650448618996; Wed, 20 Apr 2022 02:56:58 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n42-20020a05600c3baa00b0038ffadd6e4asm17683358wms.30.2022.04.20.02.56.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 02:56:58 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 20 Apr 2022 09:56:47 +0000 Subject: [PATCH v2 4/8] rebase --merge: fix reflog message after skipping Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Christian Couder , Elijah Newren , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood The reflog message for every pick after running "rebase --skip" looks like rebase (skip) (pick): commit subject line Fix this by not appending " (skip)" to the reflog action. Signed-off-by: Phillip Wood --- builtin/rebase.c | 2 -- t/t3406-rebase-message.sh | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index cd9a4f3e2f1..36863117fba 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1273,8 +1273,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) struct string_list merge_rr = STRING_LIST_INIT_DUP; options.action = "skip"; - set_reflog_action(&options); - rerere_clear(the_repository, &merge_rr); string_list_clear(&merge_rr, 1); ropts.flags = RESET_HEAD_HARD; diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index 3ca2fbb0d59..8aa6a79acc1 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -163,6 +163,30 @@ test_reflog () { # check there is only one new entry in the branch reflog test_cmp_rev fast-forward@{1} X ' + + test_expect_success "rebase $mode --skip reflog${reflog_action:+ GIT_REFLOG_ACTION=$reflog_action}" ' + git checkout conflicts && + test_when_finished "git reset --hard Q" && + + ( + if test -n "$reflog_action" + then + GIT_REFLOG_ACTION="$reflog_action" && + export GIT_REFLOG_ACTION + fi && + test_must_fail git rebase $mode main && + git rebase --skip + ) && + + git log -g --format=%gs -4 >actual && + write_reflog_expect <<-EOF && + ${reflog_action:-rebase} (finish): returning to refs/heads/conflicts + ${reflog_action:-rebase} (pick): Q + ${reflog_action:-rebase} (pick): P + ${reflog_action:-rebase} (start): checkout main + EOF + test_cmp expect actual + ' } test_reflog --merge From patchwork Wed Apr 20 09:56:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12820000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EA302C433EF for ; Wed, 20 Apr 2022 09:57:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377380AbiDTJ76 (ORCPT ); Wed, 20 Apr 2022 05:59:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377359AbiDTJ7r (ORCPT ); Wed, 20 Apr 2022 05:59:47 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 060643298E for ; Wed, 20 Apr 2022 02:57:02 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id k22so1516260wrd.2 for ; Wed, 20 Apr 2022 02:57:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=PnEkkU9Wx6HdLyfYv/KNN6gAbLsvuSzZ8V5DKhxVJIc=; b=oEJsw0JvcP65cLDbCjNX/BLHVKkrvVyncILHOPZ6H+tiqHtL9PwPqPH52wAnACPMr2 MDifOHHUviiAU0hMOI/LPswj8hTjLjuPJrn1OVWuklOxNSwCr0NiD0smMDq//qOOVFIr WNPORbVLwz7z7f2WMitOyKZd/i+9IXnPfNACoPysEXZYdD01uBM+6Js3eShaF6l92c0y Wn3KdWZstSG5Y1kOFU8H5S1ez+SJ6wYExG6S8UhulOn2BDXk/GvPNABlseqoBHXCTDOb FfTzIreIfUKPDIgLq/54cThcR8H9jOMVC52ltMEwQT1zaAPYw6VhRqthZr1bOZ1ZgJ/A 4ltQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=PnEkkU9Wx6HdLyfYv/KNN6gAbLsvuSzZ8V5DKhxVJIc=; b=T4/ZTJ5/+ScLqt/ptwpBC0HIzwHqeQzgiRSyVSBxOwsIxCBvAzTGv0qKjibwzHBK0Q dB7I7ucpYzMuT51LWVqvx8URDVYHHzHyA4thNDmEJXnnW0s/fAFLKEqqgjL0TijQgxig 5EXoiE76t3qIvZ87Bo9gEZuNbEyzkVNzkFLUq7j6YQeLCPJHgqHFHtUEGFErbe3Xbirw mmVjfzSP0jcYJPNttOfVNwP/oeYQmeiiZuTg/frGVOnHFlHGw1bRp2GrtQVwDZPT9WLg SWzs1rjCefT0HbalzUPWInQvTZKu3MhvlX5g7m9go3WQsfb+4FNL1bELxLuGFX1dmhW2 MGTA== X-Gm-Message-State: AOAM532LOky+ARh4CYCvd7iLG8ZLpnSTRdeo9/HYrCbocII9FNj3l4DR 8xhWC5g3gEPgSdBE824YprgfoTcCPFM= X-Google-Smtp-Source: ABdhPJw+2MWw7TtckneRFdQ3b0xyHCa/81luTwXOs2XgZJSiD70P4/qm968+7HEXd5anG6siajCCXg== X-Received: by 2002:a05:6000:1844:b0:20a:77b3:716e with SMTP id c4-20020a056000184400b0020a77b3716emr15454445wri.231.1650448620289; Wed, 20 Apr 2022 02:57:00 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f16-20020a05600c155000b0039288e17458sm14046484wmg.19.2022.04.20.02.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 02:56:59 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 20 Apr 2022 09:56:48 +0000 Subject: [PATCH v2 5/8] rebase --apply: respect GIT_REFLOG_ACTION Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Christian Couder , Elijah Newren , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood The reflog messages when finishing a rebase hard code "rebase" rather than using GIT_REFLOG_ACTION. Signed-off-by: Phillip Wood --- builtin/rebase.c | 7 ++++--- t/t3406-rebase-message.sh | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 36863117fba..e50361fc2a9 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -580,10 +580,11 @@ static int move_to_original_branch(struct rebase_options *opts) if (!opts->onto) BUG("move_to_original_branch without onto"); - strbuf_addf(&branch_reflog, "rebase finished: %s onto %s", + strbuf_addf(&branch_reflog, "%s finished: %s onto %s", + getenv(GIT_REFLOG_ACTION_ENVIRONMENT), opts->head_name, oid_to_hex(&opts->onto->object.oid)); - strbuf_addf(&head_reflog, "rebase finished: returning to %s", - opts->head_name); + strbuf_addf(&head_reflog, "%s finished: returning to %s", + getenv(GIT_REFLOG_ACTION_ENVIRONMENT), opts->head_name); ropts.branch = opts->head_name; ropts.flags = RESET_HEAD_REFS_ONLY; ropts.branch_msg = branch_reflog.buf; diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index 8aa6a79acc1..bb2a4949abc 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -88,7 +88,7 @@ test_expect_success 'error out early upon -C or --whitespace=' ' write_reflog_expect () { if test $mode = --apply then - sed 's/.*(finish)/rebase finished/; s/ ([^)]*)//' + sed 's/(finish)/finished/; s/ ([^)]*)//' else cat fi >expect From patchwork Wed Apr 20 09:56:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12820001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3A73C433EF for ; Wed, 20 Apr 2022 09:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377397AbiDTKAG (ORCPT ); Wed, 20 Apr 2022 06:00:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59538 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377358AbiDTJ7t (ORCPT ); Wed, 20 Apr 2022 05:59:49 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BA5238BF0 for ; Wed, 20 Apr 2022 02:57:03 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id p189so829219wmp.3 for ; Wed, 20 Apr 2022 02:57:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=2SYDa+rcqivkvUif5+HUoX5QbBb/oga7GCGFMYTLewY=; b=CaHfMayYq2dPBfGKGiEazLKnx/D+e9M4YIq0gRhSd2Mp8xE3fnSIXK979ofn05Yvaf snczfeOUSMmtL2v2kDHlmABS8MoZuWCyoQt/nuLW8j9I2s8PSS3IEClb0hSGSoLivzo2 IXJZQkbtiC3lA5L7Yrwcxaw11lTCm9uUmApZvoiIjcwMhVrltJkFpONGxe+MdQT6ycwL yYjN8/7ydYieWisX9aDxVa8/phLDpgmNl/WUl9U4Zz7nju9cIEbucqWVfDVwnqiYqY8/ 1QaK5KDHNrxHhVb6CDPrzFeOKUNNIaosvwhNAgNYw33J7OPext4zSQ4HSyDf4OZ1qicL LQzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=2SYDa+rcqivkvUif5+HUoX5QbBb/oga7GCGFMYTLewY=; b=UBV2uGO84DUlLmCuctcJKFOH0UFCpNR61BDCy4g6vUz5xDwh9wqANi3+D8NsFg230D WH3Sji3LsK/prcs4RqUhKOCGJ/mTgwXOPgKW/VF/VNVbQ/GDSAxrJNY0dqRf+jpZnn9I 6ukXR+e6GhBCTwuMDKwKXK7bHjrAV73O1vjN8wsW9fbSwxQNg1BEr6wpbK64hIsrerQ2 59hKLsfiN1EGjXwSW656dI/FhWoGW0Uqjb5pam/ZRlGWoaNy3iYdeJNs8cOtK7ITjB9h dI1wk94pLOu+SKWLdq9/+JK5jACCAHog73OqPtgDqIEBTK4Z5G+dQWg7dS8SVm8HWLzy SVyQ== X-Gm-Message-State: AOAM531W83pSoSCwhKnNlYEPaqWZvlilovdwBYLvss187HSQRsLqtiMf N8EpA+Knk7mucMnnJxXhck8eAto1tW4= X-Google-Smtp-Source: ABdhPJzdmbPGB8ZyyzOe94icl1FwUMCYnTIHFRimSHUeDwUe6hFEiDfHOtQMaoM42hK/liDu+gqwzw== X-Received: by 2002:a7b:cc17:0:b0:38d:af7:3848 with SMTP id f23-20020a7bcc17000000b0038d0af73848mr2790571wmh.41.1650448621780; Wed, 20 Apr 2022 02:57:01 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id t9-20020adfa2c9000000b002061561d4a7sm14968085wra.96.2022.04.20.02.57.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 02:57:00 -0700 (PDT) Message-Id: <95161f21e0004cff1bb0915aa39200b286e592e5.1650448612.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 20 Apr 2022 09:56:49 +0000 Subject: [PATCH v2 6/8] rebase --apply: make reflog messages match rebase --merge Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Christian Couder , Elijah Newren , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood The apply backend creates slightly different reflog messages to the merge backend when starting and finishing a rebase and when picking commits. The choice of backend is really an implementation detail so it is confusing to have the same command create different messages depending on which backend is selected. Change the apply backend so the reflog messages from the two backends match as closely as possible. Note that there is still a difference when committing a conflict resolution - the merge backend will use "(continue)" rather than "(pick)" in that case as it does not know which command created the conflict that it is committing. Signed-off-by: Phillip Wood --- builtin/rebase.c | 9 +++++---- t/t3406-rebase-message.sh | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index e50361fc2a9..678339c7bf7 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -580,10 +580,10 @@ static int move_to_original_branch(struct rebase_options *opts) if (!opts->onto) BUG("move_to_original_branch without onto"); - strbuf_addf(&branch_reflog, "%s finished: %s onto %s", + strbuf_addf(&branch_reflog, "%s (finish): %s onto %s", getenv(GIT_REFLOG_ACTION_ENVIRONMENT), opts->head_name, oid_to_hex(&opts->onto->object.oid)); - strbuf_addf(&head_reflog, "%s finished: returning to %s", + strbuf_addf(&head_reflog, "%s (finish): returning to %s", getenv(GIT_REFLOG_ACTION_ENVIRONMENT), opts->head_name); ropts.branch = opts->head_name; ropts.flags = RESET_HEAD_REFS_ONLY; @@ -613,7 +613,8 @@ static int run_am(struct rebase_options *opts) am.git_cmd = 1; strvec_push(&am.args, "am"); - + strvec_pushf(&am.env_array, GIT_REFLOG_ACTION_ENVIRONMENT "=%s (pick)", + getenv(GIT_REFLOG_ACTION_ENVIRONMENT)); if (opts->action && !strcmp("continue", opts->action)) { strvec_push(&am.args, "--resolved"); strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg); @@ -1763,7 +1764,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) printf(_("First, rewinding head to replay your work on top of " "it...\n")); - strbuf_addf(&msg, "%s: checkout %s", + strbuf_addf(&msg, "%s (start): checkout %s", getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name); ropts.oid = &options.onto->object.oid; ropts.orig_head = &options.orig_head, diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index bb2a4949abc..5c6cd9af3bc 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -88,7 +88,7 @@ test_expect_success 'error out early upon -C or --whitespace=' ' write_reflog_expect () { if test $mode = --apply then - sed 's/(finish)/finished/; s/ ([^)]*)//' + sed 's/(continue)/(pick)/' else cat fi >expect From patchwork Wed Apr 20 09:56:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12820002 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C02FC433EF for ; Wed, 20 Apr 2022 09:57:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236420AbiDTKAK (ORCPT ); Wed, 20 Apr 2022 06:00:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59592 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377369AbiDTJ7u (ORCPT ); Wed, 20 Apr 2022 05:59:50 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BBAF73B003 for ; Wed, 20 Apr 2022 02:57:04 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id o20-20020a05600c511400b0038ebbbb2ad8so890945wms.0 for ; Wed, 20 Apr 2022 02:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=DbmCoZwypBuMMIe4XObqTM7EOQuZ449bEHECh/zC6tc=; b=EsPs09eOep3qj10k3Qe14H9GxYcBFzxv8nB7xqNtrw8jNSUAKRVnqBhMX1UQGPKf1Q wprwkTdjynfxz5smN2/DEOyuXgIQ1N4aNDULZuT2sYDu3Fc0au5219Certq2+mEI86ET CtjdlFs0a7gh7FZDUzG8sBi4WhxiIr+NTaAew+IvBEL/rcL/7QJj1Dbb5x8+kt5ZWmVR /pmCIfnZcsWM5HAfifraB9irfejsj3CsYBsI5ks25ERnxGRqDo/rFWulcN2M+JO63FeF jAYU/FrHeXcRWn7cyJmAxGrguk3DzSDFri80fNLq9ujTvUcE1T9jAY98AFPp/pKdayZr Isww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=DbmCoZwypBuMMIe4XObqTM7EOQuZ449bEHECh/zC6tc=; b=RKG8wTqb4tKk+L5CcEo8wSV3VIFL5zp0D1YV/US0wdFAVJDBbst/pBu14q6G2wseO4 KqTySThDoSZHPy02T+HN2SWxH+CxzVDxwDHleGrr5RO6o2fXHx7J7do9QgtdLDB/gDL0 jgC8x0a1xp39kzLcEEGmBIiBGP3EpPSIN/Xvjz6bmrenY6+pWrSaiMHbPkRFEMXdBzyX vJlBW/XpLszJ0n3pbU7dVahZCTAYTGd11mCOZHxIIxr1aoFaaHML+76fxolWoFnVF9qv phuB+wonKSljYHeFBqZfARIfrQfHbvDSGd50NfYZlM/i4rcMafZSXxyrJaCaYRet3S9b /EOQ== X-Gm-Message-State: AOAM531aJ5mSXWvoKxs0ne6xXBctyHjxPL7Z2DxBwyriBh3gESixJt4K G3fikimYuARmLB3eCFL+9wVqCwA3vIk= X-Google-Smtp-Source: ABdhPJxceMbfmndN/ovj9HGTSFgenm0FDxs6+f+UtFqX8RR+KEH29Bmp+a6Kk8wDw2HgvjMIfakTcQ== X-Received: by 2002:a05:600c:3585:b0:392:90a9:41dc with SMTP id p5-20020a05600c358500b0039290a941dcmr2886454wmq.4.1650448622885; Wed, 20 Apr 2022 02:57:02 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u5-20020adfed45000000b00207a480e6aasm14898337wro.116.2022.04.20.02.57.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 02:57:02 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 20 Apr 2022 09:56:50 +0000 Subject: [PATCH v2 7/8] rebase --abort: improve reflog message Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Christian Couder , Elijah Newren , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood When aborting a rebase the reflog message looks like rebase (abort): updating HEAD which is not very informative. Improve the message by mentioning the branch that we are returning to as we do at the end of a successful rebase so it looks like. rebase (abort): returning to refs/heads/topic If GIT_REFLOG_ACTION is set in the environment we no longer omit "(abort)" from the reflog message. We don't omit "(start)" and "(finish)" when starting and finishing a rebase in that case so we shouldn't omit "(abort)". Signed-off-by: Phillip Wood --- builtin/rebase.c | 28 ++++++--------------- t/t3406-rebase-message.sh | 51 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 20 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 678339c7bf7..70426e17b40 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -992,23 +992,6 @@ static void NORETURN error_on_missing_default_upstream(void) exit(1); } -static void set_reflog_action(struct rebase_options *options) -{ - const char *env; - struct strbuf buf = STRBUF_INIT; - - if (!is_merge(options)) - return; - - env = getenv(GIT_REFLOG_ACTION_ENVIRONMENT); - if (env && strcmp("rebase", env)) - return; /* only override it if it is "rebase" */ - - strbuf_addf(&buf, "rebase (%s)", options->action); - setenv(GIT_REFLOG_ACTION_ENVIRONMENT, buf.buf, 1); - strbuf_release(&buf); -} - static int check_exec_cmd(const char *cmd) { if (strchr(cmd, '\n')) @@ -1287,18 +1270,23 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) } case ACTION_ABORT: { struct string_list merge_rr = STRING_LIST_INIT_DUP; - options.action = "abort"; - set_reflog_action(&options); + struct strbuf head_msg = STRBUF_INIT; + options.action = "abort"; rerere_clear(the_repository, &merge_rr); string_list_clear(&merge_rr, 1); if (read_basic_state(&options)) exit(1); + + strbuf_addf(&head_msg, "%s (abort): returning to %s", + getenv(GIT_REFLOG_ACTION_ENVIRONMENT), + options.head_name ? options.head_name + : oid_to_hex(&options.orig_head)); ropts.oid = &options.orig_head; + ropts.head_msg = head_msg.buf; ropts.branch = options.head_name; ropts.flags = RESET_HEAD_HARD; - ropts.default_reflog_action = DEFAULT_REFLOG_ACTION; if (reset_head(the_repository, &ropts) < 0) die(_("could not move back to %s"), oid_to_hex(&options.orig_head)); diff --git a/t/t3406-rebase-message.sh b/t/t3406-rebase-message.sh index 5c6cd9af3bc..ceca1600053 100755 --- a/t/t3406-rebase-message.sh +++ b/t/t3406-rebase-message.sh @@ -187,6 +187,57 @@ test_reflog () { EOF test_cmp expect actual ' + + test_expect_success "rebase $mode --abort reflog${reflog_action:+ GIT_REFLOG_ACTION=$reflog_action}" ' + git checkout conflicts && + test_when_finished "git reset --hard Q" && + + git log -g -1 conflicts >branch-expect && + ( + if test -n "$reflog_action" + then + GIT_REFLOG_ACTION="$reflog_action" && + export GIT_REFLOG_ACTION + fi && + test_must_fail git rebase $mode main && + git rebase --abort + ) && + + git log -g --format=%gs -3 >actual && + write_reflog_expect <<-EOF && + ${reflog_action:-rebase} (abort): returning to refs/heads/conflicts + ${reflog_action:-rebase} (pick): P + ${reflog_action:-rebase} (start): checkout main + EOF + test_cmp expect actual && + + # check branch reflog is unchanged + git log -g -1 conflicts >branch-actual && + test_cmp branch-expect branch-actual + ' + + test_expect_success "rebase $mode --abort detached HEAD reflog${reflog_action:+ GIT_REFLOG_ACTION=$reflog_action}" ' + git checkout Q && + test_when_finished "git reset --hard Q" && + + ( + if test -n "$reflog_action" + then + GIT_REFLOG_ACTION="$reflog_action" && + export GIT_REFLOG_ACTION + fi && + test_must_fail git rebase $mode main && + git rebase --abort + ) && + + git log -g --format=%gs -3 >actual && + write_reflog_expect <<-EOF && + ${reflog_action:-rebase} (abort): returning to $(git rev-parse Q) + ${reflog_action:-rebase} (pick): P + ${reflog_action:-rebase} (start): checkout main + EOF + test_cmp expect actual + ' } test_reflog --merge From patchwork Wed Apr 20 09:56:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 12820003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B948AC433F5 for ; Wed, 20 Apr 2022 09:57:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377411AbiDTKAP (ORCPT ); Wed, 20 Apr 2022 06:00:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377373AbiDTJ7w (ORCPT ); Wed, 20 Apr 2022 05:59:52 -0400 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D55673BF93 for ; Wed, 20 Apr 2022 02:57:05 -0700 (PDT) Received: by mail-wr1-x431.google.com with SMTP id e21so1485267wrc.8 for ; Wed, 20 Apr 2022 02:57:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=y1ESANf/m0uLV1VxDTeCxu5by2O2N28lW6PIgjqXsEY=; b=Pi7gkWalKvSSFdnOqgAhdtrl4P1fYVzd0T1PHPOgM7Cy8th5tr8wwkLFAkW9dCJ4IX 5EpZcniCM0gCfwzdZ93tn9DR3Q2iQPTUabJ/FW9A7Pe9v7PTazmCYQyd/0MwlzQV8Fcp 2GSW/qJp1WJafF5F737Sd312pSdwWnzkp3DvCRhUfMf9PZzIGbKViJirpRJunlBsrZ9y RM/LXOPGBYOROO6fwd6FTEclPiZbGCBvq1Ezik4Ziqej8wvHP4hf6oNDWZSyOFKTSocN FT9sPeBa2718/nBT3+gjur2Oxz/v/+Un+VdD4WxMtEfeIjln/yzeHfd51E7G069eZyNw NOsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=y1ESANf/m0uLV1VxDTeCxu5by2O2N28lW6PIgjqXsEY=; b=hEQWOgsL3TQN2iJvkQ2HKKL75dbgofhr5TO4JiGl0kdAy0gdOVfLa6OInaFE0xWwwu bdNEHmugCKc2NChORhmmY7CJ2juvDdDbJQwHi21oBlDR6kd2+Tx8AGK5ECvWL5oTLvpP EarSFvCGBtUXssluMIIh+x0DwRs167oQe3TS0sSLP8+0blHv7N9AmIfqc9g9CvedkFDC E8Ri1NM2kjwUmWuTDYB3pJZSrK0EoCk12lOCyyZI+sgW/yOf5nTt/90Dr463wtO9/ASQ 5zU72HoYyqfUnnOayzYD4PfPlmDJpG3LN+5Y+cjd69pRBvts4NPqlQxoDhULAIq4BgoA XEWA== X-Gm-Message-State: AOAM5314ZsKZLZcV4nfOwP18Fc5E6TAzIAJ0b5gxAe4t8d0kWlm+osWa 4L4HZQXWuFEKh5SMglLzj0gGHZ1bMlY= X-Google-Smtp-Source: ABdhPJxci5ST5/4NkAKfvCyVmhd22r+30aPB13SfsyPDsYJhVULhMYe0DeRTaeLV+orNl2ii/0W6/w== X-Received: by 2002:a5d:6201:0:b0:207:8d91:aaa9 with SMTP id y1-20020a5d6201000000b002078d91aaa9mr15006627wru.262.1650448624065; Wed, 20 Apr 2022 02:57:04 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a16-20020a056000051000b00207b5d9f51fsm14678036wrf.41.2022.04.20.02.57.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 02:57:03 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 20 Apr 2022 09:56:51 +0000 Subject: [PATCH v2 8/8] rebase: cleanup action handling Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Christian Couder , Elijah Newren , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood Treating the action as a string is a hang over from the scripted rebase. The last commit removed the only remaining use of the action that required a string so lets convert the other action users to use the existing action enum instead. If we ever need the action name as a string in the future the action_names array exists exactly for that purpose. Signed-off-by: Phillip Wood --- builtin/rebase.c | 91 +++++++++++++++++++++++------------------------- 1 file changed, 43 insertions(+), 48 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 70426e17b40..323f5154092 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -58,6 +58,26 @@ enum empty_type { EMPTY_ASK }; +enum action { + ACTION_NONE = 0, + ACTION_CONTINUE, + ACTION_SKIP, + ACTION_ABORT, + ACTION_QUIT, + ACTION_EDIT_TODO, + ACTION_SHOW_CURRENT_PATCH +}; + +static const char *action_names[] = { + "undefined", + "continue", + "skip", + "abort", + "quit", + "edit_todo", + "show_current_patch" +}; + struct rebase_options { enum rebase_type type; enum empty_type empty; @@ -84,7 +104,7 @@ struct rebase_options { REBASE_INTERACTIVE_EXPLICIT = 1<<4, } flags; struct strvec git_am_opts; - const char *action; + enum action action; int signoff; int allow_rerere_autoupdate; int keep_empty; @@ -155,24 +175,6 @@ static struct replay_opts get_replay_opts(const struct rebase_options *opts) return replay; } -enum action { - ACTION_NONE = 0, - ACTION_CONTINUE, - ACTION_SKIP, - ACTION_ABORT, - ACTION_QUIT, - ACTION_EDIT_TODO, - ACTION_SHOW_CURRENT_PATCH -}; - -static const char *action_names[] = { "undefined", - "continue", - "skip", - "abort", - "quit", - "edit_todo", - "show_current_patch" }; - static int edit_todo_file(unsigned flags) { const char *todo_file = rebase_path_todo(); @@ -309,8 +311,7 @@ static int do_interactive_rebase(struct rebase_options *opts, unsigned flags) return ret; } -static int run_sequencer_rebase(struct rebase_options *opts, - enum action command) +static int run_sequencer_rebase(struct rebase_options *opts) { unsigned flags = 0; int abbreviate_commands = 0, ret = 0; @@ -325,7 +326,7 @@ static int run_sequencer_rebase(struct rebase_options *opts, flags |= opts->reapply_cherry_picks ? TODO_LIST_REAPPLY_CHERRY_PICKS : 0; flags |= opts->flags & REBASE_NO_QUIET ? TODO_LIST_WARN_SKIPPED_CHERRY_PICKS : 0; - switch (command) { + switch (opts->action) { case ACTION_NONE: { if (!opts->onto && !opts->upstream) die(_("a base commit must be provided with --upstream or --onto")); @@ -358,7 +359,7 @@ static int run_sequencer_rebase(struct rebase_options *opts, break; } default: - BUG("invalid command '%d'", command); + BUG("invalid command '%d'", opts->action); } return ret; @@ -615,7 +616,7 @@ static int run_am(struct rebase_options *opts) strvec_push(&am.args, "am"); strvec_pushf(&am.env_array, GIT_REFLOG_ACTION_ENVIRONMENT "=%s (pick)", getenv(GIT_REFLOG_ACTION_ENVIRONMENT)); - if (opts->action && !strcmp("continue", opts->action)) { + if (opts->action == ACTION_CONTINUE) { strvec_push(&am.args, "--resolved"); strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg); if (opts->gpg_sign_opt) @@ -626,7 +627,7 @@ static int run_am(struct rebase_options *opts) return move_to_original_branch(opts); } - if (opts->action && !strcmp("skip", opts->action)) { + if (opts->action == ACTION_SKIP) { strvec_push(&am.args, "--skip"); strvec_pushf(&am.args, "--resolvemsg=%s", resolvemsg); status = run_command(&am); @@ -635,7 +636,7 @@ static int run_am(struct rebase_options *opts) return move_to_original_branch(opts); } - if (opts->action && !strcmp("show-current-patch", opts->action)) { + if (opts->action == ACTION_SHOW_CURRENT_PATCH) { strvec_push(&am.args, "--show-current-patch"); return run_command(&am); } @@ -728,7 +729,7 @@ static int run_am(struct rebase_options *opts) return status; } -static int run_specific_rebase(struct rebase_options *opts, enum action action) +static int run_specific_rebase(struct rebase_options *opts) { int status; @@ -746,7 +747,7 @@ static int run_specific_rebase(struct rebase_options *opts, enum action action) opts->gpg_sign_opt = tmp; } - status = run_sequencer_rebase(opts, action); + status = run_sequencer_rebase(opts); } else if (opts->type == REBASE_APPLY) status = run_am(opts); else @@ -1016,7 +1017,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) struct strbuf buf = STRBUF_INIT; struct object_id merge_base; int ignore_whitespace = 0; - enum action action = ACTION_NONE; const char *gpg_sign = NULL; struct string_list exec = STRING_LIST_INIT_NODUP; const char *rebase_merges = NULL; @@ -1065,18 +1065,18 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) OPT_BIT(0, "no-ff", &options.flags, N_("cherry-pick all commits, even if unchanged"), REBASE_FORCE), - OPT_CMDMODE(0, "continue", &action, N_("continue"), + OPT_CMDMODE(0, "continue", &options.action, N_("continue"), ACTION_CONTINUE), - OPT_CMDMODE(0, "skip", &action, + OPT_CMDMODE(0, "skip", &options.action, N_("skip current patch and continue"), ACTION_SKIP), - OPT_CMDMODE(0, "abort", &action, + OPT_CMDMODE(0, "abort", &options.action, N_("abort and check out the original branch"), ACTION_ABORT), - OPT_CMDMODE(0, "quit", &action, + OPT_CMDMODE(0, "quit", &options.action, N_("abort but keep HEAD where it is"), ACTION_QUIT), - OPT_CMDMODE(0, "edit-todo", &action, N_("edit the todo list " + OPT_CMDMODE(0, "edit-todo", &options.action, N_("edit the todo list " "during an interactive rebase"), ACTION_EDIT_TODO), - OPT_CMDMODE(0, "show-current-patch", &action, + OPT_CMDMODE(0, "show-current-patch", &options.action, N_("show the patch file being applied or merged"), ACTION_SHOW_CURRENT_PATCH), OPT_CALLBACK_F(0, "apply", &options, NULL, @@ -1189,7 +1189,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) if (preserve_merges_selected) die(_("--preserve-merges was replaced by --rebase-merges")); - if (action != ACTION_NONE && total_argc != 2) { + if (options.action != ACTION_NONE && total_argc != 2) { usage_with_options(builtin_rebase_usage, builtin_rebase_options); } @@ -1208,11 +1208,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) if (options.root && options.fork_point > 0) die(_("cannot combine '--root' with '--fork-point'")); - if (action != ACTION_NONE && !in_progress) + if (options.action != ACTION_NONE && !in_progress) die(_("No rebase in progress?")); setenv(GIT_REFLOG_ACTION_ENVIRONMENT, "rebase", 0); - if (action == ACTION_EDIT_TODO && !is_merge(&options)) + if (options.action == ACTION_EDIT_TODO && !is_merge(&options)) die(_("The --edit-todo action can only be used during " "interactive rebase.")); @@ -1222,16 +1222,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) else if (exec.nr) trace2_cmd_mode("interactive-exec"); else - trace2_cmd_mode(action_names[action]); + trace2_cmd_mode(action_names[options.action]); } - switch (action) { + switch (options.action) { case ACTION_CONTINUE: { struct object_id head; struct lock_file lock_file = LOCK_INIT; int fd; - options.action = "continue"; /* Sanity check */ if (get_oid("HEAD", &head)) die(_("Cannot read HEAD")); @@ -1257,7 +1256,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) case ACTION_SKIP: { struct string_list merge_rr = STRING_LIST_INIT_DUP; - options.action = "skip"; rerere_clear(the_repository, &merge_rr); string_list_clear(&merge_rr, 1); ropts.flags = RESET_HEAD_HARD; @@ -1272,7 +1270,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) struct string_list merge_rr = STRING_LIST_INIT_DUP; struct strbuf head_msg = STRBUF_INIT; - options.action = "abort"; rerere_clear(the_repository, &merge_rr); string_list_clear(&merge_rr, 1); @@ -1312,17 +1309,15 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) goto cleanup; } case ACTION_EDIT_TODO: - options.action = "edit-todo"; options.dont_finish_rebase = 1; goto run_rebase; case ACTION_SHOW_CURRENT_PATCH: - options.action = "show-current-patch"; options.dont_finish_rebase = 1; goto run_rebase; case ACTION_NONE: break; default: - BUG("action: %d", action); + BUG("action: %d", options.action); } /* Make sure no rebase is in progress */ @@ -1346,7 +1341,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) } if ((options.flags & REBASE_INTERACTIVE_EXPLICIT) || - (action != ACTION_NONE) || + (options.action != ACTION_NONE) || (exec.nr > 0) || options.autosquash) { allow_preemptive_ff = 0; @@ -1786,7 +1781,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) options.revisions = revisions.buf; run_rebase: - ret = run_specific_rebase(&options, action); + ret = run_specific_rebase(&options); cleanup: strbuf_release(&buf);