From: Eric Sunshine <sunshine@sunshineco.com>
To: Stefan Beller <sbeller@google.com>
Cc: Junio C Hamano <gitster@pobox.com>, Jeff King <peff@peff.net>,
Git List <git@vger.kernel.org>,
Jonathan Nieder <jrnieder@gmail.com>,
Johannes Schindelin <johannes.schindelin@gmail.com>,
Jens Lehmann <Jens.Lehmann@web.de>
Subject: Re: [PATCH 2/3] submodule: implement `module_name` as a builtin helper
Date: Mon, 31 Aug 2015 18:01:40 -0400 [thread overview]
Message-ID: <CAPig+cT5Z0CJVok8Za=fBarQLu4WQD3TbA7Wr1aASP4neLLXRA@mail.gmail.com> (raw)
In-Reply-To: <1441048767-29729-3-git-send-email-sbeller@google.com>
On Mon, Aug 31, 2015 at 3:19 PM, Stefan Beller <sbeller@google.com> wrote:
> This implements the helper `module_name` in C instead of shell,
> yielding a nice performance boost.
>
> Signed-off-by: Stefan Beller <sbeller@google.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
> index beaab7d..c8f7e0c 100644
> --- a/builtin/submodule--helper.c
> +++ b/builtin/submodule--helper.c
> @@ -101,6 +104,26 @@ static int module_list(int argc, const char **argv, const char *prefix)
> +static int module_name(int argc, const char **argv, const char *prefix)
> +{
> + const char *name;
> + const struct submodule *sub;
> +
> + if (argc != 1)
> + usage("git submodule--helper module_name <path>\n");
> +
> + gitmodules_config();
> + sub = submodule_from_path(null_sha1, argv[0]);
> +
> + if (!sub)
> + die("No submodule mapping found in .gitmodules for path '%s'", argv[0]);
In the original shell code, this error message went through
eval_gettext(), so don't you want:
die(_("No ..."), ...);
?
> + name = sub->name;
> + printf("%s\n", name);
Why the useless assignment to 'name'? Instead:
printf("%s\n", sub->name);
> + return 0;
> +}
> +
> int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
> {
> if (argc < 2)
> @@ -109,6 +132,9 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
> if (!strcmp(argv[1], "module_list"))
> return module_list(argc - 1, argv + 1, prefix);
>
> + if (!strcmp(argv[1], "module_name"))
> + return module_name(argc - 2, argv + 2, prefix);
> +
> usage:
> - usage("git submodule--helper module_list\n");
> + usage("git submodule--helper [module_list | module_name]\n");
> }
next prev parent reply other threads:[~2015-08-31 22:02 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-31 19:19 [PATCHv2 0/3] submodule--helper: Have some refactoring only patches first Stefan Beller
2015-08-31 19:19 ` [PATCH 1/3] submodule: implement `module_list` as a builtin helper Stefan Beller
2015-08-31 21:55 ` Eric Sunshine
2015-08-31 19:19 ` [PATCH 2/3] submodule: implement `module_name` " Stefan Beller
2015-08-31 20:35 ` Junio C Hamano
2015-08-31 20:51 ` Stefan Beller
2015-08-31 22:01 ` Eric Sunshine [this message]
2015-08-31 19:19 ` [PATCH 3/3] submodule: implement `module_clone` " Stefan Beller
2015-08-31 22:35 ` Eric Sunshine
2015-09-01 17:49 ` Stefan Beller
2015-09-01 18:35 ` Eric Sunshine
2015-08-31 20:15 ` [PATCHv2 0/3] submodule--helper: Have some refactoring only patches first Junio C Hamano
2015-09-01 0:40 ` [PATCHv3 " Stefan Beller
2015-09-01 0:40 ` [PATCHv3 1/3] submodule: implement `module-list` as a builtin helper Stefan Beller
2015-09-01 2:22 ` Eric Sunshine
2015-09-01 0:40 ` [PATCHv3 2/3] submodule: implement `module-name` " Stefan Beller
2015-09-01 2:31 ` Eric Sunshine
2015-09-01 16:18 ` Stefan Beller
2015-09-01 0:40 ` [PATCHv3 3/3] submodule: implement `module-clone` " Stefan Beller
2015-09-01 2:41 ` Eric Sunshine
2015-09-01 2:09 ` [PATCHv3 0/3] submodule--helper: Have some refactoring only patches first Eric Sunshine
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='CAPig+cT5Z0CJVok8Za=fBarQLu4WQD3TbA7Wr1aASP4neLLXRA@mail.gmail.com' \
--to=sunshine@sunshineco.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmail.com \
--cc=jrnieder@gmail.com \
--cc=peff@peff.net \
--cc=sbeller@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).