]> gitweb.fluxo.info Git - utils-git.git/commitdiff
Check for staged files at commit script
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 14 May 2017 17:21:11 +0000 (14:21 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 14 May 2017 17:21:11 +0000 (14:21 -0300)
commit

diff --git a/commit b/commit
index c5d3f4aa7ca96742ba434bdcd016789f978b3de5..ccf03f62af66355bdd54b9dacb8c4fd2ad128a2e 100755 (executable)
--- 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