From: Jeff King <peff@peff.net>
To: "François Pinard" <pinard@iro.umontreal.ca>
Cc: git mailing list <git@vger.kernel.org>
Subject: Re: Tiny bug report, interaction between alias and help
Date: Sat, 19 Jan 2008 12:41:47 -0500 [thread overview]
Message-ID: <20080119174146.GA3913@coredump.intra.peff.net> (raw)
In-Reply-To: <20080119142750.GA9182@phenix.progiciels-bpi.ca>
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
next prev parent reply other threads:[~2008-01-19 17:42 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-19 14:27 Tiny bug report, interaction between alias and help François Pinard
2008-01-19 15:23 ` Pascal Obry
2008-01-19 17:41 ` Jeff King [this message]
2008-01-19 22:55 ` Johannes Schindelin
2008-01-19 22:57 ` Jeff King
2008-01-19 23:23 ` Johannes Schindelin
[not found] ` <fcaeb9bf0801200159k26303a18ned2eef8e6b5b65d2@mail.gmail.com>
2008-01-22 3:43 ` Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080119174146.GA3913@coredump.intra.peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=pinard@iro.umontreal.ca \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).