]>
Commit | Line | Data |
---|---|---|
28e8f0d5 | 1 | #include "test-tool.h" |
e38da487 | 2 | #include "setup.h" |
28e8f0d5 ÆAB |
3 | #include "userdiff.h" |
4 | #include "config.h" | |
5 | ||
6 | static int driver_cb(struct userdiff_driver *driver, | |
7 | enum userdiff_driver_type type, void *priv) | |
8 | { | |
9 | enum userdiff_driver_type *want_type = priv; | |
10 | if (type & *want_type && driver->funcname.pattern) | |
11 | puts(driver->name); | |
12 | return 0; | |
13 | } | |
14 | ||
a4e7e317 GC |
15 | static int cmd__userdiff_config(const char *var, const char *value, |
16 | const struct config_context *ctx UNUSED, | |
17 | void *cb UNUSED) | |
28e8f0d5 ÆAB |
18 | { |
19 | if (userdiff_config(var, value) < 0) | |
20 | return -1; | |
21 | return 0; | |
22 | } | |
23 | ||
24 | int cmd__userdiff(int argc, const char **argv) | |
25 | { | |
26 | enum userdiff_driver_type want = 0; | |
27 | if (argc != 2) | |
28 | return 1; | |
29 | ||
30 | if (!strcmp(argv[1], "list-drivers")) | |
31 | want = (USERDIFF_DRIVER_TYPE_BUILTIN | | |
32 | USERDIFF_DRIVER_TYPE_CUSTOM); | |
33 | else if (!strcmp(argv[1], "list-builtin-drivers")) | |
34 | want = USERDIFF_DRIVER_TYPE_BUILTIN; | |
35 | else if (!strcmp(argv[1], "list-custom-drivers")) | |
36 | want = USERDIFF_DRIVER_TYPE_CUSTOM; | |
37 | else | |
38 | return error("unknown argument %s", argv[1]); | |
39 | ||
40 | if (want & USERDIFF_DRIVER_TYPE_CUSTOM) { | |
41 | setup_git_directory(); | |
42 | git_config(cmd__userdiff_config, NULL); | |
43 | } | |
44 | ||
45 | for_each_userdiff_driver(driver_cb, &want); | |
46 | ||
47 | return 0; | |
48 | } |