Handle symlinks graciously
[git.git] / git-commit.sh
index 5bdee54..7e39c10 100755 (executable)
@@ -3,11 +3,8 @@
 # Copyright (c) 2005 Linus Torvalds
 #
 
-. git-sh-setup || die "Not a git archive"
-
-usage () {
-       die 'git commit [-a] [-v | --no-verify]  [-m <message>] [-F <logfile>] [(-C|-c) <commit>] [<path>...]'
-}
+USAGE='[-a] [-s] [-v | --no-verify]  [-m <message> | -F <logfile> | (-C|-c) <commit>] [-e] [<path>...]'
+. git-sh-setup
 
 all= logfile= use_commit= no_edit= log_given= log_message= verify=t signoff=
 while case "$#" in 0) break;; esac
@@ -92,14 +89,17 @@ tt*)
 esac
 
 case "$all,$#" in
-t,*)
+t,0)
        git-diff-files --name-only -z |
        git-update-index --remove -z --stdin
        ;;
+t,*)
+       die "Cannot use -a and explicit files at the same time."
+       ;;
 ,0)
        ;;
 *)
-       git-diff-files --name-only -z "$@" |
+       git-diff-files --name-only -z -- "$@" |
        git-update-index --remove -z --stdin
        ;;
 esac || exit 1
@@ -129,6 +129,9 @@ 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"
+then
+       cat "$GIT_DIR/MERGE_MSG"
 fi | git-stripspace >"$GIT_DIR"/COMMIT_EDITMSG
 
 case "$signoff" in
@@ -144,9 +147,6 @@ t)
 esac
 
 if [ -f "$GIT_DIR/MERGE_HEAD" ]; then
-
-       test -f "$GIT_DIR/MERGE_MSG" && cat "$GIT_DIR/MERGE_MSG"
-
        echo "#"
        echo "# It looks like your may be committing a MERGE."
        echo "# If this is not correct, please remove the file"
@@ -184,7 +184,7 @@ then
                }
                '
                set_author_env=`git-cat-file commit "$use_commit" |
-               sed -ne "$pick_author_script"`
+               LANG=C LC_ALL=C sed -ne "$pick_author_script"`
                eval "$set_author_env"
                export GIT_AUTHOR_NAME
                export GIT_AUTHOR_EMAIL