Thread (164 messages) flat view 164 messages, 7 authors, 2021-09-18

Re: [PATCH v2 4/4] builtin/multi-pack-index.c: split sub-commands

From: Taylor Blau <hidden>
Date: 2021-02-15 22:35:37
Subsystem: the rest · Maintainer: Linus Torvalds

On Mon, Feb 15, 2021 at 10:54:31PM +0100, Ævar Arnfjörð Bjarmason wrote:
On Mon, Feb 15 2021, Taylor Blau wrote:
quoted
 	trace2_cmd_mode(argv[0]);
Not a new issue, but curious that in the commit-graph.c code we'll first
validate, but here write garbage into the trace2_cmd_mode() before
potentially dying.
Yeah, that's a good catch.
I realize this is the existing behavior, but let's just make this die()
be the usage_with_options() we emit above in this case?

So maybe this on top?
I split this into two patches: one to move the trace2_cmd_mode() calls
around, and another to replace the final 'die()' with the usage text.

Like I said in my review of your patches to the commit-graph builtin
here:

    https://lore.kernel.org/git/YCrDGhIq7kU57p1s@nand.local/ (local)

I don't find the 'if (argc && ...)' style more readable, so the second
patch looks like this instead:
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index 5ab80bc722..ce4f1a0bcb 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -165,5 +165,6 @@ int cmd_multi_pack_index(int argc, const char **argv,
        else if (!strcmp(argv[0], "expire"))
                return cmd_multi_pack_index_expire(argc, argv);
        else
-               die(_("unrecognized subcommand: %s"), argv[0]);
+               usage_with_options(builtin_multi_pack_index_usage,
+                                  builtin_multi_pack_index_options);
 }
Is it OK if I use your Signed-off-by on both of those two new patches?

Thanks,
Taylor
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help