5cf88fd8b0
As reported in [1] the "UNUSED(var)" macro introduced in
2174b8c75de (Merge branch 'jk/unused-annotation' into next,
2022-08-24) breaks coccinelle's parsing of our sources in files where
it occurs.
Let's instead partially go with the approach suggested in [2] of
making this not take an argument. As noted in [1] "coccinelle" will
ignore such tokens in argument lists that it doesn't know about, and
it's less of a surprise to syntax highlighters.
This undoes the "help us notice when a parameter marked as unused is
actually use" part of 9b24034754
(git-compat-util: add UNUSED macro,
2022-08-19), a subsequent commit will further tweak the macro to
implement a replacement for that functionality.
1. https://lore.kernel.org/git/220825.86ilmg4mil.gmgdl@evledraar.gmail.com/
2. https://lore.kernel.org/git/220819.868rnk54ju.gmgdl@evledraar.gmail.com/
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
47 lines
1.1 KiB
C
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 *cb UNUSED)
|
|
{
|
|
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;
|
|
}
|