From: Junio C Hamano <gitster@pobox•com>
To: Joel Nothman <joel.nothman@gmail•com>
Cc: git@vger•kernel.org
Subject: Re: [PATCH] help: include list of aliases in git-help --all
Date: Tue, 25 Feb 2014 15:22:24 -0800 [thread overview]
Message-ID: <xmqqmwhe4w27.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <1393289315-28982-1-git-send-email-joel.nothman@gmail.com> (Joel Nothman's message of "Tue, 25 Feb 2014 11:48:34 +1100")
Joel Nothman <joel.nothman@gmail•com> writes:
> Git help --all had listed all git commands, but no configured aliases.
> This includes aliases as a separate listing, after commands in the main
> git directory and other $PATH directories.
>
> Signed-off-by: Joel Nothman <joel.nothman <at> gmail.com>
> ---
Thanks.
> diff --git a/help.c b/help.c
> index df7d16d..3c14af4 100644
> --- a/help.c
> +++ b/help.c
> @@ -86,7 +86,7 @@ static void pretty_print_string_list(struct cmdnames *cmds,
> int i;
>
> for (i = 0; i < cmds->cnt; i++)
> - string_list_append(&list, cmds->names[i]->name);
> + string_list_append(&list, cmds->names[i]->name);
Why?
> @@ -202,8 +202,48 @@ void load_command_list(const char *prefix,
> exclude_cmds(other_cmds, main_cmds);
> }
>
> +static struct cmdnames aliases;
Instead of using a static global variable, perhaps make this an
on-stack variable in load_commands_and_aliases() that is passed as a
callback parameter to load_aliases_cb() thru git_config()?
> +static int load_aliases_cb(const char *var, const char *value, void *cb)
> +{
That is, cb here is the second parameter you gave to git_config().
> void list_commands(unsigned int colopts,
> - struct cmdnames *main_cmds, struct cmdnames *other_cmds)
> + struct cmdnames *main_cmds, struct cmdnames *other_cmds,
> + struct cmdnames *alias_cmds)
> {
> if (main_cmds->cnt) {
> const char *exec_path = git_exec_path();
> @@ -219,6 +259,13 @@ void list_commands(unsigned int colopts,
> pretty_print_string_list(other_cmds, colopts);
> putchar('\n');
> }
> +
> + if (alias_cmds->cnt) {
> + printf_ln(_("aliases defined in git configuration"));
This will not break the use of "git help -a" in our completion
script, because it ignores anything that does not begin with two SP
followed by alphanumerics.
It may however break scripts that read from "help -a" done by other
people that may remove the lines in the output that are known to
them as not names of commands (i.e. "available git commands..." and
"git commands avaliable elsewhere...")---they haven't seen this new
string and would not know that this line must be skipped.
Other than that, looks reasonably cleanly done. We'd need a test to
cover this so that other people will not break it in future patches.
prev parent reply other threads:[~2014-02-25 23:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-25 0:48 [PATCH] help: include list of aliases in git-help --all Joel Nothman
2014-02-25 19:15 ` Junio C Hamano
2014-02-25 21:20 ` Joel Nothman
2014-02-25 21:51 ` Junio C Hamano
2014-02-25 22:32 ` Joel Nothman
2014-02-25 23:01 ` Philip Oakley
2014-02-25 23:22 ` Junio C Hamano [this message]
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=xmqqmwhe4w27.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox$(echo .)com \
--cc=git@vger$(echo .)kernel.org \
--cc=joel.nothman@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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