git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Jeff King <peff@peff.net>
Date
Aug 1, 2019, 21:51 UTC
Message-ID
<20190801215148.GA30137@sigill.intra.peff.net>
In-Reply-To
<20190801160756.12601-1-vcnaik94@gmail.com>
On Thu, Aug 01, 2019 at 09:07:56AM -0700, Varun Naik wrote:
Show 26 quoted lines
> 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@peff.net>
> Signed-off-by: Varun Naik <vcnaik94@gmail.com>
> ---
> 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
Previous: Junio C HamanoNext: Varun Naik
Message 8 of 11 in “checkout.c: unstage empty deleted ita files”
  1. checkout.c: unstage empty deleted ita filesVarun Naik, Jul 26, 2019
  2. Varun NaikJul 26, 2019
  3. Jeff KingJul 26, 2019
  4. Varun NaikJul 29, 2019
  5. Jeff KingJul 29, 2019
  6. checkout.c: unstage empty deleted ita filesVarun Naik, Aug 1, 2019
  7. Junio C HamanoAug 1, 2019
  8. Jeff KingAug 1, 2019
  9. restore: add test for deleted ita filesVarun Naik, Aug 1, 2019
  10. Junio C HamanoAug 2, 2019
  11. checkout.c: unstage empty deleted ita filesVarun Naik, Aug 2, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.