Raw
1 #ifndef USERDIFF_H
2 #define USERDIFF_H
3
4 #include "notes-cache.h"
5
6 struct index_state;
7 struct repository;
8
9 struct userdiff_funcname {
10 const char *pattern;
11 char *pattern_owned;
12 int cflags;
13 };
14
15 struct external_diff {
16 char *cmd;
17 unsigned trust_exit_code:1;
18 };
19
20 struct userdiff_driver {
21 const char *name;
22 struct external_diff external;
23 const char *algorithm;
24 char *algorithm_owned;
25 int binary;
26 struct userdiff_funcname funcname;
27 const char *word_regex;
28 char *word_regex_owned;
29 const char *word_regex_multi_byte;
30 const char *textconv;
31 char *textconv_owned;
32 struct notes_cache *textconv_cache;
33 int textconv_want_cache;
34 const char *process;
35 char *process_owned;
36 };
37 enum userdiff_driver_type {
38 USERDIFF_DRIVER_TYPE_BUILTIN = 1<<0,
39 USERDIFF_DRIVER_TYPE_CUSTOM = 1<<1,
40 };
41 typedef int (*each_userdiff_driver_fn)(struct userdiff_driver *,
42 enum userdiff_driver_type, void *);
43
44 int userdiff_config(const char *k, const char *v);
45 struct userdiff_driver *userdiff_find_by_name(const char *name);
46 struct userdiff_driver *userdiff_find_by_path(struct index_state *istate,
47 const char *path);
48
49 /*
50 * Initialize any textconv-related fields in the driver and return it, or NULL
51 * if it does not have textconv enabled at all.
52 */
53 struct userdiff_driver *userdiff_get_textconv(struct repository *r,
54 struct userdiff_driver *driver);
55
56 /*
57 * Iterate over all userdiff drivers. The userdiff_driver_type
58 * argument to each_userdiff_driver_fn indicates their type. Return
59 * non-zero to exit early from the loop.
60 */
61 int for_each_userdiff_driver(each_userdiff_driver_fn, void *);
62
63 #endif /* USERDIFF */