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

Re: correct git merge behavior or corner case?

From
Jeff King <peff@peff.net>
Date
Apr 21, 2009, 02:51 UTC
Message-ID
<20090421025107.GD14479@coredump.intra.peff.net>
In-Reply-To
<20090421024433.GC14479@coredump.intra.peff.net>
On Mon, Apr 20, 2009 at 10:44:33PM -0400, Jeff King wrote:
Show 7 quoted lines
> This is _exactly_ what git's rename detection is designed to do. Yes, it
> seems horribly confusing in this toy example, but that is because it is
> a toy example: both 'date' and 'LICENSE' are empty files. But with real
> files, if a source file has actual content but is deleted, there is a
> new filename with the identical or near-identical content, and the patch
> applies to the new content without conflicts, then applying it there is
> probably exactly what you want.

Looking back over the blog post, it seems that the original question was not about a toy example, but what looks like some boilerplate that involved empty files.

Maybe git should refuse to detect exact renames between empty files. That is easy enough to special-case, and would help people who have these sorts of boilerplate hierarchies. It would mean that we fail to automatically resolve something like:

  $ touch foo && git add foo && git commit -m boilerplate
  $ git branch other
  $ echo content >foo && git commit -m 'fill in boilerplate'
  $ git checkout other
  $ git mv foo bar && git commit -m reorganize
  $ git merge master

But the failure case is actually quite reasonable. We just mark it as a conflict, which is of course trivial for the user to resolve because the ancestor, by definition, had nothing in it.

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 6 of 17 in “correct git merge behavior or corner case?”
  1. Tuncer AyazApr 19, 2009
  2. Shawn O. PearceApr 20, 2009
  3. Johannes SchindelinApr 20, 2009
  4. Anders MelchiorsenApr 20, 2009
  5. Jeff KingApr 21, 2009
  6. Jeff KingApr 21, 2009
  7. Junio C HamanoApr 21, 2009
  8. Sverre RabbelierApr 21, 2009
  9. Johannes SchindelinApr 21, 2009
  10. Sverre RabbelierApr 21, 2009
  11. Johannes SchindelinApr 21, 2009
  12. Johannes SchindelinApr 21, 2009
  13. Michał KiedrowiczApr 21, 2009
  14. Michał KiedrowiczApr 21, 2009
  15. Jeff KingApr 21, 2009
  16. Michał KiedrowiczApr 21, 2009
  17. Jeff KingApr 21, 2009

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.