git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Christian Couder <christian.couder@gmail.com>
Date
May 6, 2020, 08:09 UTC
Message-ID
<CAP8UFD0o7WwibV8+cwYOO949BkBggSphi0zbgPUZsk6nfvYyHQ@mail.gmail.com>
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".
Show 7 quoted lines
> '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.

Show 33 quoted lines
>  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".
Show 13 quoted lines
> +               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;
> +}
Previous: Shourya ShuklaNext: Shourya Shukla
Message 2 of 22 in “submodule: port subcommand 'set-url' from shell to C”
  1. submodule: port subcommand 'set-url' from shell to CShourya Shukla, May 6, 2020
  2. Christian CouderMay 6, 2020
  3. Shourya ShuklaMay 6, 2020
  4. Junio C HamanoMay 6, 2020
  5. Junio C HamanoMay 6, 2020
  6. Shourya ShuklaMay 6, 2020
  7. Junio C HamanoMay 6, 2020
  8. Shourya ShuklaMay 7, 2020
  9. Junio C HamanoMay 7, 2020
  10. Shourya ShuklaMay 8, 2020
  11. Christian CouderMay 8, 2020
  12. Re* [PATCH v4] submodule: port subcommand 'set-url' from shell to CJunio C Hamano, May 8, 2020
  13. Eric SunshineMay 8, 2020
  14. Junio C HamanoMay 8, 2020
  15. Eric SunshineMay 8, 2020
  16. Junio C HamanoMay 8, 2020
  17. Eric SunshineMay 8, 2020
  18. submodule: port subcommand 'set-url' from shell to CShourya Shukla, May 8, 2020
  19. Denton LiuMay 8, 2020
  20. Junio C HamanoMay 8, 2020
  21. Junio C HamanoMay 8, 2020
  22. submodule: port subcommand 'set-url' from shell to CJunio C Hamano, May 8, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.