From fc6d705e67aaf7489c3465d7cab85dd57b81b0f7 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 14 May 2017 14:21:11 -0300 Subject: Check for staged files at commit script --- commit | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/commit b/commit index c5d3f4a..ccf03f6 100755 --- a/commit +++ b/commit @@ -127,7 +127,14 @@ function git_user { function git_commit { # Remove '--config' from args, otherwise it goes to the commit log params="`echo $* | sed -e 's/--config//'`" - git commit -a -m "$params" + + # If there are no staged files, commit everything. + # Otherwise commit just what was staged + if git status --short | grep -q "^[AM]"; then + flag="-a" + fi + + git commit $flag -m "$params" } # Main -- cgit v1.2.3