]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-commit.sh
git-help: add -w|--web option to display html man page in a browser.
[git.git] / git-commit.sh
index cb14f0621651d2006b08d1eddf67ab3269df84d0..2c4a4062a5317c51601fc4c644c96a7f75e1ef2c 100755 (executable)
@@ -5,6 +5,7 @@
 
 USAGE='[-a | --interactive] [-s] [-v] [--no-verify] [-m <message> | -F <logfile> | (-C|-c) <commit> | --amend] [-u] [-e] [--author <author>] [--template <file>] [[-i | -o] <path>...]'
 SUBDIRECTORY_OK=Yes
+OPTIONS_SPEC=
 . git-sh-setup
 require_work_tree
 
@@ -25,7 +26,8 @@ refuse_partial () {
        exit 1
 }
 
-THIS_INDEX="$GIT_DIR/index"
+TMP_INDEX=
+THIS_INDEX="${GIT_INDEX_FILE:-$GIT_DIR/index}"
 NEXT_INDEX="$GIT_DIR/next-index$$"
 rm -f "$NEXT_INDEX"
 save_index () {
@@ -72,6 +74,7 @@ trap '
 
 all=
 also=
+allow_empty=f
 interactive=
 only=
 logfile=
@@ -112,6 +115,10 @@ do
        -a|--a|--al|--all)
                all=t
                ;;
+       --allo|--allow|--allow-|--allow-e|--allow-em|--allow-emp|\
+       --allow-empt|--allow-empty)
+               allow_empty=t
+               ;;
        --au=*|--aut=*|--auth=*|--autho=*|--author=*)
                force_author="${1#*=}"
                ;;
@@ -281,9 +288,9 @@ unset only
 case "$all,$interactive,$also,$#" in
 *t,*t,*)
        die "Cannot use -a, --interactive or -i at the same time." ;;
-t,,[1-9]*)
+t,,,[1-9]*)
        die "Paths with -a does not make sense." ;;
-,t,[1-9]*)
+,t,,[1-9]*)
        die "Paths with --interactive does not make sense." ;;
 ,,t,0)
        die "No paths with -i does not make sense." ;;
@@ -513,13 +520,18 @@ else
        # we need to check if there is anything to commit
        run_status >/dev/null
 fi
-if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ]
-then
+case "$allow_empty,$?,$PARENTS" in
+t,* | ?,0,* | ?,*,-p' '?*-p' '?*)
+       # an explicit --allow-empty, or a merge commit can record the
+       # same tree as its parent.  Otherwise having commitable paths
+       # is required.
+       ;;
+*)
        rm -f "$GIT_DIR/COMMIT_EDITMSG" "$GIT_DIR/SQUASH_MSG"
        use_status_color=t
        run_status
        exit 1
-fi
+esac
 
 case "$no_edit" in
 '')
@@ -611,6 +623,7 @@ git rerere
 
 if test "$ret" = 0
 then
+       git gc --auto
        if test -x "$GIT_DIR"/hooks/post-commit
        then
                "$GIT_DIR"/hooks/post-commit