Skip to contentSkip to conversation

git commit return code

DISCUSSION Tomasz Pajor 3 participants 3 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 7 lines · Tomasz Pajor

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.

#2 lore raw
In reply to Tomasz Pajor
Quoted 9 lines · Tomasz Pajor

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.

Signature · 2 lines
Matthieu Moy
http://www-verimag.imag.fr/~moy/