* Tiny bug report, interaction between alias and help
@ 2008-01-19 14:27 François Pinard
2008-01-19 15:23 ` Pascal Obry
2008-01-19 17:41 ` Jeff King
0 siblings, 2 replies; 7+ messages in thread
From: François Pinard @ 2008-01-19 14:27 UTC (permalink / raw)
To: git mailing list
Hi, git people. (My first message here, please be kind!)
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! :-)
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.
Thanks for your attention,
--
François Pinard http://pinard.progiciels-bpi.ca
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tiny bug report, interaction between alias and help
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
1 sibling, 0 replies; 7+ messages in thread
From: Pascal Obry @ 2008-01-19 15:23 UTC (permalink / raw)
To: François Pinard, git mailing list
François Pinard a écrit :
> It would be nice if --help was interacting better with aliases.
Agreed. I have myself been hit by this and thought it would be nice to
have help looking at aliases if necessary.
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tiny bug report, interaction between alias and help
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
2008-01-19 22:55 ` Johannes Schindelin
[not found] ` <fcaeb9bf0801200159k26303a18ned2eef8e6b5b65d2@mail.gmail.com>
1 sibling, 2 replies; 7+ messages in thread
From: Jeff King @ 2008-01-19 17:41 UTC (permalink / raw)
To: François Pinard; +Cc: git mailing list
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
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: Tiny bug report, interaction between alias and help
2008-01-19 17:41 ` Jeff King
@ 2008-01-19 22:55 ` Johannes Schindelin
2008-01-19 22:57 ` Jeff King
[not found] ` <fcaeb9bf0801200159k26303a18ned2eef8e6b5b65d2@mail.gmail.com>
1 sibling, 1 reply; 7+ messages in thread
From: Johannes Schindelin @ 2008-01-19 22:55 UTC (permalink / raw)
To: Jeff King; +Cc: François Pinard, git mailing list
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tiny bug report, interaction between alias and help
2008-01-19 22:55 ` Johannes Schindelin
@ 2008-01-19 22:57 ` Jeff King
2008-01-19 23:23 ` Johannes Schindelin
0 siblings, 1 reply; 7+ messages in thread
From: Jeff King @ 2008-01-19 22:57 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: François Pinard, git mailing list
On Sat, Jan 19, 2008 at 10:55:24PM +0000, Johannes Schindelin wrote:
> Urgh... We really have something like that in git? Looks like a prime
> candidate for refactoring a la
Yes, my patch was a one-off "how about this?". I already have a
refactored version in my tree (that also converts cmd_help to use
parse_options), but I am holding on to it until post-1.5.4.
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tiny bug report, interaction between alias and help
2008-01-19 22:57 ` Jeff King
@ 2008-01-19 23:23 ` Johannes Schindelin
0 siblings, 0 replies; 7+ messages in thread
From: Johannes Schindelin @ 2008-01-19 23:23 UTC (permalink / raw)
To: Jeff King; +Cc: François Pinard, git mailing list
Hi,
On Sat, 19 Jan 2008, Jeff King wrote:
> On Sat, Jan 19, 2008 at 10:55:24PM +0000, Johannes Schindelin wrote:
>
> > Urgh... We really have something like that in git? Looks like a prime
> > candidate for refactoring a la
>
> Yes, my patch was a one-off "how about this?". I already have a
> refactored version in my tree (that also converts cmd_help to use
> parse_options), but I am holding on to it until post-1.5.4.
Very nice!
Thanks,
Dscho
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Tiny bug report, interaction between alias and help
[not found] ` <fcaeb9bf0801200159k26303a18ned2eef8e6b5b65d2@mail.gmail.com>
@ 2008-01-22 3:43 ` Jeff King
0 siblings, 0 replies; 7+ messages in thread
From: Jeff King @ 2008-01-22 3:43 UTC (permalink / raw)
To: Nguyen Thai Ngoc Duy; +Cc: François Pinard, git mailing list
On Sun, Jan 20, 2008 at 04:59:13PM +0700, Nguyen Thai Ngoc Duy wrote:
> I've been hit by this and came up with a similar approach as well. But
> I dropped it because it made aliases higher precedence than git-foo
> while git aliases cannot override git-foo (builtin or external ones).
> Is there any other way to make "git-help" respect git command
> executing order?
Yes, and that is an issue in my refactored patch as well. The tricky
thing is that usually we say "try git-foo as a real git command, and
then fall back to aliases" but we can't here, because "try git-foo"
involves exec'ing something else.
It should be possible to do a lookup on "git-foo" and find out if it is
a real git command, but I don't know how involved that will be. I'll
look at it before I resend post-1.5.4.
And of course the other option is "so what?" People with alias.commit
set will get the alias text rather than the man page. But they will
quickly figure out that alias.commit doesn't actually _work_, and
presumably remove it.
-Peff
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2008-01-22 3:44 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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
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).