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

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

 



Jim Meyering <jim@xxxxxxxxxxxx> 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).

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

  Powered by Linux