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

Re: [PATCH v2] Do not show "diff --git" metainfo with --no-prefix

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Jan 16, 2008, 03:56 UTC
Message-ID
<alpine.LNX.1.00.0801152226000.13593@iabervon.org>
In-Reply-To
<alpine.LFD.1.00.0801151902080.2806@woody.linux-foundation.org>
On Tue, 15 Jan 2008, Linus Torvalds wrote:
Show 13 quoted lines
> On Tue, 15 Jan 2008, Junio C Hamano wrote:
> >
> > If a non-standard prefix is used by --no-prefix, --src-prefix,
> > or --dst-prefix options, the resulting diff becomes something
> > git-apply would not grok.  In such a case, we should not trigger
> > the more strict check git-apply does for patches in "diff --git"
> > format.
> 
> I think this is wrong.
> 
> If we do any git-specific stuff, we need to have that "--git" thing there. 
> That is *not* just limited to the prefix, but to all the other things git 
> diffs can do: renames, mode changes, etc.

Well, part of the issue is that, if you drop the prefix, then *git* can't understand the resulting patch (because --git causes git-apply to use open-coded -p1 handling of names, which won't be right).

I suppose the other option is to have the header in this case be:
diff --git --src-prefix= --dst-prefix= filename filename

so that apply can figure out what diff did correctly.

> > Metainformation (e.g. "index", "similarity", etc.) lines will
> > safely be ignored by patch and git-apply (even when the latter
> > parses a non-git diff output), so this patch does not bother
> > stripping them away.
> 
> It's not necessarily safe to ignore some of them, like the rename info. If 
> you see a rename patch and don't understand it as a rename, it's 
> pointless.
> 
> So I would argue that you need something stronger to say "don't do a git 
> diff", and that should also disallow rename detection at a minimum. Quite 
> frankly, any program that is so stupid as to not accept current git 
> patches (ie TortoiseSVN), then we damn well shouldn't just disable the 
> most trivial part of it. We should make sure that we do not enable *any* 
> of the rather important extensions: even if ToirtoiseSVN would ignore 
> them, if ignoring them means that it mis-understands the diff, it 
> shouldn't be allowed at all.
> 
> So maybe a --standard-diff option that removes the "--git" part, but also 
> removes everything else.

That seems wise to me. We should be able to generate patches that are 
accessible to programs that can't follow any clever instructions. I think 
the point of the "Index:" header is that these programs will freak out if 
two filenames don't match (or, more likely, break in some way), and it 
means you can't sensibly generate patches that upset them for deletes or 
creates.

	-Daniel
*This .sig left intentionally blank*
Previous: Junio C HamanoNext: Jan Hudec
Message 44 of 53 in “[FEATURE REQUEST] git-svn format-patch”
  1. Chris OrtmanJan 15, 2008
  2. Johannes SchindelinJan 15, 2008
  3. Chris OrtmanJan 15, 2008
  4. Johannes SchindelinJan 15, 2008
  5. Chris OrtmanJan 15, 2008
  6. Johannes SchindelinJan 15, 2008
  7. Chris OrtmanJan 15, 2008
  8. Johannes SchindelinJan 15, 2008
  9. Chris OrtmanJan 15, 2008
  10. Jan HudecJan 15, 2008
  11. Miles BaderJan 16, 2008
  12. Shawn O. PearceJan 16, 2008
  13. Pascal ObryJan 15, 2008
  14. Daniel BarkalowJan 15, 2008
  15. Junio C HamanoJan 16, 2008
  16. Do not show "diff --git" metainfo with --no-prefixJunio C Hamano, Jan 16, 2008
  17. Johannes SchindelinJan 16, 2008
  18. Junio C HamanoJan 16, 2008
  19. Johannes SchindelinJan 16, 2008
  20. Daniel BarkalowJan 16, 2008
  21. Junio C HamanoJan 16, 2008
  22. Do not show "diff --git" metainfo with --no-prefixJunio C Hamano, Jan 16, 2008
  23. Linus TorvaldsJan 16, 2008
  24. Linus TorvaldsJan 16, 2008
  25. Daniel BarkalowJan 16, 2008
  26. Linus TorvaldsJan 16, 2008
  27. Junio C HamanoJan 16, 2008
  28. Daniel BarkalowJan 16, 2008
  29. Junio C HamanoJan 17, 2008
  30. Johannes SchindelinJan 17, 2008
  31. Junio C HamanoJan 17, 2008
  32. Johannes SchindelinJan 17, 2008
  33. Junio C HamanoJan 17, 2008
  34. Junio C HamanoJan 17, 2008
  35. Johannes SchindelinJan 17, 2008
  36. Junio C HamanoJan 17, 2008
  37. Johannes SchindelinJan 17, 2008
  38. Jeff KingJan 17, 2008
  39. Jeff KingJan 17, 2008
  40. Johannes SchindelinJan 17, 2008
  41. Jeff KingJan 17, 2008
  42. Junio C HamanoJan 18, 2008
  43. Junio C HamanoJan 16, 2008
  44. Daniel BarkalowJan 16, 2008
  45. Jan HudecJan 19, 2008
  46. Junio C HamanoJan 16, 2008
  47. Chris OrtmanJan 16, 2008
  48. Jean-Luc HerrenJan 15, 2008
  49. Chris OrtmanJan 15, 2008
  50. Daniel BarkalowJan 16, 2008
  51. Nigel MagnayMar 11, 2008
  52. Jan HudecMar 11, 2008
  53. Daniel BarkalowMar 12, 2008

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.