git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 7/7] parse-options: drop parse_opt_unknown_cb()

From
Jeff King <peff@peff.net>
Date
Mar 28, 2023, 20:58 UTC
Message-ID
<20230328205842.GG1754055@coredump.intra.peff.net>
In-Reply-To
<20230328205253.GA1753925@coredump.intra.peff.net>

This low-level callback was introduced in ce564eb1bd5 (parse-options: add parse_opt_unknown_cb(), 2016-09-05) so that we could advertise --indent-heuristic in git-blame's "-h" output, even though the option is actually handled in parse_revision_opt(). We later stopped doing so in 44ae131e384 (builtin/blame.c: remove '--indent-heuristic' from usage string, 2019-10-28).

This is a weird thing to do, and in the intervening years, we've never used it again. Let's drop the helper in the name of simplicity.

Signed-off-by: Jeff King <peff@peff.net>
---
I guess this one is an oddball in this series, is it isn't about argv
directly. But it is argv-adjacent, and it needs to happen at some point
to silence the unused parameter warning.
 parse-options-cb.c | 15 ---------------
 parse-options.h    |  3 ---
 2 files changed, 18 deletions(-)
diff --git a/parse-options-cb.c b/parse-options-cb.c
index d346dbe2100..4729277aa69 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -213,21 +213,6 @@ int parse_opt_noop_cb(const struct option *opt, const char *arg, int unset)
 	return 0;
 }
 
-/**
- * Report that the option is unknown, so that other code can handle
- * it. This can be used as a callback together with
- * OPTION_LOWLEVEL_CALLBACK to allow an option to be documented in the
- * "-h" output even if it's not being handled directly by
- * parse_options().
- */
-enum parse_opt_result parse_opt_unknown_cb(struct parse_opt_ctx_t *ctx,
-					   const struct option *opt,
-					   const char *arg, int unset)
-{
-	BUG_ON_OPT_ARG(arg);
-	return PARSE_OPT_UNKNOWN;
-}
-
 /**
  * Recreates the command-line option in the strbuf.
  */
diff --git a/parse-options.h b/parse-options.h
index 50d852f2991..60b0a758d6b 100644
--- a/parse-options.h
+++ b/parse-options.h
@@ -348,9 +348,6 @@ int parse_opt_commit(const struct option *, const char *, int);
 int parse_opt_tertiary(const struct option *, const char *, int);
 int parse_opt_string_list(const struct option *, const char *, int);
 int parse_opt_noop_cb(const struct option *, const char *, int);
-enum parse_opt_result parse_opt_unknown_cb(struct parse_opt_ctx_t *ctx,
-					   const struct option *,
-					   const char *, int);
 int parse_opt_passthru(const struct option *, const char *, int);
 int parse_opt_passthru_argv(const struct option *, const char *, int);
 /* value is enum branch_track* */
-- 
2.40.0.675.gb17cd5d94c8
Previous: Jeff KingNext: Derrick Stolee
Message 8 of 10 in “unused argc/argv/prefix parameters”
  1. 0/7 unused argc/argv/prefix parametersJeff King, Mar 28, 2023
  2. 1/7 fast-import: fix file access when run from subdirJeff King, Mar 28, 2023
  3. 2/7 builtins: always pass prefix to parse_options()Jeff King, Mar 28, 2023
  4. 3/7 builtins: annotate always-empty prefix parametersJeff King, Mar 28, 2023
  5. 4/7 builtins: mark unused prefix parametersJeff King, Mar 28, 2023
  6. 5/7 mark "argv" as unused when we check argcJeff King, Mar 28, 2023
  7. 6/7 t/helper: mark unused argv/argc argumentsJeff King, Mar 28, 2023
  8. 7/7 parse-options: drop parse_opt_unknown_cb()Jeff King, Mar 28, 2023
  9. Derrick StoleeMar 29, 2023
  10. Junio C HamanoMar 29, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.