Skip to content

Commit bc82189

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ca1ba20 commit bc82189

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

t/t7501-commit.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,46 @@ test_expect_success 'amend commit' '
9494
EDITOR=./editor git commit --amend
9595
'
9696

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+
97137
test_expect_success '-m and -F do not mix' '
98138
echo enough with the bongos >file &&
99139
test_must_fail git commit -F msg -m amending .

0 commit comments

Comments
 (0)