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

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