Skip to content

Commit cba8d48

Browse files
committed
git-commit: partial commit of paths only removed from the index
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>
1 parent 64586e7 commit cba8d48

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

git-commit.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ t,)
404404
(
405405
GIT_INDEX_FILE="$NEXT_INDEX"
406406
export GIT_INDEX_FILE
407-
git update-index --remove --stdin
407+
git update-index --add --remove --stdin
408408
) || exit
409409
;;
410410
esac

t/t7501-commit.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ test_expect_success \
131131
'validate git-rev-list output.' \
132132
'diff current expected'
133133

134-
test_expect_success 'partial commit that involve removal (1)' '
134+
test_expect_success 'partial commit that involves removal (1)' '
135135
136136
git rm --cached file &&
137137
mv file elif &&
@@ -143,7 +143,7 @@ test_expect_success 'partial commit that involve removal (1)' '
143143
144144
'
145145

146-
test_expect_success 'partial commit that involve removal (2)' '
146+
test_expect_success 'partial commit that involves removal (2)' '
147147
148148
git commit -m "Partial: remove file" file &&
149149
git diff-tree --name-status HEAD^ HEAD >current &&
@@ -152,4 +152,15 @@ test_expect_success 'partial commit that involve removal (2)' '
152152
153153
'
154154

155+
test_expect_success 'partial commit that involves removal (3)' '
156+
157+
git rm --cached elif &&
158+
echo elif >elif &&
159+
git commit -m "Partial: modify elif" elif &&
160+
git diff-tree --name-status HEAD^ HEAD >current &&
161+
echo "M elif" >expected &&
162+
diff expected current
163+
164+
'
165+
155166
test_done

0 commit comments

Comments
 (0)