Skip to content

Commit 7eb5bbd

Browse files
datogitster
authored andcommitted
t7501-commit.sh: explicitly check that -F prevents invoking the editor
The "--signoff" test case in t7500-commit.sh was setting VISUAL while using -F -, which indeed tested that the editor is not spawned with -F. However, having it there was confusing, since there was no obvious reason to the casual reader for it to be there. This commits removes the setting of VISUAL from the --signoff test, and adds in t7501-commit.sh a dedicated test case, where the rest of tests for -F are. Signed-off-by: Adeodato Simó <[email protected]> Okay-then-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent df39877 commit 7eb5bbd

File tree

2 files changed

+21
-4
lines changed

2 files changed

+21
-4
lines changed

t/t7500-commit.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,7 @@ EOF
149149

150150
test_expect_success '--signoff' '
151151
echo "yet another content *narf*" >> foo &&
152-
echo "zort" | (
153-
test_set_editor "$TEST_DIRECTORY"/t7500/add-content &&
154-
git commit -s -F - foo
155-
) &&
152+
echo "zort" | git commit -s -F - foo &&
156153
git cat-file commit HEAD | sed "1,/^$/d" > output &&
157154
test_cmp expect output
158155
'

t/t7501-commit.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,26 @@ test_expect_success \
127127
"showing committed revisions" \
128128
"git rev-list HEAD >current"
129129

130+
cat >editor <<\EOF
131+
#!/bin/sh
132+
sed -e "s/good/bad/g" < "$1" > "$1-"
133+
mv "$1-" "$1"
134+
EOF
135+
chmod 755 editor
136+
137+
cat >msg <<EOF
138+
A good commit message.
139+
EOF
140+
141+
test_expect_success \
142+
'editor not invoked if -F is given' '
143+
echo "moo" >file &&
144+
VISUAL=./editor git commit -a -F msg &&
145+
git show -s --pretty=format:"%s" | grep -q good &&
146+
echo "quack" >file &&
147+
echo "Another good message." | VISUAL=./editor git commit -a -F - &&
148+
git show -s --pretty=format:"%s" | grep -q good
149+
'
130150
# We could just check the head sha1, but checking each commit makes it
131151
# easier to isolate bugs.
132152

0 commit comments

Comments
 (0)