git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] show help message also for aliased commands

From
Jeff King <peff@peff.net>
Date
Feb 18, 2010, 02:18 UTC
Message-ID
<20100218021850.GB21693@coredump.intra.peff.net>
In-Reply-To
<1266456562-88841-1-git-send-email-patrick.sudowe@rwth-aachen.de>
On Thu, Feb 18, 2010 at 02:29:22AM +0100, Patrick Sudowe wrote:
Show 8 quoted lines
> git help 'alias' currently only shows the actual git command
> 'alias' refers to. This patch changes the behavior so that
> the help for the actual git command is shown. The user usually
> knows the aliases defined, and sometimes its just more convenient
> to type something like git help co than git help checkout
> to find out about some rarely used option.
> The original message is still there, so users do not face
> unexpected or surprising behavior.

Won't the original message get eaten when 'man' starts a pager (I know there are other, non-paged ways of showing the help, but man is the default).

Show 16 quoted lines
> @@ -446,19 +447,22 @@ int cmd_help(int argc, const char **argv, const char *prefix)
>  	alias = alias_lookup(argv[0]);
>  	if (alias && !is_git_command(argv[0])) {
>  		printf("`git %s' is aliased to `%s'\n", argv[0], alias);
> -		return 0;
> +		cmd = alias;
> +	} else {
> +		cmd = argv[0];
>  	}
>  
> +
>  	switch (help_format) {
>  	case HELP_FORMAT_NONE:
>  	case HELP_FORMAT_MAN:
> -		show_man_page(argv[0]);
> +		show_man_page(cmd);
This breaks horribly for all but the simplest of aliases. This works:
  $ git config alias.co checkout
  $ git help co
But this would need to trim it down to just "log":
  $ git config alias.lp 'log -p'
  $ git help lp
  `git lp' is aliased to `log -p'
  No manual entry for gitlog -p
And this is just impossible:
  $ git config alias.jive '!sh -c "git log | jive"'
  $ git help jive
  `git jive' is aliased to `!sh -c "git log | jive"'
  No manual entry for git!sh -c "git log | jive"
-Peff
Previous: Junio C Hamano
Message 3 of 3 in “show help message also for aliased commands”
  1. show help message also for aliased commandsPatrick Sudowe, Feb 18, 2010
  2. Junio C HamanoFeb 18, 2010
  3. Jeff KingFeb 18, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.