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

Re: [PATCH, RFC] diff: add option to show context between close chunks

From
René Scharfe <rene.scharfe@lsrfire.ath.cx>
Date
Oct 21, 2008, 20:45 UTC
Message-ID
<48FE3F53.6030303@lsrfire.ath.cx>
In-Reply-To
<48FD721D.9030105@viscovery.net>
Johannes Sixt schrieb:
Show 12 quoted lines
> René Scharfe schrieb:
>> I have to admit my main motivation was that one line gap, where a chunk
>> header hid an interesting line of context.  Showing it didn't change the
>> length of the patch, so I found this to be a sad wastage.
> 
> "Wastage" is relative. For a given patch, the one line of context that was
> hidden by the hunk header would be welcome by a human reader, but it is
> not necessarily useful if the patch is to be applied, in particular, if it
> is applied to a version of the file that has *more* than one line between
> the hunk contexts. This is the reason that diff does not produce 7 lines
> of context between changes in -U3 mode ("you asked for 3 lines of context,
> you get 3 lines of context").

Yes, that's an interesting example of the possible "merge conflicts" I mentioned in my original mail, and one I didn't think of. And since I don't do any merges myself, I don't know how much of a problem this is.

As Daniel writes, one could teach git-apply to ignore extra context. It should even be possible to infer the -U option used to create a patch and to remove any extra lines (which might get complicated for patches that change both the start and the end of a file, though).

Also, I'd like to know how many patches of a given repo would be have created such a problem, but I can't think of a way to count them at the moment. I need some sleep first.

> BTW, nomenclature seems to have settled at the word "hunk", not "chunk".

While http://en.wikipedia.org/wiki/Diff uses both and defines "chunk" as "change hunk", the GNU patch(1) manpage uses "hunk" throughout. "Hunk" it is, then. :)

René
Previous: Johannes SixtNext: Junio C Hamano
Message 5 of 11 in “diff: add option to show context between close chunks”
  1. diff: add option to show context between close chunksRené Scharfe, Oct 19, 2008
  2. Johannes SixtOct 20, 2008
  3. René ScharfeOct 20, 2008
  4. Johannes SixtOct 21, 2008
  5. René ScharfeOct 21, 2008
  6. Junio C HamanoOct 20, 2008
  7. Johannes SixtOct 21, 2008
  8. Junio C HamanoOct 21, 2008
  9. Jeff KingOct 21, 2008
  10. René ScharfeOct 21, 2008
  11. Daniel BarkalowOct 21, 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.