Merge branch 'jc/rebase'
[git.git] / git-commit.sh
index e6793bd..ab5e6bc 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2005 Linus Torvalds
 # Copyright (c) 2006 Junio C Hamano
 
-USAGE='[-a] [-i] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>] [-e] [--author <author>] [<path>...]'
+USAGE='[-a] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit>] [-e] [--author <author>] [[-i | -o] <path>...]'
 SUBDIRECTORY_OK=Yes
 . git-sh-setup
 
@@ -87,24 +87,13 @@ run_status () {
 
        if test -z "$initial_commit"
        then
-           if test -z "$verbose"
-           then
-               git-diff-index -M --cached --name-status \
-                   --diff-filter=MDTCRA HEAD |
-               sed -e '
-                       s/\\/\\\\/g
-                       s/ /\\ /g
-               ' |
-               report "Updated but not checked in" "will commit"
-           else
-               if git-diff-index --cached -M -p --diff-filter=MDTCRA HEAD |
-                  grep .
-               then
-                  false
-               else
-                  true
-               fi
-           fi
+           git-diff-index -M --cached --name-status \
+               --diff-filter=MDTCRA HEAD |
+           sed -e '
+                   s/\\/\\\\/g
+                   s/ /\\ /g
+           ' |
+           report "Updated but not checked in" "will commit"
            committable="$?"
        else
            echo '#
@@ -155,6 +144,11 @@ run_status () {
                print "$_\n";
            }
        '
+
+       if test -n "$verbose"
+       then
+           git-diff-index --cached -M -p --diff-filter=MDTCRA HEAD
+       fi
        case "$committable" in
        0)
            echo "nothing to commit"
@@ -346,11 +340,8 @@ case "$#,$also$only" in
 0,)
   ;;
 *,)
-  echo >&2 "assuming --include paths..."
-  also=t
-  # Later when switch the defaults, we will replace them with these:
-  # echo >&2 "assuming --only paths..."
-  # also=
+  echo >&2 "assuming --only paths..."
+  also=
 
   # If we are going to launch an editor, the message won't be
   # shown without this...
@@ -578,10 +569,7 @@ else
        PARENTS=""
 fi
 
-{
-    test -z "$verbose" || echo '---'
-    run_status
-} >>"$GIT_DIR"/COMMIT_EDITMSG
+run_status >>"$GIT_DIR"/COMMIT_EDITMSG
 if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ]
 then
        rm -f "$GIT_DIR/COMMIT_EDITMSG"
@@ -612,11 +600,11 @@ t)
 esac
 
 sed -e '
-       /^---$/{
-               s///
-               q
-       }
-       /^#/d
+    /^diff --git a\/.*/{
+       s///
+       q
+    }
+    /^#/d
 ' "$GIT_DIR"/COMMIT_EDITMSG |
 git-stripspace >"$GIT_DIR"/COMMIT_MSG
 
@@ -647,7 +635,10 @@ else
 fi
 ret="$?"
 rm -f "$GIT_DIR/COMMIT_MSG" "$GIT_DIR/COMMIT_EDITMSG"
-git-rerere
+if test -d "$GIT_DIR/rr-cache"
+then
+       git-rerere
+fi
 
 if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0
 then