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

Re: [PATCH 0/2] merging renames of empty files

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 22, 2012, 23:37 UTC
Message-ID
<7vpqc4us0u.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20120322224651.GA14874@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Here's a 2-patch series to replace the old 3/3 (they go on top of the
> first two cleanups from the previous iteration).

Hrm. As this is probably useful for older maintenance track, I would have preferred not to see the first one that touches sequencer.c that did not exist in the 1.7.7.x maintenance track, as the change is purely "cosmetic" and does not have anything to do with fixing the over-agressive merge.

Show 11 quoted lines
>   [1/2]: teach diffcore-rename to optionally ignore empty content
>   [2/2]: merge-recursive: don't detect renames of empty files
>
> Thinking on this more, it is actually a more generic problem than just
> empty files. It is really a problem of having generic placeholder files
> with the same content. So a fully general solution would be something
> like a gitattribute for "don't do renames on this". However, in
> practice, these placeholder files are empty (since any non-empty file is
> likely to actually have different content). So I think just dropping the
> empty files as rename candidates is a pretty good heuristic, and it's
> nice and simple.

I thought that our recommendation for keeping an otherwise empty directories around was to have .gitignore file with two entries in it, namely:

	.*
        *
So these files will be everywhere and without being empty, no?

But I tend to prefer the simplicity of limiting this to empty files anyway.

> After responding to Jonathan, I'm on the fence about whether diff should
> follow the same heuristic. I left the diff behavior unchanged, but a 3/2
> that turns it off by default would be a trivial one-liner.

I am also torn, but somewhat in favor of avoiding random permutations of empty files.

I can think of only one situation somebody _could_ argue that detecting empty-to-empty rename is halfway sensible: when there is only one empty file that was removed, and one new empty file that was added. Even in such a case, the user could have done "rm this; >that", and depending on the nature of these two files, "mv this that" may not have made _any_ sense even if they are both empty, and that is why I said "halfway" sensible.

Previous: Jeff KingNext: Jeff King
Message 23 of 25 in “Strange effect merging empty file”
  1. Ralf NyrenMar 21, 2012
  2. Zbigniew Jędrzejewski-SzmekMar 21, 2012
  3. Junio C HamanoMar 21, 2012
  4. Randal L. SchwartzMar 22, 2012
  5. Ralf NyrenMar 22, 2012
  6. Zbigniew Jędrzejewski-SzmekMar 22, 2012
  7. Jeff KingMar 22, 2012
  8. Junio C HamanoMar 22, 2012
  9. Jeff KingMar 22, 2012
  10. Jeff KingMar 22, 2012
  11. Jeff KingMar 22, 2012
  12. 1/3 drop casts from users EMPTY_TREE_SHA1_BINJeff King, Mar 22, 2012
  13. 2/3 make is_empty_blob_sha1 available everywhereJeff King, Mar 22, 2012
  14. 3/3 merge-recursive: don't detect renames from empty filesJeff King, Mar 22, 2012
  15. Jonathan NiederMar 22, 2012
  16. Jeff KingMar 22, 2012
  17. Junio C HamanoMar 22, 2012
  18. Jeff KingMar 22, 2012
  19. Junio C HamanoMar 22, 2012
  20. 0/2 merging renames of empty filesJeff King, Mar 22, 2012
  21. 1/2 teach diffcore-rename to optionally ignore empty contentJeff King, Mar 22, 2012
  22. 2/2 merge-recursive: don't detect renames of empty filesJeff King, Mar 22, 2012
  23. Junio C HamanoMar 22, 2012
  24. Jeff KingMar 23, 2012
  25. Junio C HamanoMar 23, 2012

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.