summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4d5f347)
raw | patch | inline | side by side (parent: 4d5f347)
author | Jeff King <peff@peff.net> | |
Mon, 23 May 2011 20:30:14 +0000 (16:30 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 23 May 2011 22:46:02 +0000 (15:46 -0700) |
This function actually does two things:
1. Load the userdiff driver for the filespec.
2. Decide whether the driver has a textconv component, and
initialize the textconv cache if applicable.
Only part (1) requires the filespec object, and some callers
may not have a filespec at all. So let's split them it into
two functions, and put part (2) with the userdiff code,
which is a better fit.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1. Load the userdiff driver for the filespec.
2. Decide whether the driver has a textconv component, and
initialize the textconv cache if applicable.
Only part (1) requires the filespec object, and some callers
may not have a filespec at all. So let's split them it into
two functions, and put part (2) with the userdiff code,
which is a better fit.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c | patch | blob | history | |
userdiff.c | patch | blob | history | |
userdiff.h | patch | blob | history |
index ba5f7aa2173a7494b56395bfd88ab6228b5ed1fe..3f538f5803e414fb313ab60598682b8b8491e204 100644 (file)
--- a/diff.c
+++ b/diff.c
return NULL;
diff_filespec_load_driver(one);
- if (!one->driver->textconv)
- return NULL;
-
- if (one->driver->textconv_want_cache && !one->driver->textconv_cache) {
- struct notes_cache *c = xmalloc(sizeof(*c));
- struct strbuf name = STRBUF_INIT;
-
- strbuf_addf(&name, "textconv/%s", one->driver->name);
- notes_cache_init(c, name.buf, one->driver->textconv);
- one->driver->textconv_cache = c;
- }
-
- return one->driver;
+ return userdiff_get_textconv(one->driver);
}
static void builtin_diff(const char *name_a,
diff --git a/userdiff.c b/userdiff.c
index 1ff47977d549992ada8c1236187d4516b648ee7d..5d62e795a2e922ec9cf4d259c5315eeeec176c4c 100644 (file)
--- a/userdiff.c
+++ b/userdiff.c
return NULL;
return userdiff_find_by_name(check.value);
}
+
+struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver)
+{
+ if (!driver->textconv)
+ return NULL;
+
+ if (driver->textconv_want_cache && !driver->textconv_cache) {
+ struct notes_cache *c = xmalloc(sizeof(*c));
+ struct strbuf name = STRBUF_INIT;
+
+ strbuf_addf(&name, "textconv/%s", driver->name);
+ notes_cache_init(c, name.buf, driver->textconv);
+ driver->textconv_cache = c;
+ }
+
+ return driver;
+}
diff --git a/userdiff.h b/userdiff.h
index 942d5949501027fb5d30e0d59629aab38fd2669a..4a7e78ffbcc6d552a39dcccd9008d6c11919e432 100644 (file)
--- a/userdiff.h
+++ b/userdiff.h
struct userdiff_driver *userdiff_find_by_name(const char *name);
struct userdiff_driver *userdiff_find_by_path(const char *path);
+struct userdiff_driver *userdiff_get_textconv(struct userdiff_driver *driver);
+
#endif /* USERDIFF */