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

Re: [PATCH v3] diff-lib.c: handle empty deleted ita files

From
Varun Naik <vcnaik94@gmail.com>
Date
Aug 15, 2019, 16:26 UTC
Message-ID
<CAK_rgsGYa6LoGDHz=sGDXY26Lvg3dxV-poB5FQHf5G6BuOKVPg@mail.gmail.com>
In-Reply-To
<20190801161558.12838-1-vcnaik94@gmail.com>
On Thu, Aug 1, 2019 at 9:16 AM Varun Naik <vcnaik94@gmail.com> wrote:
Show 31 quoted lines
>
> It is possible to delete a committed file from the index and then add it
> as intent-to-add. Certain forms of `git diff` should show the file.
> After `git reset HEAD`, the file should be identical in the index and
> HEAD. The commands already work correctly if the file has contents in
> HEAD. This patch provides the desired behavior even when the file is
> empty in HEAD.
>
> The affected "diff" commands and the "reset" command call
> diff-lib.c:do_oneway_diff() with a cache entry in the index and a cache
> entry in HEAD. An ita file is represented in the index by a cache entry
> with the same hash as an empty file. For a nonempty deleted ita file,
> do_oneway_diff() calls show_modified(), which detects a diff between the
> cache entry in the index and the cache entry in HEAD and therefore deems
> the file "modified". However, for an empty deleted ita file,
> do_oneway_diff() previously detected no such diff between the two cache
> entries and therefore deemed the file "not modified". After this fix,
> for any deleted ita file, do_oneway_diff() calls diff_index_show_file()
> and deems the file "deleted".
>
> `git diff-index --cached HEAD` prints a row of output for both a
> "modified" and a "deleted" file, although the output differs slightly.
> `git reset HEAD` treats a "modified" and a "deleted" file similarly,
> resurrecting the file in the index from HEAD.
>
> This change should not affect newly added ita files. For those, the
> "tree" cache entry is NULL, so the changed code is not executed.
>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Signed-off-by: Varun Naik <vcnaik94@gmail.com>
> ---
Bumping this email, since I noticed v2 is still in pu.
Varun
Previous: Varun NaikNext: Junio C Hamano
Message 7 of 11 in “reset: unstage empty deleted ita files”
  1. reset: unstage empty deleted ita filesVarun Naik, Jul 12, 2019
  2. reset: unstage empty deleted ita filesVarun Naik, Jul 26, 2019
  3. Junio C HamanoJul 26, 2019
  4. Varun NaikJul 29, 2019
  5. Junio C HamanoJul 29, 2019
  6. diff-lib.c: handle empty deleted ita filesVarun Naik, Aug 1, 2019
  7. Varun NaikAug 15, 2019
  8. Junio C HamanoAug 15, 2019
  9. Varun NaikAug 19, 2019
  10. Junio C HamanoAug 19, 2019
  11. Varun NaikFeb 14, 2020

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.