1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-08 19:06:20 +02:00
git/t/helper/test-userdiff.c
Jeff King 783a86c142 config: mark unused callback parameters
The callback passed to git_config() must conform to a particular
interface. But most callbacks don't actually look at the extra "void
*data" parameter. Let's mark the unused parameters to make
-Wunused-parameter happy.

Note there's one unusual case here in get_remote_default() where we
actually ignore the "value" parameter. That's because it's only checking
whether the option is found at all, and not parsing its value.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2022-08-19 12:18:55 -07:00

47 lines
1.1 KiB
C

#include "test-tool.h"
#include "cache.h"
#include "userdiff.h"
#include "config.h"
static int driver_cb(struct userdiff_driver *driver,
enum userdiff_driver_type type, void *priv)
{
enum userdiff_driver_type *want_type = priv;
if (type & *want_type && driver->funcname.pattern)
puts(driver->name);
return 0;
}
static int cmd__userdiff_config(const char *var, const char *value, void *UNUSED(cb))
{
if (userdiff_config(var, value) < 0)
return -1;
return 0;
}
int cmd__userdiff(int argc, const char **argv)
{
enum userdiff_driver_type want = 0;
if (argc != 2)
return 1;
if (!strcmp(argv[1], "list-drivers"))
want = (USERDIFF_DRIVER_TYPE_BUILTIN |
USERDIFF_DRIVER_TYPE_CUSTOM);
else if (!strcmp(argv[1], "list-builtin-drivers"))
want = USERDIFF_DRIVER_TYPE_BUILTIN;
else if (!strcmp(argv[1], "list-custom-drivers"))
want = USERDIFF_DRIVER_TYPE_CUSTOM;
else
return error("unknown argument %s", argv[1]);
if (want & USERDIFF_DRIVER_TYPE_CUSTOM) {
setup_git_directory();
git_config(cmd__userdiff_config, NULL);
}
for_each_userdiff_driver(driver_cb, &want);
return 0;
}