X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=git-commit.sh;h=f7ee1aadee1eb947603dadbd6ec077dab07f6a19;hb=b992933853ccffac85f7e40310167ef7b8f0432e;hp=e6793bd67e42375f33b900e27f04b9af14d6f27f;hpb=4d44cb195aca5b744fd9f149af513637ff343a67;p=git.git diff --git a/git-commit.sh b/git-commit.sh index e6793bd6..f7ee1aad 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -3,7 +3,7 @@ # Copyright (c) 2005 Linus Torvalds # Copyright (c) 2006 Junio C Hamano -USAGE='[-a] [-i] [-s] [-v] [--no-verify] [-m | -F | (-C|-c) ] [-e] [--author ] [...]' +USAGE='[-a] [-s] [-v] [--no-verify] [-m | -F | (-C|-c) ] [-e] [--author ] [[-i | -o] ...]' 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" @@ -186,6 +180,7 @@ verify=t verbose= signoff= force_author= +only_include_assumed= while case "$#" in 0) break;; esac do case "$1" in @@ -346,15 +341,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= - - # If we are going to launch an editor, the message won't be - # shown without this... - test -z "$log_given$status_only" && sleep 1 + only_include_assumed="# Explicit paths specified without -i nor -o; assuming --only paths..." + also= ;; esac unset only @@ -389,6 +377,8 @@ t,) ;; ,t) save_index && + git-ls-files --error-unmatch -- "$@" >/dev/null || exit + git-diff-files --name-only -z -- "$@" | ( cd "$TOP" @@ -417,7 +407,7 @@ t,) refuse_partial "Different in index and the last commit: $dirty_in_index" fi - commit_only=`git-ls-files -- "$@"` + commit_only=`git-ls-files --error-unmatch -- "$@"` || exit # Build the temporary index and update the real index # the same way. @@ -579,8 +569,8 @@ else fi { - test -z "$verbose" || echo '---' - run_status + test -z "$only_include_assumed" || echo "$only_include_assumed" + run_status } >>"$GIT_DIR"/COMMIT_EDITMSG if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ] then @@ -612,11 +602,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 +637,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