summaryrefslogtreecommitdiff
path: root/userdiff.h
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2008-10-05 17:43:21 -0400
committerJunio C Hamano <gitster@pobox.com>2008-10-18 08:02:21 -0700
commitbe58e70dbadf3cb3f4aa5829d513d886ae8bc460 (patch)
tree5a0624e8c9113b4d5606ff0b2b8b240487924883 /userdiff.h
parente7881c3594d22eb711654d2febfd577dc4994f34 (diff)
downloadgit-be58e70dbadf3cb3f4aa5829d513d886ae8bc460.tar.gz
diff: unify external diff and funcname parsing code
Both sets of code assume that one specifies a diff profile as a gitattribute via the "diff=foo" attribute. They then pull information about that profile from the config as diff.foo.*. The code for each is currently completely separate from the other, which has several disadvantages: - there is duplication as we maintain code to create and search the separate lists of external drivers and funcname patterns - it is difficult to add new profile options, since it is unclear where they should go - the code is difficult to follow, as we rely on the "check if this file is binary" code to find the funcname pattern as a side effect. This is the first step in refactoring the binary-checking code. This patch factors out these diff profiles into "userdiff" drivers. A file with "diff=foo" uses the "foo" driver, which is specified by a single struct. Note that one major difference between the two pieces of code is that the funcname patterns are always loaded, whereas external drivers are loaded only for the "git diff" porcelain; the new code takes care to retain that situation. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'userdiff.h')
-rw-r--r--userdiff.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/userdiff.h b/userdiff.h
new file mode 100644
index 0000000000..c64c5f5669
--- /dev/null
+++ b/userdiff.h
@@ -0,0 +1,23 @@
+#ifndef USERDIFF_H
+#define USERDIFF_H
+
+struct userdiff_funcname {
+ const char *pattern;
+ int cflags;
+};
+
+struct userdiff_driver {
+ const char *name;
+ const char *external;
+ struct userdiff_funcname funcname;
+};
+
+extern struct userdiff_driver *USERDIFF_ATTR_TRUE;
+extern struct userdiff_driver *USERDIFF_ATTR_FALSE;
+
+int userdiff_config_basic(const char *k, const char *v);
+int userdiff_config_porcelain(const char *k, const char *v);
+struct userdiff_driver *userdiff_find_by_name(const char *name);
+struct userdiff_driver *userdiff_find_by_path(const char *path);
+
+#endif /* USERDIFF */