All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] help: show help for aliases
@ 2017-02-10  0:17 Tom Kunze
  2017-02-10  1:46 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Kunze @ 2017-02-10  0:17 UTC (permalink / raw)
  To: git

If an alias is a single git command show the man page of the
aliased git command with --help.

Signed-off-by: Tom Kunze <mail@tom-kunze.de>
---
Hi,

I noticed that when I pass --help to an alias which is only a git
command it tells me a information about the alias. But it would be
nice if it instead opens the corresponding man page of the command.

There is a memory leak but in my opinion it can be ignored because
the process will be replaced anyway.

Regards,
Tom Kunze

PS: Please add me to cc as I am not subscribed.

 builtin/help.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/builtin/help.c b/builtin/help.c
index 49f7a07..655ed49 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -437,6 +437,10 @@ static const char *check_git_cmd(const char* cmd)

 	alias = alias_lookup(cmd);
 	if (alias) {
+		if (alias[0] != '!') {
+			strtok(alias, " \t\n");
+			return alias;
+		}
 		printf_ln(_("`git %s' is aliased to `%s'"), cmd, alias);
 		free(alias);
 		exit(0);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] help: show help for aliases
  2017-02-10  0:17 [PATCH] help: show help for aliases Tom Kunze
@ 2017-02-10  1:46 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2017-02-10  1:46 UTC (permalink / raw)
  To: Tom Kunze; +Cc: git

Tom Kunze <mail@tom-kunze.de> writes:

> If an alias is a single git command show the man page of the
> aliased git command with --help.
>
> Signed-off-by: Tom Kunze <mail@tom-kunze.de>
> ...
> diff --git a/builtin/help.c b/builtin/help.c
> index 49f7a07..655ed49 100644
> --- a/builtin/help.c
> +++ b/builtin/help.c
> @@ -437,6 +437,10 @@ static const char *check_git_cmd(const char* cmd)
>
>  	alias = alias_lookup(cmd);
>  	if (alias) {
> +		if (alias[0] != '!') {
> +			strtok(alias, " \t\n");
> +			return alias;
> +		}

While I understand where you come from, I am moderately negative,
especially with that strtok() to ignore options.

For a truly simple alias, e.g.

    $ git co --help
    `git co' is aliased to `checkout'

I do not think I would mind the updated behaviour given by this
patch that much.

But most of the time, when I do "help" on an alias, I am primarily
interested in what default customization I am using over the base
command, i.e.

    $ git lgf --help
    `git lgf' is aliased to `log --oneline --boundary --first-parent'

is my way to remind me that I am using these three options to "git
log" in the alias I very often use (and forgot what they were).

Jumping directly to the "git log" manual page is the last thing I
want "help" to do.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-02-10  1:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-02-10  0:17 [PATCH] help: show help for aliases Tom Kunze
2017-02-10  1:46 ` Junio C Hamano

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.