interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / helper / test-userdiff.c

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