On Sat, Jan 19, 2008 at 09:27:50AM -0500, François Pinard wrote: > Page http://git.or.cz/#community says to report git bugs on this list. > This is a tiny bug for "git version 1.5.4.rc3.14.g44397-dirty". If the > "bug" is inappropriate, please then consider this as a suggestion! :-) I think it is more of a feature request than a bug, and as such should probably be dealt with post-1.5.4. > If, after "git config --global alias.st status", say, I try: > > git st --help > > git then replies: > > No manual entry for git-st > > It would be nice if --help was interacting better with aliases. Maybe something like the following would be nicer. It would be a lot cleaner if the parsing were done by parseopt (which is hopefully going to happen post-1.5.4). -- >8 -- help: print alias definitions When asking for "git help alias", we unhelpfully just tried to look for the manpage for "git-alias" which almost certainly doesn't exist. Instead, let's print out the alias definition. --- help.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 files changed, 38 insertions(+), 5 deletions(-) diff --git a/help.c b/help.c index 1302a61..35176eb 100644 --- a/help.c +++ b/help.c @@ -334,6 +334,27 @@ static void show_html_page(const char *git_cmd) execl_git_cmd("help--browse", page, NULL); } +static const char *alias_help_cb_key; +static char *alias_help_cb_value; +static int alias_help_cb(const char *k, const char *v) +{ + if (!prefixcmp(k, "alias.") && !strcmp(k+6, alias_help_cb_key)) + alias_help_cb_value = xstrdup(v); + return 0; +} + +static int show_alias_help(const char *git_cmd) +{ + alias_help_cb_key = git_cmd; + alias_help_cb_value = NULL; + git_config(alias_help_cb); + if (!alias_help_cb_value) + return 0; + printf("`git %s' is aliased to `%s'\n", git_cmd, alias_help_cb_value); + free(alias_help_cb_value); + return 1; +} + void help_unknown_cmd(const char *cmd) { fprintf(stderr, "git: '%s' is not a git-command. See 'git --help'.\n", cmd); @@ -349,6 +370,9 @@ int cmd_version(int argc, const char **argv, const char *prefix) int cmd_help(int argc, const char **argv, const char *prefix) { const char *help_cmd = argv[1]; + int nongit; + + setup_git_directory_gently(&nongit); if (argc < 2) { printf("usage: %s\n\n", git_usage_string); @@ -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 - 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