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

Re: [PATCH] diff --color-words -U0: fix the location of hunk headers

From
Markus Heidelberg <markus.heidelberg@web.de>
Date
Oct 29, 2009, 16:29 UTC
Message-ID
<200910291729.23562.markus.heidelberg@web.de>
In-Reply-To
<alpine.DEB.1.00.0910291425010.3687@felix-maschine>
Johannes Schindelin, 29.10.2009:
Show 29 quoted lines
> Hi,
> 
> On Thu, 29 Oct 2009, Markus Heidelberg wrote:
> 
> > Indeed my initial fix was in the same fashion:
> > 
> > @@ -772,6 +772,15 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> >         }
> > 
> >         if (line[0] == '@') {
> > +               if (ecbdata->diff_words) {
> > +                       /*
> > +                        * The content of the previous hunk, necessary for
> > +                        * 0-context.
> > +                        */
> > +                       if (ecbdata->diff_words->minus.text.size ||
> > +                           ecbdata->diff_words->plus.text.size)
> > +                               diff_words_show(ecbdata->diff_words);
> > +               }
> >                 len = sane_truncate_line(ecbdata, line, len);
> >                 find_lno(line, ecbdata);
> >                 emit_line(ecbdata->file,
> > 
> > But then I thought I should not put the diff output from --color-words
> > into the block that deals with the hunk header, but save another place
> > where diff_words_show() is called.
> 
> I found this paragraph, as well as the patches 2/3 and 3/3, hard to 
> follow.

I try to reword: With 2/3 and 3/3 I wanted to keep --color-words specific code in the block starting with

	if (ecbdata->diff_words) {
and didn't want to contaminate the block starting with
	if (line[0] == '@') {
with non-hunk-header content.
But I'm not sure what's the better way and am content with either.
> And besides, flushing in that block is the correct thing to do.  The 
> function diff_words_show() is a function for that exact purpose.

Yes, 2/3 and 3/3 just don't introduce a new invocation of this function at another place in the code.

Markus
Previous: Johannes SchindelinNext: Junio C Hamano
Message 8 of 14 in “fix "git diff --color-words -U0"”
  1. 0/3 fix "git diff --color-words -U0"Markus Heidelberg, Oct 28, 2009
  2. 1/3 t4034-diff-words: add a test for word diff without contextMarkus Heidelberg, Oct 28, 2009
  3. 2/3 diff: move the handling of the hunk header after the changed linesMarkus Heidelberg, Oct 28, 2009
  4. 3/3 diff: fix the location of hunk headers for "git diff --color-words -U0"Markus Heidelberg, Oct 28, 2009
  5. diff --color-words -U0: fix the location of hunk headersJohannes Schindelin, Oct 29, 2009
  6. Markus HeidelbergOct 29, 2009
  7. Johannes SchindelinOct 29, 2009
  8. Markus HeidelbergOct 29, 2009
  9. Junio C HamanoOct 30, 2009
  10. Johannes SchindelinOct 30, 2009
  11. Junio C HamanoOct 30, 2009
  12. Johannes SchindelinOct 31, 2009
  13. Junio C HamanoOct 28, 2009
  14. Markus HeidelbergOct 28, 2009

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.