summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-12-07 08:54:14 -0600
committerJunio C Hamano <gitster@pobox.com>2011-12-08 15:35:34 -0800
commitbc8218999863a083d725f2011e5e0371df30aa1f (patch)
treeae1d4e8215110690ae5d8ee95822a104e4f657ff
parentca1ba2010215acb305c7b5d9707e117b862067eb (diff)
downloadgit-jc/commit-amend-no-edit.tar.gz
test: commit --amend should honor --no-editjc/commit-amend-no-edit
A quick test to make sure git doesn't lose the functionality added by the recent patch "commit: honor --no-edit", plus another test to check the classical --edit use case (use with "-m"). Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xt/t7501-commit.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index bf025df6e1..8bb38337a9 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -94,6 +94,46 @@ test_expect_success 'amend commit' '
EDITOR=./editor git commit --amend
'
+test_expect_success 'set up editor' '
+ cat >editor <<-\EOF &&
+ #!/bin/sh
+ sed -e "s/unamended/amended/g" <"$1" >"$1-"
+ mv "$1-" "$1"
+ EOF
+ chmod 755 editor
+'
+
+test_expect_success 'amend without launching editor' '
+ echo unamended >expect &&
+ git commit --allow-empty -m "unamended" &&
+ echo needs more bongo >file &&
+ git add file &&
+ EDITOR=./editor git commit --no-edit --amend &&
+ git diff --exit-code HEAD -- file &&
+ git diff-tree -s --format=%s HEAD >msg &&
+ test_cmp expect msg
+'
+
+test_expect_success '--amend --edit' '
+ echo amended >expect &&
+ git commit --allow-empty -m "unamended" &&
+ echo bongo again >file &&
+ git add file &&
+ EDITOR=./editor git commit --edit --amend &&
+ git diff-tree -s --format=%s HEAD >msg &&
+ test_cmp expect msg
+'
+
+test_expect_success '-m --edit' '
+ echo amended >expect &&
+ git commit --allow-empty -m buffer &&
+ echo bongo bongo >file &&
+ git add file &&
+ EDITOR=./editor git commit -m unamended --edit &&
+ git diff-tree -s --format=%s HEAD >msg &&
+ test_cmp expect msg
+'
+
test_expect_success '-m and -F do not mix' '
echo enough with the bongos >file &&
test_must_fail git commit -F msg -m amending .