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

Re: [RFC PATCH] diff: do not use creation-half of -B as a rename target candidate

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 2, 2015, 18:25 UTC
Message-ID
<xmqqbnlcuq58.fsf@gitster.dls.corp.google.com>
In-Reply-To
<xmqqfvapuhkk.fsf@gitster.dls.corp.google.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 6 quoted lines
>  * Here is what I am at the moment; I cannot quite explain (hence I
>    cannot convince myself) why this is the right solution, but it
>    seems to make the above sample case work without breaking any
>    existing tests.  It is possible that the tests that would break
>    without the "&& !p->score" bit are expecting wrong results, but I
>    didn't look at them in detail.

Sadly, I think this is garbage. "Do not consider creation-half of a broken pair, ever" is too simple and cripples this case that starts with two files A and B that are quite different:

	$ git add A B
	$ mv A B.new
        $ mv B A
        $ mv B.new B
        $ git diff -B -M

where the internal machinery breaks both A and B into these two file pairs:

	delete A(old)
        create A(new)
	delete B(old)
        create B(new)
and then match them up to produce
	rename A to B
        rename B to A

The rule need to be "creation-half of a broken pair can be used as the destination of a rename, if and only if its corresponding deletion-half is used as the source of another rename elsewhere". Under that condition, a file A that is completely rewritten to become similar to another existing file B can be expressed as a rename of B, because A is renamed away to make room in the same change.

Fixing this is turning out to be more complex than I originally hoped X-<.

Previous: Yue Lin Ho
Message 5 of 5 in “[Git BUG] Please do not use "-B -M" in "diff" family for now”
  1. Junio C HamanoJan 31, 2015
  2. diff: do not use creation-half of -B as a rename target candidateJunio C Hamano, Feb 2, 2015
  3. Stefan BellerFeb 2, 2015
  4. Yue Lin HoFeb 2, 2015
  5. Junio C HamanoFeb 2, 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.