Skip to contentSkip to conversation

git commit --interactive creates empty commits

PATCH Jörg Sommer 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

is it expected that this test fails?

t/t7501-commit.sh +12 -0
index c0288f3..2c21428 100755
@@ -123,6 +123,18 @@ test_expect_success \
 	"interactive add" \
 	"echo 7 | git-commit --interactive | grep 'What now'"
 
+cat >editor <<\EOF
+#!/bin/sh
+echo invalid commit > $1
+EOF
+chmod 755 editor
+
+test_expect_success \
+	"interactive fails on empty index" \
+	"export VISUAL=./editor && 
+	test_must_fail git commit --interactive < /dev/null &&
+	unset VISUAL"
+
 test_expect_success \
 	"showing committed revisions" \
 	"git-rev-list HEAD >current"

Bye, Jörg.

Signature · 2 lines
Damit das Mögliche entsteht, muß immer wieder das Unmögliche versucht
werden.                                       (Hermann Hesse)
#1 lore raw
Quoted 1 line · Jörg Sommer

is it expected that this test fails?

I think you spotted a bug ;-) -i should only affect the way how you build the index. Unless the user does not ask for --allow-empty this should be prevented, I think.

Quoted 20 lines
t/t7501-commit.sh +12 -0
index c0288f3..2c21428 100755
@@ -123,6 +123,18 @@ test_expect_success \
 	"interactive add" \
 	"echo 7 | git-commit --interactive | grep 'What now'"
 
+cat >editor <<\EOF
+#!/bin/sh
+echo invalid commit > $1
+EOF
+chmod 755 editor
+
+test_expect_success \
+	"interactive fails on empty index" \
+	"export VISUAL=./editor && 
+	test_must_fail git commit --interactive < /dev/null &&
+	unset VISUAL"
+