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

Re: [PATCH] add boolean diff.suppress-blank-empty config option

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 18, 2008, 20:20 UTC
Message-ID
<7vmyjam5xh.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<87k5eiphro.fsf@rho.meyering.net>
Jim Meyering <jim@meyering.net> writes:
> GNU diff's --suppress-blank-empty option makes it so that diff does not
> add a space or tab before each empty output line of context.  With this
> option, empty context lines are empty also in "git diff" output.
> Before (and without the option), they'd have a single trailing space.
Show 18 quoted lines
> diff --git a/xdiff-interface.c b/xdiff-interface.c
> index 61dc5c5..5544e5a 100644
> --- a/xdiff-interface.c
> +++ b/xdiff-interface.c
> @@ -66,6 +66,13 @@ int xdiff_outf(void *priv_, mmbuffer_t *mb, int nbuf)
>  	struct xdiff_emit_state *priv = priv_;
>  	int i;
>
> +	if (priv->suppress_blank_empty
> +	    && mb[0].size == 1
> +	    && mb[0].ptr[0] == ' '
> +	    && mb[1].size == 1
> +	    && mb[1].ptr[0] == '\n')
> +	  mb[0].size = 0;
> +
>  	for (i = 0; i < nbuf; i++) {
>  		if (mb[i].ptr[mb[i].size-1] != '\n') {
>  			/* Incomplete line */

I do not have a fundamental objection to the optional behaviour, but from technical point of view, I had to wonder if hooking to xdiff_outf() has funny interactions with codepaths that use patch-id (namely, git-rebase, git-format-patch, and git-cherry). Luckily, patch-ids are computed over non whitespaces, so it turns out to be Ok, but there may be other unintended side effects that I haven't thought about.

I would have preferred the option to hook into a bit higher layer (namely, the part that actually writes textual diff to the output stream).

Previous: Jim MeyeringNext: Jim Meyering
Message 4 of 5 in “add boolean diff.suppress-blank-empty config option”
  1. add boolean diff.suppress-blank-empty config optionJim Meyering, Aug 15, 2008
  2. Junio C HamanoAug 15, 2008
  3. Jim MeyeringAug 16, 2008
  4. Junio C HamanoAug 18, 2008
  5. add boolean diff.suppress-blank-empty config optionJim Meyering, Aug 19, 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.