threads / patch / 24083

v2Group the default git help message by topic

Subject: [PATCH v2] Group the default git help message by topic

## tl;dr

16 messages between Jun 11, 2010 and Jun 14, 2010. Diffs are folded; open one to read it.

replies: 15people: 7as markdown or json

Scott Chacon· Jun 11, 2010, 16:03 UTC · lore

It's difficult to process 21 commands (which is what is output by default for git when no command is given). They have been re-grouped into 4 groups of 5-6 commands each, which is clearer and easier for new users to process. More advanced commands such as bisect and rebase have also been removed as this should be output for beginners.

Signed-off-by: Scott Chacon <schacon@gmail.com>
---

Here is the second version of this patch. Instead of hard-coding all the descriptions, I'm just pulling them from the common-cmds.h file.

 builtin/help.c |   54 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 42 insertions(+), 12 deletions(-)
Show changes to builtin/help.c +42 −12
diff --git a/builtin/help.c b/builtin/help.c
index 3182a2b..2975b3d 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -269,23 +269,53 @@ static int git_help_config(const char *var,
const char *value, void *cb)
 	return git_default_config(var, value, cb);
 }

-static struct cmdnames main_cmds, other_cmds;
-
-void list_common_cmds_help(void)
+void print_command(const char *s)
 {
-	int i, longest = 0;
+	int i = 0;
+	int longest = 10;

 	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		if (longest < strlen(common_cmds[i].name))
-			longest = strlen(common_cmds[i].name);
+		if (!strcmp(s, common_cmds[i].name)) {
+			printf("   %s   ", common_cmds[i].name);
+			mput_char(' ', longest - strlen(common_cmds[i].name));
+			puts(common_cmds[i].help);
+		}
 	}
+}

-	puts("The most commonly used git commands are:");
-	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		printf("   %s   ", common_cmds[i].name);
-		mput_char(' ', longest - strlen(common_cmds[i].name));
-		puts(common_cmds[i].help);
-	}
+static struct cmdnames main_cmds, other_cmds;
+
+void list_common_cmds_help(void)
+{
+	puts("The most commonly used git commands are:\n");
+
+	puts("Basic Commands:");
+	print_command("init");
+	print_command("clone");
+	print_command("add");
+	print_command("status");
+	print_command("commit");
+	puts("");
+
+	puts("Branch Commands:");
+	print_command("branch");
+	print_command("checkout");
+	print_command("merge");
+	print_command("tag");
+	puts("");
+
+	puts("History Commands:");
+	print_command("log");
+	print_command("diff");
+	print_command("reset");
+	print_command("show");
+	puts("");
+
+	puts("Remote Commands:");
+	print_command("remote");
+	print_command("fetch");
+	print_command("pull");
+	print_command("push");
 }

 static int is_git_command(const char *s)
-- 
1.7.0.1
Wincent Colaiuta· Jun 11, 2010, 16:26 UTC · re: Scott Chacon · lore

Re: [PATCH v2] Group the default git help message by topic

El 11/06/2010, a las 18:03, Scott Chacon escribió:
Show 29 quoted lines
> +	puts("The most commonly used git commands are:\n");
> +
> +	puts("Basic Commands:");
> +	print_command("init");
> +	print_command("clone");
> +	print_command("add");
> +	print_command("status");
> +	print_command("commit");
> +	puts("");
> +
> +	puts("Branch Commands:");
> +	print_command("branch");
> +	print_command("checkout");
> +	print_command("merge");
> +	print_command("tag");
> +	puts("");
> +
> +	puts("History Commands:");
> +	print_command("log");
> +	print_command("diff");
> +	print_command("reset");
> +	print_command("show");
> +	puts("");
> +
> +	puts("Remote Commands:");
> +	print_command("remote");
> +	print_command("fetch");
> +	print_command("pull");
> +	print_command("push");
Nice. I'm sure the output will be a bit less intimidating, but I am not sure about some of the grouping choices you've made here.
"git checkout" is almost certainly a "Basic" command, even though it's used for creating and switching branches.
"git tag" doesn't really seem to be a "Branch" command, as it's for tagging objects (usually commits), and not branches.
"git reset" is the odd one out in the "History" commands group. The other three commands are about _inspecting_ history, whereas "git reset" is about changing the current HEAD. I actually think "git reset" fits better with the "Branch" commands.
I think I'd be inclined to use more descriptive headings and group the commands like this:
  Basic operation:
    init
    add
    status
    commit
    checkout
  Inspecting repository state and history:
    log
    diff
    show
  Working with branches:
    branch
    merge
    reset
  Interacting with other repositories:
    clone
    fetch
    pull
    push
    remote
...</end of my 2 cents>

Cheers, Wincent

A Large Angry SCM· Jun 11, 2010, 22:00 UTC · re: Wincent Colaiuta · lore

Re: [PATCH v2] Group the default git help message by topic

Wincent Colaiuta wrote:
Show 67 quoted lines
> El 11/06/2010, a las 18:03, Scott Chacon escribió:
> 
>> +	puts("The most commonly used git commands are:\n");
>> +
>> +	puts("Basic Commands:");
>> +	print_command("init");
>> +	print_command("clone");
>> +	print_command("add");
>> +	print_command("status");
>> +	print_command("commit");
>> +	puts("");
>> +
>> +	puts("Branch Commands:");
>> +	print_command("branch");
>> +	print_command("checkout");
>> +	print_command("merge");
>> +	print_command("tag");
>> +	puts("");
>> +
>> +	puts("History Commands:");
>> +	print_command("log");
>> +	print_command("diff");
>> +	print_command("reset");
>> +	print_command("show");
>> +	puts("");
>> +
>> +	puts("Remote Commands:");
>> +	print_command("remote");
>> +	print_command("fetch");
>> +	print_command("pull");
>> +	print_command("push");
> 
> Nice. I'm sure the output will be a bit less intimidating, but I am not sure about some of the grouping choices you've made here.
> 
> "git checkout" is almost certainly a "Basic" command, even though it's used for creating and switching branches.
> 
> "git tag" doesn't really seem to be a "Branch" command, as it's for tagging objects (usually commits), and not branches.
> 
> "git reset" is the odd one out in the "History" commands group. The other three commands are about _inspecting_ history, whereas "git reset" is about changing the current HEAD. I actually think "git reset" fits better with the "Branch" commands.
> 
> I think I'd be inclined to use more descriptive headings and group the commands like this:
> 
>   Basic operation:
>     init
>     add
>     status
>     commit
>     checkout
> 
>   Inspecting repository state and history:
>     log
>     diff
>     show
> 
>   Working with branches:
>     branch
>     merge
>     reset
> 
>   Interacting with other repositories:
>     clone
>     fetch
>     pull
>     push
>     remote
> 
> ...</end of my 2 cents>

Can a command be listed twice? Some of these commands _really_ belong in more than one category.

Ævar Arnfjörð Bjarmason· Jun 11, 2010, 22:28 UTC · re: A Large Angry SCM · lore

Re: [PATCH v2] Group the default git help message by topic

On Fri, Jun 11, 2010 at 22:00, A Large Angry SCM <gitzilla@gmail.com> wrote:
> Can a command be listed twice? Some of these commands _really_ belong in
> more than one category.
Of course it can. But what specific commands do you mean?
Scott Chacon· Jun 12, 2010, 16:19 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH v2] Group the default git help message by topic

Hey,

On Fri, Jun 11, 2010 at 3:28 PM, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:

Show 6 quoted lines
> On Fri, Jun 11, 2010 at 22:00, A Large Angry SCM <gitzilla@gmail.com> wrote:
>> Can a command be listed twice? Some of these commands _really_ belong in
>> more than one category.
>
> Of course it can. But what specific commands do you mean?
>

For the sake of brevity and clarity I would prefer just choosing the most appropriate category rather than putting any in there twice. I'm trying to stay as close to 25 lines as possible, which is also why I now think we should remove 'show' from the list, too. The point is not to be as accurate as technically possible, but instead to just be a bit more presentable to new users - help them parse the needed command set a little easier than one big list.

Scott
Ævar Arnfjörð Bjarmason· Jun 12, 2010, 16:35 UTC · re: Scott Chacon · lore

Re: [PATCH v2] Group the default git help message by topic

On Sat, Jun 12, 2010 at 16:19, Scott Chacon <schacon@gmail.com> wrote:
Show 18 quoted lines
> Hey,
>
> On Fri, Jun 11, 2010 at 3:28 PM, Ævar Arnfjörð Bjarmason
> <avarab@gmail.com> wrote:
>> On Fri, Jun 11, 2010 at 22:00, A Large Angry SCM <gitzilla@gmail.com> wrote:
>>> Can a command be listed twice? Some of these commands _really_ belong in
>>> more than one category.
>>
>> Of course it can. But what specific commands do you mean?
>>
>
> For the sake of brevity and clarity I would prefer just choosing the
> most appropriate category rather than putting any in there twice.  I'm
> trying to stay as close to 25 lines as possible, which is also why I
> now think we should remove 'show' from the list, too.  The point is
> not to be as accurate as technically possible, but instead to just be
> a bit more presentable to new users - help them parse the needed
> command set a little easier than one big list.

FWIW `git show` is among my top 5 commands according to my bash history.

I think it's definitely among the commands that should be listed by `git help` by default. It's needed whenever you want to inspect a given revision.

A Large Angry SCM· Jun 12, 2010, 18:44 UTC · re: Ævar Arnfjörð Bjarmason · lore

Re: [PATCH v2] Group the default git help message by topic

Ævar Arnfjörð Bjarmason wrote:
Show 6 quoted lines
> On Fri, Jun 11, 2010 at 22:00, A Large Angry SCM <gitzilla@gmail.com> wrote:
>> Can a command be listed twice? Some of these commands _really_ belong in
>> more than one category.
> 
> Of course it can. But what specific commands do you mean?
> 
Start with git-checkout since it's a basic command and a branching command.
Scott Chacon· Jun 12, 2010, 16:17 UTC · re: Wincent Colaiuta · lore

Re: [PATCH v2] Group the default git help message by topic

Hey,
On Fri, Jun 11, 2010 at 9:26 AM, Wincent Colaiuta <win@wincent.com> wrote:
>
> Nice. I'm sure the output will be a bit less intimidating, but I am not sure about some of the grouping choices you've made here.
>
> "git checkout" is almost certainly a "Basic" command, even though it's used for creating and switching branches.

I wanted the basic commands to be commands that you had to know to use git. You really don't actually *have* to know 'checkout' - you only need to know it if you're using branches, or in a more advanced case, want to revert file contents. To just commit snapshots, 'checkout' is not a necessary command.

>
> "git tag" doesn't really seem to be a "Branch" command, as it's for tagging objects (usually commits), and not branches.

This is true - I suppose it probably actually fits better under 'history', since that's what you're doing is bookmarking a point in history.

>
> "git reset" is the odd one out in the "History" commands group. The other three commands are about _inspecting_ history, whereas "git reset" is about changing the current HEAD. I actually think "git reset" fits better with the "Branch" commands.
>

I guess - I suppose I put it there because I mainly use it to rewind my history (reset HEAD~) but it could go under branches. While we're at it, I'm not sure 'show' is really necessary in this list at all. I rarely use it, which I guess means it's not *terribly* important for day to day use.

Show 26 quoted lines
> I think I'd be inclined to use more descriptive headings and group the commands like this:
>
>  Basic operation:
>    init
>    add
>    status
>    commit
>    checkout
>
>  Inspecting repository state and history:
>    log
>    diff
>    show
>
>  Working with branches:
>    branch
>    merge
>    reset
>
>  Interacting with other repositories:
>    clone
>    fetch
>    pull
>    push
>    remote
>

I kind of like the more descriptive headings, but I still think 'clone' should be in the 'basics' section, because everyone needs to know that, but I had it in the 'remotes' section at first too, so I wouldn't be terribly opposed to moving it back down there. I really don't want 'checkout' in 'basic' - there is no good reason I can see to not have it in 'branches'.

Scott
Wincent Colaiuta· Jun 12, 2010, 17:53 UTC · re: Scott Chacon · lore

Re: [PATCH v2] Group the default git help message by topic

El 12/06/2010, a las 18:17, Scott Chacon escribió:
Show 13 quoted lines
> Hey,
> 
> On Fri, Jun 11, 2010 at 9:26 AM, Wincent Colaiuta <win@wincent.com> wrote:
>> 
>> Nice. I'm sure the output will be a bit less intimidating, but I am not sure about some of the grouping choices you've made here.
>> 
>> "git checkout" is almost certainly a "Basic" command, even though it's used for creating and switching branches.
> 
> I wanted the basic commands to be commands that you had to know to use
> git.  You really don't actually *have* to know 'checkout' - you only
> need to know it if you're using branches, or in a more advanced case,
> want to revert file contents.  To just commit snapshots, 'checkout' is
> not a necessary command.
I think that's an overly restrictive criterion. By that standard, "git status" shouldn't be there either because you don't *have* to know that to use Git either.
Show 5 quoted lines
>> "git tag" doesn't really seem to be a "Branch" command, as it's for tagging objects (usually commits), and not branches.
> 
> This is true - I suppose it probably actually fits better under
> 'history', since that's what you're doing is bookmarking a point in
> history.
In any case, now that you mention it I see that I forgot to include "git tag" anywhere in the listing. I don't think it belongs clearly in any of the categories mentioned so far, despite the fact that it is still a fairly basic command. Perhaps there's a need for a final section called "Other commands:"...
Show 7 quoted lines
>> "git reset" is the odd one out in the "History" commands group. The other three commands are about _inspecting_ history, whereas "git reset" is about changing the current HEAD. I actually think "git reset" fits better with the "Branch" commands.
> 
> I guess - I suppose I put it there because I mainly use it to rewind
> my history (reset HEAD~) but it could go under branches.  While we're
> at it, I'm not sure 'show' is really necessary in this list at all.  I
> rarely use it, which I guess means it's not *terribly* important for
> day to day use.
Well, it's a pretty useful tool IMO as you can point "git show" at just about anything and get something informative back. I use it all the time with no params to get a quick look at the latest change in a repo, and point it at tags and such to give me a quick indication of when/what they were applied to.
For me "git reset" is a much more advanced command and one of the _last_ things I would show a beginning user, seeing as it actually requires them to have a proper grasp of branches and heads in Git (and that may take a little while for them to sink in).
Show 30 quoted lines
>> I think I'd be inclined to use more descriptive headings and group the commands like this:
>> 
>>  Basic operation:
>>    init
>>    add
>>    status
>>    commit
>>    checkout
>> 
>>  Inspecting repository state and history:
>>    log
>>    diff
>>    show
>> 
>>  Working with branches:
>>    branch
>>    merge
>>    reset
>> 
>>  Interacting with other repositories:
>>    clone
>>    fetch
>>    pull
>>    push
>>    remote
>> 
> 
> I kind of like the more descriptive headings, but I still think
> 'clone' should be in the 'basics' section, because everyone needs to
> know that
That's not true. You can start learning to use Git in an empty directory with "git init", and in fact you could quite happily use Git for weeks without using "git clone". Some people use Git to track their home directories or "/etc" or whatever, and never work collaboratively with other repositories at all. So there's nothing "fundamental" about "git clone" IMO.
> but I had it in the 'remotes' section at first too, so I
> wouldn't be terribly opposed to moving it back down there.
Well it is kind of nice to have those five commands grouped together seeing as, unlike some of the other commands under discussion here, they are all indisputably about "Interacting with other repositories".
> I really don't want 'checkout' in 'basic' - there is no good reason I can see
> to not have it in 'branches'.
Well, it seems pretty basic to me. Have you ever seen a Git tutorial that didn't teach "git checkout" in the first 5 minutes? And once the user gets started using Git it's a command they'll use literally all the time. Sticking it in "branches" seems wrong to me seeing as it is a multi-purpose command that does a lot more than just work with branches.
Wincent
Ævar Arnfjörð Bjarmason· Jun 11, 2010, 16:46 UTC · re: Scott Chacon · lore

Re: [PATCH v2] Group the default git help message by topic

On Fri, Jun 11, 2010 at 16:03, Scott Chacon <schacon@gmail.com> wrote:

I like the basic idea behind this patch, i.e. grouping the help output.

Show 6 quoted lines
> It's difficult to process 21 commands (which is what is output
> by default for git when no command is given).  They have been
> re-grouped into 4 groups of 5-6 commands each, which is clearer
> and easier for new users to process.  More advanced commands
> such as bisect and rebase have also been removed as this should
> be output for beginners.
"should not"
> Here is the second version of this patch.  Instead of hard-coding
> all the descriptions, I'm just pulling them from the common-cmds.h
> file.
The reason there are 21 is:
    $ grep -c "mainporcelain common" command-list.txt
    21

Perhaps if `git help` is going to be some subset of that aimed at newbies a new command-list.txt category should be introduced as part of the patch? E.g. "mainporcelain common newbie"?

As a further suggestion for future improvements, perhaps we should document *all* commands in the future, or at least those in mainporcelain and make a full summary available through `git help --full` or something like that.

As far as I can see with this patch the the description for the commands you removed in the `cmdname_help common_cmds` struct is now dead code. If that's the case shouldn't they strings be removed from there?

These are the commands you removed (I think the commit message should be changed to explicitly mention this):

    git-bisect                              mainporcelain common
    git-grep                                mainporcelain common
    git-mv                                  mainporcelain common
    git-rebase                              mainporcelain common
    git-rm                                  mainporcelain common

"mv" and "rm" are certainly something a newbie might frequently used. Why not list it under "Basic commands" along with "add"?

I use "rebase" much more than some of the commands now listed, it's one of the main distinguishing features of git, so perhaps it should be under "Branch Commands", if for no other reason than to give users a peek down the rabbit hole.

Show 45 quoted lines
>  builtin/help.c |   54 ++++++++++++++++++++++++++++++++++++++++++------------
>  1 files changed, 42 insertions(+), 12 deletions(-)
>
> diff --git a/builtin/help.c b/builtin/help.c
> index 3182a2b..2975b3d 100644
> --- a/builtin/help.c
> +++ b/builtin/help.c
> @@ -269,23 +269,53 @@ static int git_help_config(const char *var,
> const char *value, void *cb)
>        return git_default_config(var, value, cb);
>  }
>
> -static struct cmdnames main_cmds, other_cmds;
> -
> -void list_common_cmds_help(void)
> +void print_command(const char *s)
>  {
> -       int i, longest = 0;
> +       int i = 0;
> +       int longest = 10;
>
>        for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> -               if (longest < strlen(common_cmds[i].name))
> -                       longest = strlen(common_cmds[i].name);
> +               if (!strcmp(s, common_cmds[i].name)) {
> +                       printf("   %s   ", common_cmds[i].name);
> +                       mput_char(' ', longest - strlen(common_cmds[i].name));
> +                       puts(common_cmds[i].help);
> +               }
>        }
> +}
>
> -       puts("The most commonly used git commands are:");
> -       for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> -               printf("   %s   ", common_cmds[i].name);
> -               mput_char(' ', longest - strlen(common_cmds[i].name));
> -               puts(common_cmds[i].help);
> -       }
> +static struct cmdnames main_cmds, other_cmds;
> +
> +void list_common_cmds_help(void)
> +{
> +       puts("The most commonly used git commands are:\n");
> +
> +       puts("Basic Commands:");

Why capitalize "Commands" when it's not at the beginning of a sentence? 'bzr help' doesn't do this. And For What It's Worth I Find It Uncomfortable To Read Text Formatted Like That.

Show 27 quoted lines
> +       print_command("init");
> +       print_command("clone");
> +       print_command("add");
> +       print_command("status");
> +       print_command("commit");
> +       puts("");
> +
> +       puts("Branch Commands:");
> +       print_command("branch");
> +       print_command("checkout");
> +       print_command("merge");
> +       print_command("tag");
> +       puts("");
> +
> +       puts("History Commands:");
> +       print_command("log");
> +       print_command("diff");
> +       print_command("reset");
> +       print_command("show");
> +       puts("");
> +
> +       puts("Remote Commands:");
> +       print_command("remote");
> +       print_command("fetch");
> +       print_command("pull");
> +       print_command("push");
>  }
Junio C Hamano· Jun 14, 2010, 06:30 UTC · re: Scott Chacon · lore

Re: [PATCH v2] Group the default git help message by topic

Scott Chacon <schacon@gmail.com> writes:
Show 6 quoted lines
> It's difficult to process 21 commands (which is what is output
> by default for git when no command is given).  They have been
> re-grouped into 4 groups of 5-6 commands each, which is clearer
> and easier for new users to process.  More advanced commands
> such as bisect and rebase have also been removed as this should
> be output for beginners.

I am lazy, and I loathe having to maintain another hardcoded table (let alone sequence of print_command() calls, like this patch does, yuck).

The two words, "21" and "group", in your proposed commit log message have been nagging me for a while, and I finally figured out why this patch made me feel very disturbed. We already have a perfect source to generate the necessary most commonly used command list with a good grouping hint, but the patch does not make use of it.

So here is a counterproposal.

If readers notice that there are some commands that are out of fashion (e.g. I don't think many people use show-branch anymore in the presence of "log --oneline --graph" and friends) listed in the "git help" output, that is a _good thing_. It will give us an incentive to keep the Everyday document up to date, and with the effort spent for that, "git help" will automatically be kept up to date as well for free ;-)

-- >8 --
Subject: generate "git help" command list using the "Everyday" document

Alphabetized list of "commonly used commands" we currently give is hard to approach. Instead, using the "Everyday" document as a template, group commands by the role the user plays, and present the commands in the order they typically used while playing each role.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile            |    2 +-
 builtin/help.c      |   14 ++++++++---
 generate-cmdlist.sh |   64 +++++++++++++++++++++++++++++++++++---------------
 3 files changed, 56 insertions(+), 24 deletions(-)
Show changes to 3 files +56 −24

Makefile, builtin/help.c, generate-cmdlist.sh

diff --git a/Makefile b/Makefile
index 5fa893c..770bea8 100644
--- a/Makefile
+++ b/Makefile
@@ -1529,7 +1529,7 @@ $(BUILT_INS): git$X
 
 common-cmds.h: ./generate-cmdlist.sh command-list.txt
 
-common-cmds.h: $(wildcard Documentation/git-*.txt)
+common-cmds.h: $(wildcard Documentation/git-*.txt) Documentation/everyday.txt
 	$(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
 
 define cmd_munge_script
diff --git a/builtin/help.c b/builtin/help.c
index 3182a2b..546b3a7 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -276,15 +276,21 @@ void list_common_cmds_help(void)
 	int i, longest = 0;
 
 	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+		if (!common_cmds[i].help)
+			continue;
 		if (longest < strlen(common_cmds[i].name))
 			longest = strlen(common_cmds[i].name);
 	}
 
-	puts("The most commonly used git commands are:");
+	puts("Some commonly used git commands per developer roles are:");
 	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
-		printf("   %s   ", common_cmds[i].name);
-		mput_char(' ', longest - strlen(common_cmds[i].name));
-		puts(common_cmds[i].help);
+		if (!common_cmds[i].help) {
+			printf(" * %s\n", common_cmds[i].name);
+		} else {
+			printf("   %s  ", common_cmds[i].name);
+			mput_char(' ', longest - strlen(common_cmds[i].name));
+			puts(common_cmds[i].help);
+		}
 	}
 }
 
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 75c68d9..c6cab26 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -1,24 +1,50 @@
 #!/bin/sh
 
-echo "/* Automatically generated by $0 */
-struct cmdname_help
+echo "/* Automatically generated by $0 - do not edit */
+
+/*
+ * Special entries without 'help' are section headers.
+ */
+static struct cmdname_help
 {
-    char name[16];
-    char help[80];
-};
+	const char *name;
+	const char *help;
+} common_cmds[] = {"
+
+perl -e '
+my %seen = ();
+my $section = undef;
+
+while (<STDIN>) {
+	chomp;
+	if (/^\S.*\[\[(.+)\]\]$/) {
+		print "\n  { \"$1\", NULL },\n\n";
+		next;
+	}
+	while (s/linkgit:git-([-a-z]*)//) {
+		my $cmd = $1;
+		next if ($seen{$cmd}++);
 
-static struct cmdname_help common_cmds[] = {"
+		my $desc = undef;
+		open I, "<", "Documentation/git-$cmd.txt"
+			or die "Cannot read Documentation/git-$cmd.txt: $!";
+		while (<I>) {
+			next if (1../^NAME/);
+			if (/^git-$cmd /) {
+				s/^git-$cmd - //;
+				chomp;
+				$desc = $_;
+				last;
+			}
+		}
+		close I;
+		if (!defined $desc) {
+			die "Cannot read description for $cmd";
+		}
+		print "  { \"$cmd\", \"$desc\" },\n";
+	}
+}
+' <Documentation/everyday.txt
 
-sed -n -e 's/^git-\([^ 	]*\)[ 	].* common.*/\1/p' command-list.txt |
-sort |
-while read cmd
-do
-     sed -n '
-     /^NAME/,/git-'"$cmd"'/H
-     ${
-            x
-            s/.*git-'"$cmd"' - \(.*\)/  {"'"$cmd"'", "\1"},/
-	    p
-     }' "Documentation/git-$cmd.txt"
-done
-echo "};"
+echo "
+};"
Scott Chacon· Jun 14, 2010, 15:31 UTC · re: Junio C Hamano · lore

Re: [PATCH v2] Group the default git help message by topic

Hey,
On Sun, Jun 13, 2010 at 11:30 PM, Junio C Hamano <gitster@pobox.com> wrote:
>
> I am lazy, and I loathe having to maintain another hardcoded table (let
> alone sequence of print_command() calls, like this patch does, yuck).
>

Sorry, but it seemed to me this would have to be separately maintained anyhow, plus it doesn't change much. How often are basic commands going to be added or removed? Also, it may not be that pretty, but it's undeniably clear.

Show 5 quoted lines
> The two words, "21" and "group", in your proposed commit log message have
> been nagging me for a while, and I finally figured out why this patch made
> me feel very disturbed.  We already have a perfect source to generate the
> necessary most commonly used command list with a good grouping hint, but
> the patch does not make use of it.
The only issue I would have with this statement is the word 'perfect'.

To disambiguate what we're talking about here, this is the output that is generated from this new patch:

Some commonly used git commands per developer roles are:
 * Individual Developer (Standalone)
   init          Create an empty git repository or reinitialize an existing one
   show-branch   Show branches and their commits
   log           Show commit logs
   checkout      Checkout a branch or paths to the working tree
   add           Add file contents to the index
   diff          Show changes between commits, commit and working tree, etc
   commit        Record changes to the repository
   reset         Reset current HEAD to the specified state
   merge         Join two or more development histories together
   rebase        Forward-port local commits to the updated upstream head
   tag           Create, list, delete or verify a tag object signed with GPG
 * Individual Developer (Participant)
   clone         Clone a repository into a new directory
   pull          Fetch from and merge with another repository or a local branch
   push          Update remote refs along with associated objects
   format-patch  Prepare patches for e-mail submission
 * Integrator
   am            Apply a series of patches from a mailbox
   revert        Revert an existing commit
 * Repository Administration
   daemon        A really simple server for git repositories
   shell         Restricted login shell for GIT-only SSH access

Though the implementation of the solution is undeniably more elegant, I have some serious issues with the output. As you mention next, 'show-branches' is second in the list, which is an issue, but there are several more. 'am', 'revert', 'daemon', 'shell', 'rebase' - none of these are appropriate for someone running 'git' and trying to see where to start. If we put those aside, all we have is a big list of commands again which adds almost no value to what we had before.

Show 6 quoted lines
> If readers notice that there are some commands that are out of fashion
> (e.g. I don't think many people use show-branch anymore in the presence of
> "log --oneline --graph" and friends) listed in the "git help" output, that
> is a _good thing_.  It will give us an incentive to keep the Everyday
> document up to date, and with the effort spent for that, "git help" will
> automatically be kept up to date as well for free ;-)

That's a fine goal, but I feel like it shouldn't be an "everyday" document that generates that output, it should be a "beginner" document or a "how to start using Git" document that isn't really in the Git source. I mean, I suppose we could write one with the goal of using it to generate the help output, but given how much people disagreed with even the basic grouping of the first patch I sent, I can't see how we're going to agree on a new help doc. Perhaps we should decide on what we would ultimately like the basic help output to look like and then I can craft a document that would produce it given this patch and then the list can rip it apart until it's basically acceptable.

Thoughts?
Scott
Tay Ray Chuan· Jun 14, 2010, 16:49 UTC · re: Scott Chacon · lore

Re: [PATCH v2] Group the default git help message by topic

Hi,
On Mon, Jun 14, 2010 at 11:31 PM, Scott Chacon <schacon@gmail.com> wrote:
Show 30 quoted lines
> [snip]
> On Sun, Jun 13, 2010 at 11:30 PM, Junio C Hamano <gitster@pobox.com> wrote:
> [snip]
> To disambiguate what we're talking about here, this is the output that
> is generated from this new patch:
>
> Some commonly used git commands per developer roles are:
>  * Individual Developer (Standalone)
>   init          Create an empty git repository or reinitialize an existing one
>   show-branch   Show branches and their commits
>   log           Show commit logs
>   checkout      Checkout a branch or paths to the working tree
>   add           Add file contents to the index
>   diff          Show changes between commits, commit and working tree, etc
>   commit        Record changes to the repository
>   reset         Reset current HEAD to the specified state
>   merge         Join two or more development histories together
>   rebase        Forward-port local commits to the updated upstream head
>   tag           Create, list, delete or verify a tag object signed with GPG
>  * Individual Developer (Participant)
>   clone         Clone a repository into a new directory
>   pull          Fetch from and merge with another repository or a local branch
>   push          Update remote refs along with associated objects
>   format-patch  Prepare patches for e-mail submission
>  * Integrator
>   am            Apply a series of patches from a mailbox
>   revert        Revert an existing commit
>  * Repository Administration
>   daemon        A really simple server for git repositories
>   shell         Restricted login shell for GIT-only SSH access
On behalf of people too lazy to patch and compile, like myself - thanks.
> [snip]
> As you mention next,
> 'show-branches' is second in the list, which is an issue,
Then perhaps we should do something about Documentation/everyday.txt.
Show 5 quoted lines
> but there
> are several more.  'am', 'revert', 'daemon', 'shell', 'rebase' - none
> of these are appropriate for someone running 'git' and trying to see
> where to start.  If we put those aside, all we have is a big list of
> commands again which adds almost no value to what we had before.

They are placed under the titles 'Integrator' and 'Repository Administration', which, I think, is enough to serve as a 'warning! git-fu ahead' for users who wish to preserve their sanity.

On 'big' - mercurial, which is associated with 'user-friendly', shows a list of 50 commands.

Show 11 quoted lines
>> If readers notice that there are some commands that are out of fashion
>> (e.g. I don't think many people use show-branch anymore in the presence of
>> "log --oneline --graph" and friends) listed in the "git help" output, that
>> is a _good thing_.  It will give us an incentive to keep the Everyday
>> document up to date, and with the effort spent for that, "git help" will
>> automatically be kept up to date as well for free ;-)
>
> That's a fine goal, but I feel like it shouldn't be an "everyday"
> document that generates that output, it should be a "beginner"
> document or a "how to start using Git" document that isn't really in
> the Git source.

I, for one, don't think "git help" is the place beginners go to when they first start off - I sure didn't.

The goal of re-grouping and having a short list of commands is nice, and I see this as useful for people starting to use git, but not for people learning it.

-- 
Cheers,
Ray Chuan
Scott Chacon· Jun 14, 2010, 16:59 UTC · re: Tay Ray Chuan · lore

Re: [PATCH v2] Group the default git help message by topic

Hey,
On Mon, Jun 14, 2010 at 9:49 AM, Tay Ray Chuan <rctay89@gmail.com> wrote:
Show 8 quoted lines
>
> I, for one, don't think "git help" is the place beginners go to when
> they first start off - I sure didn't.
>
> The goal of re-grouping and having a short list of commands is nice,
> and I see this as useful for people starting to use git, but not for
> people learning it.
>

I would still argue that 'git daemon' and friends are not what people starting to use Git need to see.

Scott
Junio C Hamano· Jun 14, 2010, 17:24 UTC · re: Scott Chacon · lore

Re: [PATCH v2] Group the default git help message by topic

Scott Chacon <schacon@gmail.com> writes:
Show 21 quoted lines
> Though the implementation of the solution is undeniably more elegant,
> I have some serious issues with the output.  As you mention next,
> 'show-branches' is second in the list, which is an issue, but there
> are several more.  'am', 'revert', 'daemon', 'shell', 'rebase' - none
> of these are appropriate for someone running 'git' and trying to see
> where to start.  If we put those aside, all we have is a big list of
> commands again which adds almost no value to what we had before.
> ...
>> If readers notice that there are some commands that are out of fashion
>> (e.g. I don't think many people use show-branch anymore in the presence of
>> "log --oneline --graph" and friends) listed in the "git help" output, that
>> is a _good thing_.  It will give us an incentive to keep the Everyday
>> document up to date, and with the effort spent for that, "git help" will
>> automatically be kept up to date as well for free ;-)
>
> That's a fine goal, but I feel like it shouldn't be an "everyday"
> document that generates that output, it should be a "beginner"
> document or a "how to start using Git" document that isn't really in
> the Git source.
>
> Thoughts?
Three points.
 - The fact that you noticed "show-branches" is _a good thing_.  If it
   doesn't deserve to be "this is the list of often used commands" given
   by "git help", it shouldn't be in (an early part of) Everyday either.
 - I think the "git help" list and "Everyday" document should serve the
   same purpose for two classes of audiences, ones that prefer online vs
   ones that prefer offline.  "Repository Maintenance" are pushed down in
   the Everyday document as they are sometimes needed but should not be
   necessary in "Everyday" operation.  I think it may be a good idea to
   stop generate-cmdlist.sh early before reading Everyday to the end,
   which would cut the cruft from "git help" output.
 - I do not necessarily agree with your notion that "git help" output is
   for "someone trying to see where to start".  To me, it is primarily to
   serve as a reminder for people who have been casually using git for
   some time (i.e. "I know what I do but I don't offhand recall how it is
   spelled").  Not everybody will stay as a newbie.

I think the last point is the crux of disagreement between us. You have been in the "git teaching" business for a long time, and I am very much willing to be pursuaded, together with other participants on the list.

Matthieu Moy· Jun 14, 2010, 07:48 UTC · re: Scott Chacon · lore

Re: [PATCH v2] Group the default git help message by topic

Scott Chacon <schacon@gmail.com> writes:
Show 7 quoted lines
> +	puts("Basic Commands:");
> +	print_command("init");
> +	print_command("clone");
> +	print_command("add");
> +	print_command("status");
> +	print_command("commit");
> +	puts("");
Shouldn't "git rm" be listed next to "git add"?
-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

← back to recent threads