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

Re: [PATCH] Make sure diff-helper can tell rename/copy in the new diff-raw format.

From
Linus Torvalds <torvalds@osdl.org>
Date
May 23, 2005, 14:49 UTC
Message-ID
<Pine.LNX.4.58.0505230736180.2307@ppc970.osdl.org>
In-Reply-To
<7vfywe769d.fsf@assigned-by-dhcp.cox.net>
On Mon, 23 May 2005, Junio C Hamano wrote:
>
> This adds tests to make sure that diff-helper can tell renames
> from copies using the same "everything but the last one are
> copies and the last one is either rename or stay" logic.

Btw, I still disagree with this notion that the order of the use of the names makes a difference.

I think that when we generate a diff, we should always have the _option_ to make sure that we generate it in a format where you can apply it "incrementally". But I disagree with the notion that it's something fundamental, and in fact, I even think that it's not necessarily a good default.

For example, let's say that you have modified "fileA" _and_ you have created a "fileB" that is a copy of the original "fileA" with some _other_ slight modifications. We'll call the SHA1's involved "sha_A", "sha_A'" and "sha_B"

I think it's perfectly valid to say
	:100644 100644 <sha_A> <sha_A'> M	fileA	fileA
	:100644 100644 <sha_A> <sha_B> C89	fileA	fileB

which says "fileA" was modified from orig-A to new-A, and "fileB" is a copy based on orig-A.

(I've used a new syntax just to confuse the issue, with the extra field for "what happened", aka "M" for "modify", "C89" for "copy a 89% similar file").

Now, when the above is turned into a "diff", that diff is no longer something you can apply "incrementally" - you have to apply it as if you're applying all differences to the "original tree". But the thing is, that's actually what I _want_, because I was planning on writing a tool that applies patches that applies them all-or-nothing.

Also, it turns out that this kind of "non-incremental" diff is the kind that I personally want to see as a _human_, because quite frankly, my brain-capacity is that of a demented ocelot, and I can't _remember_ what happened in other parts of the diff. I much prefer the stateless "oh, this file X is in that relation Y to the previous version of file Z".

I do that partly because I actually routinely edit patches. If you have the incremental format, that's practically impossible, while the stateless version is fine.

See?

So I think all the clever "don't re-use files we have modified" etc is actually wrong. If you want to make a traditional diff that can be applied with normal "patch", you just don't use the -M or -C flags.

		Linus
Previous: Junio C HamanoNext: Junio C Hamano
Message 2 of 20 in “Make sure diff-helper can tell rename/copy in the new diff-raw format.”
  1. Make sure diff-helper can tell rename/copy in the new diff-raw format.Junio C Hamano, May 23, 2005
  2. Linus TorvaldsMay 23, 2005
  3. Junio C HamanoMay 23, 2005
  4. Linus TorvaldsMay 23, 2005
  5. Linus TorvaldsMay 23, 2005
  6. diff-raw format update take #2.Junio C Hamano, May 23, 2005
  7. diff-raw format update take #2.Junio C Hamano, May 23, 2005
  8. Chris WedgwoodMay 24, 2005
  9. Junio C HamanoMay 24, 2005
  10. Chris WedgwoodMay 24, 2005
  11. Junio C HamanoMay 24, 2005
  12. Linus TorvaldsMay 24, 2005
  13. Chris WedgwoodMay 24, 2005
  14. David LangMay 24, 2005
  15. Chris WedgwoodMay 24, 2005
  16. Thomas GlanzmannMay 24, 2005
  17. Linus TorvaldsMay 24, 2005
  18. Linus TorvaldsMay 24, 2005
  19. Junio C HamanoMay 26, 2005
  20. Thomas GlanzmannMay 24, 2005

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.