From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: git@vger.kernel.org, gitster@pobox.com
Subject: [PATCH 2/2] Simplify "external diff from attributes" logic
Date: Sat, 7 Jul 2007 18:21:34 +0100 (BST) [thread overview]
Message-ID: <Pine.LNX.4.64.0707071821170.4093@racer.site> (raw)
Since we already store the given diff attribute in the filespec,
we can just as well reuse that, instead of going through the whole
attributes checking process again, when checking for an external
diff program.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
diff.c | 39 +++++++++++++++++----------------------
1 files changed, 17 insertions(+), 22 deletions(-)
diff --git a/diff.c b/diff.c
index a5444df..121524e 100644
--- a/diff.c
+++ b/diff.c
@@ -1195,6 +1195,20 @@ int diff_filespec_is_binary(struct diff_filespec *one)
return one->is_binary;
}
+static const char *external_diff_attr(struct diff_filespec *one)
+{
+ diff_filespec_check_attr(one);
+ if (one->diff_attr) {
+ struct ll_diff_driver *drv;
+
+ read_config_if_needed();
+ for (drv = user_diff; drv; drv = drv->next)
+ if (!strcmp(drv->name, one->diff_attr))
+ return drv->cmd;
+ }
+ return NULL;
+}
+
static const char *funcname_pattern(const char *ident)
{
struct funcname_pattern *pp;
@@ -1860,27 +1874,6 @@ static void run_external_diff(const char *pgm,
}
}
-static const char *external_diff_attr(const char *name)
-{
- struct git_attr_check attr_diff_check;
-
- setup_diff_attr_check(&attr_diff_check);
- if (!git_checkattr(name, 1, &attr_diff_check)) {
- const char *value = attr_diff_check.value;
- if (!ATTR_TRUE(value) &&
- !ATTR_FALSE(value) &&
- !ATTR_UNSET(value)) {
- struct ll_diff_driver *drv;
-
- read_config_if_needed();
- for (drv = user_diff; drv; drv = drv->next)
- if (!strcmp(drv->name, value))
- return drv->cmd;
- }
- }
- return NULL;
-}
-
static void run_diff_cmd(const char *pgm,
const char *name,
const char *other,
@@ -1893,7 +1886,9 @@ static void run_diff_cmd(const char *pgm,
if (!o->allow_external)
pgm = NULL;
else {
- const char *cmd = external_diff_attr(name);
+ const char *cmd = external_diff_attr(one);
+ if (!cmd)
+ cmd = external_diff_attr(two);
if (cmd)
pgm = cmd;
}
--
1.5.3.rc0.2712.g125b7f
reply other threads:[~2007-07-07 17:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=Pine.LNX.4.64.0707071821170.4093@racer.site \
--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).