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

Re: [PATCH] apply: fix adding new files on i-t-a entries

From
Duy Nguyen <pclouds@gmail.com>
Date
Jun 25, 2015, 12:26 UTC
Message-ID
<CACsJy8AVeGxOS4pWfkcbPnxRQ0-gJRC7B1NSs+Ci81x46ieDzQ@mail.gmail.com>
In-Reply-To
<xmqqzj3p9gv7.fsf@gitster.dls.corp.google.com>
On Thu, Jun 25, 2015 at 12:05 AM, Junio C Hamano <gitster@pobox.com> wrote:
Show 37 quoted lines
> Internal "diff-index --cached" is used for another reason you did
> not mention (and scripted Porcelains literally use that externally
> for the same reason).  When we start a mergy operation, we say it is
> OK if the working tree has local changes relative to the index, but
> we require the index does not have any modifications since the HEAD
> was read.
>
>         Side note: some codepaths insist that "diff-index --cached"
>         and "diff-files" are both clean, so d95d728a is harmless;
>         the former may say "clean" on i-t-a entries more than
>         before, but the latter will still catch the difference
>         between the index and the working tree and stop the caller
>         from going forward.
>
> With d95d728a (diff-lib.c: adjust position of i-t-a entries in diff,
> 2015-03-16)'s world view, an empty output from "diff-index --cached"
> no longer means that.  Entries added with any "git add -N" are not
> reported, so we would go ahead to record the merge result on top of
> that "half-dirty" index.
>
>         Side note: a merge based on unpack-trees has an extra layer
>         of safety that unpack_trees() does not ignore i-t-a entry as
>         "not exist (yet)" and notices that the path does exist in
>         the index but not in HEAD.  But that just shows that some
>         parts of the world do need to consider that having an i-t-a
>         in the index makes it different from HEAD.
>
> If the mergy operation goes without any conflict, the next thing we
> do typically is to write the index out as a tree (to record in a new
> commit, etc.) and we are OK only in that particular case, because
> i-t-a entries are ignored.  But what would happen when the mergy
> operation conflicts?  I haven't thought about that fully, but I
> doubt it is a safe thing to do in general.
>
> But that is just one example that there are also other codepaths
> that do not want to be fooled into thinking that i-t-a entries do
> not exist in the index at all.

I think it's clear that you need to revert that commit. I didn't see this at all when I made the commit.

Show 17 quoted lines
> All we learned from the above discussion is that unconditionally
> declaring that adding i-t-a entries to the index without doing
> anything else should keep the index compare the same to HEAD.
>
> If d95d728a were only about what wt_status.c sees (and gets reported
> in "git status" output), which was what the change wanted to address
> anyway, we didn't have to have this discussion.  Without realizing
> that two kinds of callers want different view out of "diff-index
> --cached" and "diff-files", we broke half the world by changing the
> world order unconditionally for everybody, I am afraid.
>
> Perhaps a good and safe way forward to resurrect what d95d728a
> wanted to do is to first add an option to tell run_diff_index() and
> run_diff_files() which behaviour the caller wants to see, add that
> only to the caller in wt-status.c?  Then incrementally pass that
> option from more callsites that we are absolutely certain that want
> this different worldview with respect to i-t-a?
Agreed.
-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 28 in “apply --cached --whitespace=fix now failing on items added with "add -N"”
  1. Patrick HigginsJun 22, 2015
  2. Duy NguyenJun 22, 2015
  3. Junio C HamanoJun 22, 2015
  4. apply: fix adding new files on i-t-a entriesNguyễn Thái Ngọc Duy, Jun 23, 2015
  5. Junio C HamanoJun 23, 2015
  6. Junio C HamanoJun 23, 2015
  7. Junio C HamanoJun 24, 2015
  8. Duy NguyenJun 24, 2015
  9. Junio C HamanoJun 24, 2015
  10. Duy NguyenJun 25, 2015
  11. Junio C HamanoJun 25, 2015
  12. 0/8 Resurrect "diff-lib.c: adjust position of i-t-a entries in diff"Nguyễn Thái Ngọc Duy, Aug 22, 2015
  13. 1/8 blame: remove obsolete commentNguyễn Thái Ngọc Duy, Aug 22, 2015
  14. 2/8 Add and use convenient macro ce_intent_to_add()Nguyễn Thái Ngọc Duy, Aug 22, 2015
  15. 3/8 apply: fix adding new files on i-t-a entriesNguyễn Thái Ngọc Duy, Aug 22, 2015
  16. Junio C HamanoAug 25, 2015
  17. 4/8 apply: make sure check_preimage() does not leave empty file on errorNguyễn Thái Ngọc Duy, Aug 22, 2015
  18. Junio C HamanoAug 25, 2015
  19. 5/8 checkout(-index): do not checkout i-t-a entriesNguyễn Thái Ngọc Duy, Aug 22, 2015
  20. Junio C HamanoAug 25, 2015
  21. Duy NguyenNov 29, 2015
  22. Junio C HamanoNov 30, 2015
  23. 6/8 grep: make it clear i-t-a entries are ignoredNguyễn Thái Ngọc Duy, Aug 22, 2015
  24. 7/8 diff.h: extend "flags" field to 64 bits because we're out of bitsNguyễn Thái Ngọc Duy, Aug 22, 2015
  25. Junio C HamanoAug 25, 2015
  26. Duy NguyenAug 31, 2015
  27. Junio C HamanoAug 25, 2015
  28. Junio C HamanoAug 25, 2015

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.