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
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 30, 2009, 17:32 UTC
Message-ID
<alpine.DEB.1.00.0910301831190.5383@felix-maschine>
In-Reply-To
<7v3a50n6hw.fsf@alter.siamese.dyndns.org>
Hi,
On Fri, 30 Oct 2009, Junio C Hamano wrote:
Show 15 quoted lines
> Markus Heidelberg <markus.heidelberg@web.de> writes:
> 
> > 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.
> 
> The contamination was already done long time ago.
Actually, it was don on purpose.
Show 15 quoted lines
> diff --git a/diff.c b/diff.c
> index b7ecfe3..8c66e4a 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -541,14 +541,18 @@ struct emit_callback {
>  	FILE *file;
>  };
>  
> +/* In "color-words" mode, show word-diff of words accumulated in the buffer */
> +static void diff_words_flush(struct emit_callback *ecbdata)
> +{
> +	if (ecbdata->diff_words->minus.text.size ||
> +	    ecbdata->diff_words->plus.text.size)
> +		diff_words_show(ecbdata->diff_words);
> +}

Instead of this function, you can check the same at the beginning of diff_words_show().

The reason I did not do that was to avoid a full subroutine call, as I expected this code path to be very expensive.

Ciao, Dscho

Previous: Junio C HamanoNext: Junio C Hamano
Message 10 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.