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

Re: Optimizing writes to unchanged files during merges?

From
Elijah Newren <newren@gmail.com>
Date
Apr 16, 2018, 23:03 UTC
Message-ID
<CABPp-BHa47a-nH6dZ+LdGuf2XdYTFHyhHVv39dGeuEux10DY_A@mail.gmail.com>
In-Reply-To
<xmqqbmekylgc.fsf@gitster-ct.c.googlers.com>
On Sun, Apr 15, 2018 at 6:44 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 16 quoted lines
> One thing that makes me curious is what happens (and what we want to
> happen) when such a "we already have the changes the side branch
> tries to bring in" path has local (i.e. not yet in the index)
> changes.  For a dirty file that trivially merges (e.g. a path we
> modified since our histories forked, while the other side didn't do
> anything, has local changes in the working tree), we try hard to
> make the merge succeed while keeping the local changes, and we
> should be able to do the same in this case, too.
>
> Your illustration patch that reads from the working tree to compare
> with the contents we are about to write out of course won't cope
> with this case ;-).  If we do things in the index like the approach
> to fix was_tracked(), I suspect that we would just say "as long as
> the index and the HEAD matches, i.e. we are keeping the path as it is
> found in HEAD as the merge result, we do not touch the working tree"
> and leave such a local modification alone.

I could see it going either way (fail early, or succeed because we don't need to overwrite anything), but my suspicion is also towards letting the merge succeed.

It looks like my patches need a little more fixing up (the was_dirty() calls would be mixing both the old and the new index -- it used the original index via was_tracked(), but used the current index via cache_file_exists(); it should be more consistent). I'm fixing that up, will add this as another testcase to t6046, and will submit a newer RFC in a day or so.

Previous: Elijah NewrenNext: Linus Torvalds
Message 27 of 29 in “Optimizing writes to unchanged files during merges?”
  1. Linus TorvaldsApr 12, 2018
  2. Junio C HamanoApr 12, 2018
  3. Junio C HamanoApr 12, 2018
  4. Linus TorvaldsApr 12, 2018
  5. Linus TorvaldsApr 12, 2018
  6. Linus TorvaldsApr 12, 2018
  7. Linus TorvaldsApr 13, 2018
  8. Elijah NewrenApr 13, 2018
  9. Linus TorvaldsApr 13, 2018
  10. Stefan BellerApr 13, 2018
  11. Linus TorvaldsApr 13, 2018
  12. Elijah NewrenApr 13, 2018
  13. Junio C HamanoApr 13, 2018
  14. Junio C HamanoApr 16, 2018
  15. Linus TorvaldsApr 16, 2018
  16. Lars SchneiderApr 16, 2018
  17. Ævar Arnfjörð BjarmasonApr 16, 2018
  18. Lars SchneiderApr 17, 2018
  19. Jacob KellerApr 16, 2018
  20. Jacob KellerApr 16, 2018
  21. Junio C HamanoApr 16, 2018
  22. Lars SchneiderApr 17, 2018
  23. Jacob KellerApr 17, 2018
  24. Phillip WoodApr 16, 2018
  25. Stefan HallerApr 16, 2018
  26. Elijah NewrenApr 16, 2018
  27. Elijah NewrenApr 16, 2018
  28. Linus TorvaldsApr 12, 2018
  29. Elijah NewrenApr 13, 2018

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.