From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v2 1/2] xdiff: reassign xpparm_t.flags bits
Date: Tue, 7 Nov 2017 13:44:44 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.21.1.1711071336120.6482@virtualbox> (raw)
In-Reply-To: <20171107064011.18399-2-gitster@pobox.com>
Hi Junio,
On Tue, 7 Nov 2017, Junio C Hamano wrote:
> We have packed the bits too tightly in such a way that it is not
> easy to add a new type of whitespace ignoring option, a new type
> of LCS algorithm, or a new type of post-cleanup heuristics.
>
> Reorder bits a bit to give room for these three classes of options
> to grow. Also make use of XDF_WHITESPACE_FLAGS macro where we check
> any of these bits are on, instead of using DIFF_XDL_TST() macro on
> individual possibilities. That way, the "is any of the bits on?"
> code does not have to change when we add more ways to ignore
> whitespaces.
>
> While at it, add a comment in front of the bit definitions to
> clarify in which structure these defined bits may appear.
Makes sense.
> diff --git a/diff.c b/diff.c
> index 74283d9001..790250fe86 100644
> --- a/diff.c
> +++ b/diff.c
> @@ -3434,9 +3434,7 @@ void diff_setup_done(struct diff_options *options)
> * inside contents.
> */
>
> - if (DIFF_XDL_TST(options, IGNORE_WHITESPACE) ||
> - DIFF_XDL_TST(options, IGNORE_WHITESPACE_CHANGE) ||
> - DIFF_XDL_TST(options, IGNORE_WHITESPACE_AT_EOL))
> + if ((options->xdl_opts & XDF_WHITESPACE_FLAGS))
Not only shorter now, but a lot clearer, too: nobody needs to wonder now
whether one whitespace flag was excluded on purpose.
> DIFF_OPT_SET(options, DIFF_FROM_CONTENTS);
> else
> DIFF_OPT_CLR(options, DIFF_FROM_CONTENTS);
> diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
> index b090ad8eac..cbf5d8e166 100644
> --- a/xdiff/xdiff.h
> +++ b/xdiff/xdiff.h
> @@ -27,22 +27,26 @@
> extern "C" {
> #endif /* #ifdef __cplusplus */
>
> +/* xpparm_t.flags */
> +#define XDF_NEED_MINIMAL (1 << 0)
>
> -#define XDF_NEED_MINIMAL (1 << 1)
This change makes me wonder whether the least significant bit was omitted
on purpose originally. You probably looked at that? May be worth
mentioning in the commit message.
> -#define XDF_IGNORE_WHITESPACE (1 << 2)
> -#define XDF_IGNORE_WHITESPACE_CHANGE (1 << 3)
> -#define XDF_IGNORE_WHITESPACE_AT_EOL (1 << 4)
> -#define XDF_WHITESPACE_FLAGS (XDF_IGNORE_WHITESPACE | XDF_IGNORE_WHITESPACE_CHANGE | XDF_IGNORE_WHITESPACE_AT_EOL)
> +#define XDF_IGNORE_WHITESPACE (1 << 1)
> +#define XDF_IGNORE_WHITESPACE_CHANGE (1 << 2)
> +#define XDF_IGNORE_WHITESPACE_AT_EOL (1 << 3)
> +#define XDF_WHITESPACE_FLAGS (XDF_IGNORE_WHITESPACE | \
> + XDF_IGNORE_WHITESPACE_CHANGE | \
> + XDF_IGNORE_WHITESPACE_AT_EOL)
>
> -#define XDF_PATIENCE_DIFF (1 << 5)
> -#define XDF_HISTOGRAM_DIFF (1 << 6)
> +#define XDF_IGNORE_BLANK_LINES (1 << 7)
> +
> +#define XDF_PATIENCE_DIFF (1 << 14)
> +#define XDF_HISTOGRAM_DIFF (1 << 15)
> #define XDF_DIFF_ALGORITHM_MASK (XDF_PATIENCE_DIFF | XDF_HISTOGRAM_DIFF)
> #define XDF_DIFF_ALG(x) ((x) & XDF_DIFF_ALGORITHM_MASK)
>
> -#define XDF_IGNORE_BLANK_LINES (1 << 7)
> -
> -#define XDF_INDENT_HEURISTIC (1 << 8)
> +#define XDF_INDENT_HEURISTIC (1 << 23)
>
> +/* xdemitconf_t.flags */
> #define XDL_EMIT_FUNCNAMES (1 << 0)
> #define XDL_EMIT_FUNCCONTEXT (1 << 2)
It is a pity that this diff is not easier to review, but it shows how much
it was in need of cleaning up. Looks much nicer now.
I wonder, however, what your guiding principle was in determining the
gaps? I would have expected consecutive bits, except for the one gap to
make room for the upcoming flag, of course.
Future patch series could always start by making room for new flags, as
needed, after all.
Ciao,
Dscho
next prev parent reply other threads:[~2017-11-07 12:45 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-24 17:48 Consequences of CRLF in index? Lars Schneider
2017-10-24 18:14 ` Jonathan Nieder
2017-10-24 19:02 ` Torsten Bögershausen
2017-10-25 12:13 ` Johannes Schindelin
2017-10-25 1:51 ` Junio C Hamano
2017-10-25 4:53 ` Junio C Hamano
2017-10-25 16:44 ` Stefan Beller
2017-10-26 5:54 ` Junio C Hamano
2017-10-27 6:13 ` Re* " Junio C Hamano
2017-10-27 17:06 ` Stefan Beller
2017-10-27 17:07 ` [PATCH 0/2] " Stefan Beller
2017-10-27 17:07 ` [PATCH 1/2] xdiff/xdiff.h: remove unused flags Stefan Beller
2017-10-27 17:07 ` [PATCH 2/2] xdiff/xdiffi.c: remove unneeded function declarations Stefan Beller
2017-10-30 17:20 ` [PATCH 0/2] Re* Consequences of CRLF in index? Stefan Beller
2017-10-31 2:44 ` Junio C Hamano
2017-10-31 16:41 ` Stefan Beller
2017-10-31 17:01 ` Jeff King
2017-11-07 6:40 ` [PATCH v2 0/2] Teach "diff" to ignore only CR at EOL Junio C Hamano
2017-11-07 6:40 ` [PATCH v2 1/2] xdiff: reassign xpparm_t.flags bits Junio C Hamano
2017-11-07 12:44 ` Johannes Schindelin [this message]
2017-11-07 15:02 ` Junio C Hamano
2017-11-07 6:40 ` [PATCH v2 2/2] diff: --ignore-cr-at-eol Junio C Hamano
2017-11-07 13:23 ` Johannes Schindelin
2017-11-08 0:43 ` Junio C Hamano
2017-11-08 0:49 ` Junio C Hamano
2017-11-15 4:28 ` Junio C Hamano
2017-11-07 12:30 ` [PATCH v2 0/2] Teach "diff" to ignore only CR at EOL Johannes Schindelin
2017-11-07 15:12 ` Junio C Hamano
2017-11-07 17:42 ` Stefan Beller
2017-10-25 17:04 ` Consequences of CRLF in index? Lars Schneider
2017-10-25 17:13 ` Jonathan Nieder
2017-10-26 11:06 ` Lars Schneider
2017-10-26 19:15 ` Torsten Bögershausen
2017-10-24 21:04 ` Johannes Sixt
2017-10-25 12:19 ` Johannes Schindelin
2017-10-26 7:09 ` Johannes Sixt
2017-10-26 11:01 ` Lars Schneider
2017-10-26 19:22 ` Torsten Bögershausen
2017-10-26 20:20 ` Johannes Sixt
2017-10-26 20:30 ` Jonathan Nieder
2017-10-26 20:51 ` Johannes Sixt
2017-10-26 22:27 ` Ross Kabus
2017-10-27 1:05 ` Junio C Hamano
2017-10-27 15:18 ` Johannes Schindelin
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=alpine.DEB.2.21.1.1711071336120.6482@virtualbox \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).