# git commit --interactive creates empty commits

2 messages from 2008-04-14 to 2008-04-14. Participants: Jörg Sommer, Junio C Hamano.
Thread: https://gitlist.dev/t/13100

## Jörg Sommer, 2008-04-14 00:35

Subject: git commit --interactive creates empty commits
Message-ID: <slrng059n3.nd8.joerg@alea.gnuu.de>
URL: https://gitlist.dev/e/slrng059n3.nd8.joerg%40alea.gnuu.de

```
Hi,

is it expected that this test fails?

diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
index c0288f3..2c21428 100755
--- a/t/t7501-commit.sh
+++ b/t/t7501-commit.sh
@@ -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.
-- 
Damit das Mögliche entsteht, muß immer wieder das Unmögliche versucht
werden.                                       (Hermann Hesse)

```

## Junio C Hamano, 2008-04-14 07:01

Subject: Re: git commit --interactive creates empty commits
Message-ID: <7vk5j0apie.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vk5j0apie.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <slrng059n3.nd8.joerg@alea.gnuu.de>

```
Jörg Sommer <joerg@alea.gnuu.de> writes:

> 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.

> diff --git a/t/t7501-commit.sh b/t/t7501-commit.sh
> index c0288f3..2c21428 100755
> --- a/t/t7501-commit.sh
> +++ b/t/t7501-commit.sh
> @@ -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"
> +

```
