From patchwork Fri Dec 6 16:06:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 11276745 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A3FA217EF for ; Fri, 6 Dec 2019 16:08:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 78A59206DF for ; Fri, 6 Dec 2019 16:08:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="foRtLCie" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726313AbfLFQIe (ORCPT ); Fri, 6 Dec 2019 11:08:34 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46134 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726271AbfLFQIe (ORCPT ); Fri, 6 Dec 2019 11:08:34 -0500 Received: by mail-wr1-f65.google.com with SMTP id z7so8277248wrl.13 for ; Fri, 06 Dec 2019 08:08:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=GfEaOtzUHDGbmxdQOAOP0/euqYz6dr2IJX2UdXmg+lM=; b=foRtLCiecT3syd8XZrW5elvPTVi712TEcOEFOKXsvTagu+OAoN/AQG2Et9wP+qg4Pg QRfuFf6/mT75/WXCMloUAFUxIw5FiB/ydtwSLSGx0LshqDsEyN5ZJVV122ZScfXs15vy 9CvMUalHhBNXhY3L9oGHqIWanmtPM93kTrsfRkMWuDdrzR0QFcMGUctpyshBgSm46cc/ +NK5OxxMl8E3MkbFgsZ/6qI4BOIVu9aFVm9VgOkbeV5NK9M8eijah/AFlHwctUsUGex3 7cuW9Uc7Bhfb+1NUOke0YCEBCGLSzloLTfVEc79puX3ExuZu0cVz391Mlsd2uThiOvYH yRBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=GfEaOtzUHDGbmxdQOAOP0/euqYz6dr2IJX2UdXmg+lM=; b=K68eAARUa4WsHpc8dEnwnZV+YJg51vN0ZsIf21clhZeIMeC9Xnk1H0Mo5k9UV9CfIk YaLjcEmjty0CvAS+EsHuwcUkng0VyAdhhz7fJ4TvoWdkCQlvNkO4fItgU+DtZSYEK24E eX1a9aYfeEYDAgALPrhZoXnQLyNj+G2ZxyehMHJ879Cj7DUBOT/Ot/vOTI9J7MvyiW9g Vr92slGbmqgyFJh70gPnrccKB5B/BbxBm9/T1qLDZLXbCNm8dkREDyBOXLLSMm30/zHh R6+Qdifl44qq0g6Q1N07B/u/4emV2W5EQaulPs06GZOCqnNyLEu65Lu90nttz6ATV2IU h+ag== X-Gm-Message-State: APjAAAUMgcfrsSRyiWE3jysW15l8nVLlixMRTSqrrKsNp1RH340JQulD zUVtWUUD+y+gvnec8v1jnnQBrnG1 X-Google-Smtp-Source: APXvYqxuNX68hlEJfAnVE9iaHOHSlM50d49Jwz8oAqHI5TShWBT7rQvcKHm5sdgKbknXv88o4e4brQ== X-Received: by 2002:a5d:690e:: with SMTP id t14mr14997762wru.65.1575648511064; Fri, 06 Dec 2019 08:08:31 -0800 (PST) Received: from localhost.localdomain (host-92-22-0-192.as13285.net. [92.22.0.192]) by smtp.gmail.com with ESMTPSA id q15sm16649799wrr.11.2019.12.06.08.08.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:08:30 -0800 (PST) From: Phillip Wood To: Git Mailing List Cc: Johannes Schindelin , Junio C Hamano , Phillip Wood Subject: [PATCH v2 1/9] t3404: use test_cmp_rev Date: Fri, 6 Dec 2019 16:06:06 +0000 Message-Id: <20191206160614.631724-2-phillip.wood123@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206160614.631724-1-phillip.wood123@gmail.com> References: <20191206160614.631724-1-phillip.wood123@gmail.com> Reply-To: Phillip Wood MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood There are a number of places where we compare two revisions with test $(git rev-parse rev1) = $(git rev-parse rev2) when these fail there's no indication what has gone wrong and you need to be running with `-x` to see where the test has failed. Lets use test_cmp_rev instead. Signed-off-by: Phillip Wood --- t/t3404-rebase-interactive.sh | 38 +++++++++++++++++------------------ 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index c573c99069..d8a05fd439 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -191,7 +191,7 @@ test_expect_success 'no changes are a nop' ' git checkout branch2 && git rebase -i F && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && - test $(git rev-parse I) = $(git rev-parse HEAD) + test_cmp_rev I HEAD ' test_expect_success 'test the [branch] option' ' @@ -200,16 +200,16 @@ test_expect_success 'test the [branch] option' ' git commit -m "stop here" && git rebase -i F branch2 && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch2" && - test $(git rev-parse I) = $(git rev-parse branch2) && - test $(git rev-parse I) = $(git rev-parse HEAD) + test_cmp_rev I branch2 && + test_cmp_rev I HEAD ' test_expect_success 'test --onto ' ' git checkout -b test-onto branch2 && git rebase -i --onto branch1 F && test "$(git symbolic-ref -q HEAD)" = "refs/heads/test-onto" && - test $(git rev-parse HEAD^) = $(git rev-parse branch1) && - test $(git rev-parse I) = $(git rev-parse branch2) + test_cmp_rev HEAD^ branch1 && + test_cmp_rev I branch2 ' test_expect_success 'rebase on top of a non-conflicting commit' ' @@ -218,12 +218,12 @@ test_expect_success 'rebase on top of a non-conflicting commit' ' git rebase -i branch2 && test file6 = $(git diff --name-only original-branch1) && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" && - test $(git rev-parse I) = $(git rev-parse branch2) && - test $(git rev-parse I) = $(git rev-parse HEAD~2) + test_cmp_rev I branch2 && + test_cmp_rev I HEAD~2 ' test_expect_success 'reflog for the branch shows state before rebase' ' - test $(git rev-parse branch1@{1}) = $(git rev-parse original-branch1) + test_cmp_rev branch1@{1} original-branch1 ' test_expect_success 'reflog for the branch shows correct finish message' ' @@ -280,7 +280,7 @@ test_expect_success 'show conflicted patch' ' test_expect_success 'abort' ' git rebase --abort && - test $(git rev-parse new-branch1) = $(git rev-parse HEAD) && + test_cmp_rev new-branch1 HEAD && test "$(git symbolic-ref -q HEAD)" = "refs/heads/branch1" && test_path_is_missing .git/rebase-merge ' @@ -323,7 +323,7 @@ test_expect_success 'retain authorship w/ conflicts' ' echo resolved >conflict && git add conflict && git rebase --continue && - test $(git rev-parse conflict-a^0) = $(git rev-parse HEAD^) && + test_cmp_rev conflict-a^0 HEAD^ && git show >out && grep AttributeMe out ' @@ -340,7 +340,7 @@ test_expect_success 'squash' ' git rebase -i --onto master HEAD~2 ) && test B = $(cat file7) && - test $(git rev-parse HEAD^) = $(git rev-parse master) + test_cmp_rev HEAD^ master ' test_expect_success 'retain authorship when squashing' ' @@ -399,9 +399,9 @@ test_expect_success REBASE_P 'preserve merges with -p' ' git update-index --refresh && git diff-files --quiet && git diff-index --quiet --cached HEAD -- && - test $(git rev-parse HEAD~6) = $(git rev-parse branch1) && - test $(git rev-parse HEAD~4^2) = $(git rev-parse to-be-preserved) && - test $(git rev-parse HEAD^^2^) = $(git rev-parse HEAD^^^) && + test_cmp_rev HEAD~6 branch1 && + test_cmp_rev HEAD~4^2 to-be-preserved && + test_cmp_rev HEAD^^2^ HEAD^^^ && test $(git show HEAD~5:file1) = B && test $(git show HEAD~3:file1) = C && test $(git show HEAD:file1) = E && @@ -433,7 +433,7 @@ test_expect_success '--continue tries to commit' ' git add file1 && FAKE_COMMIT_MESSAGE="chouette!" git rebase --continue ) && - test $(git rev-parse HEAD^) = $(git rev-parse new-branch1) && + test_cmp_rev HEAD^ new-branch1 && git show HEAD | grep chouette ' @@ -740,7 +740,7 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' ' --author="Somebody else " && test $(git rev-parse branch3) != $(git rev-parse branch4) && git rebase -i branch3 && - test $(git rev-parse branch3) = $(git rev-parse branch4) + test_cmp_rev branch3 branch4 ' @@ -799,7 +799,7 @@ test_expect_success 'rebase -i continue with unstaged submodule' ' test_must_fail git rebase -i submodule-base && git reset && git rebase --continue && - test $(git rev-parse submodule-base) = $(git rev-parse HEAD) + test_cmp_rev submodule-base HEAD ' test_expect_success 'avoid unnecessary reset' ' @@ -822,7 +822,7 @@ test_expect_success 'reword' ' git rebase -i A && git show HEAD | grep "E changed" && test $(git rev-parse master) != $(git rev-parse HEAD) && - test $(git rev-parse master^) = $(git rev-parse HEAD^) && + test_cmp_rev master^ HEAD^ && FAKE_LINES="1 2 reword 3 4" FAKE_COMMIT_MESSAGE="D changed" \ git rebase -i A && git show HEAD^ | grep "D changed" && @@ -886,7 +886,7 @@ test_expect_success 'always cherry-pick with --no-ff' ' git diff HEAD~$p original-no-ff-branch~$p > out && test_must_be_empty out done && - test $(git rev-parse HEAD~3) = $(git rev-parse original-no-ff-branch~3) && + test_cmp_rev HEAD~3 original-no-ff-branch~3 && git diff HEAD~3 original-no-ff-branch~3 > out && test_must_be_empty out ' From patchwork Fri Dec 6 16:06:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 11276739 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA4BC13B6 for ; Fri, 6 Dec 2019 16:08:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B8D2124659 for ; Fri, 6 Dec 2019 16:08:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jPoSSFYL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726347AbfLFQIf (ORCPT ); Fri, 6 Dec 2019 11:08:35 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:32869 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726284AbfLFQIe (ORCPT ); Fri, 6 Dec 2019 11:08:34 -0500 Received: by mail-wr1-f66.google.com with SMTP id b6so8400013wrq.0 for ; Fri, 06 Dec 2019 08:08:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=jRHOwhRboHnHFU+uWN8bpu3Ve38iukMqNPqsvq2lXEc=; b=jPoSSFYLTqRC6QX6w7JT5/aFg0pjmb/utTcr3kSXhZbDDzQHQcPe+PkparPaBPqTFI j7EJQi6ZWkAQVOyvrLFmBgA+/udm4M1gHPOHJf5DfpU2Q1hYm6YZujYgaebN4wrITtJ2 GwkmtndmIq181U68oeNi2i0sEf9tf2j1/hVxMkxEx2IGmgzyOvAGed10xyuIZ5emKX+Z oG79oZ6c+UawHKtMlKIF7vRzJorARnoK6cu64J8yODDOgZLs1nO4L0t7O8+Z1oVRs1mQ dKjlQmJvwl3cmlfjWDELmwF/2o/8VAB/LSv7nUimPPwmpI0Um5NUGWSYgvxY99mqVxuL wLUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=jRHOwhRboHnHFU+uWN8bpu3Ve38iukMqNPqsvq2lXEc=; b=UekAcsCXkWvMlV1iFwu5gGnsponhcFnjaopc+QQhSNuqNYP9AlbjVy4zZMXyZ7uF0M DFwzeHkd3xp/3u/T9MWq5uUef7WrkW6gntJCiHHb/oeyKuFi5hSBKS12H/4an1Thd33J lk/2dGWPRvp9YC3sOlUIAfR8iPmOezBw1xsTPcKLbFCdF521sAQvqxmoouiFPhGl423+ 07psIBdwNqqYnR7FzK4OHPWFZIoaShvVLjY6RgIjNnlJSs+DwphtvMqwSyYp9mgyRLLh dZSkqJknQigxc/NDVbrYQshBMPCv7y3W1psHA36B5ZlSF4djGwHGMWw6Lpv6Z7SfYByf iAgQ== X-Gm-Message-State: APjAAAVUozAdgLiYoBydGxsiK4zL7OXBOMB1Uz5sqD3+f5gyzu3a7zr3 WxmaWl7f9up8N6hoOeSdSaqb3sY8 X-Google-Smtp-Source: APXvYqwrjiJfhgO5AAe13qCSdXiW0BsR1m1xov9lb7RR13E+GUBFKrPy9Czd6+59+Z5SfcSg13Mk0g== X-Received: by 2002:a5d:45c4:: with SMTP id b4mr16347624wrs.303.1575648512144; Fri, 06 Dec 2019 08:08:32 -0800 (PST) Received: from localhost.localdomain (host-92-22-0-192.as13285.net. [92.22.0.192]) by smtp.gmail.com with ESMTPSA id q15sm16649799wrr.11.2019.12.06.08.08.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:08:31 -0800 (PST) From: Phillip Wood To: Git Mailing List Cc: Johannes Schindelin , Junio C Hamano , Johannes Schindelin Subject: [PATCH v2 2/9] cherry-pick: add test for `--skip` advice in `git commit` Date: Fri, 6 Dec 2019 16:06:07 +0000 Message-Id: <20191206160614.631724-3-phillip.wood123@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206160614.631724-1-phillip.wood123@gmail.com> References: <20191206160614.631724-1-phillip.wood123@gmail.com> Reply-To: Phillip Wood MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Johannes Schindelin In dcb500dc16c (cherry-pick/revert: advise using --skip, 2019-07-02), `git commit` learned to suggest to run `git cherry-pick --skip` when trying to cherry-pick an empty patch, but that was never tested for. Here is a test that verifies that a message is given to the user that contains the correct invocation. Signed-off-by: Johannes Schindelin --- t/t3510-cherry-pick-sequence.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t3510-cherry-pick-sequence.sh b/t/t3510-cherry-pick-sequence.sh index 793bcc7fe3..5b94fdaa67 100755 --- a/t/t3510-cherry-pick-sequence.sh +++ b/t/t3510-cherry-pick-sequence.sh @@ -123,7 +123,8 @@ test_expect_success 'revert --skip to skip commit' ' test_expect_success 'skip "empty" commit' ' pristine_detach picked && test_commit dummy foo d && - test_must_fail git cherry-pick anotherpick && + test_must_fail git cherry-pick anotherpick 2>err && + test_i18ngrep "git cherry-pick --skip" err && git cherry-pick --skip && test_cmp_rev dummy HEAD ' From patchwork Fri Dec 6 16:06:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 11276741 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 144D1109A for ; Fri, 6 Dec 2019 16:08:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E763824659 for ; Fri, 6 Dec 2019 16:08:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pcKb4ACM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbfLFQIf (ORCPT ); Fri, 6 Dec 2019 11:08:35 -0500 Received: from mail-wr1-f53.google.com ([209.85.221.53]:45950 "EHLO mail-wr1-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbfLFQIf (ORCPT ); Fri, 6 Dec 2019 11:08:35 -0500 Received: by mail-wr1-f53.google.com with SMTP id j42so8303987wrj.12 for ; Fri, 06 Dec 2019 08:08:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=8fpKHkrGVyle9dM7aXLs3Ow6RrFQkR3jnzzeRadZEIs=; b=pcKb4ACMx374+3ls9J7TnDi1eEGvBphRJukCrf7lromV3LfaRufixhrI5IYDfkbmhS tVZzZjPJDwqgAlpRe4C75XQBR7HdzvcCgo0QU35A1dPwFrlAvRpX1Zdid9TEZWmVfAz0 dmwr/PNJz+or+1v+6kj6+aSBIGaRoDC/16vEUm9tWqjz3rC+eoEhv+WaOEvIkMd3gCKH r0qYgVmpChOxSCQt73s8ZsIZ/qo9dTkOWtJ4F5eH0MI8k28XZDgdtpvVraXFNTqZDFkZ I6Lob1xUd1RYBT3xLwJrZ5gGy4LcZLeUbikbH+eUEwsT7Wn9M8CXrj21/ol2RfjTOZv5 oBUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=8fpKHkrGVyle9dM7aXLs3Ow6RrFQkR3jnzzeRadZEIs=; b=PKbxIWAW6KiMoVslu7GaLcvbVxxBYZ4UiA81PL8/v/XH7gnOz3O4svNRtMXHmto9M6 AoYwjlzHdpI7TepJMp7sJVpHIbhHa++/BblpNHu1xdeqYrJtuFa6AKcjzkCYwLTStkgR SzWg4d+v3ifyEKol5K4wrCxTxCyPsdT8MY5voAJkQGUtM8fYQRmrWNsW1vXc0Vs6vyeA EXscqyvh0rhtw2PImq27RVCcba4Mws66k0urDL8us+R0wHyAiK3yBgcirhUDMB8tS8dH tnOpBT8f8lDxbH/g8EmnRWLdDGGx3R7nyw4CvAAQhJSraxRBP2KAuJuMn4JBuvVNcURe dgAw== X-Gm-Message-State: APjAAAXvhtvthKF5V8Hyi0YYA3MFUBiOa2Dr+sMXOEtfGueUq0dVC6v7 M6ADc5UJqo5KQbcLaim8wLu+uZf1 X-Google-Smtp-Source: APXvYqyWVE2RGikZOFKpi/8Oll5jeDamkqk3M7QBmYBsw7ReDVBKNDKS9/3mRQUbD9fV09YPPLsd2g== X-Received: by 2002:adf:fa12:: with SMTP id m18mr15803197wrr.309.1575648512961; Fri, 06 Dec 2019 08:08:32 -0800 (PST) Received: from localhost.localdomain (host-92-22-0-192.as13285.net. [92.22.0.192]) by smtp.gmail.com with ESMTPSA id q15sm16649799wrr.11.2019.12.06.08.08.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:08:32 -0800 (PST) From: Phillip Wood To: Git Mailing List Cc: Johannes Schindelin , Junio C Hamano , Phillip Wood Subject: [PATCH v2 3/9] cherry-pick: check commit error messages Date: Fri, 6 Dec 2019 16:06:08 +0000 Message-Id: <20191206160614.631724-4-phillip.wood123@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206160614.631724-1-phillip.wood123@gmail.com> References: <20191206160614.631724-1-phillip.wood123@gmail.com> Reply-To: Phillip Wood MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood We disallow partial commits and amending when CHERRY_PICK_HEAD exists. Add a couple of tests to check the error message printed in each case before we refactor the code responsible for this. Signed-off-by: Phillip Wood --- t/t3507-cherry-pick-conflict.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 9b9b4ca8d4..c9715bf674 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -161,6 +161,29 @@ test_expect_success 'successful commit clears CHERRY_PICK_HEAD' ' test_must_fail git rev-parse --verify CHERRY_PICK_HEAD ' + +test_expect_success 'partial commit of cherry-pick fails' ' + pristine_detach initial && + + test_must_fail git cherry-pick picked && + echo resolved >foo && + git add foo && + test_must_fail git commit foo 2>err && + + test_i18ngrep "cannot do a partial commit during a cherry-pick." err +' + +test_expect_success 'commit --amend of cherry-pick fails' ' + pristine_detach initial && + + test_must_fail git cherry-pick picked && + echo resolved >foo && + git add foo && + test_must_fail git commit --amend 2>err && + + test_i18ngrep "in the middle of a cherry-pick -- cannot amend." err +' + test_expect_success 'successful final commit clears cherry-pick state' ' pristine_detach initial && From patchwork Fri Dec 6 16:06:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 11276743 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AA20F17EF for ; Fri, 6 Dec 2019 16:08:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8861424659 for ; Fri, 6 Dec 2019 16:08:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vGW/v9Y6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726374AbfLFQIg (ORCPT ); Fri, 6 Dec 2019 11:08:36 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:34616 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726284AbfLFQIf (ORCPT ); Fri, 6 Dec 2019 11:08:35 -0500 Received: by mail-wr1-f68.google.com with SMTP id t2so8394394wrr.1 for ; Fri, 06 Dec 2019 08:08:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=KAX+kBFFNg1/q2sm2IoZMcUdZ+PNB6/Zcr50lilElDs=; b=vGW/v9Y6iSVs+mdRf6meBlnbo1XMX/OvugUvVMoNz6zmcRCljpr47H0I21KmXLFyrL QioTeJzuT0CzD3vpB3TwhNA2QfzLYbZIl0DabmyApuNz7sw1NB0XNffaPtL68hV1yNwf OKHuUPwBFaVrtlOefBkLW64iouKFAsBemK1KMFzKyYW+YLum2akNqe5EujkZlp/vUWbT ZOYfPKrEIgdJcc8dcXpzecNBVRl7+2Qw6gVwZ/AdRK5oo5G4DTCs0m7MHMKBsoRizAhr /E3f8/jsfziFQhhuotHFCVncKy+infgWFq/+Otoc/h487Byxrh3ZQib2fW7zg0x/hXGL S/YQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=KAX+kBFFNg1/q2sm2IoZMcUdZ+PNB6/Zcr50lilElDs=; b=b61ethzN/ug90GHbCZ396caEFfGrkfhnIJckQOTWaJCLvBZMsNgyFZt3uXsIxlPUUa TrFSvP27XmsXJ2XVkLlAgj6kCAg/6sedV64kMWz7UM/3Bl2s9fo6WHdNBw/7Z5YMD4i6 0mImb33AdnK+z4YICd/LSL4hkl1JZsuMv1Vz2wkZESKr+z6huAglDB+7q6I0rH8yfTY2 PoSBq0TqU4xG0XNpEuMp9hNapkPTFfKFesX9589ZLlMZwv/4qAIAmdPGFbVXSJSNj9a1 yNjR2I5r1CSnpqd3KiAlpAx/5W8jcRADRf/1czIDPkyZJDz6vkeJN5RTpZJlWvOE3YIX Rr0g== X-Gm-Message-State: APjAAAVw5T+NZEXcL/LFXxYF1fFkdXY49WtDgV/fmcKpLUohKht16i3M AvkR+Q6hcUhy+iMu/EPthbvxMOEv X-Google-Smtp-Source: APXvYqxzxGjEFF2RqZZB5UpMICg4qxkN4FfZ1j8gpKMyfFGaLXNQqICgO8OGbF1xd8yDegn1HXFLjQ== X-Received: by 2002:a5d:46c7:: with SMTP id g7mr12654068wrs.11.1575648514102; Fri, 06 Dec 2019 08:08:34 -0800 (PST) Received: from localhost.localdomain (host-92-22-0-192.as13285.net. [92.22.0.192]) by smtp.gmail.com with ESMTPSA id q15sm16649799wrr.11.2019.12.06.08.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:08:33 -0800 (PST) From: Phillip Wood To: Git Mailing List Cc: Johannes Schindelin , Junio C Hamano , Phillip Wood Subject: [PATCH v2 4/9] sequencer: write CHERRY_PICK_HEAD for reword and edit Date: Fri, 6 Dec 2019 16:06:09 +0000 Message-Id: <20191206160614.631724-5-phillip.wood123@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206160614.631724-1-phillip.wood123@gmail.com> References: <20191206160614.631724-1-phillip.wood123@gmail.com> Reply-To: Phillip Wood MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood `git commit` relies on the presence of CHERRY_PICK_HEAD to show the correct error message in the case of an empty pick. This fixes a regression introduced by the conversion from shell to C. In the shell version everything was a cherry-pick as far as the sequencer code was concerned so it always wrote CHERRY_PICK_HEAD. The conversion to C forgot to update the code that creates CHERRY_PICK_HEAD. We do not want to create CHERRY_PICK_HEAD for fixup and squash commands as that would prevent `git commit --amend` from running. Note that the error message shown by `git commit` for an empty pick during a rebase is currently wrong as it talks about running `git cherry-pick --skip` rather than `git rebase --skip`. This will be fixed in a future commit which is why the tests are in t3403-rebase-skip.sh. Signed-off-by: Phillip Wood --- sequencer.c | 4 +++- t/t3403-rebase-skip.sh | 53 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/sequencer.c b/sequencer.c index 408b7885c7..4e0370277b 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1916,7 +1916,9 @@ static int do_pick_commit(struct repository *r, * However, if the merge did not even start, then we don't want to * write it at all. */ - if (command == TODO_PICK && !opts->no_commit && (res == 0 || res == 1) && + if ((command == TODO_PICK || command == TODO_REWORD || + command == TODO_EDIT) && !opts->no_commit && + (res == 0 || res == 1) && update_ref(NULL, "CHERRY_PICK_HEAD", &commit->object.oid, NULL, REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) res = -1; diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh index ee8a8dba52..db7e917248 100755 --- a/t/t3403-rebase-skip.sh +++ b/t/t3403-rebase-skip.sh @@ -29,6 +29,13 @@ test_expect_success setup ' test_tick && git commit -m reverted-goodbye && git tag reverted-goodbye && + git checkout goodbye && + test_tick && + GIT_AUTHOR_NAME="Another Author" \ + GIT_AUTHOR_EMAIL="another.author@example.com" \ + git commit --amend --no-edit -m amended-goodbye && + test_tick && + git tag amended-goodbye && git checkout -f skip-reference && echo moo > hello && @@ -85,6 +92,52 @@ test_expect_success 'moved back to branch correctly' ' test_debug 'gitk --all & sleep 1' +test_expect_success 'correct advice upon picking empty commit' ' + test_when_finished "git rebase --abort" && + test_must_fail git rebase -i --onto goodbye \ + amended-goodbye^ amended-goodbye 2>err && + test_i18ngrep "previous cherry-pick is now empty" err && + test_i18ngrep "git cherry-pick --skip" err && + test_must_fail git commit && + test_i18ngrep "git cherry-pick --skip" err +' + +test_expect_success 'correct authorship when committing empty pick' ' + test_when_finished "git rebase --abort" && + test_must_fail git rebase -i --onto goodbye \ + amended-goodbye^ amended-goodbye && + git commit --allow-empty && + git log --pretty=format:"%an <%ae>%n%ad%B" -1 amended-goodbye >expect && + git log --pretty=format:"%an <%ae>%n%ad%B" -1 HEAD >actual && + test_cmp expect actual +' + +test_expect_success 'correct advice upon rewording empty commit' ' + test_when_finished "git rebase --abort" && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="reword 1" git rebase -i \ + --onto goodbye amended-goodbye^ amended-goodbye 2>err + ) && + test_i18ngrep "previous cherry-pick is now empty" err && + test_i18ngrep "git cherry-pick --skip" err && + test_must_fail git commit && + test_i18ngrep "git cherry-pick --skip" err +' + +test_expect_success 'correct advice upon editing empty commit' ' + test_when_finished "git rebase --abort" && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="edit 1" git rebase -i \ + --onto goodbye amended-goodbye^ amended-goodbye 2>err + ) && + test_i18ngrep "previous cherry-pick is now empty" err && + test_i18ngrep "git cherry-pick --skip" err && + test_must_fail git commit && + test_i18ngrep "git cherry-pick --skip" err +' + test_expect_success 'fixup that empties commit fails' ' test_when_finished "git rebase --abort" && ( From patchwork Fri Dec 6 16:06:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 11276751 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 304F313B6 for ; Fri, 6 Dec 2019 16:08:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 05ECC24659 for ; Fri, 6 Dec 2019 16:08:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HMwTdq7V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726400AbfLFQIm (ORCPT ); Fri, 6 Dec 2019 11:08:42 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:46141 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726287AbfLFQIg (ORCPT ); Fri, 6 Dec 2019 11:08:36 -0500 Received: by mail-wr1-f68.google.com with SMTP id z7so8277459wrl.13 for ; Fri, 06 Dec 2019 08:08:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=gxbWZ+1ZWkEp150t9d3q1/aGZxiFuyXJ5oXrQYsQaIs=; b=HMwTdq7Vv51j7Ssge5GkqQPsCDvB6LG6pxMjtWiw4Faqqrp0HvSdLiJ5J3t3SEatE+ IW2MTPZX2evR/++VJeJ/lSOWEuadg2y6O8n7UEsrL8jqvtpvkMrjfEdeustZfflRknkA PIJllwCZyZLW7N7zr1sCwAOjP4hZ7fCDT4G1ELorBsvKhbP6KF/ox8HiOfSnnXz6+yix MTtDmThqFxYc8yhWxbT9GN+0z3xAzkcVJaJjPN636Czw4RdYg6plxaaCeJZ/45G4WL8B lTM6jKCNzpXqrRD+rV5Pequm5VVhnpiBIca/6zUqumtBuk8ny0oBWivuzP+s7e2DAUXU epdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=gxbWZ+1ZWkEp150t9d3q1/aGZxiFuyXJ5oXrQYsQaIs=; b=M4r99KVf9fRDDStJwwjZnutPjK2luGlcME9L3nRVBmmFSBY1okxmgA4vPcu+3ieffd hGCryElGcbaB2OW+VEKawos6GLWGd3GwM5gHvrQMOao0E5sfEKjr5nbx1kk6t7yqPtpk ORhtpcJLBnFmirRIrJJqH5chc5QlMPoiJJvSWZ6GHS2llgbXeyvNnP5G19g+gsv2c5WA JajhTbsRT/rPBY6devmzEKxd12l7ZB60EkAhU/6iFa0Jr2549deuabhF6LQ3JS0ccvpb D2PcrnoaZiIP2Z85L5Pp/mrS7av4/k0py9zNWWK8/5UKbylNc7nmxd44opTEsQLi+zs1 LDbw== X-Gm-Message-State: APjAAAU9Ov9NtoT51YS2uhE08X6rhBGExs87TCOGT+y4HLtN5+5PWxQY v06n0Wouggb4IvD+99rcLY2ofJab X-Google-Smtp-Source: APXvYqzQaLScLrPSuesrlng+yADA3QNToV9+aqBq7WoW5r7N5ujYYKbAAj73uQfInlpdZ9EFuXf06A== X-Received: by 2002:a5d:53d1:: with SMTP id a17mr15961434wrw.327.1575648514932; Fri, 06 Dec 2019 08:08:34 -0800 (PST) Received: from localhost.localdomain (host-92-22-0-192.as13285.net. [92.22.0.192]) by smtp.gmail.com with ESMTPSA id q15sm16649799wrr.11.2019.12.06.08.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:08:34 -0800 (PST) From: Phillip Wood To: Git Mailing List Cc: Johannes Schindelin , Junio C Hamano , Phillip Wood Subject: [PATCH v2 5/9] commit: use enum value for multiple cherry-picks Date: Fri, 6 Dec 2019 16:06:10 +0000 Message-Id: <20191206160614.631724-6-phillip.wood123@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206160614.631724-1-phillip.wood123@gmail.com> References: <20191206160614.631724-1-phillip.wood123@gmail.com> Reply-To: Phillip Wood MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood Add FROM_CHERRY_PICK_MULTI for a sequence of cherry-picks rather than using a separate variable. Signed-off-by: Phillip Wood --- builtin/commit.c | 25 +++++++++++-------------- wt-status.h | 9 ++++++++- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index d85e0ad560..3b463522be 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -122,7 +122,6 @@ static enum commit_msg_cleanup_mode cleanup_mode; static const char *cleanup_arg; static enum commit_whence whence; -static int sequencer_in_use; static int use_editor = 1, include_status = 1; static int have_option_m; static struct strbuf message = STRBUF_INIT; @@ -179,11 +178,9 @@ static void determine_whence(struct wt_status *s) { if (file_exists(git_path_merge_head(the_repository))) whence = FROM_MERGE; - else if (file_exists(git_path_cherry_pick_head(the_repository))) { - whence = FROM_CHERRY_PICK; - if (file_exists(git_path_seq_dir())) - sequencer_in_use = 1; - } + else if (file_exists(git_path_cherry_pick_head(the_repository))) + whence = file_exists(git_path_seq_dir()) ? + FROM_CHERRY_PICK_MULTI : FROM_CHERRY_PICK_SINGLE; else whence = FROM_COMMIT; if (s) @@ -453,7 +450,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix if (whence != FROM_COMMIT) { if (whence == FROM_MERGE) die(_("cannot do a partial commit during a merge.")); - else if (whence == FROM_CHERRY_PICK) + else if (is_from_cherry_pick(whence)) die(_("cannot do a partial commit during a cherry-pick.")); } @@ -771,7 +768,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, */ else if (whence == FROM_MERGE) hook_arg1 = "merge"; - else if (whence == FROM_CHERRY_PICK) { + else if (is_from_cherry_pick(whence)) { hook_arg1 = "commit"; hook_arg2 = "CHERRY_PICK_HEAD"; } @@ -948,9 +945,9 @@ static int prepare_to_commit(const char *index_file, const char *prefix, run_status(stdout, index_file, prefix, 0, s); if (amend) fputs(_(empty_amend_advice), stderr); - else if (whence == FROM_CHERRY_PICK) { + else if (is_from_cherry_pick(whence)) { fputs(_(empty_cherry_pick_advice), stderr); - if (!sequencer_in_use) + if (whence == FROM_CHERRY_PICK_SINGLE) fputs(_(empty_cherry_pick_advice_single), stderr); else fputs(_(empty_cherry_pick_advice_multi), stderr); @@ -1143,7 +1140,7 @@ static int parse_and_validate_options(int argc, const char *argv[], if (amend && whence != FROM_COMMIT) { if (whence == FROM_MERGE) die(_("You are in the middle of a merge -- cannot amend.")); - else if (whence == FROM_CHERRY_PICK) + else if (is_from_cherry_pick(whence)) die(_("You are in the middle of a cherry-pick -- cannot amend.")); } if (fixup_message && squash_message) @@ -1166,7 +1163,7 @@ static int parse_and_validate_options(int argc, const char *argv[], use_message = edit_message; if (amend && !use_message && !fixup_message) use_message = "HEAD"; - if (!use_message && whence != FROM_CHERRY_PICK && renew_authorship) + if (!use_message && !is_from_cherry_pick(whence) && renew_authorship) die(_("--reset-author can be used only with -C, -c or --amend.")); if (use_message) { use_message_buffer = read_commit_message(use_message); @@ -1175,7 +1172,7 @@ static int parse_and_validate_options(int argc, const char *argv[], author_message_buffer = use_message_buffer; } } - if (whence == FROM_CHERRY_PICK && !renew_authorship) { + if (is_from_cherry_pick(whence) && !renew_authorship) { author_message = "CHERRY_PICK_HEAD"; author_message_buffer = read_commit_message(author_message); } @@ -1589,7 +1586,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) reduce_heads_replace(&parents); } else { if (!reflog_msg) - reflog_msg = (whence == FROM_CHERRY_PICK) + reflog_msg = is_from_cherry_pick(whence) ? "commit (cherry-pick)" : "commit"; commit_list_insert(current_head, &parents); diff --git a/wt-status.h b/wt-status.h index 64f1ddc9fd..0098fdb0b5 100644 --- a/wt-status.h +++ b/wt-status.h @@ -39,9 +39,16 @@ enum show_ignored_type { enum commit_whence { FROM_COMMIT, /* normal */ FROM_MERGE, /* commit came from merge */ - FROM_CHERRY_PICK /* commit came from cherry-pick */ + FROM_CHERRY_PICK_SINGLE, /* commit came from cherry-pick */ + FROM_CHERRY_PICK_MULTI /* commit came from a sequence of cherry-picks */ }; +static inline int is_from_cherry_pick(enum commit_whence whence) +{ + return whence == FROM_CHERRY_PICK_SINGLE || + whence == FROM_CHERRY_PICK_MULTI; +} + struct wt_status_change_data { int worktree_status; int index_status; From patchwork Fri Dec 6 16:06:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 11276749 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 66F3317EF for ; Fri, 6 Dec 2019 16:08:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3DF94206DF for ; Fri, 6 Dec 2019 16:08:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fNIafgW/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726395AbfLFQIl (ORCPT ); Fri, 6 Dec 2019 11:08:41 -0500 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39048 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726366AbfLFQIh (ORCPT ); Fri, 6 Dec 2019 11:08:37 -0500 Received: by mail-wm1-f65.google.com with SMTP id s14so7873900wmh.4 for ; Fri, 06 Dec 2019 08:08:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=TCQU2DKHEVOPy3Lfp3LqKeXOREm8ZdiIZgF89ow4lDY=; b=fNIafgW/1/8Buu9axLO9WpdJRZAL22LDbuj6PkwsGZT7iRBzhtFi5XNY9gp4+Kb+y2 boENL84Q7mRIfD6vLr68jGUh3XYbZuPiE6wgs/uKXgo3OtUoqb045KJ/jZr8Xlu9ejb+ pfJ/asabGFR1UE+ZtF34tMqLVjUmXt0G30mgFUVHMnbvWUvrVQ8qDkkJc7Ba3EwbANUN ryhXqW1h4Jf2o/fOBmf+uziEQS5Nghy138iqoPjd3YISqzjpdCjq3yOrU3hrKVXcTRgK RXtEOE76kr4/BRu9u/it2wefZEtZGl7Qzyljv+ptkxQHymnh0A0K2mt9kl+xcC5n2FqX FhCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=TCQU2DKHEVOPy3Lfp3LqKeXOREm8ZdiIZgF89ow4lDY=; b=j8+x5SYekGYx1z8PBY/JGU5YiaRVvc2CQD2dlSoDYAWaFhVWlDbeHLWo49sY/ouIXD 701hIXkXp3TFzanVscsLzsXOH5hE4/nvr3jOWIKr87/Y60ckIgnc6dC5oCIRPawtcF/4 IIO6acRlN70sYpH3fnVcTQsE6NvPxZ3ED0KP7RidupR1HMkp1STauLSGxgp2qEk8b6t+ p8dxZ1gdm0cAyGSTtABDxIKDQVSbEAlNu8uI5Vzs+tEPO5uli1gC0d2h1AkZhDKwwL0F VJF/ayJVpVQLzcbFiTt4S2BUynl5HIdpdbP6xIpHKKQdE8yRzBH+hFwPrwcO3ybU7cRD DVCg== X-Gm-Message-State: APjAAAXiQCtOpbObqsb5li2KSj+IvlSc1OCjbZgq9CePUtioE8DN6WUF nWLzoLB4P/L8V1xwiNAR6zn2u0M2 X-Google-Smtp-Source: APXvYqwcSCWh6LfHCXMV6M0mBkhgeod3eO2Hb3dpuCzEXHaPEvWEwpOI2da3gIc+F4EcKMpX9F/cCQ== X-Received: by 2002:a1c:7910:: with SMTP id l16mr11107195wme.27.1575648515786; Fri, 06 Dec 2019 08:08:35 -0800 (PST) Received: from localhost.localdomain (host-92-22-0-192.as13285.net. [92.22.0.192]) by smtp.gmail.com with ESMTPSA id q15sm16649799wrr.11.2019.12.06.08.08.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:08:35 -0800 (PST) From: Phillip Wood To: Git Mailing List Cc: Johannes Schindelin , Junio C Hamano , Phillip Wood Subject: [PATCH v2 6/9] commit: encapsulate determine_whence() for sequencer Date: Fri, 6 Dec 2019 16:06:11 +0000 Message-Id: <20191206160614.631724-7-phillip.wood123@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206160614.631724-1-phillip.wood123@gmail.com> References: <20191206160614.631724-1-phillip.wood123@gmail.com> Reply-To: Phillip Wood MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood Working out which command wants to create a commit requires detailed knowledge of the sequencer internals and that knowledge is going to increase in subsequent commits. With that in mind lets encapsulate that knowledge in sequencer.c rather than spreading it into builtin/commit.c. Signed-off-by: Phillip Wood --- builtin/commit.c | 5 +---- sequencer.c | 13 ++++++++++++- sequencer.h | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 3b463522be..d8d4c8e419 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -178,10 +178,7 @@ static void determine_whence(struct wt_status *s) { if (file_exists(git_path_merge_head(the_repository))) whence = FROM_MERGE; - else if (file_exists(git_path_cherry_pick_head(the_repository))) - whence = file_exists(git_path_seq_dir()) ? - FROM_CHERRY_PICK_MULTI : FROM_CHERRY_PICK_SINGLE; - else + else if (!sequencer_determine_whence(the_repository, &whence)) whence = FROM_COMMIT; if (s) s->whence = whence; diff --git a/sequencer.c b/sequencer.c index 4e0370277b..98e007556c 100644 --- a/sequencer.c +++ b/sequencer.c @@ -40,7 +40,7 @@ static const char cherry_picked_prefix[] = "(cherry picked from commit "; GIT_PATH_FUNC(git_path_commit_editmsg, "COMMIT_EDITMSG") -GIT_PATH_FUNC(git_path_seq_dir, "sequencer") +static GIT_PATH_FUNC(git_path_seq_dir, "sequencer") static GIT_PATH_FUNC(git_path_todo_file, "sequencer/todo") static GIT_PATH_FUNC(git_path_opts_file, "sequencer/opts") @@ -5256,3 +5256,14 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) return 0; } + +int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) +{ + if (file_exists(git_path_cherry_pick_head(r))) { + *whence = file_exists(git_path_seq_dir()) ? + FROM_CHERRY_PICK_MULTI : FROM_CHERRY_PICK_SINGLE; + return 1; + } + + return 0; +} diff --git a/sequencer.h b/sequencer.h index 56881a6baa..8d451dbfcb 100644 --- a/sequencer.h +++ b/sequencer.h @@ -3,12 +3,12 @@ #include "cache.h" #include "strbuf.h" +#include "wt-status.h" struct commit; struct repository; const char *git_path_commit_editmsg(void); -const char *git_path_seq_dir(void); const char *rebase_path_todo(void); const char *rebase_path_todo_backup(void); @@ -202,4 +202,5 @@ int write_basic_state(struct replay_opts *opts, const char *head_name, void sequencer_post_commit_cleanup(struct repository *r); int sequencer_get_last_command(struct repository* r, enum replay_action *action); +int sequencer_determine_whence(struct repository *r, enum commit_whence *whence); #endif /* SEQUENCER_H */ From patchwork Fri Dec 6 16:06:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 11276755 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B58F413B6 for ; Fri, 6 Dec 2019 16:08:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8036024659 for ; Fri, 6 Dec 2019 16:08:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mkU/rOaV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726388AbfLFQIl (ORCPT ); Fri, 6 Dec 2019 11:08:41 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:34622 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726284AbfLFQIj (ORCPT ); Fri, 6 Dec 2019 11:08:39 -0500 Received: by mail-wr1-f67.google.com with SMTP id t2so8394587wrr.1 for ; Fri, 06 Dec 2019 08:08:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=rDWwEI+LNv9vjMasneiWrih6Zrpg14xC0lNJ4p0LlBg=; b=mkU/rOaVWh0uC2yrZdibHz1KKBfMADrP9PWDy2hK723iBV+GLdyerSxOjId8yrx8Ze Zx2YYKzzrh2gfoBZr6mkNg0Q5akuGFftmi9m/xpy0afGp0T2BuOKneIs7JWg4Lub2R6Z 0pqHHshl1upNNAwusUQQDTbEee35L7jOHH3+v/r0KGgvMpksEV9z0B0obzWPgNbnWFX2 yYcPLmwdKWCsnIa3oX/r8HVpkUlfntU2sQm8roBYzLG9tMBumWKTqWRRJW+WTD6azLtY VXiHptVx0QDERVmm4SmOKycbbsxPJhj5yu/gnDY4iRTjKtVnuht2sgm5TW9EDZOmALpX IFTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=rDWwEI+LNv9vjMasneiWrih6Zrpg14xC0lNJ4p0LlBg=; b=KZurvHUmjyqI2ZfXTOi1u/h5sTjHb1TXAP1cCv4fn6rJ9/7CwtpEEiRe7fmmQV7ao+ erIq+0Sa9WRXGG8jEAdpnGpP6lJx9mOT+nGe50meC0YJl0tZhPlBBbSZ/whiPfQt0yGm aB/14TdNuZT4s7TfOD757a4LHKlJLilHTlzzSIf+rKLDIPo2f7C4SmxY047AFoWXiT9V UDwtcDkfd/3HDOkwP4VAtd4pZP+hZZZiDB+sYpR23vOiyh9o/n2qHAuEzICLFB2RhX9j Ic0ny9SuPSlsnjnLe6cKQvQzjG5oKIEfHo9WBH3OU8AMdbCK8zEDXUocJ2Yaxlli2T1S a9vw== X-Gm-Message-State: APjAAAUSbyrWbqxanA/g2GzvQhDIljmDRVsjh4roCf+IBOj5m7ODCg+W COHe7GQAjqZmgVoZjqNQmhFvHS8p X-Google-Smtp-Source: APXvYqz1q9gci5Nhe5dmUpmCpSKgZPASVpcahvTmM6VaQKKWSVTJ0L/QxDjmGD94BEq1G7XtDxrfOw== X-Received: by 2002:adf:d183:: with SMTP id v3mr16615129wrc.180.1575648516898; Fri, 06 Dec 2019 08:08:36 -0800 (PST) Received: from localhost.localdomain (host-92-22-0-192.as13285.net. [92.22.0.192]) by smtp.gmail.com with ESMTPSA id q15sm16649799wrr.11.2019.12.06.08.08.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:08:36 -0800 (PST) From: Phillip Wood To: Git Mailing List Cc: Johannes Schindelin , Junio C Hamano , Phillip Wood , Johannes Schindelin Subject: [PATCH v2 7/9] commit: give correct advice for empty commit during a rebase Date: Fri, 6 Dec 2019 16:06:12 +0000 Message-Id: <20191206160614.631724-8-phillip.wood123@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206160614.631724-1-phillip.wood123@gmail.com> References: <20191206160614.631724-1-phillip.wood123@gmail.com> Reply-To: Phillip Wood MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood In dcb500dc16c (cherry-pick/revert: advise using --skip, 2019-07-02), `git commit` learned to suggest to run `git cherry-pick --skip` when trying to cherry-pick an empty patch. However, it was overlooked that there are more conditions than just a `git cherry-pick` when this advice is printed (which originally suggested the neutral `git reset`): the same can happen during a rebase. Let's suggest the correct command, even during a rebase. While at it, we adjust more places in `builtin/commit.c` that incorrectly assumed that the presence of a `CHERRY_PICK_HEAD` meant that surely this must be a `cherry-pick` in progress. Note: we take pains to handle the situation when a user runs a `git cherry-pick` _during_ a rebase. This is quite valid (e.g. in an `exec` line in an interactive rebase). On the other hand, it is not possible to run a rebase during a cherry-pick, meaning: if both `rebase-merge/` and `sequencer/` exist or CHERRY_PICK_HEAD and REBASE_HEAD point to the same commit , we still want to advise to use `git cherry-pick --skip`. Original-patch-by: Johannes Schindelin Signed-off-by: Phillip Wood --- builtin/commit.c | 24 ++++++++++++++++----- sequencer.c | 39 ++++++++++++++++++++++++++++------- t/t3403-rebase-skip.sh | 36 +++++++++++++++++++++++++++----- t/t3404-rebase-interactive.sh | 26 +++++++++++++++++++++++ wt-status.h | 8 ++++++- 5 files changed, 114 insertions(+), 19 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index d8d4c8e419..c3b6b8a6bd 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -59,6 +59,9 @@ N_("The previous cherry-pick is now empty, possibly due to conflict resolution.\ " git commit --allow-empty\n" "\n"); +static const char empty_rebase_pick_advice[] = +N_("Otherwise, please use 'git rebase --skip'\n"); + static const char empty_cherry_pick_advice_single[] = N_("Otherwise, please use 'git cherry-pick --skip'\n"); @@ -449,6 +452,8 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix die(_("cannot do a partial commit during a merge.")); else if (is_from_cherry_pick(whence)) die(_("cannot do a partial commit during a cherry-pick.")); + else if (is_from_rebase(whence)) + die(_("cannot do a partial commit during a rebase.")); } if (list_paths(&partial, !current_head ? NULL : "HEAD", &pathspec)) @@ -765,7 +770,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, */ else if (whence == FROM_MERGE) hook_arg1 = "merge"; - else if (is_from_cherry_pick(whence)) { + else if (is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) { hook_arg1 = "commit"; hook_arg2 = "CHERRY_PICK_HEAD"; } @@ -942,12 +947,15 @@ static int prepare_to_commit(const char *index_file, const char *prefix, run_status(stdout, index_file, prefix, 0, s); if (amend) fputs(_(empty_amend_advice), stderr); - else if (is_from_cherry_pick(whence)) { + else if (is_from_cherry_pick(whence) || + whence == FROM_REBASE_PICK) { fputs(_(empty_cherry_pick_advice), stderr); if (whence == FROM_CHERRY_PICK_SINGLE) fputs(_(empty_cherry_pick_advice_single), stderr); - else + else if (whence == FROM_CHERRY_PICK_MULTI) fputs(_(empty_cherry_pick_advice_multi), stderr); + else + fputs(_(empty_rebase_pick_advice), stderr); } return 0; } @@ -1139,6 +1147,8 @@ static int parse_and_validate_options(int argc, const char *argv[], die(_("You are in the middle of a merge -- cannot amend.")); else if (is_from_cherry_pick(whence)) die(_("You are in the middle of a cherry-pick -- cannot amend.")); + else if (whence == FROM_REBASE_PICK) + die(_("You are in the middle of a rebase -- cannot amend.")); } if (fixup_message && squash_message) die(_("Options --squash and --fixup cannot be used together")); @@ -1160,7 +1170,8 @@ static int parse_and_validate_options(int argc, const char *argv[], use_message = edit_message; if (amend && !use_message && !fixup_message) use_message = "HEAD"; - if (!use_message && !is_from_cherry_pick(whence) && renew_authorship) + if (!use_message && !is_from_cherry_pick(whence) && + !is_from_rebase(whence) && renew_authorship) die(_("--reset-author can be used only with -C, -c or --amend.")); if (use_message) { use_message_buffer = read_commit_message(use_message); @@ -1169,7 +1180,8 @@ static int parse_and_validate_options(int argc, const char *argv[], author_message_buffer = use_message_buffer; } } - if (is_from_cherry_pick(whence) && !renew_authorship) { + if ((is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) && + !renew_authorship) { author_message = "CHERRY_PICK_HEAD"; author_message_buffer = read_commit_message(author_message); } @@ -1585,6 +1597,8 @@ int cmd_commit(int argc, const char **argv, const char *prefix) if (!reflog_msg) reflog_msg = is_from_cherry_pick(whence) ? "commit (cherry-pick)" + : is_from_rebase(whence) + ? "commit (rebase)" : "commit"; commit_list_insert(current_head, &parents); } diff --git a/sequencer.c b/sequencer.c index 98e007556c..6e153fea76 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1430,9 +1430,19 @@ static int try_to_commit(struct repository *r, return res; } +static int write_rebase_head(struct object_id *oid) +{ + if (update_ref("rebase", "REBASE_HEAD", oid, + NULL, REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) + return error(_("could not update %s"), "REBASE_HEAD"); + + return 0; +} + static int do_commit(struct repository *r, const char *msg_file, const char *author, - struct replay_opts *opts, unsigned int flags) + struct replay_opts *opts, unsigned int flags, + struct object_id *oid) { int res = 1; @@ -1457,8 +1467,12 @@ static int do_commit(struct repository *r, return res; } } - if (res == 1) + if (res == 1) { + if (is_rebase_i(opts) && oid) + if (write_rebase_head(oid)) + return -1; return run_git_commit(r, msg_file, opts, flags); + } return res; } @@ -1945,7 +1959,8 @@ static int do_pick_commit(struct repository *r, flags |= ALLOW_EMPTY; if (!opts->no_commit) { if (author || command == TODO_REVERT || (flags & AMEND_MSG)) - res = do_commit(r, msg_file, author, opts, flags); + res = do_commit(r, msg_file, author, opts, flags, + commit? &commit->object.oid : NULL); else res = error(_("unable to parse commit author")); *check_todo = !!(flags & EDIT_MSG); @@ -2960,9 +2975,7 @@ static int make_patch(struct repository *r, p = short_commit_name(commit); if (write_message(p, strlen(p), rebase_path_stopped_sha(), 1) < 0) return -1; - if (update_ref("rebase", "REBASE_HEAD", &commit->object.oid, - NULL, REF_NO_DEREF, UPDATE_REFS_MSG_ON_ERR)) - res |= error(_("could not update %s"), "REBASE_HEAD"); + res |= write_rebase_head(&commit->object.oid); strbuf_addf(&buf, "%s/patch", get_dir(opts)); memset(&log_tree_opt, 0, sizeof(log_tree_opt)); @@ -5260,8 +5273,18 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) { if (file_exists(git_path_cherry_pick_head(r))) { - *whence = file_exists(git_path_seq_dir()) ? - FROM_CHERRY_PICK_MULTI : FROM_CHERRY_PICK_SINGLE; + struct object_id cherry_pick_head, rebase_head; + + if (file_exists(git_path_seq_dir())) + *whence = FROM_CHERRY_PICK_MULTI; + if (file_exists(rebase_path()) && + !get_oid("REBASE_HEAD", &rebase_head) && + !get_oid("CHERRY_PICK_HEAD", &cherry_pick_head) && + oideq(&rebase_head, &cherry_pick_head)) + *whence = FROM_REBASE_PICK; + else + *whence = FROM_CHERRY_PICK_SINGLE; + return 1; } diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh index db7e917248..a927774910 100755 --- a/t/t3403-rebase-skip.sh +++ b/t/t3403-rebase-skip.sh @@ -97,9 +97,9 @@ test_expect_success 'correct advice upon picking empty commit' ' test_must_fail git rebase -i --onto goodbye \ amended-goodbye^ amended-goodbye 2>err && test_i18ngrep "previous cherry-pick is now empty" err && - test_i18ngrep "git cherry-pick --skip" err && + test_i18ngrep "git rebase --skip" err && test_must_fail git commit && - test_i18ngrep "git cherry-pick --skip" err + test_i18ngrep "git rebase --skip" err ' test_expect_success 'correct authorship when committing empty pick' ' @@ -120,9 +120,9 @@ test_expect_success 'correct advice upon rewording empty commit' ' --onto goodbye amended-goodbye^ amended-goodbye 2>err ) && test_i18ngrep "previous cherry-pick is now empty" err && - test_i18ngrep "git cherry-pick --skip" err && + test_i18ngrep "git rebase --skip" err && test_must_fail git commit && - test_i18ngrep "git cherry-pick --skip" err + test_i18ngrep "git rebase --skip" err ' test_expect_success 'correct advice upon editing empty commit' ' @@ -133,8 +133,34 @@ test_expect_success 'correct advice upon editing empty commit' ' --onto goodbye amended-goodbye^ amended-goodbye 2>err ) && test_i18ngrep "previous cherry-pick is now empty" err && - test_i18ngrep "git cherry-pick --skip" err && + test_i18ngrep "git rebase --skip" err && test_must_fail git commit && + test_i18ngrep "git rebase --skip" err +' + +test_expect_success 'correct advice upon cherry-picking an empty commit during a rebase' ' + test_when_finished "git rebase --abort" && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_amended-goodbye" \ + git rebase -i goodbye^ goodbye 2>err + ) && + test_i18ngrep "previous cherry-pick is now empty" err && + test_i18ngrep "git cherry-pick --skip" err && + test_must_fail git commit 2>err && + test_i18ngrep "git cherry-pick --skip" err +' + +test_expect_success 'correct advice upon multi cherry-pick picking an empty commit during a rebase' ' + test_when_finished "git rebase --abort" && + ( + set_fake_editor && + test_must_fail env FAKE_LINES="1 exec_git_cherry-pick_goodbye_amended-goodbye" \ + git rebase -i goodbye^^ goodbye 2>err + ) && + test_i18ngrep "previous cherry-pick is now empty" err && + test_i18ngrep "git cherry-pick --skip" err && + test_must_fail git commit 2>err && test_i18ngrep "git cherry-pick --skip" err ' diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index d8a05fd439..5afa6f28cd 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -1602,6 +1602,32 @@ test_expect_success 'post-commit hook is called' ' test_cmp expect actual ' +test_expect_success 'correct error message for partial commit after empty pick' ' + test_when_finished "git rebase --abort" && + ( + set_fake_editor && + FAKE_LINES="2 1 1" && + export FAKE_LINES && + test_must_fail git rebase -i A D + ) && + echo x >file1 && + test_must_fail git commit file1 2>err && + test_i18ngrep "cannot do a partial commit during a rebase." err +' + +test_expect_success 'correct error message for commit --amend after empty pick' ' + test_when_finished "git rebase --abort" && + ( + set_fake_editor && + FAKE_LINES="1 1" && + export FAKE_LINES && + test_must_fail git rebase -i A D + ) && + echo x>file1 && + test_must_fail git commit -a --amend 2>err && + test_i18ngrep "middle of a rebase -- cannot amend." err +' + # This must be the last test in this file test_expect_success '$EDITOR and friends are unchanged' ' test_editor_unchanged diff --git a/wt-status.h b/wt-status.h index 0098fdb0b5..5f81bf7507 100644 --- a/wt-status.h +++ b/wt-status.h @@ -40,7 +40,8 @@ enum commit_whence { FROM_COMMIT, /* normal */ FROM_MERGE, /* commit came from merge */ FROM_CHERRY_PICK_SINGLE, /* commit came from cherry-pick */ - FROM_CHERRY_PICK_MULTI /* commit came from a sequence of cherry-picks */ + FROM_CHERRY_PICK_MULTI, /* commit came from a sequence of cherry-picks */ + FROM_REBASE_PICK /* commit came from a pick/reword/edit */ }; static inline int is_from_cherry_pick(enum commit_whence whence) @@ -49,6 +50,11 @@ static inline int is_from_cherry_pick(enum commit_whence whence) whence == FROM_CHERRY_PICK_MULTI; } +static inline int is_from_rebase(enum commit_whence whence) +{ + return whence == FROM_REBASE_PICK; +} + struct wt_status_change_data { int worktree_status; int index_status; From patchwork Fri Dec 6 16:06:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 11276757 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0A49F13B6 for ; Fri, 6 Dec 2019 16:08:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D35C224659 for ; Fri, 6 Dec 2019 16:08:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SDsRQgHC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726410AbfLFQIq (ORCPT ); Fri, 6 Dec 2019 11:08:46 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36812 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726371AbfLFQIl (ORCPT ); Fri, 6 Dec 2019 11:08:41 -0500 Received: by mail-wr1-f65.google.com with SMTP id z3so8386768wru.3 for ; Fri, 06 Dec 2019 08:08:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=0PbHtX8Zhg2EuQHin+/zjjfoert8TGnxLn5Rrht0Lyc=; b=SDsRQgHCYIdGsbTe+D2RzMHYSXfe8/K2+FQb9OmBuVczdQZmUVwhb5G1gZ5CSa+vUB Aj0bAF8PWvP6l27czNixIjssm1xPSV6SCVW+hioBXq6XBsVLpx21gTmV/6hoSJTjHxXY dXndeoAe6itmYTDZkywKdsZIdQ+vvps8yONO/D5IfKfPTKFu3cA/koeyuzQ6mwvyphvi CYf6+aFjgcfMG3nNtMxojAv+82a2XoNW1ubGK6zPSYBZDTu1o8cZid3qy3s+71jscYiQ qg3OVnM2d8VIHqYnWOFMeK912OtHSTLM/kWx50UGvWlSbXUFzSD/ZOVzic4BaAcQ8chK 932w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=0PbHtX8Zhg2EuQHin+/zjjfoert8TGnxLn5Rrht0Lyc=; b=XzxXGxDLBl3UDlbywGICA7si+pozV1+VEU0W1piiu6Z0EFJTKodF36VSPsYKmvt34o bo6LDtkjAIEGbsdl9MGXyPzy8u7E8m9f2gLOWGQoHWKnmobeS9h6er+DWo/pVudTZGbt yhr7vYT8by0SY482rpbivCMCLmbGbQSmTjQyfbsM58AfreZjIadhbU3/W6dSV99pSgOS ERdP6GAE8W/iUNHHgKA4/yxyO5ghP1TS1PhuEd61PgV2fssPrms2kwrxpbrdTkTnV5wa PsRFmFS4/2D5OAEtEf1bagt5MQhYq80Omn/HNBicp/x85P4YxXiPWK2gTzzWsRrMGKI4 q5OA== X-Gm-Message-State: APjAAAVCy44HyUSzuDb/YzonxrWnP+g0vpS6aHb4svA1vNvU4Z6kUqK/ CvsaWrvWypFym0RhlkTWC4vRMhML X-Google-Smtp-Source: APXvYqzCahQ2Pl8V8rPHMwkpFcy3V2xM9qG/SSDlo7yoJbKeBcs/t3l4fr2JLevXbtc2WIDXf45kSQ== X-Received: by 2002:adf:f20b:: with SMTP id p11mr16044865wro.195.1575648517937; Fri, 06 Dec 2019 08:08:37 -0800 (PST) Received: from localhost.localdomain (host-92-22-0-192.as13285.net. [92.22.0.192]) by smtp.gmail.com with ESMTPSA id q15sm16649799wrr.11.2019.12.06.08.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:08:37 -0800 (PST) From: Phillip Wood To: Git Mailing List Cc: Johannes Schindelin , Junio C Hamano , Phillip Wood Subject: [PATCH v2 8/9] [RFC] rebase: fix advice when a fixup creates an empty commit Date: Fri, 6 Dec 2019 16:06:13 +0000 Message-Id: <20191206160614.631724-9-phillip.wood123@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206160614.631724-1-phillip.wood123@gmail.com> References: <20191206160614.631724-1-phillip.wood123@gmail.com> Reply-To: Phillip Wood MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood Add a specific message to advise the user what to do when a fixup or squash command would create an empty commit. Signed-off-by: Phillip Wood --- Notes: I'm slightly nervous of moving the call to determine_whence() to finalized_deferred_config(). I think it is ok but need to do a more thorough audit of the code to be sure. builtin/commit.c | 32 ++++++++++++++++++++++++++++---- sequencer.c | 31 ++++++++++++++++++++++++++++++- sequencer.h | 3 ++- t/t3403-rebase-skip.sh | 18 ++++++++++++------ wt-status.h | 5 +++-- 5 files changed, 75 insertions(+), 14 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index c3b6b8a6bd..4ae984c470 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -52,6 +52,20 @@ N_("You asked to amend the most recent commit, but doing so would make\n" "it empty. You can repeat your command with --allow-empty, or you can\n" "remove the commit entirely with \"git reset HEAD^\".\n"); +static const char empty_rebase_fixup_advice[] = +N_("The fixup would make the commit empty\n" +"If you wish to commit it anyway use:\n" +"\n" +" git commit --amend --allow-empty\n" +" git rebase --continue\n" +"\n" +"To remove the commit entirely use:\n" +"\n" +" git reset HEAD^\n" +" git rebase --continue\n" +"\n" +"Otherwise, please use 'git rebase --skip' to skip it\n"); + static const char empty_cherry_pick_advice[] = N_("The previous cherry-pick is now empty, possibly due to conflict resolution.\n" "If you wish to commit it anyway, use:\n" @@ -181,8 +195,14 @@ static void determine_whence(struct wt_status *s) { if (file_exists(git_path_merge_head(the_repository))) whence = FROM_MERGE; - else if (!sequencer_determine_whence(the_repository, &whence)) - whence = FROM_COMMIT; + else { + int res = sequencer_determine_whence(the_repository, &whence, + amend); + if (res < 0) + die(_("could not read sequencer state")); + else if (!res) + whence = FROM_COMMIT; + } if (s) s->whence = whence; } @@ -192,7 +212,6 @@ static void status_init_config(struct wt_status *s, config_fn_t fn) wt_status_prepare(the_repository, s); init_diff_ui_defaults(); git_config(fn, s); - determine_whence(s); s->hints = advice_status_hints; /* must come after git_config() */ } @@ -943,9 +962,12 @@ static int prepare_to_commit(const char *index_file, const char *prefix, */ if (!committable && whence != FROM_MERGE && !allow_empty && !(amend && is_a_merge(current_head))) { + fprintf(stderr, "\nwhence = %d\n", whence); s->display_comment_prefix = old_display_comment_prefix; run_status(stdout, index_file, prefix, 0, s); - if (amend) + if (whence == FROM_REBASE_FIXUP) + fputs(_(empty_rebase_fixup_advice), stderr); + else if (amend) fputs(_(empty_amend_advice), stderr); else if (is_from_cherry_pick(whence) || whence == FROM_REBASE_PICK) { @@ -1114,6 +1136,8 @@ static void finalize_deferred_config(struct wt_status *s) if (s->ahead_behind_flags == AHEAD_BEHIND_UNSPECIFIED) s->ahead_behind_flags = AHEAD_BEHIND_FULL; + + determine_whence(s); } static int parse_and_validate_options(int argc, const char *argv[], diff --git a/sequencer.c b/sequencer.c index 6e153fea76..64242f4ce7 100644 --- a/sequencer.c +++ b/sequencer.c @@ -5270,7 +5270,8 @@ int todo_list_rearrange_squash(struct todo_list *todo_list) return 0; } -int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) +int sequencer_determine_whence(struct repository *r, enum commit_whence *whence, + int amending) { if (file_exists(git_path_cherry_pick_head(r))) { struct object_id cherry_pick_head, rebase_head; @@ -5286,6 +5287,34 @@ int sequencer_determine_whence(struct repository *r, enum commit_whence *whence) *whence = FROM_CHERRY_PICK_SINGLE; return 1; + } else if (amending && file_exists(rebase_path_current_fixups()) && + (file_exists(git_path_squash_msg(r)) || + file_exists(git_path_merge_msg(r)))) { + /* + * If rebase_path_amend() exists the user is running `git + * commit`, if not we're committing a fixup/squash directly from + * the sequencer + */ + if (file_exists(rebase_path_amend())) { + struct strbuf rev = STRBUF_INIT; + struct object_id to_amend, head; + + if (get_oid("HEAD", &head)) + return error(_("amending invalid head")); /* let commit deal with error */ + if (!read_oneliner(&rev, rebase_path_amend(), 0)) + return error(_("invalid file: '%s'"), + rebase_path_amend()); + if (get_oid_hex(rev.buf, &to_amend)) + return error(_("invalid contents: '%s'"), + rebase_path_amend()); + if (oideq(&head, &to_amend)) { + *whence = FROM_REBASE_FIXUP; + return 1; + } + } else { + *whence = FROM_REBASE_FIXUP; + return 1; + } } return 0; diff --git a/sequencer.h b/sequencer.h index 8d451dbfcb..4e631900b4 100644 --- a/sequencer.h +++ b/sequencer.h @@ -202,5 +202,6 @@ int write_basic_state(struct replay_opts *opts, const char *head_name, void sequencer_post_commit_cleanup(struct repository *r); int sequencer_get_last_command(struct repository* r, enum replay_action *action); -int sequencer_determine_whence(struct repository *r, enum commit_whence *whence); +int sequencer_determine_whence(struct repository *r, enum commit_whence *whence, + int amending); #endif /* SEQUENCER_H */ diff --git a/t/t3403-rebase-skip.sh b/t/t3403-rebase-skip.sh index a927774910..bc110b66b3 100755 --- a/t/t3403-rebase-skip.sh +++ b/t/t3403-rebase-skip.sh @@ -164,22 +164,28 @@ test_expect_success 'correct advice upon multi cherry-pick picking an empty comm test_i18ngrep "git cherry-pick --skip" err ' -test_expect_success 'fixup that empties commit fails' ' +test_expect_success 'correct advice when fixup empties commit' ' test_when_finished "git rebase --abort" && ( set_fake_editor && test_must_fail env FAKE_LINES="1 fixup 2" git rebase -i \ - goodbye^ reverted-goodbye - ) + goodbye^ reverted-goodbye 2>err + ) && + test_i18ngrep "git rebase --skip" err && + test_must_fail git commit --amend --no-edit 2>err && + test_i18ngrep "git rebase --skip" err ' -test_expect_success 'squash that empties commit fails' ' +test_expect_success 'correct advice when squash empties commit' ' test_when_finished "git rebase --abort" && ( set_fake_editor && test_must_fail env FAKE_LINES="1 squash 2" git rebase -i \ - goodbye^ reverted-goodbye - ) + goodbye^ reverted-goodbye 2>err + ) && + test_i18ngrep "git rebase --skip" err && + test_must_fail git commit --amend --no-edit 2>err && + test_i18ngrep "git rebase --skip" err ' # Must be the last test in this file diff --git a/wt-status.h b/wt-status.h index 5f81bf7507..a4b7fe6de9 100644 --- a/wt-status.h +++ b/wt-status.h @@ -41,7 +41,8 @@ enum commit_whence { FROM_MERGE, /* commit came from merge */ FROM_CHERRY_PICK_SINGLE, /* commit came from cherry-pick */ FROM_CHERRY_PICK_MULTI, /* commit came from a sequence of cherry-picks */ - FROM_REBASE_PICK /* commit came from a pick/reword/edit */ + FROM_REBASE_PICK, /* commit came from a pick/reword/edit */ + FROM_REBASE_FIXUP /* commit came from fixup/squash */ }; static inline int is_from_cherry_pick(enum commit_whence whence) @@ -52,7 +53,7 @@ static inline int is_from_cherry_pick(enum commit_whence whence) static inline int is_from_rebase(enum commit_whence whence) { - return whence == FROM_REBASE_PICK; + return whence == FROM_REBASE_PICK || whence == FROM_REBASE_FIXUP; } struct wt_status_change_data { From patchwork Fri Dec 6 16:06:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Phillip Wood X-Patchwork-Id: 11276753 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E186D109A for ; Fri, 6 Dec 2019 16:08:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B76CE24659 for ; Fri, 6 Dec 2019 16:08:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="PYXTvS86" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726403AbfLFQIn (ORCPT ); Fri, 6 Dec 2019 11:08:43 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:40833 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726375AbfLFQIl (ORCPT ); Fri, 6 Dec 2019 11:08:41 -0500 Received: by mail-wm1-f66.google.com with SMTP id t14so7863807wmi.5 for ; Fri, 06 Dec 2019 08:08:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references:reply-to :mime-version:content-transfer-encoding; bh=g/MhRBzkiypceIxVnALCyjM1eHKvec54D0R09F/4Whc=; b=PYXTvS868GhfwLg418zKY2UQgis2vrJBw6ZZPaOzos53rKoRxJCzVUslkWQ46/Vu2x Uoe77sSF+ghiV64zBGPJlv4MkfvIrxozn+hVbZHpsHQfrsX0f1DXklDrwiEN60dD2w0w x+ZpbysQGJcsemKHGWqdWy+at2BY1qjyRVB1kXiB7rhbwGVYAXCWZVj9Po/1VbRXBUab MKTjQTbmAz+f3whm6F8EWoIoIKVZOVK8c6gV1ScXRUemcLxhbvQ2Vy+0TKnY6v7ZUh7k tbVpccqvSaw6C73RdKGmgQnpCDDTMGHbiyg7/K/HoYB2VbpLJPUjDilOLTWkPHJ6zGo2 bn2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:reply-to:mime-version:content-transfer-encoding; bh=g/MhRBzkiypceIxVnALCyjM1eHKvec54D0R09F/4Whc=; b=dKXLRFqP+p2QGyjj2+TJvpFXGGq1svy+y5nd/F2shdu5ip116/1exOz6H7TF0edxg7 kj6/oKlVt9fWBMVjfKkOnvmGZwkclvbhNc1Oj6m/6WBuEYbH+Gl3egTbBMuZu7Y7DoEq Z/GJLfmNY7MJwO8Qj6X64XgzZSBYeq35aXbZgT1bjPp7hblq0DunUWvl6kQ8uAt1MEEw ANPr4sbHDBcIUaq+qdbblutGRV+ggjp/1OMCDh/KxHR5upplUk2m9oy4AFmqG2P6/vfZ s4l9GMeIlkBUMU4SJOY93laQGc2IiT30HZuwO5cDutuF95Qmo7BDIYvqgMMznBxCZJwo MnWg== X-Gm-Message-State: APjAAAURMpn5iqk/sCGkqczpdm4fQctwXm2sWE19lpqSlO7b0ix4IHnH WIvE0XDlea7cXx6khuz9e1PzoqP+ X-Google-Smtp-Source: APXvYqyYhKpOZzuqgTCpBT6qxxiAM4kuo3RUi9ovsBgb/0TmBrpmyWtNJ6+pfvGMDI/CpPp2KQLl/Q== X-Received: by 2002:a05:600c:2318:: with SMTP id 24mr9357712wmo.48.1575648518819; Fri, 06 Dec 2019 08:08:38 -0800 (PST) Received: from localhost.localdomain (host-92-22-0-192.as13285.net. [92.22.0.192]) by smtp.gmail.com with ESMTPSA id q15sm16649799wrr.11.2019.12.06.08.08.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Dec 2019 08:08:38 -0800 (PST) From: Phillip Wood To: Git Mailing List Cc: Johannes Schindelin , Junio C Hamano , Phillip Wood Subject: [PATCH v2 9/9] [RFC] rebase -i: leave CHERRY_PICK_HEAD when there are conflicts Date: Fri, 6 Dec 2019 16:06:14 +0000 Message-Id: <20191206160614.631724-10-phillip.wood123@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191206160614.631724-1-phillip.wood123@gmail.com> References: <20191206160614.631724-1-phillip.wood123@gmail.com> Reply-To: Phillip Wood MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Phillip Wood Since the inception of CHERRY_PICK_HEAD in d7e5c0cbfb ("Introduce CHERRY_PICK_HEAD", 2011-02-19) 'rebase -i' has removed it when there are conflicts. The rationale for this was that the rebase wanted to handle the conflicts itself. However sometimes (e.g. after an edit command) the user wants to commit the conflict resolution before making some other changes or running some tests. Without CHERRY_PICK_HEAD the authorship information is lost when the user makes the commit. Fix this by leaving CHERRY_PICK_HEAD when we're not amending. Note that this changes the output of `git status`. The advice to run `git reset` is not appropriate for rebase as we do not allow partial commits. Signed-off-by: Phillip Wood --- Notes: This has semantic conflicts with ra/rebase-i-more-options as it does not respect the options passed to rebase when the user commits I haven't checked how this affects the shell prompt in contrib yet, I suspect it may need changing to cope the presence of CHERRY_PICK_HEAD during a rebase. I'd like to change the existing authorship tests to rely on the "Original Author" changes here, but they are a web of hidden interdependencies which is hard to untangle. sequencer.c | 12 ++-- t/t3404-rebase-interactive.sh | 104 +++++++++++++++++++++++++--------- t/t7512-status-help.sh | 2 - 3 files changed, 85 insertions(+), 33 deletions(-) diff --git a/sequencer.c b/sequencer.c index 64242f4ce7..624e96c930 100644 --- a/sequencer.c +++ b/sequencer.c @@ -372,11 +372,15 @@ static void print_advice(struct repository *r, int show_hint, if (msg) { fprintf(stderr, "%s\n", msg); /* - * A conflict has occurred but the porcelain - * (typically rebase --interactive) wants to take care - * of the commit itself so remove CHERRY_PICK_HEAD + * A conflict has occurred but the porcelain wants to take care + * of the commit itself so remove CHERRY_PICK_HEAD. Note that we + * do not do this for interactive rebases anymore in order to + * preserve the author identity when the user runs 'git commit' + * to commit the conflict resolution rather than relying on + * 'rebase --continue' to do it for them. */ - unlink(git_path_cherry_pick_head(r)); + if (!is_rebase_i(opts)) + unlink(git_path_cherry_pick_head(r)); return; } diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh index 5afa6f28cd..5cd7db18f8 100755 --- a/t/t3404-rebase-interactive.sh +++ b/t/t3404-rebase-interactive.sh @@ -33,31 +33,35 @@ Initial setup: # in the expect2 file for the 'stop on conflicting pick' test. test_expect_success 'setup' ' - test_commit A file1 && - test_commit B file1 && - test_commit C file2 && - test_commit D file1 && - test_commit E file3 && - git checkout -b branch1 A && - test_commit F file4 && - test_commit G file1 && - test_commit H file5 && - git checkout -b branch2 F && - test_commit I file6 && - git checkout -b conflict-branch A && - test_commit one conflict && - test_commit two conflict && - test_commit three conflict && - test_commit four conflict && - git checkout -b no-conflict-branch A && - test_commit J fileJ && - test_commit K fileK && - test_commit L fileL && - test_commit M fileM && - git checkout -b no-ff-branch A && - test_commit N fileN && - test_commit O fileO && - test_commit P fileP + ( + GIT_AUTHOR_NAME="Original Author" && + GIT_AUTHOR_EMAIL="original.author@example.com" && + test_commit A file1 && + test_commit B file1 && + test_commit C file2 && + test_commit D file1 && + test_commit E file3 && + git checkout -b branch1 A && + test_commit F file4 && + test_commit G file1 && + test_commit H file5 && + git checkout -b branch2 F && + test_commit I file6 && + git checkout -b conflict-branch A && + test_commit one conflict && + test_commit two conflict && + test_commit three conflict && + test_commit four conflict && + git checkout -b no-conflict-branch A && + test_commit J fileJ && + test_commit K fileK && + test_commit L fileL && + test_commit M fileM && + git checkout -b no-ff-branch A && + test_commit N fileN && + test_commit O fileO && + test_commit P fileP + ) ' # "exec" commands are run with the user shell by default, but this may @@ -252,12 +256,12 @@ test_expect_success 'stop on conflicting pick' ' -A +G EOF - cat >expect2 <<-\EOF && + cat >expect2 <<-EOF && <<<<<<< HEAD D ======= G - >>>>>>> 5d18e54... G + >>>>>>> $(git rev-parse --short HEAD)... G EOF git tag new-branch1 && test_must_fail git rebase -i master && @@ -1628,6 +1632,52 @@ test_expect_success 'correct error message for commit --amend after empty pick' test_i18ngrep "middle of a rebase -- cannot amend." err ' +test_expect_success 'correct error message for partial commit after confilct' ' + test_when_finished "git rebase --abort" && + git checkout D && + ( + set_fake_editor && + FAKE_LINES="2 3" && + export FAKE_LINES && + test_must_fail git rebase -i A + ) && + echo x >file1 && + echo y >file2 && + git add file1 file2 && + test_must_fail git commit file1 2>err && + test_i18ngrep "cannot do a partial commit during a rebase." err +' + +test_expect_success 'correct error message for commit --amend after conflict' ' + test_when_finished "git rebase --abort" && + git checkout D && + ( + set_fake_editor && + FAKE_LINES=3 && + export FAKE_LINES && + test_must_fail git rebase -i A + ) && + echo x>file1 && + test_must_fail git commit -a --amend 2>err && + test_i18ngrep "middle of a rebase -- cannot amend." err +' + +test_expect_success 'correct authorship and message after conflict' ' + git checkout D && + ( + set_fake_editor && + FAKE_LINES=3 && + export FAKE_LINES && + test_must_fail git rebase -i A + ) && + echo x >file1 && + git commit -a && + git log --pretty=format:"%an <%ae>%n%ad%n%B" -1 D >expect && + git log --pretty=format:"%an <%ae>%n%ad%n%B" -1 HEAD >actual && + test_cmp expect actual && + git rebase --continue +' + # This must be the last test in this file test_expect_success '$EDITOR and friends are unchanged' ' test_editor_unchanged diff --git a/t/t7512-status-help.sh b/t/t7512-status-help.sh index c1eb72555d..2adceb35e2 100755 --- a/t/t7512-status-help.sh +++ b/t/t7512-status-help.sh @@ -148,7 +148,6 @@ You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO (use "git rebase --abort" to check out the original branch) Unmerged paths: - (use "git reset HEAD ..." to unstage) (use "git add ..." to mark resolution) both modified: main.txt @@ -176,7 +175,6 @@ You are currently rebasing branch '\''rebase_i_conflicts_second'\'' on '\''$ONTO (all conflicts fixed: run "git rebase --continue") Changes to be committed: - (use "git reset HEAD ..." to unstage) modified: main.txt