From patchwork Wed Oct 12 09:35:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13004915 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 1D44EC4332F for ; Wed, 12 Oct 2022 09:35:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230016AbiJLJfU (ORCPT ); Wed, 12 Oct 2022 05:35:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229798AbiJLJfR (ORCPT ); Wed, 12 Oct 2022 05:35:17 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C69A533E3A for ; Wed, 12 Oct 2022 02:35:16 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id r13so25349955wrj.11 for ; Wed, 12 Oct 2022 02:35:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=xGrXmzqqST9iXNfjUV8b8UO/R2MiFaBpmcQ8GxkqVDg=; b=NlYY/gqw5TEoJUBuXS8ts7/hnYbjRqP6F0GlO/wJc3LsChfzpiIr4IH0ZidW8CEcHK blAZlQPhpfiMMhoBML8kaxDNPQIahEyzuPBMvTKbgQNUtfMRgdtAxz+6K8TFO8Zisjae XfcY2vUrhxMZQKpqS4MU8VaWaxg4T8x21Y0gOiPk7+yGrvewd2Ia8qhFdN1sRqN4eiLJ kjbi/5Tf8kfFy29y4JoM/MjD9mcPFd7aG3Gal/DlJkHpvzdirldpWJ4LgF5D1RJFBx1G FcfAHcBFBObV/2N5lXls0zrt/nqkwTRanVashdhR+LNr4UuK9vlb83Aov82yFDA7u7OQ xF5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xGrXmzqqST9iXNfjUV8b8UO/R2MiFaBpmcQ8GxkqVDg=; b=hhAbaf3K++XLHe1dRkIf1QsDfgKLqR/Xfr53Qk+JJ2UQktfaXUfQS+LlK6xWLGWYbT zDifALwstlkVmJVsyb7VhnA5dBFkJCr8FHNKloUXHqZ9mzB15ykG2UUEoBoILgfo0KXF gibbHwPTKWpOAFIwpzSg3eEanqaI3rSaOj1ivWXho6NINO1rqewsFBmOnCOyiqvwLvwJ h76ntvzmWH5NJ2svHdn0LTfuqHo4JQmoaa2mvPGwOrzz6WXBak0Gs8V2PVPXPPLi8ui8 9hk+LnOxhCVq/EcGjNACSqGnk6DzWLVuRMz0uD0NHBMnYTXOCoc5uoA7O+2V86yD0yDK 1IVQ== X-Gm-Message-State: ACrzQf3nDNT0eNI01wqqgIbXtQw2qp7xDhHnjUF/wRvgLwwC2TicPNqN lxI3xhl4EaPUryPesl6ugBd9Atiokrk= X-Google-Smtp-Source: AMsMyM7rAFBnS013QxlwI90oP07HlrfPABGiHyAUBQ+Ie96M81RclqfGe2+5304LXGKZZiXovziUwA== X-Received: by 2002:a5d:6111:0:b0:22e:5476:9659 with SMTP id v17-20020a5d6111000000b0022e54769659mr18185955wrt.711.1665567315128; Wed, 12 Oct 2022 02:35:15 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n2-20020a1ca402000000b003c5571c27a1sm1672449wme.32.2022.10.12.02.35.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 02:35:14 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 12 Oct 2022 09:35:05 +0000 Subject: [PATCH v3 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 , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Calvin Wan , Emily Shaffer , Glen Choo , Victoria Dye , Phillip Wood , Phillip Wood Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood From: Phillip Wood Use move_to_original_branch() when reattaching HEAD after a fast-forward rather than open coding a copy of that code. move_to_original_branch() does not call reset_head() if head_name is NULL but there should be no user visible changes even though we currently call reset_head() in that case. The reason for this is that the reset_head() call does not add a message to the reflog because we're not changing the commit that HEAD points to and so lock_ref_for_update() elides the update. When head_name is not NULL then reset_head() behaves like "git symbolic-ref" and so the reflog is updated. 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 a2ca66b54be..51accb4fd61 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1808,19 +1808,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(&branch_base, &options.orig_head->object.oid)) { 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 Oct 12 09:35:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13004917 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 D86CCC4332F for ; Wed, 12 Oct 2022 09:35:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230021AbiJLJfY (ORCPT ); Wed, 12 Oct 2022 05:35:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbiJLJfT (ORCPT ); Wed, 12 Oct 2022 05:35:19 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBE0533E0C for ; Wed, 12 Oct 2022 02:35:17 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id w18so25380912wro.7 for ; Wed, 12 Oct 2022 02:35:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=vz48/RSPFOJlzJ3tJY1CkSjfI97YkEq4vzNOy46Tkig=; b=NwjcA7SCToCMWKSP5jmttqcTKCX9QAhE6LCRTXGFpjxs6z65URUGMldLDLKIreAdJm D7pKkMaxLwrFcBo5xZjgQd0N+rm5bVnN95yvofhUqoJGLJ2ZzuMI6Vm5FtrN6tqELOtA RZ0DWAzfI9Y01XcUA0asFDhl/3QqUyZN/TbTU7rK5slJjrFn7iyLf5kj0uX4cBSowE98 itZmb7jfwVHjB7pWIGAkf28T4bhsqx98Xk6LV0F3r9d81NQVSTgkOsryx5MjfYpKaO7i kaQENSd17AiZ+QT6BeEqOVp00OXGXDLQOvNolfoeN+PAY2Vb7Mlvqi1zNwfVxBTI0+dU ypaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vz48/RSPFOJlzJ3tJY1CkSjfI97YkEq4vzNOy46Tkig=; b=yzwoS4zvaiZ7I+xa+4iV0XAVgkz4f65i4qJic2il/iAaYMVi57BMHY1EIHJZfK79T4 DV7c4RwUePvpfN+Mqx+qaN3gAv8OJEHVU9AwDsvQu7upy6y9HTiMa1j76vX2Z10jvBL0 fUZicX6OKxnAqc6IGHmOys8HCP+xlMWKUEqckBhcnyHO5AJpq/qPtpVg256XZKL7+ygT xT7O5AUrsEIvrxnUxJaj6jsbgrnK/ORjm2UJ7M5ebSmMGXmAgfGoB6myYRfGAqKqpNcq as9P+wSSEhjxQaoLcyKAUrJTpOHosEz4kC6fd4Bs2MaRVFbC7fx62Wo0gQaP27buHEfp nrXQ== X-Gm-Message-State: ACrzQf0DVQxeA4QOQ2bJVGGkwPXKH58Z3A0g0/x24n4pF6NXdHjTwLsm mKHuQFnYY6NsYnRvkxkT88C70CiGxtM= X-Google-Smtp-Source: AMsMyM7P49bRrMZAAM2U1FhNTE034cuyEPRSOLGDVdqrnG+wUHzF69DfJm/2M/ptM77aL8N3+oKDGw== X-Received: by 2002:adf:f591:0:b0:22e:504e:fe76 with SMTP id f17-20020adff591000000b0022e504efe76mr17584789wro.553.1665567316193; Wed, 12 Oct 2022 02:35:16 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c10-20020a056000104a00b0022917d58603sm13248177wrx.32.2022.10.12.02.35.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 02:35:15 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 12 Oct 2022 09:35:06 +0000 Subject: [PATCH v3 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 , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Calvin Wan , Emily Shaffer , Glen Choo , Victoria Dye , 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 Oct 12 09:35:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13004918 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 F02B5C43217 for ; Wed, 12 Oct 2022 09:35:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbiJLJf0 (ORCPT ); Wed, 12 Oct 2022 05:35:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230017AbiJLJfU (ORCPT ); Wed, 12 Oct 2022 05:35:20 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AED203DBC4 for ; Wed, 12 Oct 2022 02:35:18 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id r13so25350100wrj.11 for ; Wed, 12 Oct 2022 02:35:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=dwSI2JOAV5uK62X0arUbDystpACPly3g4ieSBxPwtSw=; b=ARVHxRPAgLH9GM70QVZxJY1RXH8E95CG1q4ZRxrD69+MVyomtPvoAZNxoXYS2FS++t FzuvwpTN3hSy5NVclmiU6D2DJTmCD88bLlvLZErYw6jT2bhkikAhW+bpa1JsJ26nghxr eS09eB1jkwmuZ4xX1amGa636uxwevoA2rY97Q8Sn6vPalHD96z2sGFU3Dfy07delzdS4 8HfXUBL+UYbLJgkEEECfWgz7juNmUuexe8gYjNSK2fGeDa1K/5R3c62y53YYo163QeuO 5QHPNzYQBEdnSD500851chkjNq8PeFh2LeL6hYutcnB0hrRKu/ZSDn/SydwqqMWdFgLE 0Jyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dwSI2JOAV5uK62X0arUbDystpACPly3g4ieSBxPwtSw=; b=wc+hH+DnqGGiVYUtP2aJsNgp/a2mMpJZWOF3LVs62fpIfvyzD1kuVokRwtIYOB/0iW cMQ/bPzVXbGXuqJzk9iIawdYvwWjqM+iG8+3qTy623MBTrXLoM5aCccPIh9lsPNqI+fI 4NHNGlsJl7Uii9VPJ8qfEXxncjEWax2YKRCJnwPakLxLLra2PWF47J7Wvl60jY/EDy9b CWx4WmtDoUtJd6awmmVhMDaRaYYoLNPsxf5PiDG8m+OgmpguEFGV1RCBc+x8hXQyT5NV 9a2lUov98sXzDZ9LzwhgQaQZIScYt+q3cZCFXTjz/nOT85zRdk0NU9E7sU4mSJUMGS0W XQnA== X-Gm-Message-State: ACrzQf0kY6SyY+8TtKZe22Dw3h1+K0rl3UpWBZUaOaRnDHrPXteBSzF5 QIckbKWtD87w9X+7yCYiC3lwR8Sk2lY= X-Google-Smtp-Source: AMsMyM7ASxgeFYee9W3SwJLlg+0frdYP8r4xiIeLhAXyVxKwkLNqmdz91nYPK06NUY0/NYwKjPZuaA== X-Received: by 2002:a5d:588e:0:b0:22e:5601:f6d with SMTP id n14-20020a5d588e000000b0022e56010f6dmr17607041wrf.207.1665567317022; Wed, 12 Oct 2022 02:35:17 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id bj4-20020a0560001e0400b0022e0580b7a9sm6380490wrb.17.2022.10.12.02.35.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 02:35:16 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 12 Oct 2022 09:35:07 +0000 Subject: [PATCH v3 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 , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Calvin Wan , Emily Shaffer , Glen Choo , Victoria Dye , 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(). If we fail to commit the staged changes then we error out so GIT_REFLOG_ACTION does not need to be reset in that case. 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 51accb4fd61..488e6bdfd3e 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1271,8 +1271,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 61a8e0020d5..5790b35d763 100644 --- a/sequencer.c +++ b/sequencer.c @@ -4785,6 +4785,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; @@ -4795,10 +4797,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 Oct 12 09:35:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13004919 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 7DC22C4332F for ; Wed, 12 Oct 2022 09:35:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230033AbiJLJf2 (ORCPT ); Wed, 12 Oct 2022 05:35:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229841AbiJLJfW (ORCPT ); Wed, 12 Oct 2022 05:35:22 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C190942E4D for ; Wed, 12 Oct 2022 02:35:19 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id n12so25347257wrp.10 for ; Wed, 12 Oct 2022 02:35:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ym2AjMjoUDx0dWGfr7DyY/Iq92p8LkDIY83/P8cBkhI=; b=Lsa/T42Ef1j8H3IXVg84PXAQUqExoSdIXnzmRQRw42ip88weE3YmdjPVuagqoMeqHY 5aPbkshhXhp9bm3u9LsXQoJwiZnfPoAqOpmhLlk8yK5pobkL30kA0K5XIvqiqKSOm1Nv VcRMq2BuqRrPvG5/p6eWnI8Q1xow11+2cED1+QOeIyTtMamplIfXswXzIooIwf4YUI+K Y/xAOuEL1qyRZCc6jU2bVqNceV3noRQQy6/C6iCljzDAoSGwU9T0gaQ9V3/vbDj57tKq 0IQrAQGcfwJXhrhQ2AHWBOj/cE5a8yO81U2IxrFKliFORrGrzdPeq1jwdMsX5m9yyijj EPkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ym2AjMjoUDx0dWGfr7DyY/Iq92p8LkDIY83/P8cBkhI=; b=o/EfA3HaZ5xrRxjx4ocTKbCzu0hEb2FQJ/zpGQwm3DRePv1J4nmbgxzpX+gwNg7K+I pF04C/BIpcvHOvb1sPilQuCZOQs2ehCMZ4plk9O1DRzfX4E9gq5qhGInRdmMZ0RoVIbR o+L6ibe+Ruk/ECIOdHeslch+bvmVRk90p6WVBW1KwulG76rUonwLbHC+fzWc4aRQ56lW Kq042vmmD+xkYpAsl2fPLjSV0MTrn2IlvF2obXJqTHEWUvM2RBFYjmtqWkTyz9Bl45yv MoAeFrD/CL1kgTRmZa2ANxD0jGLqVvlJ/HMmRCpMf3Xwd/FfRaLoC3z5CiS7gL+el8ae L4KQ== X-Gm-Message-State: ACrzQf0chCJ1MArGgVx8GswDHxJN4D5Qc6otYUuDoS9yDJfK2g6SjXQW WjYkmYXgYi5ZhAq3JOGwZlodARCXQc0= X-Google-Smtp-Source: AMsMyM4Iu6kv7iNAiQdLi9cpGTP2gNbC3mataG/wR9XSePI/JZeYLKTyJVWMonizDq8UOG1f2oJeAA== X-Received: by 2002:a5d:47a8:0:b0:231:ca77:ac57 with SMTP id 8-20020a5d47a8000000b00231ca77ac57mr2775587wrb.384.1665567318029; Wed, 12 Oct 2022 02:35:18 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g13-20020adfe40d000000b0022e3d7c9887sm12922543wrm.101.2022.10.12.02.35.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 02:35:17 -0700 (PDT) Message-Id: <225ff4baef75e5a8429608d174cde8ff6edb0ccc.1665567312.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 12 Oct 2022 09:35:08 +0000 Subject: [PATCH v3 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 , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Calvin Wan , Emily Shaffer , Glen Choo , Victoria Dye , 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 488e6bdfd3e..9a40a5e27f8 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1297,8 +1297,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 Oct 12 09:35:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13004920 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 7AC77C4332F for ; Wed, 12 Oct 2022 09:35:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbiJLJfa (ORCPT ); Wed, 12 Oct 2022 05:35:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49028 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229975AbiJLJfX (ORCPT ); Wed, 12 Oct 2022 05:35:23 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65DFD4D240 for ; Wed, 12 Oct 2022 02:35:21 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id h131-20020a1c2189000000b003c6c154d528so846004wmh.4 for ; Wed, 12 Oct 2022 02:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=nHBpt9SecOHHTeViI0YJnz4MzO19KKdL/aPF1VZPjoQ=; b=N0FQY/QR5rnLSfedt1ojf8Os9vmIQYvGA0iMoMb+uohgJ5joxd8SMkeZycfrr0O6if TZ5mzeu9It00B4rcqch7Dze2Cn83Qcd2OGLw5cMU9hzSGsFKOfEqWIV6w3ndbKEbyF5e bKEOEHBvgTcHGujAGllpRTeZ5P27i8Hx294P1b/O8zo25hDwX5wFMFiEqOCnVlB8IFjk Wum9F9x4LjIXctqSG4KwkH08VPFeMMBheB+KW/kfrfe1qnekhdXnkGhvW8oHRwOXCuVm s015i2FyQdrZa8YtQqSEcKOboC19nuVFsV0/QuXcu/V/CmUnzO0qtAgnNstM5D7qEnS4 OdcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nHBpt9SecOHHTeViI0YJnz4MzO19KKdL/aPF1VZPjoQ=; b=0oatbgTmYhLD6xYVgQ0RTVwzUkwWnmRUFZq3g3IyPdGmTEeMJ9GktH8lguNSRntxuA BBpmORGQOhkS1OD1yDJU5PrcZRt2g3nyllRBuuiPedtIlQj5epAWtSStXt659JtVXIcd ZoqK32MMseiUxSh3AE3679cbO5mrKXjdj8LKRQCBoFUuqDgXpdwmk0vzrF/smbJxmXvo zdG779D9Ns3Sy8STIi+xLtR2NEJExV9lqeseE1BqTSaFYlXRYf9FRZUzA6huedXEz1Mo V0PMqV45buTa4qd8DpcBmxzqEenvwoDoRUZvUXeV7o+V6davOS0SXTsuhXeyKeM2MnET 8Jdw== X-Gm-Message-State: ACrzQf2yBpvWNpcc3DStpksVAL9cMd0MeH4flttyf2n/VP9oeOAxtl5w jr4v+MtVdvUUcpfGTKVc6XEoKpqyQdw= X-Google-Smtp-Source: AMsMyM6S+cDqtB7QUtZKhMUEoZVRW7NhODSpPa1rt3RfHn/Xp729Q5ZPi3/og0Ej5NkfIEwfNQZq1w== X-Received: by 2002:a05:600c:6885:b0:3bd:d782:623c with SMTP id fn5-20020a05600c688500b003bdd782623cmr2048639wmb.102.1665567319057; Wed, 12 Oct 2022 02:35:19 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j26-20020adfd21a000000b0022cc0a2cbecsm13165096wrh.15.2022.10.12.02.35.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 02:35:18 -0700 (PDT) Message-Id: <1094681eb115edd5a40b85790179b6d44a0fc521.1665567312.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 12 Oct 2022 09:35:09 +0000 Subject: [PATCH v3 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 , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Calvin Wan , Emily Shaffer , Glen Choo , Victoria Dye , 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 9a40a5e27f8..f7b00efeb92 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -582,10 +582,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 Oct 12 09:35:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13004921 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 97EC9C4332F for ; Wed, 12 Oct 2022 09:35:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230040AbiJLJfc (ORCPT ); Wed, 12 Oct 2022 05:35:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49024 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230022AbiJLJfX (ORCPT ); Wed, 12 Oct 2022 05:35:23 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA93F4B9A5 for ; Wed, 12 Oct 2022 02:35:20 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id w18so25381185wro.7 for ; Wed, 12 Oct 2022 02:35:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=xxEsvSkDYLHED1mTisNm5Ze7OCeeJZRDcAy6Ltwch8Y=; b=XBoPqfznjLLZrH3Edrf6fqSbICLofRMc7JR07adzcg2FWg9oLLtJcc8qzGwvfaUGfh /kaAMyrzAg/0wlEuKXxtsZy3Hb0bTCfT/bSFSslZzKduKDO/CAiE44CmB4v2OUSJQTpL w2N5yfF+y8qOZEi5C1LH3CqIMcnA/dabnxFZ8BVbhXX9lkBDwWe8DbdR5oKsGQOOH8mp geg305fIpz+OiZ13VHlG56mQQOc3oERLwMCuE/Rm7489xSDsbr5R6I16cTWHpSYzhogc 3IAmJEeOsUC6/ymUnTguyZvohZT4GiAc4iUcqnYiHr0IfsaAgOLBkdIgpgRPpMqGd23h rQ9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xxEsvSkDYLHED1mTisNm5Ze7OCeeJZRDcAy6Ltwch8Y=; b=11JNheDFofg3uN1Y/8+EzVFciY0S3ozC+Zh0kB0y3tZkVxdSeZlrgbLFGTstRvo9Fw VgCUHqgY9Ouv7nrSyNTQuGhEfT7QOGp7DbAGm+l4DZjhFLgtPkyFcfQuZ+sQKAgjCohH j8dI00CnP6hKVCa+ht9FjtwbqM+jDFaNGtsV6s77+nDFHIPNQENm0IWrkDIElSacswdU 1XkIi5BjfZaZokGwPREOXwsJ0KkXHgLk/FK+FkvdjMcOF0Wjvo+Zg/Eecx+6+wSQbIPr 1nXm3dQs/dO7Yn3k1GM7Kh1S2dxBwsN22I+gf/bd72i3MhAJGS9TnoANnkn/4tZtVsIn DpAw== X-Gm-Message-State: ACrzQf3K1GaZl3usqWxb8ndDSD9FK6mrurwgUc3cHMbsHOqGMAU0PnjE o/SVIvq/6cuYe9LvfyaK69JGvgNg7lk= X-Google-Smtp-Source: AMsMyM7NRX6Fm2SXRvxX5j+xyDC06rJOFL79675vgR17gLtcclomT/yx7pg2qS5K3f06Wacx90qHfA== X-Received: by 2002:a05:6000:18a5:b0:231:e0c5:1322 with SMTP id b5-20020a05600018a500b00231e0c51322mr2268096wri.376.1665567320037; Wed, 12 Oct 2022 02:35:20 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l3-20020a7bc343000000b003b47ff307e1sm1259763wmj.31.2022.10.12.02.35.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 02:35:19 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 12 Oct 2022 09:35:10 +0000 Subject: [PATCH v3 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 , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Calvin Wan , Emily Shaffer , Glen Choo , Victoria Dye , 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 or finishing a rebase and when picking commits. These differences make it harder than it needs to be to parse the reflog (I have a script that reads the finishing messages from rebase and it is a pain to have to accommodate two different message formats). While it is possible to determine the backend used for a rebase from the reflog messages, the differences are not designed for that purpose. c2417d3af7 (rebase: drop '-i' from the reflog for interactive-based rebases, 2020-02-15) removed the clear distinction between the reflog messages of the two backends without complaint. As the merge backend is the default it is likely to be the format most common in existing reflogs. For that reason the apply backend is changed to format its reflog messages to match the merge backend as closely as possible. Note that there is still a difference as when committing a conflict resolution the apply backend will use "(pick)" rather than "(continue)" because it is not currently possible to change the message for a single commit. In addition to c2417d3af7 we also changed the reflog messages in 68aa495b59 (rebase: implement --merge via the interactive machinery, 2018-12-11) and 2ac0d6273f (rebase: change the default backend from "am" to "merge", 2020-02-15). This commit makes the same change to "git rebase --apply" that 2ac0d6273f made to "git rebase" without any backend specific options. As the messages are changed to use an existing format any scripts that can parse the reflog messages of the default rebase backend should be unaffected by this change. There are existing tests for the messages from both backends which are adjusted to ensure that they do not get out of sync in the future. 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 f7b00efeb92..ed612c2d0c3 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -582,10 +582,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; @@ -615,7 +615,8 @@ static int run_am(struct rebase_options *opts) am.git_cmd = 1; strvec_push(&am.args, "am"); - + strvec_pushf(&am.env, 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); @@ -1789,7 +1790,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->object.oid, 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 Oct 12 09:35:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13004922 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 33E47C4332F for ; Wed, 12 Oct 2022 09:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230053AbiJLJgB (ORCPT ); Wed, 12 Oct 2022 05:36:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50642 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230035AbiJLJfc (ORCPT ); Wed, 12 Oct 2022 05:35:32 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB4BE537F0 for ; Wed, 12 Oct 2022 02:35:23 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id o20-20020a05600c4fd400b003b4a516c479so843367wmq.1 for ; Wed, 12 Oct 2022 02:35:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=fowo9SAEGEk8jvA9tSepjAFsyJTa5RUMorcFYWRqTNw=; b=SQ4JpRfrzE7SehRlTaEVHgsU3974E87VDeRvcLPlQyQNsrko6WkCknpa9g1/tkt0sw LGY2DYUbfGgebqdnmtn9jkP3u0bWJfiH7Zuf6/E+h5z4pf1bzyT8t99DVUCsAuAhuUNk UGpwwMAlicpeiw7RSJ9bQ2hk9FbGyaZzW2SsQ8f9VF1Rgtkkm0e5cyy2IvKauGal8Y2n NyqQ5uHgl9ULofgkRzEJupdavcvZa36X3jKfnNZIQXR7AvYYlb7sxRXEH5eUi2352IUb a/xSLNctJ17rjKBMSM/eTUw1FQVRpn8FXaP+nt1oQlBKiN/ohMFL1CyPg/qIUrsXxeTy xlMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fowo9SAEGEk8jvA9tSepjAFsyJTa5RUMorcFYWRqTNw=; b=CIB0OjXirxBRHPCpw/PlYf1SJzKLBwDvwMA+qAoEkxDgLaiXpP0eJAhpRn4o3ntkNT onv/S7EE/Js6l87cOz8uL3sOXjdI070jRR7AJmMsDsn/apRmRsADgfwJSpAMRUWH6whD xLAR9i8d2NV/knjbyP4a6aD25BLQdthqKZV31rqFCMEtnq3dDhV5KSZKZE8ecjxzfGqb AVoZgEO92i22XUboSTDkxSHxCyL63tfbDTpvP/99QA+aJFuq/u6VzQZnUaZLCPCys1Dj BCyLPNtF1qdSk7uVK2/yrRcscoyiJZ6AV2/dUYFms1qE4NakreCsi41lG6NJ32/lQaBf z+lQ== X-Gm-Message-State: ACrzQf3YCW0I6A3BkgN1C0ackZi0yexPVnQTKhYhS5itTiQa9/hwxFrn 1n94Io7AUvTp/8Dyl9en5DWNutwZVtc= X-Google-Smtp-Source: AMsMyM7leN2U1Wg6AJ8xpqnGupj3/td5Cn9hc6an7at7jwnadN8ztkYXO+uYRlk5ASMnXrhZxwGb+g== X-Received: by 2002:a05:600c:4e52:b0:3b4:a828:1d84 with SMTP id e18-20020a05600c4e5200b003b4a8281d84mr1996268wmq.143.1665567320865; Wed, 12 Oct 2022 02:35:20 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v14-20020adfe28e000000b00231ed902a4esm1507935wri.5.2022.10.12.02.35.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 02:35:20 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 12 Oct 2022 09:35:11 +0000 Subject: [PATCH v3 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 , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Calvin Wan , Emily Shaffer , Glen Choo , Victoria Dye , 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 ed612c2d0c3..e4620935129 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1001,23 +1001,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')) @@ -1311,18 +1294,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->object.oid)); ropts.oid = &options.orig_head->object.oid; + 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->object.oid)); 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 Oct 12 09:35:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 13004923 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 C9F7CC4332F for ; Wed, 12 Oct 2022 09:36:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230044AbiJLJgH (ORCPT ); Wed, 12 Oct 2022 05:36:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50652 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229764AbiJLJfw (ORCPT ); Wed, 12 Oct 2022 05:35:52 -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 50AE357207 for ; Wed, 12 Oct 2022 02:35:23 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id u10so25396593wrq.2 for ; Wed, 12 Oct 2022 02:35:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:from:to:cc:subject:date :message-id:reply-to; bh=BieU9AgaJF5Ji/4FX7MwcUWI5/IOor7hnP5k7IMVWkk=; b=mHtEbLh+mzoGPUt0Dgjx6HDnmI0EfNEdtJLSABU2QsbnrIsc6o7LhpuqR0cBohYIT2 kAqQ9gIfIuiu+294SaBPsxdRAfjB6qDw+RorpFGfV1+ek2oRnjx5G0aaiIr9jjLeBj0v biCKUuw9srqgL+r8TFL9aRsioeWyLD7bo9+4C15CVjLofVanuTPUrk6ks/ELH5lqxTey rPHeKu31DegXb3rAxcQFNwz5VsF6Y8Ez+ENxSOQUb36KJooouHJ1/2gA9QWzWPcD0Flz Uz3CtTIUapok3kcKJCYv9p4vrQWg7aUklQDLg8TIeX1r5JnrnnbEtMYMT+QEJfEAVb0p ztrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date:from :references:in-reply-to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=BieU9AgaJF5Ji/4FX7MwcUWI5/IOor7hnP5k7IMVWkk=; b=mS0DwVgfvOrD0bizF8otJiuy2ApXS+UYQk0rrn7uqFNfBsJ7HmR0KxU2xvu+lMvn3j a71Wbo+ojKk2r9uYX7SEA/RjUWzMN4aeT8fpcsDfpRXsUwewQ/W8hAyuDQjN02ZZdc/N H+LErYabm8GWu24G1KtTx9sequpt+hmb5AhiRs6N2HgJK4SK/UXOQARLWeeHESwiEpZW uFo7vN+Ncp1jGZsL82ux/jbptviD4rTVA/xKeI3rddBZTWtu6/tz36R6f6gdDG9mlOmc qxWctcwaSmbFHcm29PmVvW/BhtQU+NJOK0HW64N2o9Y680TpiHHEYYqVnKBzUgufLnbx xm4w== X-Gm-Message-State: ACrzQf2YXyoTDmNn6Gd/EUv5WhjkTM08eecEJ8pSd6RUzXNqbcZBAPXg AgNSBYgKvT+gS2SOK22OPVyQ5GCZRW0= X-Google-Smtp-Source: AMsMyM4/c39o+99BxvRs9zhxfnEvZ/T09W7cdR3TkuzFT5e6W/US2qqc2VPcQoPafjPghsulOXn5ww== X-Received: by 2002:adf:ee0a:0:b0:22f:6a2a:92ab with SMTP id y10-20020adfee0a000000b0022f6a2a92abmr12475276wrn.545.1665567321805; Wed, 12 Oct 2022 02:35:21 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u7-20020a05600c19c700b003bf6da9d2cesm1275108wmq.28.2022.10.12.02.35.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Oct 2022 02:35:21 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Wed, 12 Oct 2022 09:35:12 +0000 Subject: [PATCH v3 8/8] rebase: cleanup action handling Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: Phillip Wood , Christian Couder , Elijah Newren , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason , Calvin Wan , Emily Shaffer , Glen Choo , Victoria Dye , 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 | 93 +++++++++++++++++++++++------------------------- 1 file changed, 44 insertions(+), 49 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index e4620935129..eb1fb8e3551 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -59,6 +59,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; @@ -85,7 +105,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; @@ -156,24 +176,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(); @@ -310,8 +312,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; @@ -326,7 +327,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")); @@ -359,7 +360,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; @@ -617,7 +618,7 @@ static int run_am(struct rebase_options *opts) strvec_push(&am.args, "am"); strvec_pushf(&am.env, 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) @@ -628,7 +629,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); @@ -637,7 +638,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); } @@ -730,7 +731,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; @@ -748,7 +749,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 @@ -1025,7 +1026,6 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) struct strbuf buf = STRBUF_INIT; struct object_id branch_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; @@ -1074,18 +1074,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, @@ -1174,7 +1174,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) } else if (is_directory(merge_dir())) { strbuf_reset(&buf); strbuf_addf(&buf, "%s/rewritten", merge_dir()); - if (!(action == ACTION_ABORT) && is_directory(buf.buf)) { + if (!(options.action == ACTION_ABORT) && is_directory(buf.buf)) { die(_("`rebase --preserve-merges` (-p) is no longer supported.\n" "Use `git rebase --abort` to terminate current rebase.\n" "Or downgrade to v2.33, or earlier, to complete the rebase.")); @@ -1201,7 +1201,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) "Note: Your `pull.rebase` configuration may also be set to 'preserve',\n" "which is no longer supported; use 'merges' instead")); - if (action != ACTION_NONE && total_argc != 2) { + if (options.action != ACTION_NONE && total_argc != 2) { usage_with_options(builtin_rebase_usage, builtin_rebase_options); } @@ -1232,11 +1232,11 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) if (options.root && options.fork_point > 0) die(_("options '%s' and '%s' cannot be used together"), "--root", "--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.")); @@ -1246,16 +1246,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")); @@ -1281,7 +1280,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; @@ -1296,7 +1294,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); @@ -1336,17 +1333,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 */ @@ -1370,7 +1365,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; @@ -1812,7 +1807,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);