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

Re: Tiny bug report, interaction between alias and help

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jan 19, 2008, 22:55 UTC
Message-ID
<alpine.LSU.1.00.0801192252060.5731@racer.site>
In-Reply-To
<20080119174146.GA3913@coredump.intra.peff.net>
Hi,
On Sat, 19 Jan 2008, Jeff King wrote:
Show 38 quoted lines
> @@ -362,21 +386,30 @@ int cmd_help(int argc, const char **argv, const char *prefix)
>  	}
>  
>  	else if (!strcmp(help_cmd, "--web") || !strcmp(help_cmd, "-w")) {
> -		show_html_page(argc > 2 ? argv[2] : NULL);
> +		const char *cmd = argc > 2 ? argv[2] : NULL;
> +		if (cmd && show_alias_help(cmd))
> +			return 0;
> +		show_html_page(cmd);
>  	}
>  
>  	else if (!strcmp(help_cmd, "--info") || !strcmp(help_cmd, "-i")) {
> -		show_info_page(argc > 2 ? argv[2] : NULL);
> +		const char *cmd = argc > 2 ? argv[2] : NULL;
> +		if (cmd && show_alias_help(cmd))
> +			return 0;
> +		show_info_page(cmd);
>  	}
>  
>  	else if (!strcmp(help_cmd, "--man") || !strcmp(help_cmd, "-m")) {
> -		show_man_page(argc > 2 ? argv[2] : NULL);
> +		const char *cmd = argc > 2 ? argv[2] : NULL;
> +		if (cmd && show_alias_help(cmd))
> +			return 0;
> +		show_man_page(cmd);
>  	}
>  
>  	else {
> -		int nongit;
> +		if (show_alias_help(help_cmd))
> +			return 0;
>  
> -		setup_git_directory_gently(&nongit);
>  		git_config(git_help_config);
>  		if (help_default_format)
>  			parse_help_format(help_default_format);
> -- 
> 1.5.4.rc3.1129.g3e1ca-dirty

Urgh... We really have something like that in git? Looks like a prime candidate for refactoring a la

	void (*show_cmd)(const char *git_cmd) = show_man_page;
	const char *cmd = argc > 2 ? argv[2] : NULL;
	if (cmd && show_alias_help(cmd))
		return 0;
	if (!strcmp(help_cmd, "--web") || !strcmp(help_cmd, "-w"))
		show_cmd = show_html_page;
	else ...
		...
	show_cmd(cmd);

Ciao, Dscho

Previous: Jeff KingNext: Jeff King
Message 4 of 7 in “Tiny bug report, interaction between alias and help”
  1. François PinardJan 19, 2008
  2. Pascal ObryJan 19, 2008
  3. Jeff KingJan 19, 2008
  4. Johannes SchindelinJan 19, 2008
  5. Jeff KingJan 19, 2008
  6. Johannes SchindelinJan 19, 2008
  7. Jeff KingJan 22, 2008

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.