[PATCH 4/7] builtin/commit-graph: drop global "--object-dir=" switch
flat view
HOTtoday
From: Patrick Steinhardt <hidden>
Date: 2026-10-28 12:02:48
Subsystem:
the rest · Maintainer:
Linus Torvalds
When invoking git-commit-graph(1) it is possible for the user to pass the "--object-dir=" switch either before or after the subcommand: both "git commit-graph --object-dir= write" and "git commit-graph write --object-dir=" do the same thing. This calling convention is very atypical in Git, we don't document this and none of our tests even use the former syntax. Furthermore, this requires us to keep track of the object directory via global state as we don't have an easy way to pass the parsed option down to the individual subcommands. We _could_ of course adapt the logic and prepend the object directory to the `argv` we end up passing down. But that feels rather pointless. Adapt the code to only allow the "--object-dir=" option for subcommands. This brings the command in line with how Git typically handles options, and it avoids adding complexity in subsequent commits where we're about to remove all global state in "builtin/commit-graph.c". Signed-off-by: Patrick Steinhardt <redacted> --- builtin/commit-graph.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index f8825980f40..7140433a39a 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c@@ -365,12 +365,11 @@ int cmd_commit_graph(int argc, struct repository *repo) { parse_opt_subcommand_fn *fn = NULL; - struct option builtin_commit_graph_options[] = { + struct option options[] = { OPT_SUBCOMMAND("verify", &fn, cmd_commit_graph_verify), OPT_SUBCOMMAND("write", &fn, cmd_commit_graph_write), OPT_END(), }; - struct option *options = parse_options_concat(builtin_commit_graph_options, common_opts); repo_config(repo, git_default_config, NULL);
@@ -379,7 +378,6 @@ int cmd_commit_graph(int argc, argc = parse_options(argc, argv, prefix, options, builtin_commit_graph_usage, 0); - FREE_AND_NULL(options); return fn(argc, argv, prefix, repo); }
--
2.56.0.341.g393f52fd96.dirty