All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jim Meyering <jim@meyering.net>
Cc: git list <git@vger.kernel.org>, Paul Eggert <eggert@cs.ucla.edu>
Subject: Re: [PATCH] add boolean diff.suppress-blank-empty config option
Date: Mon, 18 Aug 2008 13:20:10 -0700	[thread overview]
Message-ID: <7vmyjam5xh.fsf@gitster.siamese.dyndns.org> (raw)
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.

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

  parent reply	other threads:[~2008-08-18 20:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-15 12:47 [PATCH] add boolean diff.suppress-blank-empty config option Jim Meyering
2008-08-15 18:28 ` Junio C Hamano
2008-08-16 11:07   ` Jim Meyering
2008-08-18 20:20 ` Junio C Hamano [this message]
2008-08-19 13:29   ` Jim Meyering

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vmyjam5xh.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=eggert@cs.ucla.edu \
    --cc=git@vger.kernel.org \
    --cc=jim@meyering.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.