Re: [PATCH v3 03/36] bundle: define subcommand -h in terms of command -h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ævar Arnfjörð Bjarmason  <avarab@xxxxxxxxx> writes:

> 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)

This of course is an improvement, but makes me wonder if we need to
device even more concise ways to simplify all these commands with
subcommands.  

Unlike the simplest case like this one, where no subcommand take any
option, a more general mechanism needs to allow some subcommands to
take their own options, so it will probably not an easy thing to do,
and a more general one that allows us to write each string only once
would probably need its own "mark-up" language, so it would probably
not be a good direction to go.  So let's declare that the pattern
used in the result of applying this patch is the optimal one and
stop there.

Thanks.

>
> Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
> ---
>  builtin/bundle.c | 29 +++++++++++++++++++----------
>  1 file changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/builtin/bundle.c b/builtin/bundle.c
> index 5c78894afd5..1b08700bf9e 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 [<options>] <file> <git-rev-list args>"),
> -	N_("git bundle verify [<options>] <file>"),
> -	N_("git bundle list-heads <file> [<refname>...]"),
> -	N_("git bundle unbundle <file> [<refname>...]"),
> -	NULL
> +#define BUILTIN_BUNDLE_CREATE_USAGE \
> +	N_("git bundle create [<options>] <file> <git-rev-list args>")
> +#define BUILTIN_BUNDLE_VERIFY_USAGE \
> +	N_("git bundle verify [<options>] <file>")
> +#define BUILTIN_BUNDLE_LIST_HEADS_USAGE \
> +	N_("git bundle list-heads <file> [<refname>...]")
> +#define BUILTIN_BUNDLE_UNBUNDLE_USAGE \
> +	N_("git bundle unbundle <file> [<refname>...]")
> +
> +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 [<options>] <file> <git-rev-list args>"),
> +	BUILTIN_BUNDLE_CREATE_USAGE,
>  	NULL
>  };
>  
>  static const char * const builtin_bundle_verify_usage[] = {
> -	N_("git bundle verify [<options>] <file>"),
> +	BUILTIN_BUNDLE_VERIFY_USAGE,
>  	NULL
>  };
>  
>  static const char * const builtin_bundle_list_heads_usage[] = {
> -	N_("git bundle list-heads <file> [<refname>...]"),
> +	BUILTIN_BUNDLE_LIST_HEADS_USAGE,
>  	NULL
>  };
>  
>  static const char * const builtin_bundle_unbundle_usage[] = {
> -	N_("git bundle unbundle <file> [<refname>...]"),
> +	BUILTIN_BUNDLE_UNBUNDLE_USAGE,
>  	NULL
>  };




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux