test: commit --amend should honor --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>

Jonathan Nieder committed Dec 7, 2011 at 08:54 UTC bc8218999863a083d725f2011e5e0371df30aa1f
1 file changed +40
t/t7501-commit.sh
+40
@@ -94,6 +94,46 @@ test_expect_success 'amend commit' '
94 EDITOR=./editor git commit --amend
95 '
96
97 +test_expect_success 'set up editor' '
98 + cat >editor <<-\EOF &&
99 + #!/bin/sh
100 + sed -e "s/unamended/amended/g" <"$1" >"$1-"
101 + mv "$1-" "$1"
102 + EOF
103 + chmod 755 editor
104 +'
105 +
106 +test_expect_success 'amend without launching editor' '
107 + echo unamended >expect &&
108 + git commit --allow-empty -m "unamended" &&
109 + echo needs more bongo >file &&
110 + git add file &&
111 + EDITOR=./editor git commit --no-edit --amend &&
112 + git diff --exit-code HEAD -- file &&
113 + git diff-tree -s --format=%s HEAD >msg &&
114 + test_cmp expect msg
115 +'
116 +
117 +test_expect_success '--amend --edit' '
118 + echo amended >expect &&
119 + git commit --allow-empty -m "unamended" &&
120 + echo bongo again >file &&
121 + git add file &&
122 + EDITOR=./editor git commit --edit --amend &&
123 + git diff-tree -s --format=%s HEAD >msg &&
124 + test_cmp expect msg
125 +'
126 +
127 +test_expect_success '-m --edit' '
128 + echo amended >expect &&
129 + git commit --allow-empty -m buffer &&
130 + echo bongo bongo >file &&
131 + git add file &&
132 + EDITOR=./editor git commit -m unamended --edit &&
133 + git diff-tree -s --format=%s HEAD >msg &&
134 + test_cmp expect msg
135 +'
136 +
137 test_expect_success '-m and -F do not mix' '
138 echo enough with the bongos >file &&
139 test_must_fail git commit -F msg -m amending .