Skip to content

Commit

Permalink
git-commit: partial commit of paths only removed from the index
Browse files Browse the repository at this point in the history
Because a partial commit is meant to be a way to ignore what are
staged in the index, "git rm --cached A && git commit A" should
just record what is in A on the filesystem.  The previous patch
made the command sequence to barf, saying that A has not been
added yet.  This fixes it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Sep 18, 2007
1 parent 64586e7 commit cba8d48
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion git-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ t,)
(
GIT_INDEX_FILE="$NEXT_INDEX"
export GIT_INDEX_FILE
git update-index --remove --stdin
git update-index --add --remove --stdin
) || exit
;;
esac
Expand Down
15 changes: 13 additions & 2 deletions t/t7501-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ test_expect_success \
'validate git-rev-list output.' \
'diff current expected'

test_expect_success 'partial commit that involve removal (1)' '
test_expect_success 'partial commit that involves removal (1)' '
git rm --cached file &&
mv file elif &&
Expand All @@ -143,7 +143,7 @@ test_expect_success 'partial commit that involve removal (1)' '
'

test_expect_success 'partial commit that involve removal (2)' '
test_expect_success 'partial commit that involves removal (2)' '
git commit -m "Partial: remove file" file &&
git diff-tree --name-status HEAD^ HEAD >current &&
Expand All @@ -152,4 +152,15 @@ test_expect_success 'partial commit that involve removal (2)' '
'

test_expect_success 'partial commit that involves removal (3)' '
git rm --cached elif &&
echo elif >elif &&
git commit -m "Partial: modify elif" elif &&
git diff-tree --name-status HEAD^ HEAD >current &&
echo "M elif" >expected &&
diff expected current
'

test_done

0 comments on commit cba8d48

Please sign in to comment.