Re: [PATCH v4] submodule: port subcommand 'set-url' from shell to C

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

 



On Wed, May 6, 2020 at 9:37 AM Shourya Shukla
<shouryashukla.oo@xxxxxxxxx> wrote:
>
> Convert submodule subcommand 'set-url' to a builtin. Port 'set-url'to

There is a space missing between "'set-url'" and "to".

> 'submodule--helper.c' and call the latter via 'git-submodule.sh'.
>
> Signed-off-by: Shourya Shukla <shouryashukla.oo@xxxxxxxxx>
> ---
> Thank you Junio for the review! :)
> BTW, how detailed should the commit message be about the
> patch?

It looks good to me. Maybe it could more explicitely state that the
larger goal is to convert shell code in 'git-submodule.sh' to C code
in 'submodule--helper.c'. It can be guessed from the subject though.

>  builtin/submodule--helper.c | 39 +++++++++++++++++++++++++++++++++++++
>  git-submodule.sh            | 22 +--------------------
>  2 files changed, 40 insertions(+), 21 deletions(-)
>
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index 1a4b391c88..f50745a03f 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -2246,6 +2246,44 @@ static int module_config(int argc, const char **argv, const char *prefix)
>         usage_with_options(git_submodule_helper_usage, module_config_options);
>  }
>
> +static int module_set_url(int argc, const char **argv, const char *prefix)
> +{
> +       int quiet = 0;
> +       const char *newurl;
> +       const char *path;
> +       struct strbuf config_name = STRBUF_INIT;
> +
> +       struct option set_url_options[] = {
> +               OPT__QUIET(&quiet, N_("Suppress output for setting url of a submodule")),
> +               OPT_END()
> +       };
> +
> +       const char *const usage[] = {
> +               N_("git submodule--helper set-url [--quiet] <path> <newurl>"),
> +               NULL
> +       };
> +
> +       argc = parse_options(argc, argv, prefix, set_url_options,
> +                            usage, 0);
> +
> +       if (argc!=2) {

Please add space chars around "!=" like "argc != 2".

> +               usage_with_options(usage, set_url_options);
> +               return 1;
> +       }
> +
> +       path = argv[0];
> +       newurl = argv[1];
> +
> +       strbuf_addf(&config_name, "submodule.%s.url", path);
> +
> +       config_set_in_gitmodules_file_gently(config_name.buf, newurl);
> +       sync_submodule(path, prefix, quiet ? OPT_QUIET : 0);
> +
> +       strbuf_release(&config_name);

Nit: it might be a bit simpler to define config_name as a "char *",
and then use xstrfmt() and free() instead of strbuf_addf() and
strbuf_release().

> +       return 0;
> +}



[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