diff options
author | Junio C Hamano <junkio@cox.net> | 2006-02-14 12:40:20 -0800 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-02-14 14:48:22 -0800 |
commit | bba319b5cecacaccef85ce3c4cf9e3593532e328 (patch) | |
tree | e9b0fd57d6793b381b3208084212c282545fa682 /git-commit.sh | |
parent | 9ece7169a434d69a942b71dc49f507da37bbdbc3 (diff) | |
download | git-bba319b5cecacaccef85ce3c4cf9e3593532e328.tar.gz |
commit: detect misspelled pathspec while making a partial commit.
When you say "git commit Documentaiton" to make partial commit
for the files only in that directory, we did not detect that as
a misspelled pathname and attempted to commit index without
change. If nothing matched, there is no harm done, but if the
index gets modified otherwise by having another valid pathspec
or after an explicit update-index, a user will not notice
without paying attention to the "git status" preview.
This introduces --error-unmatch option to ls-files, and uses it
to detect this common user error.
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-commit.sh')
-rwxr-xr-x | git-commit.sh | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/git-commit.sh b/git-commit.sh index 59551d99f9..fe9b6e7528 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -180,6 +180,7 @@ verify=t verbose= signoff= force_author= +only_include_assumed= while case "$#" in 0) break;; esac do case "$1" in @@ -340,15 +341,8 @@ case "$#,$also$only" in 0,) ;; *,) - echo >&2 "assuming --include paths..." + only_include_assumed="# Explicit paths specified without -i nor -o; 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 ;; esac unset only @@ -383,6 +377,8 @@ t,) ;; ,t) save_index && + git-ls-files --error-unmatch -- "$@" >/dev/null || exit + git-diff-files --name-only -z -- "$@" | ( cd "$TOP" @@ -411,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. @@ -572,7 +568,10 @@ else PARENTS="" fi -run_status >>"$GIT_DIR"/COMMIT_EDITMSG +{ + test -z "$only_include_assumed" || echo "$only_include_assumed" + run_status +} >>"$GIT_DIR"/COMMIT_EDITMSG if [ "$?" != "0" -a ! -f "$GIT_DIR/MERGE_HEAD" ] then rm -f "$GIT_DIR/COMMIT_EDITMSG" |