All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Couder <christian.couder@gmail.com>
To: Shourya Shukla <shouryashukla.oo@gmail.com>
Cc: git <git@vger.kernel.org>, Junio C Hamano <gitster@pobox.com>,
	Kaartic Sivaraam <kaartic.sivaraam@gmail.com>,
	Denton Liu <liu.denton@gmail.com>
Subject: Re: [PATCH v4] submodule: port subcommand 'set-url' from shell to C
Date: Wed, 6 May 2020 10:09:31 +0200	[thread overview]
Message-ID: <CAP8UFD0o7WwibV8+cwYOO949BkBggSphi0zbgPUZsk6nfvYyHQ@mail.gmail.com> (raw)
In-Reply-To: <20200506073717.9789-1-shouryashukla.oo@gmail.com>

On Wed, May 6, 2020 at 9:37 AM Shourya Shukla
<shouryashukla.oo@gmail.com> 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@gmail.com>
> ---
> 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;
> +}

  reply	other threads:[~2020-05-06  8:09 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-06  7:37 [PATCH v4] submodule: port subcommand 'set-url' from shell to C Shourya Shukla
2020-05-06  8:09 ` Christian Couder [this message]
2020-05-06 16:31   ` Shourya Shukla
2020-05-06 17:16     ` Junio C Hamano
2020-05-06 17:12 ` Junio C Hamano
2020-05-06 18:12   ` Shourya Shukla
2020-05-06 18:22     ` Junio C Hamano
2020-05-07  4:40       ` Shourya Shukla
2020-05-07  5:08         ` Junio C Hamano
2020-05-08  5:47           ` Shourya Shukla
2020-05-08  6:18             ` Christian Couder
2020-05-08 15:18               ` Re* " Junio C Hamano
2020-05-08 15:38                 ` Eric Sunshine
2020-05-08 15:57                   ` Junio C Hamano
2020-05-08 16:13                     ` Eric Sunshine
2020-05-08 16:38                       ` Junio C Hamano
2020-05-08 17:51                         ` Eric Sunshine
2020-05-08  6:21 ` [PATCH v5] " Shourya Shukla
2020-05-08  6:30   ` Denton Liu
2020-05-08 16:13     ` Junio C Hamano
2020-05-08 16:17     ` Junio C Hamano
2020-05-08 16:18   ` [PATCH v6] " Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAP8UFD0o7WwibV8+cwYOO949BkBggSphi0zbgPUZsk6nfvYyHQ@mail.gmail.com \
    --to=christian.couder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=kaartic.sivaraam@gmail.com \
    --cc=liu.denton@gmail.com \
    --cc=shouryashukla.oo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.