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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 01, 2019 at 09:07:56AM -0700, Varun Naik wrote:

> 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. The command already works correctly if
> the file has contents in HEAD. This patch provides the desired behavior
> even when the file is empty in HEAD.
> 
> `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.
> 
> This change should not affect newly added ita files. For those, inside
> tree.c:read_tree_1(), tree_entry_interesting() returns
> entry_not_interesting, so fn is never called.
> 
> Helped-by: Jeff King <peff@xxxxxxxx>
> Signed-off-by: Varun Naik <vcnaik94@xxxxxxxxx>
> ---
> This patch fixes and tests only "checkout", because "restore" has not
> reached maint yet. A second patch on the merge of this patch into master
> with a test case for "restore" is coming.

Thanks, this version looks good to me!

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux