]> git.ipfire.org Git - thirdparty/git.git/blob - t/helper/test-userdiff.c
Merge branch 'bb/unicode-width-table-15'
[thirdparty/git.git] / t / helper / test-userdiff.c
1 #include "test-tool.h"
2 #include "setup.h"
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
15 static int cmd__userdiff_config(const char *var, const char *value,
16 const struct config_context *ctx UNUSED,
17 void *cb UNUSED)
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 }