Re: [PATCHv6 2/7] submodule helper: support super prefix

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

 



On Thu, Dec 8, 2016 at 8:46 AM, Stefan Beller <sbeller@xxxxxxxxxx> wrote:
> Just like main commands in Git, the submodule helper needs
> access to the superproject prefix. Enable this in the git.c
> but have its own fuse in the helper code by having a flag to
> turn on the super prefix.
>
> Signed-off-by: Stefan Beller <sbeller@xxxxxxxxxx>
> Signed-off-by: Junio C Hamano <gitster@xxxxxxxxx>
> ---
>  builtin/submodule--helper.c | 31 ++++++++++++++++++++-----------
>  git.c                       |  2 +-
>  2 files changed, 21 insertions(+), 12 deletions(-)
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 4beeda5f9f..33676a57cf 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -1076,21 +1076,24 @@ static int resolve_remote_submodule_branch(int argc, const char **argv,
>         return 0;
>  }
>
> +#define SUPPORT_SUPER_PREFIX (1<<0)
> +
>  struct cmd_struct {
>         const char *cmd;
>         int (*fn)(int, const char **, const char *);
> +       int option;

unsigned int is probably safer for variables that are used as bit-flags.

>  int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
> @@ -1100,9 +1103,15 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
>                 die(_("submodule--helper subcommand must be "
>                       "called with a subcommand"));
>
> -       for (i = 0; i < ARRAY_SIZE(commands); i++)
> -               if (!strcmp(argv[1], commands[i].cmd))
> +       for (i = 0; i < ARRAY_SIZE(commands); i++) {
> +               if (!strcmp(argv[1], commands[i].cmd)) {
> +                       if (get_super_prefix() &&
> +                           !(commands[i].option & SUPPORT_SUPER_PREFIX))
> +                               die("%s doesn't support --super-prefix",
> +                                   commands[i].cmd);

If it's meant for users to see, please _() the string.

>                         return commands[i].fn(argc - 1, argv + 1, prefix);
> +               }
> +       }
>
>         die(_("'%s' is not a valid submodule--helper "
>               "subcommand"), argv[1]);
> diff --git a/git.c b/git.c
> index efa1059fe0..98dcf6c518 100644
> --- a/git.c
> +++ b/git.c
> @@ -493,7 +493,7 @@ static struct cmd_struct commands[] = {
>         { "stage", cmd_add, RUN_SETUP | NEED_WORK_TREE },
>         { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
>         { "stripspace", cmd_stripspace },
> -       { "submodule--helper", cmd_submodule__helper, RUN_SETUP },
> +       { "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX},

The same macro defined twice in two separate .c files? Hmm.. it
confused me a bit because i thought there was a connection.. I guess
it's ok.
-- 
Duy



[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]