Thread (1 message) 1 message, 1 author, 2019-08-01

Re: [PATCH v2] checkout.c: unstage empty deleted ita files

From: Junio C Hamano <hidden>
Date: 2019-08-01 17:34:18

Varun Naik [off-list ref] writes:
It is possible to delete a committed file from the index and then add it
as intent-to-add. After `git checkout HEAD`, the file should be
identical in the index and HEAD.
We should write this as `git checkout HEAD <pathspec>`; with the
command without the <pathspec> form, the files changed in various
ways should not be changed with it at all.

	$ echo modified >>file1
	$ rm file2
	$ git rm --cached file3 && git add -N file3
	$ git checkout HEAD
	M	file1
	D	file2
	M	file3
`git checkout HEAD` calls tree.c:read_tree_1(), with fn pointing to
checkout.c:update_some(). update_some() creates a new cache entry but
discards it when its mode and oid match those of the old entry. A cache
entry for an ita file and a cache entry for an empty file have the same
oid. Therefore, an empty deleted ita file previously passed both of
these checks, and the new entry was discarded, so the file remained
unchanged in the index. After this fix, if the file is marked as ita in
the cache, then we avoid discarding the new entry and add the new entry
to the cache instead.
Thanks; the flow of thought above is quite straight-forward to
follow.

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help