git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] help: show manpage for aliased command on git <alias> --help
@ 2013-03-05 14:44 Ævar Arnfjörð Bjarmason
  2013-03-05 15:42 ` Johannes Sixt
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2013-03-05 14:44 UTC (permalink / raw)
  To: git
  Cc: Junio C Hamano, Jonathan Nieder, Jeff King, H.Merijn Brand,
	Ævar Arnfjörð Bjarmason

Change the semantics of "git <alias> --help" to show the help for the
command <alias> is aliased to, instead of just saying:

    `git <alias>' is aliased to `<whatever>'

E.g. if you have "checkout" aliased to "co" you won't get:

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

But will instead get the manpage for git-checkout. The behavior this
is replacing was originally added by Jeff King in 2156435. I'm
changing it because of this off-the-cuff comment on IRC:

    14:27:43 <@Tux> git can be very unhelpful, literally:
    14:27:46 <@Tux> $ git co --help
    14:27:46 <@Tux> `git co' is aliased to `checkout'
    14:28:08 <@Tux> I know!, gimme the help for checkout, please

And because I also think it makes more sense than showing you what the
thing is aliased to.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
---
 builtin/help.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/builtin/help.c b/builtin/help.c
index d1d7181..fdb3312 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -417,6 +417,7 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 {
 	int nongit;
 	const char *alias;
+	const char *show_help_for;
 	enum help_format parsed_help_format;
 	load_command_list("git-", &main_cmds, &other_cmds);
 
@@ -449,20 +450,21 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 
 	alias = alias_lookup(argv[0]);
 	if (alias && !is_git_command(argv[0])) {
-		printf_ln(_("`git %s' is aliased to `%s'"), argv[0], alias);
-		return 0;
+		show_help_for = alias;
+	} else {
+		show_help_for = argv[0];
 	}
 
 	switch (help_format) {
 	case HELP_FORMAT_NONE:
 	case HELP_FORMAT_MAN:
-		show_man_page(argv[0]);
+		show_man_page(show_help_for);
 		break;
 	case HELP_FORMAT_INFO:
-		show_info_page(argv[0]);
+		show_info_page(show_help_for);
 		break;
 	case HELP_FORMAT_WEB:
-		show_html_page(argv[0]);
+		show_html_page(show_help_for);
 		break;
 	}
 
-- 
1.7.10.4

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

* Re: [PATCH] help: show manpage for aliased command on git <alias> --help
  2013-03-05 14:44 [PATCH] help: show manpage for aliased command on git <alias> --help Ævar Arnfjörð Bjarmason
@ 2013-03-05 15:42 ` Johannes Sixt
  2013-03-05 15:54   ` H.Merijn Brand
  2013-03-05 16:16 ` Junio C Hamano
  2013-03-05 17:38 ` Jeff King
  2 siblings, 1 reply; 10+ messages in thread
From: Johannes Sixt @ 2013-03-05 15:42 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, Jonathan Nieder, Jeff King, H.Merijn Brand

Am 3/5/2013 15:44, schrieb Ævar Arnfjörð Bjarmason:
> Change the semantics of "git <alias> --help" to show the help for the
> command <alias> is aliased to, instead of just saying:
> 
>     `git <alias>' is aliased to `<whatever>'
> 
> E.g. if you have "checkout" aliased to "co" you won't get:
> 
>     $ git co --help
>     `git co' is aliased to `checkout'
> 
> But will instead get the manpage for git-checkout.
...
>  	alias = alias_lookup(argv[0]);
>  	if (alias && !is_git_command(argv[0])) {
> -		printf_ln(_("`git %s' is aliased to `%s'"), argv[0], alias);
> -		return 0;
> +		show_help_for = alias;
> +	} else {
> +		show_help_for = argv[0];
>  	}

This needs a lot more scrutiny. The alias can be more than just a single
word, and it can even be a shell scriptlet, i.e., not a git command at all.

It may make sense to show the help of the aliased-to command if the alias
resolves to just a single word.

-- Hannes

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

* Re: [PATCH] help: show manpage for aliased command on git <alias> --help
  2013-03-05 15:42 ` Johannes Sixt
@ 2013-03-05 15:54   ` H.Merijn Brand
  2013-03-05 16:41     ` Matthieu Moy
  0 siblings, 1 reply; 10+ messages in thread
From: H.Merijn Brand @ 2013-03-05 15:54 UTC (permalink / raw)
  To: Johannes Sixt
  Cc: Ævar Arnfjörð Bjarmason, git, Junio C Hamano,
	Jonathan Nieder, Jeff King

On Tue, 05 Mar 2013 16:42:52 +0100, Johannes Sixt
<j.sixt@viscovery.net> wrote:

> Am 3/5/2013 15:44, schrieb Ævar Arnfjörð Bjarmason:
> > Change the semantics of "git <alias> --help" to show the help for the
> > command <alias> is aliased to, instead of just saying:
> > 
> >     `git <alias>' is aliased to `<whatever>'
> > 
> > E.g. if you have "checkout" aliased to "co" you won't get:
> > 
> >     $ git co --help
> >     `git co' is aliased to `checkout'
> > 
> > But will instead get the manpage for git-checkout.
> ...
> >  	alias = alias_lookup(argv[0]);
> >  	if (alias && !is_git_command(argv[0])) {
> > -		printf_ln(_("`git %s' is aliased to `%s'"), argv[0], alias);
> > -		return 0;
> > +		show_help_for = alias;
> > +	} else {
> > +		show_help_for = argv[0];
> >  	}
> 
> This needs a lot more scrutiny. The alias can be more than just a single
> word, and it can even be a shell scriptlet, i.e., not a git command at all.
> 
> It may make sense to show the help of the aliased-to command if the alias
> resolves to just a single word.

A single word that is (already) known to git as being a valid command
to do --help with. I which case I fully agree.

-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.17   porting perl5 on HP-UX, AIX, and openSUSE
http://mirrors.develooper.com/hpux/        http://www.test-smoke.org/
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

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

* Re: [PATCH] help: show manpage for aliased command on git <alias> --help
  2013-03-05 14:44 [PATCH] help: show manpage for aliased command on git <alias> --help Ævar Arnfjörð Bjarmason
  2013-03-05 15:42 ` Johannes Sixt
@ 2013-03-05 16:16 ` Junio C Hamano
  2013-03-05 16:32   ` Ævar Arnfjörð Bjarmason
  2013-03-05 17:38 ` Jeff King
  2 siblings, 1 reply; 10+ messages in thread
From: Junio C Hamano @ 2013-03-05 16:16 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Jonathan Nieder, Jeff King, H.Merijn Brand

Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:

> Change the semantics of "git <alias> --help" to show the help for the
> command <alias> is aliased to, instead of just saying:
>
>     `git <alias>' is aliased to `<whatever>'
>
> E.g. if you have "checkout" aliased to "co" you won't get:
>
>     $ git co --help
>     `git co' is aliased to `checkout'

If you had "lg" aliased to "log --oneline" and you made

    $ git lg --help

to give anything but

    'git lg' is aliased to `log --oneline'

I would say that is a grave regression.

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

* Re: [PATCH] help: show manpage for aliased command on git <alias> --help
  2013-03-05 16:16 ` Junio C Hamano
@ 2013-03-05 16:32   ` Ævar Arnfjörð Bjarmason
  2013-03-05 16:52     ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2013-03-05 16:32 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Jonathan Nieder, Jeff King, H.Merijn Brand

On Tue, Mar 5, 2013 at 5:16 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Ævar Arnfjörð Bjarmason  <avarab@gmail.com> writes:
>
>> Change the semantics of "git <alias> --help" to show the help for the
>> command <alias> is aliased to, instead of just saying:
>>
>>     `git <alias>' is aliased to `<whatever>'
>>
>> E.g. if you have "checkout" aliased to "co" you won't get:
>>
>>     $ git co --help
>>     `git co' is aliased to `checkout'
>
> If you had "lg" aliased to "log --oneline" and you made
>
>     $ git lg --help
>
> to give anything but
>
>     'git lg' is aliased to `log --oneline'
>
> I would say that is a grave regression.

Good point. I'll fix that up.

No objection to the patch in principle though? I.e. not showing you
what the alias points to.

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

* Re: [PATCH] help: show manpage for aliased command on git <alias> --help
  2013-03-05 15:54   ` H.Merijn Brand
@ 2013-03-05 16:41     ` Matthieu Moy
  0 siblings, 0 replies; 10+ messages in thread
From: Matthieu Moy @ 2013-03-05 16:41 UTC (permalink / raw)
  To: H.Merijn Brand
  Cc: Johannes Sixt, Ævar Arnfjörð Bjarmason, git,
	Junio C Hamano, Jonathan Nieder, Jeff King

"H.Merijn Brand" <h.m.brand@xs4all.nl> writes:

> A single word that is (already) known to git as being a valid command
> to do --help with. I which case I fully agree.

Just to insist on "that is known to git as being a valid command".

Compare:

$ git foo --help
`git foo' is aliased to `bar'

with

$ git foo --help
No manual entry for gitbar

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

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

* Re: [PATCH] help: show manpage for aliased command on git <alias> --help
  2013-03-05 16:32   ` Ævar Arnfjörð Bjarmason
@ 2013-03-05 16:52     ` Junio C Hamano
  0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2013-03-05 16:52 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Jonathan Nieder, Jeff King, H.Merijn Brand

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

> No objection to the patch in principle though? I.e. not showing you
> what the alias points to.

I am not interested enough to even strongly object to such a change,
because it is not reasonable to react with a "I know!" to the output
of "git co --help", i.e. "'git co' is aliased to 'checkout'", in the
first place.  Also some users may find it inconsistent if a single
bareword jumps directly to the manpage and other input shows alias
expansion.

So,... I do not see a very big plus in the proposed (and then
amended by others in the thread) change, but if the damage to the
code that is necessary to implement it is not too bad, perhaps it is
an OK thing to do.  I don't know without seeing the patch.

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

* Re: [PATCH] help: show manpage for aliased command on git <alias> --help
  2013-03-05 14:44 [PATCH] help: show manpage for aliased command on git <alias> --help Ævar Arnfjörð Bjarmason
  2013-03-05 15:42 ` Johannes Sixt
  2013-03-05 16:16 ` Junio C Hamano
@ 2013-03-05 17:38 ` Jeff King
  2013-03-06 13:10   ` Michael J Gruber
  2 siblings, 1 reply; 10+ messages in thread
From: Jeff King @ 2013-03-05 17:38 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: git, Junio C Hamano, Jonathan Nieder, H.Merijn Brand

On Tue, Mar 05, 2013 at 02:44:41PM +0000, Ævar Arnfjörð Bjarmason wrote:

> Change the semantics of "git <alias> --help" to show the help for the
> command <alias> is aliased to, instead of just saying:
> 
>     `git <alias>' is aliased to `<whatever>'
> 
> E.g. if you have "checkout" aliased to "co" you won't get:
> 
>     $ git co --help
>     `git co' is aliased to `checkout'
> 
> But will instead get the manpage for git-checkout. The behavior this
> is replacing was originally added by Jeff King in 2156435. I'm
> changing it because of this off-the-cuff comment on IRC:
> 
>     14:27:43 <@Tux> git can be very unhelpful, literally:
>     14:27:46 <@Tux> $ git co --help
>     14:27:46 <@Tux> `git co' is aliased to `checkout'
>     14:28:08 <@Tux> I know!, gimme the help for checkout, please
> 
> And because I also think it makes more sense than showing you what the
> thing is aliased to.

In this simple case, I think it is helpful to show the "checkout"
manpage, because there is no other information to give (and by showing
the checkout manpage, you implicitly indicate that "co" maps to
"checkout").

But like others, I am concerned about the other cases, where there is no
manpage, it is not a git command with a manpage, or it is a git command
with options.  You are losing useful information that is currently given
to the user in all but the single-word case.

In an ideal world, we could say "here is how the alias expands, and by
the way, here is the manpage for the expanded command". And obviously
just omit the latter part when there is no such page. But we are relying
on external programs to do the presentation and paging. Doing the
C equivalent of:

  echo "'git co' is aliased to 'checkout'" &&
  man checkout

does not quite work, because "man" will start a pager. We can run our
own pager (which should suppress man's invocation), but that is a
regression for anyone who uses MANPAGER.

The user may also be using help.format to use something besides man. If
help.format is set to "html", we will spawn a browser. In that case we
can still output the alias information, but it may or may not be seen
(though come to think of it, that is probably already a problem for "git
help <alias>" on Windows systems, or anybody invoking git help from a
GUI porcelain).

So I'd only be in favor of this patch if it managed to avoid information
loss in the more complicated cases. And I'm not sure how best to do
that. The "only trigger for a single-word alias" suggestion seems like
the least ugly to me.

-Peff

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

* Re: [PATCH] help: show manpage for aliased command on git <alias> --help
  2013-03-05 17:38 ` Jeff King
@ 2013-03-06 13:10   ` Michael J Gruber
  2013-03-06 23:55     ` Junio C Hamano
  0 siblings, 1 reply; 10+ messages in thread
From: Michael J Gruber @ 2013-03-06 13:10 UTC (permalink / raw)
  To: Jeff King
  Cc: Ævar Arnfjörð Bjarmason, git, Junio C Hamano,
	Jonathan Nieder, H.Merijn Brand

Jeff King venit, vidit, dixit 05.03.2013 18:38:
> On Tue, Mar 05, 2013 at 02:44:41PM +0000, Ævar Arnfjörð Bjarmason wrote:
> 
>> Change the semantics of "git <alias> --help" to show the help for the
>> command <alias> is aliased to, instead of just saying:
>>
>>     `git <alias>' is aliased to `<whatever>'
>>
>> E.g. if you have "checkout" aliased to "co" you won't get:
>>
>>     $ git co --help
>>     `git co' is aliased to `checkout'
>>
>> But will instead get the manpage for git-checkout. The behavior this
>> is replacing was originally added by Jeff King in 2156435. I'm
>> changing it because of this off-the-cuff comment on IRC:
>>
>>     14:27:43 <@Tux> git can be very unhelpful, literally:
>>     14:27:46 <@Tux> $ git co --help
>>     14:27:46 <@Tux> `git co' is aliased to `checkout'
>>     14:28:08 <@Tux> I know!, gimme the help for checkout, please
>>
>> And because I also think it makes more sense than showing you what the
>> thing is aliased to.
> 
> In this simple case, I think it is helpful to show the "checkout"
> manpage, because there is no other information to give (and by showing
> the checkout manpage, you implicitly indicate that "co" maps to
> "checkout").

Well, even in the simple case one has to wonder: Why does the user
invoke help for "co"? There are two very likely cases:

A) User does not remember what "co" is aliased to.
B) User wants to see the man page.

If A is not the case then it's easy for the user to request help for
"checkout" (or "commit" or ...).

Removing the only easy way to look up the definition of an alias is a
major regression. And no, "git config --get alias.co" is not an easy way.

Removing that easy way would be OK only after introducing a "git alias"
command which works similar to shell's alias. You can even set it up as
an alias for git config, of course.

> But like others, I am concerned about the other cases, where there is no
> manpage, it is not a git command with a manpage, or it is a git command
> with options.  You are losing useful information that is currently given
> to the user in all but the single-word case.
> 
> In an ideal world, we could say "here is how the alias expands, and by
> the way, here is the manpage for the expanded command". And obviously
> just omit the latter part when there is no such page. But we are relying
> on external programs to do the presentation and paging. Doing the
> C equivalent of:
> 
>   echo "'git co' is aliased to 'checkout'" &&
>   man checkout
> 
> does not quite work, because "man" will start a pager. We can run our
> own pager (which should suppress man's invocation), but that is a
> regression for anyone who uses MANPAGER.
> 
> The user may also be using help.format to use something besides man. If
> help.format is set to "html", we will spawn a browser. In that case we
> can still output the alias information, but it may or may not be seen
> (though come to think of it, that is probably already a problem for "git
> help <alias>" on Windows systems, or anybody invoking git help from a
> GUI porcelain).
> 
> So I'd only be in favor of this patch if it managed to avoid information
> loss in the more complicated cases. And I'm not sure how best to do
> that. The "only trigger for a single-word alias" suggestion seems like
> the least ugly to me.
> 
> -Peff
> 

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

* Re: [PATCH] help: show manpage for aliased command on git <alias> --help
  2013-03-06 13:10   ` Michael J Gruber
@ 2013-03-06 23:55     ` Junio C Hamano
  0 siblings, 0 replies; 10+ messages in thread
From: Junio C Hamano @ 2013-03-06 23:55 UTC (permalink / raw)
  To: Michael J Gruber
  Cc: Jeff King, Ævar Arnfjörð Bjarmason, git,
	Jonathan Nieder, H.Merijn Brand

Michael J Gruber <git@drmicha.warpmail.net> writes:

> Well, even in the simple case one has to wonder: Why does the user
> invoke help for "co"? There are two very likely cases:
>
> A) User does not remember what "co" is aliased to.
> B) User wants to see the man page.
>
> If A is not the case then it's easy for the user to request help for
> "checkout" (or "commit" or ...).
>
> Removing the only easy way to look up the definition of an alias is a
> major regression.

Very well said ;-).

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

end of thread, other threads:[~2013-03-06 23:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-05 14:44 [PATCH] help: show manpage for aliased command on git <alias> --help Ævar Arnfjörð Bjarmason
2013-03-05 15:42 ` Johannes Sixt
2013-03-05 15:54   ` H.Merijn Brand
2013-03-05 16:41     ` Matthieu Moy
2013-03-05 16:16 ` Junio C Hamano
2013-03-05 16:32   ` Ævar Arnfjörð Bjarmason
2013-03-05 16:52     ` Junio C Hamano
2013-03-05 17:38 ` Jeff King
2013-03-06 13:10   ` Michael J Gruber
2013-03-06 23:55     ` Junio C Hamano

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).