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

Re: [BUG?] Patches created with 'diff.noprefix=true' don't 'git apply'.

From
Nathan Collins <nathan.collins@gmail.com>
Date
May 8, 2014, 04:53 UTC
Message-ID
<CAO8RVvdfEPrtNNr1bFAA-aUigz67swS-rzUhTkZE76DJO3TBaA@mail.gmail.com>
In-Reply-To
<CAO8RVvcyi6KvrZqueBA+PKCTocL=s7NJGann4CzU0WAf6DxWcA@mail.gmail.com>
On Wed, May 7, 2014 at 9:38 PM, Nathan Collins <nathan.collins@gmail.com> wrote:
Show 42 quoted lines
> On Wed, May 7, 2014 at 4:39 PM, Nathan Collins <nathan.collins@gmail.com> wrote:
>> On Wed, May 7, 2014 at 11:42 AM, Junio C Hamano <gitster@pobox.com> wrote:
>>> Nathan Collins <nathan.collins@gmail.com> writes:
>>
>>>> For (2), the solution may be to add a separate
>>>> 'diff.add-clickable-paths' option (probably there is a better name?
>>>> 'diff.add-copyable-paths'? ...),...
>>>> ...
>>>> Concretely, if 'diff.add-clickable-paths' is set, then instead of e.g.
>>>>
>>>>   diff --git a/src/Data/Function/Decorator/Memoizer/Unsafe.hs
>>>> b/src/Data/Function/Decorator/Memoizer
>>>>   index 3ef17da..a0586d3 100644
>>>>   --- a/src/Data/Function/Decorator/Memoizer/Unsafe.hs
>>>>   +++ b/src/Data/Function/Decorator/Memoizer/Unsafe.hs
>>>
>>> If you do something along that line, perhaps
>>>
>>>         Index: src/Data/Function/Decorator/Memoizer/Unsafe.hs
>>>         diff --git a/src/Data/Function/Decorator/Memoizer/Unsafe.hs ...
>>>         index 3ef17da..a0586d3 100644
>>>         --- a/src/Data/Function/Decorator/Memoizer/Unsafe.hs
>>>         +++ b/src/Data/Function/Decorator/Memoizer/Unsafe.hs
>>>
>>> to imitate what "cvs diff" does may be more familar to people.
>>>
>>> What would you propose to make clickable in a renaming diff, though?
>>
>> Your 'Index' header looks good, and I would expect a renaming diff to
>> have something like
>>
>>   Index: foo -> bar
>>
>> as in 'git status', but I just realized that a "clickable paths"
>> option already exists in some sense! There is a '--patch-with-raw'
>> option (which is "short" for '--patch' and '--raw', hahaha) which
>> inserts clickable file names in the patch, above each diff.
>
> Or not: I stupidly only tested this with a single file modified: it
> turns out that all the clickable file names appear at the top of the
> patch, not as one file name above each corresponding diff as I
> claimed.

The following may be a non-option, since presumably many tools depend on the current Git patch format.

The paths in the "extended header lines" in Git patches are clickable by default, and respect the '--relative' option. So, adding a path to the extended header lines that don't already have one would solve the "clickable paths" problem.

E.g.
  index <hash>..<hash> <mode>
becomes
  index <hash>..<hash> <mode> <path>

The 'man git-diff' description of extended header lines in the "Generating Patches with -p" section:

  2. It is followed by one or more extended header lines:
         old mode <mode>
         new mode <mode>
         deleted file mode <mode>
         new file mode <mode>
         copy from <path>
         copy to <path>
         rename from <path>
         rename to <path>
         similarity index <number>
         dissimilarity index <number>
         index <hash>..<hash> <mode>
     File modes are printed as 6-digit octal numbers including the
file type and file
     permission bits.
     Path names in extended headers do not include the a/ and b/ prefixes.
Cheers,
-nathan
Previous: Nathan CollinsNext: Junio C Hamano
Message 12 of 13 in “[BUG?] Patches created with 'diff.noprefix=true' don't 'git apply'.”
  1. Nathan CollinsMay 1, 2014
  2. Jonathan NiederMay 1, 2014
  3. Nathan CollinsMay 6, 2014
  4. Jonathan NiederMay 6, 2014
  5. Junio C HamanoMay 6, 2014
  6. Nathan CollinsMay 6, 2014
  7. Junio C HamanoMay 6, 2014
  8. Nathan CollinsMay 7, 2014
  9. Junio C HamanoMay 7, 2014
  10. Nathan CollinsMay 7, 2014
  11. Nathan CollinsMay 8, 2014
  12. Nathan CollinsMay 8, 2014
  13. Junio C HamanoMay 8, 2014

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.