From: Adam Dinwoodie <adam@dinwoodie.org>
To: git@vger.kernel.org
Cc: "Chris Webb" <chris@arachsys.com>, "Jeff King" <peff@peff.net>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH] commit: --amend -m '' silently fails to wipe message
Date: Wed, 6 Apr 2016 18:15:03 +0100 [thread overview]
Message-ID: <20160406171503.GA2345@dinwoodie.org> (raw)
`git commit --amend -m ''` seems to be an unambiguous request to blank a
commit message, but it actually leaves the commit message as-is. That's
the case regardless of whether `--allow-empty-message` is specified, and
doesn't so much as drop a non-zero return code.
Add failing tests to show this behaviour.
Signed-off-by: Adam Dinwoodie <adam@dinwoodie.org>
---
I've had to guess at the correct file to add these tests to; t7500
covers the mainline --allow-empty-message cases, while t7501 doesn't
(currently) cover --allow-empty-message but does cover --amend. I've
made an educated guess about the correct file, but moving the new tests
to the other file should be reasonably trivial.
t/t7501-commit.sh | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index 63e0427..a7e9322 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -200,6 +200,26 @@ test_expect_success '--amend --edit of empty message' '
test_cmp expect msg
'
+test_expect_failure '--amend to set message to empty' '
+ echo batá >file &&
+ git add file &&
+ git commit -m "unamended" &&
+ git commit --amend --allow-empty-message -m "" &&
+ git diff-tree -s --format=%s HEAD >msg &&
+ echo "" >expect &&
+ test_cmp expect msg
+'
+
+test_expect_failure '--amend to set empty message needs --allow-empty-message' '
+ echo conga >file &&
+ git add file &&
+ git commit -m "unamended" &&
+ test_must_fail git commit --amend -m "" &&
+ git diff-tree -s --format=%s HEAD >msg &&
+ echo "unamended" >expect &&
+ test_cmp expect msg
+'
+
test_expect_success '-m --edit' '
echo amended >expect &&
git commit --allow-empty -m buffer &&
--
2.7.4
next reply other threads:[~2016-04-06 17:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-06 17:15 Adam Dinwoodie [this message]
2016-04-07 4:42 ` [PATCH] commit: --amend -m '' silently fails to wipe message Jeff King
2016-04-07 4:48 ` Jeff King
2016-04-07 18:12 ` Junio C Hamano
2016-04-07 19:02 ` Jeff King
2016-04-07 19:56 ` Junio C Hamano
2016-04-07 20:28 ` Jeff King
2016-04-07 9:50 ` Adam Dinwoodie
2016-04-07 19:02 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160406171503.GA2345@dinwoodie.org \
--to=adam@dinwoodie.org \
--cc=avarab@gmail.com \
--cc=chris@arachsys.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).