Re: Tiny bug report, interaction between alias and help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Sat, 19 Jan 2008, Jeff King wrote:

> @@ -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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux