Asked By – kojiro
I’m trying to write a fabric script that does a
git commit; however, if there is nothing to commit, git exits with a status of
1. The deploy script takes that as unsuccessful, and quits. I do want to detect actual failures-to-commit, so I can’t just give fabric a blanket ignore for
git commit failures. How can I allow empty-commit failures to be ignored so that deploy can continue, but still catch errors caused when a real commit fails?
def commit(): local("git add -p && git commit")
Now we will see solution for issue: How to git commit nothing without an error?
Catch this condition beforehand by checking the exit code of git diff?
For example (in shell):
git add -A git diff-index --quiet HEAD || git commit -m 'bla'
git diff command according to Holger’s comment.