From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 3/5] xdiff: introduce XDF_INEXACT_MATCH
Date: Sun, 19 Feb 2012 18:16:26 -0800 [thread overview]
Message-ID: <1329704188-9955-4-git-send-email-gitster@pobox.com> (raw)
In-Reply-To: <1329704188-9955-1-git-send-email-gitster@pobox.com>
The XDF_WHITESPACE_FLAGS mask is used to decide if a simple memcmp() is
sufficient to tell if two lines are the same for the purpose of producing
diff. In the current code, only options in the ignore-whitespace family
happen to call for a matching logic that is more complex than memcmp(),
but when we add new options, e.g. ignore-case, it will become apparent
that the mask is misnamed.
Introduce XDF_INEXACT_MATCH mask to express its true meaning: when any of
these bits are set, we may need to inspect the contents of the two lines
that are not exactly the same, as we may still consider them "matching".
The XDF_WHITESPACE_FLAGS will become useful again in a later patch in the
series and its definition is kept.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
diff.c | 2 +-
xdiff/xdiff.h | 6 +++++-
xdiff/xutils.c | 4 ++--
3 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/diff.c b/diff.c
index 52cda7a..87b2ec1 100644
--- a/diff.c
+++ b/diff.c
@@ -2142,7 +2142,7 @@ static void builtin_diff(const char *name_a,
struct emit_callback ecbdata;
const struct userdiff_funcname *pe;
- if (!DIFF_XDL_TST(o, WHITESPACE_FLAGS) || must_show_header) {
+ if (!DIFF_XDL_TST(o, INEXACT_MATCH) || must_show_header) {
fprintf(o->file, "%s", header.buf);
strbuf_reset(&header);
}
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index 09215af..48793f9 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -32,7 +32,11 @@ extern "C" {
#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_WHITESPACE_FLAGS \
+ (XDF_IGNORE_WHITESPACE | \
+ XDF_IGNORE_WHITESPACE_CHANGE | \
+ XDF_IGNORE_WHITESPACE_AT_EOL)
+#define XDF_INEXACT_MATCH XDF_WHITESPACE_FLAGS
#define XDF_PATIENCE_DIFF (1 << 5)
#define XDF_HISTOGRAM_DIFF (1 << 6)
diff --git a/xdiff/xutils.c b/xdiff/xutils.c
index 0de084e..aa6de74 100644
--- a/xdiff/xutils.c
+++ b/xdiff/xutils.c
@@ -176,7 +176,7 @@ int xdl_recmatch(const char *l1, long s1, const char *l2, long s2, long flags)
if (s1 == s2 && !memcmp(l1, l2, s1))
return 1;
- if (!(flags & XDF_WHITESPACE_FLAGS))
+ if (!(flags & XDF_INEXACT_MATCH))
return 0;
i1 = 0;
@@ -281,7 +281,7 @@ unsigned long xdl_hash_record(char const **data, char const *top, long flags) {
unsigned long ha = 5381;
char const *ptr = *data;
- if (flags & XDF_WHITESPACE_FLAGS)
+ if (flags & XDF_INEXACT_MATCH)
return xdl_hash_record_with_whitespace(data, top, flags);
for (; ptr < top && *ptr != '\n'; ptr++) {
--
1.7.9.1.265.g25f75
next prev parent reply other threads:[~2012-02-20 2:16 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-20 2:16 [PATCH 0/5] diff --ignore-case Junio C Hamano
2012-02-20 2:16 ` [PATCH 1/5] xdiff: remove XDL_PATCH_* macros Junio C Hamano
2012-02-20 2:16 ` [PATCH 2/5] xdiff: PATIENCE/HISTOGRAM are not independent option bits Junio C Hamano
2012-02-20 2:16 ` Junio C Hamano [this message]
2012-02-20 2:16 ` [PATCH 4/5] xdiff: introduce XDF_IGNORE_CASE Junio C Hamano
2012-02-22 18:07 ` Jakub Narebski
2012-02-20 2:16 ` [PATCH 5/5] diff: --ignore-case Junio C Hamano
2012-02-20 7:36 ` [PATCH 6/5] diff -i Junio C Hamano
2012-02-20 8:41 ` [PATCH 0/5] diff --ignore-case Johannes Sixt
2012-02-20 8:52 ` Junio C Hamano
2012-02-20 14:06 ` Thomas Rast
2012-02-20 19:47 ` Junio C Hamano
2012-02-20 22:10 ` Chris Leong
2012-02-21 9:02 ` Re* " Junio C Hamano
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=1329704188-9955-4-git-send-email-gitster@pobox.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/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).