From f587d16471a8ce438b7d19afe6f3cdbf5a42cb63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Date: Thu, 13 Oct 2022 17:38:58 +0200 Subject: [PATCH] bundle: define subcommand -h in terms of command -h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Avoid repeating the "-h" output for the "git bundle" command, and instead define the usage of each subcommand with macros, so that the "-h" output for the command itself can re-use those definitions. See [1], [2] and [3] for prior art using the same pattern. 1. b25b727494f (builtin/multi-pack-index.c: define common usage with a macro, 2021-03-30) 2. 8757b35d443 (commit-graph: define common usage with a macro, 2021-08-23) 3. 1e91d3faf6c (reflog: move "usage" variables and use macros, 2022-03-17) Signed-off-by: Ævar Arnfjörð Bjarmason Signed-off-by: Junio C Hamano --- builtin/bundle.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/builtin/bundle.c b/builtin/bundle.c index 5c78894afd..1b08700bf9 100644 --- a/builtin/bundle.c +++ b/builtin/bundle.c @@ -11,31 +11,40 @@ * bundle supporting "fetch", "pull", and "ls-remote". */ -static const char * const builtin_bundle_usage[] = { - N_("git bundle create [] "), - N_("git bundle verify [] "), - N_("git bundle list-heads [...]"), - N_("git bundle unbundle [...]"), - NULL +#define BUILTIN_BUNDLE_CREATE_USAGE \ + N_("git bundle create [] ") +#define BUILTIN_BUNDLE_VERIFY_USAGE \ + N_("git bundle verify [] ") +#define BUILTIN_BUNDLE_LIST_HEADS_USAGE \ + N_("git bundle list-heads [...]") +#define BUILTIN_BUNDLE_UNBUNDLE_USAGE \ + N_("git bundle unbundle [...]") + +static char const * const builtin_bundle_usage[] = { + BUILTIN_BUNDLE_CREATE_USAGE, + BUILTIN_BUNDLE_VERIFY_USAGE, + BUILTIN_BUNDLE_LIST_HEADS_USAGE, + BUILTIN_BUNDLE_UNBUNDLE_USAGE, + NULL, }; static const char * const builtin_bundle_create_usage[] = { - N_("git bundle create [] "), + BUILTIN_BUNDLE_CREATE_USAGE, NULL }; static const char * const builtin_bundle_verify_usage[] = { - N_("git bundle verify [] "), + BUILTIN_BUNDLE_VERIFY_USAGE, NULL }; static const char * const builtin_bundle_list_heads_usage[] = { - N_("git bundle list-heads [...]"), + BUILTIN_BUNDLE_LIST_HEADS_USAGE, NULL }; static const char * const builtin_bundle_unbundle_usage[] = { - N_("git bundle unbundle [...]"), + BUILTIN_BUNDLE_UNBUNDLE_USAGE, NULL };