]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-commit.sh
Replace mmap with xmmap, better handling MAP_FAILED.
[git.git] / git-commit.sh
index 5b1cf85825b0c69f2515445842812a0caf48ef10..6bce41af4dc73d90028e76ba174e4e7795103d6c 100755 (executable)
@@ -80,6 +80,7 @@ no_edit=
 log_given=
 log_message=
 verify=t
+quiet=
 verbose=
 signoff=
 force_author=
@@ -241,6 +242,10 @@ $1"
                signoff=t
                shift
                ;;
+       -q|--q|--qu|--qui|--quie|--quiet)
+               quiet=t
+               shift
+               ;;
        -v|--v|--ve|--ver|--verb|--verbo|--verbos|--verbose)
                verbose=t
                shift
@@ -350,19 +355,9 @@ t,)
                        refuse_partial "Cannot do a partial commit during a merge."
                fi
                TMP_INDEX="$GIT_DIR/tmp-index$$"
-               if test -z "$initial_commit"
-               then
-                       # make sure index is clean at the specified paths, or
-                       # they are additions.
-                       dirty_in_index=`git-diff-index --cached --name-status \
-                               --diff-filter=DMTU HEAD -- "$@"`
-                       test -z "$dirty_in_index" ||
-                       refuse_partial "Different in index and the last commit:
-$dirty_in_index"
-               fi
                commit_only=`git-ls-files --error-unmatch -- "$@"` || exit
 
-               # Build the temporary index and update the real index
+               # Build a temporary index and update the real index
                # the same way.
                if test -z "$initial_commit"
                then
@@ -441,7 +436,7 @@ then
 elif test "$use_commit" != ""
 then
        git-cat-file commit "$use_commit" | sed -e '1,/^$/d'
-elif test -f "$GIT_DIR/MERGE_HEAD" && test -f "$GIT_DIR/MERGE_MSG"
+elif test -f "$GIT_DIR/MERGE_MSG"
 then
        cat "$GIT_DIR/MERGE_MSG"
 elif test -f "$GIT_DIR/SQUASH_MSG"
@@ -522,15 +517,15 @@ then
                PARENTS=$(git-cat-file commit HEAD |
                        sed -n -e '/^$/q' -e 's/^parent /-p /p')
        fi
-       current=$(git-rev-parse --verify HEAD)
+       current="$(git-rev-parse --verify HEAD)"
 else
        if [ -z "$(git-ls-files)" ]; then
-               echo >&2 Nothing to commit
+               echo >&2 'nothing to commit (use "git add file1 file2" to include for commit)'
                exit 1
        fi
        PARENTS=""
-       current=
        rloga='commit (initial)'
+       current=''
 fi
 
 if test -z "$no_edit"
@@ -606,8 +601,8 @@ then
        fi &&
        commit=$(cat "$GIT_DIR"/COMMIT_MSG | git-commit-tree $tree $PARENTS) &&
        rlogm=$(sed -e 1q "$GIT_DIR"/COMMIT_MSG) &&
-       git-update-ref -m "$rloga: $rlogm" HEAD $commit $current &&
-       rm -f -- "$GIT_DIR/MERGE_HEAD" &&
+       git-update-ref -m "$rloga: $rlogm" HEAD $commit "$current" &&
+       rm -f -- "$GIT_DIR/MERGE_HEAD" "$GIT_DIR/MERGE_MSG" &&
        if test -f "$NEXT_INDEX"
        then
                mv "$NEXT_INDEX" "$THIS_INDEX"
@@ -625,8 +620,17 @@ then
        git-rerere
 fi
 
-if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0
+if test "$ret" = 0
 then
-       "$GIT_DIR"/hooks/post-commit
+       if test -x "$GIT_DIR"/hooks/post-commit
+       then
+               "$GIT_DIR"/hooks/post-commit
+       fi
+       if test -z "$quiet"
+       then
+               echo "Created${initial_commit:+ initial} commit $commit"
+               git-diff-tree --shortstat --summary --root --no-commit-id HEAD
+       fi
 fi
+
 exit "$ret"