From: Junio C Hamano Date: Sun, 10 Dec 2006 06:32:43 +0000 (-0800) Subject: git-commit: allow --only to lose what was staged earlier. X-Git-Tag: v1.5.0-rc0~120^2 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=158d0577891441c01457bbcaf45585d3b50f5d75;p=git.git git-commit: allow --only to lose what was staged earlier. The command used to have a safety valve to prevent this sequence: edit foo git update-index foo edit foo git diff foo git commit --only foo The reason for this was because an inexperienced user might mistakenly think what is shown with the last-minute diff contains all the change that is being committed (instead, what the user asked to check was an incremental diff since what has been staged so far). However, this turns out to only annoy people who know what they are doing. Inexperienced people would not be using the first "update-index" anyway, in which case they would see the full changes in the "git diff". Signed-off-by: Junio C Hamano --- diff --git a/git-commit.sh b/git-commit.sh index 81c3a0cb6..c82979117 100755 --- a/git-commit.sh +++ b/git-commit.sh @@ -350,19 +350,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