threads / discuss / 3871

git log is a bit antisocial

Subject: git log is a bit antisocial

## tl;dr

8 messages between Apr 14, 2006 and Apr 14, 2006.

replies: 7people: 3as markdown or json

Nicolas Pitre· Apr 14, 2006, 20:50 UTC · lore

$ git log -h fatal: unrecognized argument: -h $ git log --help fatal: unrecognized argument: --help

Maybe the usage string could be printed in those cases?
Nicolas
Junio C Hamano· Apr 14, 2006, 20:56 UTC · re: Nicolas Pitre · lore

Re: git log is a bit antisocial

Nicolas Pitre <nico@cam.org> writes:
Show 6 quoted lines
> $  git log -h
> fatal: unrecognized argument: -h
> $ git log --help
> fatal: unrecognized argument: --help
>
> Maybe the usage string could be printed in those cases?
Perhaps.  Alternatively, "git help log", perhaps.
Nicolas Pitre· Apr 14, 2006, 21:20 UTC · re: Junio C Hamano · lore

Re: git log is a bit antisocial

On Fri, 14 Apr 2006, Junio C Hamano wrote:
Show 10 quoted lines
> Nicolas Pitre <nico@cam.org> writes:
> 
> > $  git log -h
> > fatal: unrecognized argument: -h
> > $ git log --help
> > fatal: unrecognized argument: --help
> >
> > Maybe the usage string could be printed in those cases?
> 
> Perhaps.  Alternatively, "git help log", perhaps.
What about git-log then?
Nicolas
Junio C Hamano· Apr 14, 2006, 21:28 UTC · re: Nicolas Pitre · lore

Re: git log is a bit antisocial

Nicolas Pitre <nico@cam.org> writes:
Show 14 quoted lines
> On Fri, 14 Apr 2006, Junio C Hamano wrote:
>
>> Nicolas Pitre <nico@cam.org> writes:
>> 
>> > $  git log -h
>> > fatal: unrecognized argument: -h
>> > $ git log --help
>> > fatal: unrecognized argument: --help
>> >
>> > Maybe the usage string could be printed in those cases?
>> 
>> Perhaps.  Alternatively, "git help log", perhaps.
>
> What about git-log then?
What about it?

Asking for help on log could be spelled as "git log --help" with a patch like the attached, but I am not sure that is worth it...

-- >8 --
diff --git a/git.c b/git.c
index 78ed403..7fdacdd 100644
--- a/git.c
+++ b/git.c
@@ -497,6 +497,16 @@ int main(int argc, const char **argv, ch
 	}
 	argv[0] = cmd;
 
+	/* It could be git blah --help or git boo -h, but be
+	 * careful; most commands have their own '-h' and '--help'.
+	 */
+	if (argc == 2 &&
+	    (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help"))) {
+		argv[0] = "help";
+		argv[1] = cmd;
+		exit(cmd_help(1, argv, envp));
+	}
+
 	/*
 	 * We search for git commands in the following order:
 	 *  - git_exec_path()
Sébastien Pierre· Apr 14, 2006, 21:44 UTC · re: Junio C Hamano · lore

Re: git log is a bit antisocial

Le vendredi 14 avril 2006 à 14:28 -0700, Junio C Hamano a écrit :
> What about it?
> 
> Asking for help on log could be spelled as "git log --help" with
> a patch like the attached, but I am not sure that is worth it...

I would say that it is very useful to newbies, or simply not to frustrate users trying to get help. It is really worth it, at least for me.

 -- Sébastien
Junio C Hamano· Apr 14, 2006, 22:06 UTC · re: Sébastien Pierre · lore

Re: git log is a bit antisocial

Sébastien Pierre <sebastien@xprima.com> writes:
Show 10 quoted lines
> Le vendredi 14 avril 2006 à 14:28 -0700, Junio C Hamano a écrit :
>
>> What about it?
>> 
>> Asking for help on log could be spelled as "git log --help" with
>> a patch like the attached, but I am not sure that is worth it...
>
> I would say that it is very useful to newbies, or simply not to
> frustrate users trying to get help. It is really worth it, at least for
> me.

Have you read the patch, especially the comment in it? With and without the patch, this command would behave quite differently:

	$ git commit --help
Sébastien Pierre· Apr 14, 2006, 22:15 UTC · re: Junio C Hamano · lore

Re: git log is a bit antisocial

Le vendredi 14 avril 2006 à 15:06 -0700, Junio C Hamano a écrit :
> Have you read the patch, especially the comment in it?  With and
> without the patch, this command would behave quite differently:

I did not realize that at first (I thought this would be a fallback method).

Anyway, on git 1.2.3, here is something interesting:
>> git log -h
fatal: Not a git repository
>> git log --help
Usage: /home/sebastien/Local/bin/git-log [--max-count=<n>]
[<since>..<limit>] [--pretty=<format>] [git-rev-list options]

Which is confusing, so having a consistent behaviour for "git help cmd", "git cmd help", "git cmd -h" and "git cmd --help" would be nice.

For instance, Darcs works just like that, which makes it easy for newbies to find there ways through.

 -- Sébastien
Junio C Hamano· Apr 14, 2006, 22:45 UTC · re: Sébastien Pierre · lore

Re: git log is a bit antisocial

Sébastien Pierre <sebastien@xprima.com> writes:
Show 8 quoted lines
> Anyway, on git 1.2.3, here is something interesting:
>
>>> git log -h
> fatal: Not a git repository
>
>>> git log --help
> Usage: /home/sebastien/Local/bin/git-log [--max-count=<n>]
> [<since>..<limit>] [--pretty=<format>] [git-rev-list options]

You are talking about old codebase in the maitenance branch, which is an independent issue, but thanks for noticing anyway.

The attached patch would help with that.
Show 5 quoted lines
> Which is confusing, so having a consistent behaviour for "git help cmd",
> "git cmd help", "git cmd -h" and "git cmd --help" would be nice.
>
> For instance, Darcs works just like that, which makes it easy for
> newbies to find there ways through.

Patches welcome, but a new development should be based on the "master" branch, not the maintenance 1.2.X series.

-- >8 --
diff --git a/git-sh-setup.sh b/git-sh-setup.sh
index 025ef2d..d15747f 100755
--- a/git-sh-setup.sh
+++ b/git-sh-setup.sh
@@ -30,7 +30,7 @@ else
 fi
 
 case "$1" in
-	--h|--he|--hel|--help)
+	-h|--h|--he|--hel|--help)
 	echo "$LONG_USAGE"
 	exit
 esac

← back to recent threads