threads / discuss / 24681

git commit return code

Subject: git commit return code

## tl;dr

3 messages between Aug 9, 2010 and Aug 10, 2010.

replies: 2people: 3as markdown or json

Tomasz Pajor· Aug 9, 2010, 15:32 UTC · lore
Hello,
Is this proper behaviour:

root# su <username> -c "git commit --quiet -a -m \"templates generation\";" # On branch master nothing to commit (working directory clean) root# echo $? 1

root# git --version git version 1.7.1

Ævar Arnfjörð Bjarmason· Aug 9, 2010, 16:13 UTC · re: Tomasz Pajor · lore

Re: git commit return code

On Mon, Aug 9, 2010 at 15:32, Tomasz Pajor <nikon@puffy.pl> wrote:
Show 7 quoted lines
> Is this proper behaviour:
>
> root# su <username> -c "git commit --quiet -a -m \"templates generation\";"
> # On branch master
> nothing to commit (working directory clean)
> root# echo $?
> 1

Yes, you asked it to create a commit, but there's nothing to commit. Hence the failure to commit.

Matthieu Moy· Aug 10, 2010, 06:46 UTC · re: Tomasz Pajor · lore

Re: git commit return code

Tomasz Pajor <nikon@puffy.pl> writes:
Show 9 quoted lines
> Hello,
>
> Is this proper behaviour:
>
> root# su <username> -c "git commit --quiet -a -m \"templates generation\";"
> # On branch master
> nothing to commit (working directory clean)
> root# echo $?
> 1

The exit status doesn't seem documented in the manpage, but it's expected behavior that "git commit" refuses to create an empty commit, and it seems sensible to "exit(1)" in this case.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

← back to recent threads