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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Thu, 29 Oct 2009, Markus Heidelberg wrote:

> Johannes Schindelin, 29.10.2009:
> > 
> > 	I would strongly prefer this fix instead of your 2/3 and 3/3.
> > 
> >  diff.c                |    6 ++++++
> >  t/t4034-diff-words.sh |    2 +-
> >  2 files changed, 7 insertions(+), 1 deletions(-)
> > 
> > diff --git a/diff.c b/diff.c
> > index 51b5dbb..4eafaf5 100644
> > --- a/diff.c
> > +++ b/diff.c
> > @@ -656,6 +656,12 @@ static void fn_out_consume(void *priv, char *line, unsigned long len)
> >  	for (i = 0; i < len && line[i] == '@'; i++)
> >  		;
> >  	if (2 <= i && i < len && line[i] == ' ') {
> > +		/* flush --color-words even for --unified=0 */
> > +		if (ecbdata->diff_words &&
> > +		    (ecbdata->diff_words->minus.text.size ||
> > +		     ecbdata->diff_words->plus.text.size))
> > +			diff_words_show(ecbdata->diff_words);
> > +
> >  		ecbdata->nparents = i - 1;
> >  		len = sane_truncate_line(ecbdata, line, len);
> >  		emit_line(ecbdata->file,
> 
> This seems to apply before commit b8d9c1a (diff.c: the builtin_diff()
> deals with only two-file comparison, 2009-09-03).

Yes, sorry, for some reason I worked on a machine where I do not work from 
junio's next, but my own fork (which is outdated due to lack of time).

> 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.

And besides, flushing in that block is the correct thing to do.  The 
function diff_words_show() is a function for that exact purpose.

Ciao,
Dscho

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]