From: Adam Dinwoodie Date: Wed, 6 Apr 2016 17:15:03 +0000 (+0100) Subject: commit: --amend -m '' silently fails to wipe message X-Git-Tag: v2.8.3~38^2~1 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/178e8143b4f79290b3ffe40fe2ebf769fccc1ab7 commit: --amend -m '' silently fails to wipe message `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 Signed-off-by: Junio C Hamano --- diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh index 63e04277f9..a7e9322d2f 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 &&