{"thread":{"id":"59492","subject":"[PATCH 0/7] unused argc/argv/prefix parameters","startedAt":"2023-03-28T20:52:57Z","lastAt":"2023-03-29T15:21:42Z","messageCount":10,"participants":["Jeff King","Derrick Stolee","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":7},"messages":[{"id":"474371","messageId":"20230328205253.GA1753925@coredump.intra.peff.net","threadId":"59492","inReplyTo":null,"subject":"[PATCH 0/7] unused argc/argv/prefix parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-28T20:52:53Z","receivedAt":"2023-03-28T20:52:57Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"More from my -Wunused-parameter silencing. The first one actually fixes\na bug. The second is a cleanup, and the rest are just UNUSED annotations\n(but grouped into similar cases).\n\n  [1/7]: fast-import: fix file access when run from subdir\n  [2/7]: builtins: always pass prefix to parse_options()\n  [3/7]: builtins: annotate always-empty prefix parameters\n  [4/7]: builtins: mark unused prefix parameters\n  [5/7]: mark \"argv\" as unused when we check argc\n  [6/7]: t/helper: mark unused argv/argc arguments\n  [7/7]: parse-options: drop parse_opt_unknown_cb()\n\n builtin.h                            | 10 ++++++++++\n builtin/check-ref-format.c           |  2 ++\n builtin/credential.c                 |  2 +-\n builtin/diff.c                       |  6 +++---\n builtin/fast-import.c                | 10 ++++++++--\n builtin/fetch-pack.c                 |  2 +-\n builtin/fsmonitor--daemon.c          |  2 +-\n builtin/get-tar-commit-id.c          |  4 +++-\n builtin/mailsplit.c                  |  2 ++\n builtin/merge-index.c                |  2 +-\n builtin/merge-ours.c                 |  2 +-\n builtin/merge-recursive.c            |  2 +-\n builtin/mktag.c                      |  2 +-\n builtin/pack-redundant.c             |  2 +-\n builtin/remote-ext.c                 |  2 ++\n builtin/remote-fd.c                  |  2 ++\n builtin/revert.c                     |  9 +++++----\n builtin/stash.c                      |  2 +-\n builtin/submodule--helper.c          |  2 +-\n builtin/unpack-file.c                |  2 +-\n builtin/unpack-objects.c             |  2 +-\n builtin/upload-archive.c             |  2 ++\n builtin/var.c                        |  2 +-\n parse-options-cb.c                   | 15 --------------\n parse-options.h                      |  3 ---\n scalar.c                             |  2 +-\n t/helper/test-ctype.c                |  2 +-\n t/helper/test-date.c                 |  2 +-\n t/helper/test-drop-caches.c          |  2 +-\n t/helper/test-dump-cache-tree.c      |  2 +-\n t/helper/test-dump-fsmonitor.c       |  2 +-\n t/helper/test-dump-split-index.c     |  2 +-\n t/helper/test-dump-untracked-cache.c |  2 +-\n t/helper/test-example-decorate.c     |  2 +-\n t/helper/test-fsmonitor-client.c     |  2 +-\n t/helper/test-hexdump.c              |  2 +-\n t/helper/test-index-version.c        |  2 +-\n t/helper/test-match-trees.c          |  2 +-\n t/helper/test-oid-array.c            |  2 +-\n t/helper/test-oidmap.c               |  2 +-\n t/helper/test-oidtree.c              |  4 ++--\n t/helper/test-online-cpus.c          |  2 +-\n t/helper/test-parse-options.c        |  4 ++--\n t/helper/test-prio-queue.c           |  2 +-\n t/helper/test-read-graph.c           |  2 +-\n t/helper/test-ref-store.c            |  5 +++--\n t/helper/test-scrap-cache-tree.c     |  2 +-\n t/helper/test-sigchain.c             |  2 +-\n t/helper/test-strcmp-offset.c        |  2 +-\n t/helper/test-submodule-config.c     |  2 +-\n t/helper/test-submodule.c            |  2 +-\n t/helper/test-trace2.c               |  6 +++---\n t/helper/test-xml-encode.c           |  2 +-\n t/t9304-fast-import-marks.sh         | 29 ++++++++++++++++++++++++++++\n 54 files changed, 115 insertions(+), 74 deletions(-)\n\n"},{"id":"474372","messageId":"20230328205413.GA1754055@coredump.intra.peff.net","threadId":"59492","inReplyTo":"20230328205253.GA1753925@coredump.intra.peff.net","subject":"[PATCH 1/7] fast-import: fix file access when run from subdir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-28T20:54:13Z","receivedAt":"2023-03-28T20:54:18Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"In cmd_fast_import(), we ignore the \"prefix\" argument entirely, even\nthough it tells us how we may have changed directory to the root of the\nrepository earlier in the process. Which means that if you run it from a\nsubdir and point to paths in the filesystem, like:\n\n  cd subdir\n  git fast-import --import-marks=foo <dump\n\nthen it will look for \"foo\" in the root of the repository, not the\ncurrent directory (\"subdir/\") which the user would have expected.\n\nWe can fix this by recording the prefix and using it as appropriate\nwhenever we open a file for reading or writing. I found each of these by\nlooking for cases where we call fopen() within fast-import.c, so this\nshould cover all cases. The new test triggers each one, as well as\nmaking sure we don't accidentally apply the prefix when --relative-marks\nis in use (since that option interprets some paths as relative to a\nspecific directory).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nIt's curious that several of the file-writing options do not respect the\n\"relative-marks\" feature. I'm not sure if that is a bug, but if so, it\nis orthogonal to this patch (and arguably fixing it now may create more\nconfusion than it's worth).\n\nI also wondered if this bug was introduced when we switched fast-import\nto a builtin. But nope, before that it did call setup_git_directory()\nitself, but ignored the prefix value which was returned.\n\n builtin/fast-import.c        | 10 ++++++++--\n t/t9304-fast-import-marks.sh | 29 +++++++++++++++++++++++++++++\n 2 files changed, 37 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin/fast-import.c b/builtin/fast-import.c\nindex f7548ff4a35..19427e05f1c 100644\n--- a/builtin/fast-import.c\n+++ b/builtin/fast-import.c\n@@ -176,6 +176,7 @@ static FILE *pack_edges;\n static unsigned int show_stats = 1;\n static int global_argc;\n static const char **global_argv;\n+static const char *global_prefix;\n \n /* Memory pools */\n static struct mem_pool fi_mem_pool = {\n@@ -3246,7 +3247,7 @@ static void parse_alias(void)\n static char* make_fast_import_path(const char *path)\n {\n \tif (!relative_marks_paths || is_absolute_path(path))\n-\t\treturn xstrdup(path);\n+\t\treturn prefix_filename(global_prefix, path);\n \treturn git_pathdup(\"info/fast-import/%s\", path);\n }\n \n@@ -3317,9 +3318,11 @@ static void option_cat_blob_fd(const char *fd)\n \n static void option_export_pack_edges(const char *edges)\n {\n+\tchar *fn = prefix_filename(global_prefix, edges);\n \tif (pack_edges)\n \t\tfclose(pack_edges);\n-\tpack_edges = xfopen(edges, \"a\");\n+\tpack_edges = xfopen(fn, \"a\");\n+\tfree(fn);\n }\n \n static void option_rewrite_submodules(const char *arg, struct string_list *list)\n@@ -3334,11 +3337,13 @@ static void option_rewrite_submodules(const char *arg, struct string_list *list)\n \tf++;\n \tCALLOC_ARRAY(ms, 1);\n \n+\tf = prefix_filename(global_prefix, f);\n \tfp = fopen(f, \"r\");\n \tif (!fp)\n \t\tdie_errno(\"cannot read '%s'\", f);\n \tread_mark_file(&ms, fp, insert_oid_entry);\n \tfclose(fp);\n+\tfree(f);\n \n \tstring_list_insert(list, s)->util = ms;\n }\n@@ -3552,6 +3557,7 @@ int cmd_fast_import(int argc, const char **argv, const char *prefix)\n \n \tglobal_argc = argc;\n \tglobal_argv = argv;\n+\tglobal_prefix = prefix;\n \n \trc_free = mem_pool_alloc(&fi_mem_pool, cmd_save * sizeof(*rc_free));\n \tfor (i = 0; i < (cmd_save - 1); i++)\ndiff --git a/t/t9304-fast-import-marks.sh b/t/t9304-fast-import-marks.sh\nindex a98ef032d94..410a871c52a 100755\n--- a/t/t9304-fast-import-marks.sh\n+++ b/t/t9304-fast-import-marks.sh\n@@ -49,4 +49,33 @@ test_expect_success 'import with submodule mapping' '\n \ttest_cmp expect actual\n '\n \n+test_expect_success 'paths adjusted for relative subdir' '\n+\tgit init deep-dst &&\n+\tmkdir deep-dst/subdir &&\n+\t>deep-dst/subdir/empty-marks &&\n+\tgit -C deep-dst/subdir fast-import \\\n+\t\t--rewrite-submodules-from=sub:../../from \\\n+\t\t--rewrite-submodules-to=sub:../../to \\\n+\t\t--import-marks=empty-marks \\\n+\t\t--export-marks=exported-marks \\\n+\t\t--export-pack-edges=exported-edges \\\n+\t\t<dump &&\n+\t# we do not bother checking resulting repo; we just care that nothing\n+\t# complained about failing to open files for reading, and that files\n+\t# for writing were created in the expected spot\n+\ttest_path_is_file deep-dst/subdir/exported-marks &&\n+\ttest_path_is_file deep-dst/subdir/exported-edges\n+'\n+\n+test_expect_success 'relative marks are not affected by subdir' '\n+\tgit init deep-relative &&\n+\tmkdir deep-relative/subdir &&\n+\tgit -C deep-relative/subdir fast-import \\\n+\t\t--relative-marks \\\n+\t\t--export-marks=exported-marks \\\n+\t\t<dump &&\n+\ttest_path_is_missing deep-relative/subdir/exported-marks &&\n+\ttest_path_is_file deep-relative/.git/info/fast-import/exported-marks\n+'\n+\n test_done\n-- \n2.40.0.675.gb17cd5d94c8\n\n"},{"id":"474373","messageId":"20230328205432.GB1754055@coredump.intra.peff.net","threadId":"59492","inReplyTo":"20230328205253.GA1753925@coredump.intra.peff.net","subject":"[PATCH 2/7] builtins: always pass prefix to parse_options()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-28T20:54:32Z","receivedAt":"2023-03-28T20:54:37Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Our builtins receive a \"prefix\" argument as part of their cmd_foo()\nfunction. We should always pass this to parse_options() if we're calling\nit, as it may be used for OPT_FILENAME() options.\n\nIn the cases here, there's no option that would use it, so we're not\nfixing any bug. This is just future-proofing and setting a good example\n(plus quelling some -Wunused-parameter warnings).\n\nNote in the case of revert/cherry-pick, that we plumb the prefix through\nto run_sequencer(), as those builtins are just thin wrappers around it.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/mktag.c  | 2 +-\n builtin/revert.c | 9 +++++----\n 2 files changed, 6 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/mktag.c b/builtin/mktag.c\nindex 42c2457c705..967a4442dee 100644\n--- a/builtin/mktag.c\n+++ b/builtin/mktag.c\n@@ -81,7 +81,7 @@ int cmd_mktag(int argc, const char **argv, const char *prefix)\n \tint tagged_type;\n \tstruct object_id result;\n \n-\targc = parse_options(argc, argv, NULL,\n+\targc = parse_options(argc, argv, prefix,\n \t\t\t     builtin_mktag_options,\n \t\t\t     builtin_mktag_usage, 0);\n \ndiff --git a/builtin/revert.c b/builtin/revert.c\nindex 62986a7b1b0..287721fd37b 100644\n--- a/builtin/revert.c\n+++ b/builtin/revert.c\n@@ -94,7 +94,8 @@ static void verify_opt_compatible(const char *me, const char *base_opt, ...)\n \t\tdie(_(\"%s: %s cannot be used with %s\"), me, this_opt, base_opt);\n }\n \n-static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)\n+static int run_sequencer(int argc, const char **argv, const char *prefix,\n+\t\t\t struct replay_opts *opts)\n {\n \tconst char * const * usage_str = revert_or_cherry_pick_usage(opts);\n \tconst char *me = action_name(opts);\n@@ -141,7 +142,7 @@ static int run_sequencer(int argc, const char **argv, struct replay_opts *opts)\n \t\toptions = parse_options_concat(options, cp_extra);\n \t}\n \n-\targc = parse_options(argc, argv, NULL, options, usage_str,\n+\targc = parse_options(argc, argv, prefix, options, usage_str,\n \t\t\tPARSE_OPT_KEEP_ARGV0 |\n \t\t\tPARSE_OPT_KEEP_UNKNOWN_OPT);\n \n@@ -246,7 +247,7 @@ int cmd_revert(int argc, const char **argv, const char *prefix)\n \n \topts.action = REPLAY_REVERT;\n \tsequencer_init_config(&opts);\n-\tres = run_sequencer(argc, argv, &opts);\n+\tres = run_sequencer(argc, argv, prefix, &opts);\n \tif (res < 0)\n \t\tdie(_(\"revert failed\"));\n \treplay_opts_release(&opts);\n@@ -260,7 +261,7 @@ int cmd_cherry_pick(int argc, const char **argv, const char *prefix)\n \n \topts.action = REPLAY_PICK;\n \tsequencer_init_config(&opts);\n-\tres = run_sequencer(argc, argv, &opts);\n+\tres = run_sequencer(argc, argv, prefix, &opts);\n \tif (res < 0)\n \t\tdie(_(\"cherry-pick failed\"));\n \treplay_opts_release(&opts);\n-- \n2.40.0.675.gb17cd5d94c8\n\n"},{"id":"474374","messageId":"20230328205517.GC1754055@coredump.intra.peff.net","threadId":"59492","inReplyTo":"20230328205253.GA1753925@coredump.intra.peff.net","subject":"[PATCH 3/7] builtins: annotate always-empty prefix parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-28T20:55:17Z","receivedAt":"2023-03-28T20:55:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"It's usually a bad idea for a builtin's cmd_foo() to ignore the \"prefix\"\nargument it gets, as it needs to prepend that string when accessing any\npaths given by the user.\n\nBut if a builtin does not ask for the git wrapper to run repository\nsetup (via the RUN_SETUP or RUN_SETUP_GENTLY flags), then we know the\nprefix will always be NULL (it is adjusting for the chdir() done during\nrepo setup, but there cannot be one if we did not set up the repo). In\nthose cases it's OK to ignore \"prefix\", but it's worth annotating for a\nfew reasons:\n\n  1. It serves as documentation to somebody reading the code about what\n     we expect.\n\n  2. If the flags in git.c ever change, the run-time assertion may help\n     detect the problem (though only if the command is run from a\n     subdirectory of the repository).\n\n  3. It notes to the compiler that we are OK ignoring \"prefix\". In\n     particular, this silences -Wunused-parameter. It _could_ also help\n     the compiler generate better code (because it will know the prefix\n     is NULL), but in practice this is quite unlikely to matter.\n\nNote that I've only added this annotation to commands which triggered\n-Wunused-parameter. It would be correct to add it to any builtin which\ndoesn't ask for RUN_SETUP, but most of the rest of them do the sensible\nthing with \"prefix\" by passing it to parse_options(). So they're much\nmore likely to just work if they ever switched to RUN_SETUP, and aren't\nworth annotating.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin.h                   | 10 ++++++++++\n builtin/check-ref-format.c  |  2 ++\n builtin/get-tar-commit-id.c |  2 ++\n builtin/mailsplit.c         |  2 ++\n builtin/remote-ext.c        |  2 ++\n builtin/remote-fd.c         |  2 ++\n builtin/upload-archive.c    |  2 ++\n 7 files changed, 22 insertions(+)\n\ndiff --git a/builtin.h b/builtin.h\nindex 46cc7897898..cb0db676814 100644\n--- a/builtin.h\n+++ b/builtin.h\n@@ -107,6 +107,16 @@ void setup_auto_pager(const char *cmd, int def);\n \n int is_builtin(const char *s);\n \n+/*\n+ * Builtins which do not use RUN_SETUP should never see\n+ * a prefix that is not empty; use this to protect downstream\n+ * code which is not prepared to call prefix_filename(), etc.\n+ */\n+#define BUG_ON_NON_EMPTY_PREFIX(prefix) do { \\\n+\tif ((prefix)) \\\n+\t\tBUG(\"unexpected prefix in builtin: %s\", (prefix)); \\\n+} while (0)\n+\n int cmd_add(int argc, const char **argv, const char *prefix);\n int cmd_am(int argc, const char **argv, const char *prefix);\n int cmd_annotate(int argc, const char **argv, const char *prefix);\ndiff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c\nindex fd0e5f86832..462eefe1023 100644\n--- a/builtin/check-ref-format.c\n+++ b/builtin/check-ref-format.c\n@@ -60,6 +60,8 @@ int cmd_check_ref_format(int argc, const char **argv, const char *prefix)\n \tchar *to_free = NULL;\n \tint ret = 1;\n \n+\tBUG_ON_NON_EMPTY_PREFIX(prefix);\n+\n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n \t\tusage(builtin_check_ref_format_usage);\n \ndiff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c\nindex 491af9202dc..8f8f2ac3e68 100644\n--- a/builtin/get-tar-commit-id.c\n+++ b/builtin/get-tar-commit-id.c\n@@ -24,6 +24,8 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)\n \tlong len;\n \tchar *end;\n \n+\tBUG_ON_NON_EMPTY_PREFIX(prefix);\n+\n \tif (argc != 1)\n \t\tusage(builtin_get_tar_commit_id_usage);\n \ndiff --git a/builtin/mailsplit.c b/builtin/mailsplit.c\nindex 73509f651bd..91e93f0c777 100644\n--- a/builtin/mailsplit.c\n+++ b/builtin/mailsplit.c\n@@ -277,6 +277,8 @@ int cmd_mailsplit(int argc, const char **argv, const char *prefix)\n \tconst char **argp;\n \tstatic const char *stdin_only[] = { \"-\", NULL };\n \n+\tBUG_ON_NON_EMPTY_PREFIX(prefix);\n+\n \tfor (argp = argv+1; *argp; argp++) {\n \t\tconst char *arg = *argp;\n \ndiff --git a/builtin/remote-ext.c b/builtin/remote-ext.c\nindex ee338bf440c..282782eccdd 100644\n--- a/builtin/remote-ext.c\n+++ b/builtin/remote-ext.c\n@@ -197,6 +197,8 @@ static int command_loop(const char *child)\n \n int cmd_remote_ext(int argc, const char **argv, const char *prefix)\n {\n+\tBUG_ON_NON_EMPTY_PREFIX(prefix);\n+\n \tif (argc != 3)\n \t\tusage(usage_msg);\n \ndiff --git a/builtin/remote-fd.c b/builtin/remote-fd.c\nindex b2a3980b1d5..9020fab9c58 100644\n--- a/builtin/remote-fd.c\n+++ b/builtin/remote-fd.c\n@@ -59,6 +59,8 @@ int cmd_remote_fd(int argc, const char **argv, const char *prefix)\n \tint output_fd = -1;\n \tchar *end;\n \n+\tBUG_ON_NON_EMPTY_PREFIX(prefix);\n+\n \tif (argc != 3)\n \t\tusage(usage_msg);\n \ndiff --git a/builtin/upload-archive.c b/builtin/upload-archive.c\nindex 945ee2b4126..7f9320ac6d0 100644\n--- a/builtin/upload-archive.c\n+++ b/builtin/upload-archive.c\n@@ -79,6 +79,8 @@ int cmd_upload_archive(int argc, const char **argv, const char *prefix)\n {\n \tstruct child_process writer = CHILD_PROCESS_INIT;\n \n+\tBUG_ON_NON_EMPTY_PREFIX(prefix);\n+\n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n \t\tusage(upload_archive_usage);\n \n-- \n2.40.0.675.gb17cd5d94c8\n\n"},{"id":"474375","messageId":"20230328205655.GD1754055@coredump.intra.peff.net","threadId":"59492","inReplyTo":"20230328205253.GA1753925@coredump.intra.peff.net","subject":"[PATCH 4/7] builtins: mark unused prefix parameters","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-28T20:56:55Z","receivedAt":"2023-03-28T20:57:20Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"All builtins receive a \"prefix\" parameter, but it is only useful if they\nneed to adjust filenames given by the user on the command line. For\nbuiltins that do not even call parse_options(), they often don't look at\nthe prefix at all, and -Wunused-parameter complains.\n\nLet's annotate those to silence the compiler warning. I gave a quick\nscan of each of these cases, and it seems like they don't have anything\nthey _should_ be using the prefix for (i.e., there is no hidden bug that\nwe are missing). The only questionable cases I saw were:\n\n  - in git-unpack-file, we create a tempfile which will always be at the\n    root of the repository, even if the command is run from a subdir.\n    Arguably this should be created in the subdir from which we're run\n    (as we report the path only as a relative name). However, nobody has\n    complained, and I'm hesitant to change something that is deep\n    plumbing going back to April 2005 (though I think within our\n    scripts, the sole caller in git-merge-one-file would be OK, as it\n    moves to the toplevel itself).\n\n  - in fetch-pack, local-filesystem remotes are taken as relative to the\n    project root, not the current directory. So:\n\n       git init server.git\n       [...put stuff in server.git...]\n       git init client.git\n       cd client.git\n       mkdir subdir\n       cd subdir\n       git fetch-pack ../../server.git ...\n\n    won't work, as we quietly move to the top of the repository before\n    interpreting the path (so \"../server.git\" would work). This is\n    weird, but again, nobody has complained and this is how it has\n    always worked. And this is how \"git fetch\" works, too. Plus it\n    raises questions about how a configured remote like:\n\n      git config remote.origin.url ../server.git\n\n    should behave. I can certainly come up with a reasonable set of\n    behavior, but it may not be worth stirring up complications in a\n    plumbing tool.\n\nSo I've left the behavior untouched in both of those cases. If anybody\nreally wants to revisit them, it's easy enough to drop the UNUSED\nmarker. This commit is just about removing them as obstacles to turning\non -Wunused-parameter all the time.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/credential.c        | 2 +-\n builtin/fetch-pack.c        | 2 +-\n builtin/fsmonitor--daemon.c | 2 +-\n builtin/merge-index.c       | 2 +-\n builtin/merge-ours.c        | 2 +-\n builtin/merge-recursive.c   | 2 +-\n builtin/pack-redundant.c    | 2 +-\n builtin/stash.c             | 2 +-\n builtin/submodule--helper.c | 2 +-\n builtin/unpack-file.c       | 2 +-\n builtin/unpack-objects.c    | 2 +-\n builtin/var.c               | 2 +-\n 12 files changed, 12 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/credential.c b/builtin/credential.c\nindex d7b304fa084..70107529876 100644\n--- a/builtin/credential.c\n+++ b/builtin/credential.c\n@@ -6,7 +6,7 @@\n static const char usage_msg[] =\n \t\"git credential (fill|approve|reject)\";\n \n-int cmd_credential(int argc, const char **argv, const char *prefix)\n+int cmd_credential(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tconst char *op;\n \tstruct credential c = CREDENTIAL_INIT;\ndiff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c\nindex d1a4306da3a..0d75e474f02 100644\n--- a/builtin/fetch-pack.c\n+++ b/builtin/fetch-pack.c\n@@ -42,7 +42,7 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc,\n \t(*sought)[*nr - 1] = ref;\n }\n \n-int cmd_fetch_pack(int argc, const char **argv, const char *prefix)\n+int cmd_fetch_pack(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tint i, ret;\n \tstruct ref *ref = NULL;\ndiff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c\nindex cae804a1908..3d4f2ae1d0c 100644\n--- a/builtin/fsmonitor--daemon.c\n+++ b/builtin/fsmonitor--daemon.c\n@@ -1575,7 +1575,7 @@ int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix)\n }\n \n #else\n-int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix)\n+int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tstruct option options[] = {\n \t\tOPT_END()\ndiff --git a/builtin/merge-index.c b/builtin/merge-index.c\nindex c875f5d37ee..b747b4ed983 100644\n--- a/builtin/merge-index.c\n+++ b/builtin/merge-index.c\n@@ -71,7 +71,7 @@ static void merge_all(void)\n \t}\n }\n \n-int cmd_merge_index(int argc, const char **argv, const char *prefix)\n+int cmd_merge_index(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tint i, force_file = 0;\n \ndiff --git a/builtin/merge-ours.c b/builtin/merge-ours.c\nindex 284eb486098..c2e519301e9 100644\n--- a/builtin/merge-ours.c\n+++ b/builtin/merge-ours.c\n@@ -14,7 +14,7 @@\n static const char builtin_merge_ours_usage[] =\n \t\"git merge-ours <base>... -- HEAD <remote>...\";\n \n-int cmd_merge_ours(int argc, const char **argv, const char *prefix)\n+int cmd_merge_ours(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n \t\tusage(builtin_merge_ours_usage);\ndiff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c\nindex b9acbf5d342..0a50d0a0ae2 100644\n--- a/builtin/merge-recursive.c\n+++ b/builtin/merge-recursive.c\n@@ -20,7 +20,7 @@ static char *better_branch_name(const char *branch)\n \treturn xstrdup(name ? name : branch);\n }\n \n-int cmd_merge_recursive(int argc, const char **argv, const char *prefix)\n+int cmd_merge_recursive(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tconst struct object_id *bases[21];\n \tunsigned bases_count = 0;\ndiff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c\nindex 82115c5808c..104d10877b4 100644\n--- a/builtin/pack-redundant.c\n+++ b/builtin/pack-redundant.c\n@@ -558,7 +558,7 @@ static void load_all(void)\n \t}\n }\n \n-int cmd_pack_redundant(int argc, const char **argv, const char *prefix)\n+int cmd_pack_redundant(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tint i;\n \tint i_still_use_this = 0;\ndiff --git a/builtin/stash.c b/builtin/stash.c\nindex 6a12fed2713..5f327435b53 100644\n--- a/builtin/stash.c\n+++ b/builtin/stash.c\n@@ -1466,7 +1466,7 @@ static int do_create_stash(const struct pathspec *ps, struct strbuf *stash_msg_b\n \treturn ret;\n }\n \n-static int create_stash(int argc, const char **argv, const char *prefix)\n+static int create_stash(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tint ret;\n \tstruct strbuf stash_msg_buf = STRBUF_INIT;\ndiff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c\nindex d05d1a84623..65a053261a9 100644\n--- a/builtin/submodule--helper.c\n+++ b/builtin/submodule--helper.c\n@@ -2766,7 +2766,7 @@ static int module_update(int argc, const char **argv, const char *prefix)\n \treturn ret;\n }\n \n-static int push_check(int argc, const char **argv, const char *prefix)\n+static int push_check(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tstruct remote *remote;\n \tconst char *superproject_head;\ndiff --git a/builtin/unpack-file.c b/builtin/unpack-file.c\nindex e9b105a5397..374d980c910 100644\n--- a/builtin/unpack-file.c\n+++ b/builtin/unpack-file.c\n@@ -24,7 +24,7 @@ static char *create_temp_file(struct object_id *oid)\n \treturn path;\n }\n \n-int cmd_unpack_file(int argc, const char **argv, const char *prefix)\n+int cmd_unpack_file(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tstruct object_id oid;\n \ndiff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c\nindex 1908dcfcffb..3d8510ccf81 100644\n--- a/builtin/unpack-objects.c\n+++ b/builtin/unpack-objects.c\n@@ -600,7 +600,7 @@ static void unpack_all(void)\n \t\tdie(\"unresolved deltas left after unpacking\");\n }\n \n-int cmd_unpack_objects(int argc, const char **argv, const char *prefix)\n+int cmd_unpack_objects(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tint i;\n \tstruct object_id oid;\ndiff --git a/builtin/var.c b/builtin/var.c\nindex d9943be9afd..acb988d2d56 100644\n--- a/builtin/var.c\n+++ b/builtin/var.c\n@@ -78,7 +78,7 @@ static int show_config(const char *var, const char *value, void *cb)\n \treturn git_default_config(var, value, cb);\n }\n \n-int cmd_var(int argc, const char **argv, const char *prefix)\n+int cmd_var(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tconst struct git_var *git_var;\n \tconst char *val;\n-- \n2.40.0.675.gb17cd5d94c8\n\n"},{"id":"474376","messageId":"20230328205704.GE1754055@coredump.intra.peff.net","threadId":"59492","inReplyTo":"20230328205253.GA1753925@coredump.intra.peff.net","subject":"[PATCH 5/7] mark \"argv\" as unused when we check argc","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-28T20:57:04Z","receivedAt":"2023-03-28T20:57:53Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"A few commands don't take any options at all, and confirm this by\nchecking argc. After that they have no need to look at argv, but we're\nstill stuck with it by convention. Let's annotate these cases so that\nthe compiler doesn't complain with -Wunused-parameter.\n\nNote that in scalar and get-tar-commit-id, we're forced to keep argv by\ncalling convention (the functions must match cmd_main() and builtin\ncmd_foo() conventions, respectively). In diff, these are subcommand\nmodes that we call individually, so we _could_ just drop the argv\nparameters entirely. But it's weird to pass argc without argv, and it\nimplies that the caller knows that the subcommands aren't interested in\nfurther arguments. It's less confusing to just keep them and silence the\ncompiler warning.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n builtin/diff.c              | 6 +++---\n builtin/get-tar-commit-id.c | 2 +-\n scalar.c                    | 2 +-\n 3 files changed, 5 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/diff.c b/builtin/diff.c\nindex 26f1e532c66..bc9da7bcb60 100644\n--- a/builtin/diff.c\n+++ b/builtin/diff.c\n@@ -74,7 +74,7 @@ static void stuff_change(struct diff_options *opt,\n }\n \n static int builtin_diff_b_f(struct rev_info *revs,\n-\t\t\t    int argc, const char **argv,\n+\t\t\t    int argc, const char **argv UNUSED,\n \t\t\t    struct object_array_entry **blob)\n {\n \t/* Blob vs file in the working tree*/\n@@ -109,7 +109,7 @@ static int builtin_diff_b_f(struct rev_info *revs,\n }\n \n static int builtin_diff_blobs(struct rev_info *revs,\n-\t\t\t      int argc, const char **argv,\n+\t\t\t      int argc, const char **argv UNUSED,\n \t\t\t      struct object_array_entry **blob)\n {\n \tconst unsigned mode = canon_mode(S_IFREG | 0644);\n@@ -209,7 +209,7 @@ static int builtin_diff_tree(struct rev_info *revs,\n }\n \n static int builtin_diff_combined(struct rev_info *revs,\n-\t\t\t\t int argc, const char **argv,\n+\t\t\t\t int argc, const char **argv UNUSED,\n \t\t\t\t struct object_array_entry *ent,\n \t\t\t\t int ents, int first_non_parent)\n {\ndiff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c\nindex 8f8f2ac3e68..4324d39fb49 100644\n--- a/builtin/get-tar-commit-id.c\n+++ b/builtin/get-tar-commit-id.c\n@@ -14,7 +14,7 @@ static const char builtin_get_tar_commit_id_usage[] =\n #define RECORDSIZE\t(512)\n #define HEADERSIZE (2 * RECORDSIZE)\n \n-int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)\n+int cmd_get_tar_commit_id(int argc, const char **argv UNUSED, const char *prefix)\n {\n \tchar buffer[HEADERSIZE];\n \tstruct ustar_header *header = (struct ustar_header *)buffer;\ndiff --git a/scalar.c b/scalar.c\nindex ca19b95ce46..c7b8c16c8ee 100644\n--- a/scalar.c\n+++ b/scalar.c\n@@ -563,7 +563,7 @@ static int cmd_diagnose(int argc, const char **argv)\n \treturn res;\n }\n \n-static int cmd_list(int argc, const char **argv)\n+static int cmd_list(int argc, const char **argv UNUSED)\n {\n \tif (argc != 1)\n \t\tdie(_(\"`scalar list` does not take arguments\"));\n-- \n2.40.0.675.gb17cd5d94c8\n\n"},{"id":"474377","messageId":"20230328205725.GF1754055@coredump.intra.peff.net","threadId":"59492","inReplyTo":"20230328205253.GA1753925@coredump.intra.peff.net","subject":"[PATCH 6/7] t/helper: mark unused argv/argc arguments","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-28T20:57:25Z","receivedAt":"2023-03-28T20:58:22Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"Many test helper programs do not bother to look at argc or argv, because\nthey don't take any options. In a user-facing program, it's a good idea\nto check for unexpected arguments and complain. But for a test helper,\nit's not worth the trouble to enforce this.\n\nBut we do want to tell the compiler we're OK with ignoring them, to\nsilence -Wunused-parameter (and obviously we can't get rid of them,\nsince we have to conform to the usual cmd__foo() interface).\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n t/helper/test-ctype.c                | 2 +-\n t/helper/test-date.c                 | 2 +-\n t/helper/test-drop-caches.c          | 2 +-\n t/helper/test-dump-cache-tree.c      | 2 +-\n t/helper/test-dump-fsmonitor.c       | 2 +-\n t/helper/test-dump-split-index.c     | 2 +-\n t/helper/test-dump-untracked-cache.c | 2 +-\n t/helper/test-example-decorate.c     | 2 +-\n t/helper/test-fsmonitor-client.c     | 2 +-\n t/helper/test-hexdump.c              | 2 +-\n t/helper/test-index-version.c        | 2 +-\n t/helper/test-match-trees.c          | 2 +-\n t/helper/test-oid-array.c            | 2 +-\n t/helper/test-oidmap.c               | 2 +-\n t/helper/test-oidtree.c              | 4 ++--\n t/helper/test-online-cpus.c          | 2 +-\n t/helper/test-parse-options.c        | 4 ++--\n t/helper/test-prio-queue.c           | 2 +-\n t/helper/test-read-graph.c           | 2 +-\n t/helper/test-ref-store.c            | 5 +++--\n t/helper/test-scrap-cache-tree.c     | 2 +-\n t/helper/test-sigchain.c             | 2 +-\n t/helper/test-strcmp-offset.c        | 2 +-\n t/helper/test-submodule-config.c     | 2 +-\n t/helper/test-submodule.c            | 2 +-\n t/helper/test-trace2.c               | 6 +++---\n t/helper/test-xml-encode.c           | 2 +-\n 27 files changed, 33 insertions(+), 32 deletions(-)\n\ndiff --git a/t/helper/test-ctype.c b/t/helper/test-ctype.c\nindex 534ca66441c..71a1a5c9b04 100644\n--- a/t/helper/test-ctype.c\n+++ b/t/helper/test-ctype.c\n@@ -47,7 +47,7 @@ static int is_in(const char *s, int ch)\n \t\"\\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17\\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f\" \\\n \t\"\\x7f\"\n \n-int cmd__ctype(int argc, const char **argv)\n+int cmd__ctype(int argc UNUSED, const char **argv UNUSED)\n {\n \tTEST_CLASS(isdigit, DIGIT);\n \tTEST_CLASS(isspace, \" \\n\\r\\t\");\ndiff --git a/t/helper/test-date.c b/t/helper/test-date.c\nindex 45951b1df87..cd6a6df7023 100644\n--- a/t/helper/test-date.c\n+++ b/t/helper/test-date.c\n@@ -104,7 +104,7 @@ static void getnanos(const char **argv)\n \tprintf(\"%lf\\n\", seconds);\n }\n \n-int cmd__date(int argc, const char **argv)\n+int cmd__date(int argc UNUSED, const char **argv)\n {\n \tconst char *x;\n \ndiff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c\nindex e37396dd9c2..73e551cfc22 100644\n--- a/t/helper/test-drop-caches.c\n+++ b/t/helper/test-drop-caches.c\n@@ -155,7 +155,7 @@ static int cmd_dropcaches(void)\n \n #endif\n \n-int cmd__drop_caches(int argc, const char **argv)\n+int cmd__drop_caches(int argc UNUSED, const char **argv UNUSED)\n {\n \tcmd_sync();\n \treturn cmd_dropcaches();\ndiff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c\nindex 92dfc1aa8c4..ba1c5ce7175 100644\n--- a/t/helper/test-dump-cache-tree.c\n+++ b/t/helper/test-dump-cache-tree.c\n@@ -57,7 +57,7 @@ static int dump_cache_tree(struct cache_tree *it,\n \treturn errs;\n }\n \n-int cmd__dump_cache_tree(int ac, const char **av)\n+int cmd__dump_cache_tree(int ac UNUSED, const char **av UNUSED)\n {\n \tstruct index_state istate;\n \tstruct cache_tree *another = cache_tree();\ndiff --git a/t/helper/test-dump-fsmonitor.c b/t/helper/test-dump-fsmonitor.c\nindex 975f0ac8905..3d2fb92ade8 100644\n--- a/t/helper/test-dump-fsmonitor.c\n+++ b/t/helper/test-dump-fsmonitor.c\n@@ -1,7 +1,7 @@\n #include \"test-tool.h\"\n #include \"cache.h\"\n \n-int cmd__dump_fsmonitor(int ac, const char **av)\n+int cmd__dump_fsmonitor(int ac UNUSED, const char **av UNUSED)\n {\n \tstruct index_state *istate = the_repository->index;\n \tint i;\ndiff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c\nindex 813d0a38fae..4fabbdea496 100644\n--- a/t/helper/test-dump-split-index.c\n+++ b/t/helper/test-dump-split-index.c\n@@ -10,7 +10,7 @@ static void show_bit(size_t pos, void *data)\n \tprintf(\" %d\", (int)pos);\n }\n \n-int cmd__dump_split_index(int ac, const char **av)\n+int cmd__dump_split_index(int ac UNUSED, const char **av)\n {\n \tstruct split_index *si;\n \tint i;\ndiff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c\nindex af953fabe87..bc1ef8d4dc0 100644\n--- a/t/helper/test-dump-untracked-cache.c\n+++ b/t/helper/test-dump-untracked-cache.c\n@@ -41,7 +41,7 @@ static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)\n \tstrbuf_setlen(base, len);\n }\n \n-int cmd__dump_untracked_cache(int ac, const char **av)\n+int cmd__dump_untracked_cache(int ac UNUSED, const char **av UNUSED)\n {\n \tstruct untracked_cache *uc;\n \tstruct strbuf base = STRBUF_INIT;\ndiff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c\nindex 7c7fc8efc13..2cf302ffcb3 100644\n--- a/t/helper/test-example-decorate.c\n+++ b/t/helper/test-example-decorate.c\n@@ -3,7 +3,7 @@\n #include \"object.h\"\n #include \"decorate.h\"\n \n-int cmd__example_decorate(int argc, const char **argv)\n+int cmd__example_decorate(int argc UNUSED, const char **argv UNUSED)\n {\n \tstruct decoration n;\n \tstruct object_id one_oid = { {1} };\ndiff --git a/t/helper/test-fsmonitor-client.c b/t/helper/test-fsmonitor-client.c\nindex 54a4856c48c..0a1e492e5bc 100644\n--- a/t/helper/test-fsmonitor-client.c\n+++ b/t/helper/test-fsmonitor-client.c\n@@ -11,7 +11,7 @@\n #include \"trace2.h\"\n \n #ifndef HAVE_FSMONITOR_DAEMON_BACKEND\n-int cmd__fsmonitor_client(int argc, const char **argv)\n+int cmd__fsmonitor_client(int argc UNUSED, const char **argv UNUSED)\n {\n \tdie(\"fsmonitor--daemon not available on this platform\");\n }\ndiff --git a/t/helper/test-hexdump.c b/t/helper/test-hexdump.c\nindex 811e89c1bcb..05f55eca21a 100644\n--- a/t/helper/test-hexdump.c\n+++ b/t/helper/test-hexdump.c\n@@ -4,7 +4,7 @@\n /*\n  * Read stdin and print a hexdump to stdout.\n  */\n-int cmd__hexdump(int argc, const char **argv)\n+int cmd__hexdump(int argc UNUSED, const char **argv UNUSED)\n {\n \tchar buf[1024];\n \tssize_t i, len;\ndiff --git a/t/helper/test-index-version.c b/t/helper/test-index-version.c\nindex fcd10968cc1..a06c45c1f84 100644\n--- a/t/helper/test-index-version.c\n+++ b/t/helper/test-index-version.c\n@@ -1,7 +1,7 @@\n #include \"test-tool.h\"\n #include \"cache.h\"\n \n-int cmd__index_version(int argc, const char **argv)\n+int cmd__index_version(int argc UNUSED, const char **argv UNUSED)\n {\n \tstruct cache_header hdr;\n \tint version;\ndiff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c\nindex 04bc2563f3e..184aa1a0870 100644\n--- a/t/helper/test-match-trees.c\n+++ b/t/helper/test-match-trees.c\n@@ -3,7 +3,7 @@\n #include \"hex.h\"\n #include \"tree.h\"\n \n-int cmd__match_trees(int ac, const char **av)\n+int cmd__match_trees(int ac UNUSED, const char **av)\n {\n \tstruct object_id hash1, hash2, shifted;\n \tstruct tree *one, *two;\ndiff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c\nindex 0906993ad59..c3a1a00466a 100644\n--- a/t/helper/test-oid-array.c\n+++ b/t/helper/test-oid-array.c\n@@ -9,7 +9,7 @@ static int print_oid(const struct object_id *oid, void *data)\n \treturn 0;\n }\n \n-int cmd__oid_array(int argc, const char **argv)\n+int cmd__oid_array(int argc UNUSED, const char **argv UNUSED)\n {\n \tstruct oid_array array = OID_ARRAY_INIT;\n \tstruct strbuf line = STRBUF_INIT;\ndiff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c\nindex 883d40efd45..ee92ae84949 100644\n--- a/t/helper/test-oidmap.c\n+++ b/t/helper/test-oidmap.c\n@@ -22,7 +22,7 @@ struct test_entry {\n  * iterate -> oidkey1 namevalue1\\noidkey2 namevalue2\\n...\n  *\n  */\n-int cmd__oidmap(int argc, const char **argv)\n+int cmd__oidmap(int argc UNUSED, const char **argv UNUSED)\n {\n \tstruct strbuf line = STRBUF_INIT;\n \tstruct oidmap map = OIDMAP_INIT;\ndiff --git a/t/helper/test-oidtree.c b/t/helper/test-oidtree.c\nindex 0b82431a70f..6a18e1bce80 100644\n--- a/t/helper/test-oidtree.c\n+++ b/t/helper/test-oidtree.c\n@@ -3,13 +3,13 @@\n #include \"hex.h\"\n #include \"oidtree.h\"\n \n-static enum cb_next print_oid(const struct object_id *oid, void *data)\n+static enum cb_next print_oid(const struct object_id *oid, void *data UNUSED)\n {\n \tputs(oid_to_hex(oid));\n \treturn CB_CONTINUE;\n }\n \n-int cmd__oidtree(int argc, const char **argv)\n+int cmd__oidtree(int argc UNUSED, const char **argv UNUSED)\n {\n \tstruct oidtree ot;\n \tstruct strbuf line = STRBUF_INIT;\ndiff --git a/t/helper/test-online-cpus.c b/t/helper/test-online-cpus.c\nindex 8cb0d53840f..47dc2117112 100644\n--- a/t/helper/test-online-cpus.c\n+++ b/t/helper/test-online-cpus.c\n@@ -2,7 +2,7 @@\n #include \"git-compat-util.h\"\n #include \"thread-utils.h\"\n \n-int cmd__online_cpus(int argc, const char **argv)\n+int cmd__online_cpus(int argc UNUSED, const char **argv UNUSED)\n {\n \tprintf(\"%d\\n\", online_cpus());\n \treturn 0;\ndiff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c\nindex 506835521a4..b66039e5751 100644\n--- a/t/helper/test-parse-options.c\n+++ b/t/helper/test-parse-options.c\n@@ -263,14 +263,14 @@ int cmd__parse_options_flags(int argc, const char **argv)\n \treturn parse_options_flags__cmd(argc, argv, test_flags);\n }\n \n-static int subcmd_one(int argc, const char **argv, const char *prefix)\n+static int subcmd_one(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tprintf(\"fn: subcmd_one\\n\");\n \tprint_args(argc, argv);\n \treturn 0;\n }\n \n-static int subcmd_two(int argc, const char **argv, const char *prefix)\n+static int subcmd_two(int argc, const char **argv, const char *prefix UNUSED)\n {\n \tprintf(\"fn: subcmd_two\\n\");\n \tprint_args(argc, argv);\ndiff --git a/t/helper/test-prio-queue.c b/t/helper/test-prio-queue.c\nindex 4915412e074..f0bf255f5f0 100644\n--- a/t/helper/test-prio-queue.c\n+++ b/t/helper/test-prio-queue.c\n@@ -16,7 +16,7 @@ static void show(int *v)\n \tfree(v);\n }\n \n-int cmd__prio_queue(int argc, const char **argv)\n+int cmd__prio_queue(int argc UNUSED, const char **argv)\n {\n \tstruct prio_queue pq = { intcmp };\n \ndiff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c\nindex 98b73bb8f25..f92aea9d1fd 100644\n--- a/t/helper/test-read-graph.c\n+++ b/t/helper/test-read-graph.c\n@@ -5,7 +5,7 @@\n #include \"object-store.h\"\n #include \"bloom.h\"\n \n-int cmd__read_graph(int argc, const char **argv)\n+int cmd__read_graph(int argc UNUSED, const char **argv UNUSED)\n {\n \tstruct commit_graph *graph = NULL;\n \tstruct object_directory *odb;\ndiff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c\nindex 1745b088b7c..31c79a777a0 100644\n--- a/t/helper/test-ref-store.c\n+++ b/t/helper/test-ref-store.c\n@@ -201,7 +201,8 @@ static int cmd_verify_ref(struct ref_store *refs, const char **argv)\n \treturn ret;\n }\n \n-static int cmd_for_each_reflog(struct ref_store *refs, const char **argv)\n+static int cmd_for_each_reflog(struct ref_store *refs,\n+\t\t\t       const char **argv UNUSED)\n {\n \treturn refs_for_each_reflog(refs, each_ref, NULL);\n }\n@@ -323,7 +324,7 @@ static struct command commands[] = {\n \t{ NULL, NULL }\n };\n \n-int cmd__ref_store(int argc, const char **argv)\n+int cmd__ref_store(int argc UNUSED, const char **argv)\n {\n \tstruct ref_store *refs;\n \tconst char *func;\ndiff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c\nindex a26107ed70a..8a42c475b3b 100644\n--- a/t/helper/test-scrap-cache-tree.c\n+++ b/t/helper/test-scrap-cache-tree.c\n@@ -5,7 +5,7 @@\n #include \"tree.h\"\n #include \"cache-tree.h\"\n \n-int cmd__scrap_cache_tree(int ac, const char **av)\n+int cmd__scrap_cache_tree(int ac UNUSED, const char **av UNUSED)\n {\n \tstruct lock_file index_lock = LOCK_INIT;\n \ndiff --git a/t/helper/test-sigchain.c b/t/helper/test-sigchain.c\nindex d1cf7377b7c..2d5ecf73831 100644\n--- a/t/helper/test-sigchain.c\n+++ b/t/helper/test-sigchain.c\n@@ -13,7 +13,7 @@ X(two)\n X(three)\n #undef X\n \n-int cmd__sigchain(int argc, const char **argv)\n+int cmd__sigchain(int argc UNUSED, const char **argv UNUSED)\n {\n \tsigchain_push(SIGTERM, one);\n \tsigchain_push(SIGTERM, two);\ndiff --git a/t/helper/test-strcmp-offset.c b/t/helper/test-strcmp-offset.c\nindex 44e4a6d143e..96b9a5b5291 100644\n--- a/t/helper/test-strcmp-offset.c\n+++ b/t/helper/test-strcmp-offset.c\n@@ -1,7 +1,7 @@\n #include \"test-tool.h\"\n #include \"cache.h\"\n \n-int cmd__strcmp_offset(int argc, const char **argv)\n+int cmd__strcmp_offset(int argc UNUSED, const char **argv)\n {\n \tint result;\n \tsize_t offset;\ndiff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c\nindex 22a41c40926..edeee41abdd 100644\n--- a/t/helper/test-submodule-config.c\n+++ b/t/helper/test-submodule-config.c\n@@ -4,7 +4,7 @@\n #include \"submodule-config.h\"\n #include \"submodule.h\"\n \n-static void die_usage(int argc, const char **argv, const char *msg)\n+static void die_usage(int argc UNUSED, const char **argv, const char *msg)\n {\n \tfprintf(stderr, \"%s\\n\", msg);\n \tfprintf(stderr, \"Usage: %s [<commit> <submodulepath>] ...\\n\", argv[0]);\ndiff --git a/t/helper/test-submodule.c b/t/helper/test-submodule.c\nindex e060cc62268..3b75358723c 100644\n--- a/t/helper/test-submodule.c\n+++ b/t/helper/test-submodule.c\n@@ -174,7 +174,7 @@ static int cmd__submodule_config_unset(int argc, const char **argv)\n \tusage_with_options(usage, options);\n }\n \n-static int cmd__submodule_config_writeable(int argc, const char **argv)\n+static int cmd__submodule_config_writeable(int argc, const char **argv UNUSED)\n {\n \tstruct option options[] = {\n \t\tOPT_END()\ndiff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c\nindex f374c21ec32..688c8d017db 100644\n--- a/t/helper/test-trace2.c\n+++ b/t/helper/test-trace2.c\n@@ -208,23 +208,23 @@ static int ut_007BUG(int argc, const char **argv)\n \tBUG(\"the bug message\");\n }\n \n-static int ut_008bug(int argc, const char **argv)\n+static int ut_008bug(int argc UNUSED, const char **argv UNUSED)\n {\n \tbug(\"a bug message\");\n \tbug(\"another bug message\");\n \tBUG_if_bug(\"an explicit BUG_if_bug() following bug() call(s) is nice, but not required\");\n \treturn 0;\n }\n \n-static int ut_009bug_BUG(int argc, const char **argv)\n+static int ut_009bug_BUG(int argc UNUSED, const char **argv UNUSED)\n {\n \tbug(\"a bug message\");\n \tbug(\"another bug message\");\n \t/* The BUG_if_bug(...) isn't here, but we'll spot bug() calls on exit()! */\n \treturn 0;\n }\n \n-static int ut_010bug_BUG(int argc, const char **argv)\n+static int ut_010bug_BUG(int argc UNUSED, const char **argv UNUSED)\n {\n \tbug(\"a %s message\", \"bug\");\n \tBUG(\"a %s message\", \"BUG\");\ndiff --git a/t/helper/test-xml-encode.c b/t/helper/test-xml-encode.c\nindex a648bbd961c..b2f330d1a44 100644\n--- a/t/helper/test-xml-encode.c\n+++ b/t/helper/test-xml-encode.c\n@@ -6,7 +6,7 @@ static const char *utf8_replace_character = \"&#xfffd;\";\n  * Encodes (possibly incorrect) UTF-8 on <stdin> to <stdout>, to be embedded\n  * in an XML file.\n  */\n-int cmd__xml_encode(int argc, const char **argv)\n+int cmd__xml_encode(int argc UNUSED, const char **argv UNUSED)\n {\n \tunsigned char buf[1024], tmp[4], *tmp2 = NULL;\n \tssize_t cur = 0, len = 1, remaining = 0;\n-- \n2.40.0.675.gb17cd5d94c8\n\n"},{"id":"474378","messageId":"20230328205842.GG1754055@coredump.intra.peff.net","threadId":"59492","inReplyTo":"20230328205253.GA1753925@coredump.intra.peff.net","subject":"[PATCH 7/7] parse-options: drop parse_opt_unknown_cb()","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2023-03-28T20:58:42Z","receivedAt":"2023-03-28T20:59:08Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This low-level callback was introduced in ce564eb1bd5 (parse-options:\nadd parse_opt_unknown_cb(), 2016-09-05) so that we could advertise\n--indent-heuristic in git-blame's \"-h\" output, even though the option is\nactually handled in parse_revision_opt(). We later stopped doing so in\n44ae131e384 (builtin/blame.c: remove '--indent-heuristic' from usage\nstring, 2019-10-28).\n\nThis is a weird thing to do, and in the intervening years, we've never\nused it again. Let's drop the helper in the name of simplicity.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\nI guess this one is an oddball in this series, is it isn't about argv\ndirectly. But it is argv-adjacent, and it needs to happen at some point\nto silence the unused parameter warning.\n\n parse-options-cb.c | 15 ---------------\n parse-options.h    |  3 ---\n 2 files changed, 18 deletions(-)\n\ndiff --git a/parse-options-cb.c b/parse-options-cb.c\nindex d346dbe2100..4729277aa69 100644\n--- a/parse-options-cb.c\n+++ b/parse-options-cb.c\n@@ -213,21 +213,6 @@ int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset)\n \treturn 0;\n }\n \n-/**\n- * Report that the option is unknown, so that other code can handle\n- * it. This can be used as a callback together with\n- * OPTION_LOWLEVEL_CALLBACK to allow an option to be documented in the\n- * \"-h\" output even if it's not being handled directly by\n- * parse_options().\n- */\n-enum parse_opt_result parse_opt_unknown_cb(struct parse_opt_ctx_t *ctx,\n-\t\t\t\t\t   const struct option *opt,\n-\t\t\t\t\t   const char *arg, int unset)\n-{\n-\tBUG_ON_OPT_ARG(arg);\n-\treturn PARSE_OPT_UNKNOWN;\n-}\n-\n /**\n  * Recreates the command-line option in the strbuf.\n  */\ndiff --git a/parse-options.h b/parse-options.h\nindex 50d852f2991..60b0a758d6b 100644\n--- a/parse-options.h\n+++ b/parse-options.h\n@@ -348,9 +348,6 @@ int parse_opt_commit(const struct option *, const char *, int);\n int parse_opt_tertiary(const struct option *, const char *, int);\n int parse_opt_string_list(const struct option *, const char *, int);\n int parse_opt_noop_cb(const struct option *, const char *, int);\n-enum parse_opt_result parse_opt_unknown_cb(struct parse_opt_ctx_t *ctx,\n-\t\t\t\t\t   const struct option *,\n-\t\t\t\t\t   const char *, int);\n int parse_opt_passthru(const struct option *, const char *, int);\n int parse_opt_passthru_argv(const struct option *, const char *, int);\n /* value is enum branch_track* */\n-- \n2.40.0.675.gb17cd5d94c8\n"},{"id":"474407","messageId":"90a8dd7d-59ed-8de8-27c7-c7dc9cf8a77a@github.com","threadId":"59492","inReplyTo":"20230328205253.GA1753925@coredump.intra.peff.net","subject":"Re: [PATCH 0/7] unused argc/argv/prefix parameters","fromName":"Derrick Stolee","fromEmail":"derrickstolee@github.com","sentAt":"2023-03-29T13:17:18Z","receivedAt":"2023-03-29T13:17:32Z","isPatch":true,"sender":{"key":"stolee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/570044?v=4"},"body":"On 3/28/2023 4:52 PM, Jeff King wrote:\n> More from my -Wunused-parameter silencing. The first one actually fixes\n> a bug. The second is a cleanup, and the rest are just UNUSED annotations\n> (but grouped into similar cases).\n\nThis was easy to read and LGTM.\n\nThanks,\n-Stolee\n"},{"id":"474409","messageId":"xmqqv8ijd1mn.fsf@gitster.g","threadId":"59492","inReplyTo":"90a8dd7d-59ed-8de8-27c7-c7dc9cf8a77a@github.com","subject":"Re: [PATCH 0/7] unused argc/argv/prefix parameters","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-03-29T15:21:36Z","receivedAt":"2023-03-29T15:21:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Derrick Stolee <derrickstolee@github.com> writes:\n\n> On 3/28/2023 4:52 PM, Jeff King wrote:\n>> More from my -Wunused-parameter silencing. The first one actually fixes\n>> a bug. The second is a cleanup, and the rest are just UNUSED annotations\n>> (but grouped into similar cases).\n>\n> This was easy to read and LGTM.\n\nThanks, both, for writing and reviewing.  I agree that the series\nwas a clear and easy read.\n\nLet's merge it down to 'next'.\n\n"}]}