From: "Sébastien Guimmara" <sebastien.guimmara@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: "Git List" <git@vger.kernel.org>,
"Junio C Hamano" <gitster@pobox.com>,
"Sébastien Guimmara" <sebastien.guimmara@gmail.com>
Subject: Re: [PATCH 3/3] git help: group common commands by theme
Date: Wed, 06 May 2015 22:31:45 +0200 [thread overview]
Message-ID: <554A7A31.1080604@gmail.com> (raw)
In-Reply-To: <CAPig+cS=u-HK1qNicWiLOQC6RPkR7QueX+kOu8fQwpHekgs1yg@mail.gmail.com>
On 05/06/2015 05:16 AM, Eric Sunshine wrote:
> On Mon, May 4, 2015 at 4:28 PM, Sébastien Guimmara
> <sebastien.guimmara@gmail.com> wrote:
>> 'git help' shows common commands in alphabetical order:
>>
>> The most commonly used git commands are:
>> add Add file contents to the index
>> bisect Find by binary search the change that introduced a bug
>> branch List, create, or delete branches
>> checkout Checkout a branch or paths to the working tree
>> clone Clone a repository into a new directory
>> commit Record changes to the repository
>> [...]
>>
>> without any indication of how commands relate to high-level
>> concepts or each other. Revise the output to group commands by
>> concept, like this:
>>
>> The most commonly used git commands are:
>>
>> * starting a working area:
>> clone Clone a repository into a new directory
>> init Create an empty Git repository or reinitialize an existing one
>>
>> * working on the current change:
>> add Add file contents to the index
>> reset Reset current HEAD to the specified state
>> [...]
>
> This looks better. A couple minor style nits and a question below...
>
>> ---
>> diff --git a/help.c b/help.c
>> index 2072a87..c8b0bb6 100644
>> --- a/help.c
>> +++ b/help.c
>> @@ -218,18 +218,44 @@ void list_commands(unsigned int colopts,
>> }
>> }
>>
>> +int cmd_group_cmp(const void *elem1, const void *elem2)
>> +{
>> + int group1, group2;
>> +
>> + group1 = ((struct cmdname_help *) elem1)->group;
>> + group2 = ((struct cmdname_help *) elem2)->group;
>
> Style: Drop space after the cast: (type *)var
>
>> +
>> + if (group1 == group2)
>> + return 0;
>> + if (group1 > group2)
>> + return 1;
>> + else
>> + return -1;
>
> Do you also want to sort the commands alphabetically within group?
> That is, something like this?
>
> struct cmdname_help *e1 = elem1;
> struct cmdname_help *e2 = elem2;
>
> if (e1->group < e2->group)
> return -1;
> if (e1->group > e2->group)
> return 1;
> return strcmp(e1->name, e2->name);
>
Hmmm yes. Good idea.
>> +}
>> +
>> void list_common_cmds_help(void)
>> {
>> int i, longest = 0;
>> + unsigned char current_grp = -1;
>>
>> for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
>> if (longest < strlen(common_cmds[i].name))
>> longest = strlen(common_cmds[i].name);
>> }
>>
>> + qsort(common_cmds, ARRAY_SIZE(common_cmds),
>> + sizeof(common_cmds[0]), cmd_group_cmp);
>> +
>> puts(_("The most commonly used git commands are:"));
>> +
>> for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
>> - printf(" %s ", common_cmds[i].name);
>> + if (common_cmds[i].group != current_grp) {
>> + printf("\n * %s:\n", _(common_cmd_groups[common_cmds[i].group]));
>> + }
>
> Style: Drop unnecessary braces.
Understood.
next prev parent reply other threads:[~2015-05-06 20:31 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-04 20:28 [PATCH 0/3] git help: group common commands by theme Sébastien Guimmara
2015-05-04 20:28 ` [PATCH 1/3] command-list.txt: " Sébastien Guimmara
2015-05-06 6:57 ` Eric Sunshine
2015-05-06 20:58 ` Sébastien Guimmara
2015-05-07 16:50 ` Eric Sunshine
2015-05-07 19:23 ` Johannes Sixt
2015-05-08 10:11 ` Johannes Schindelin
2015-05-08 12:01 ` Andreas Schwab
2015-05-08 13:02 ` Johannes Schindelin
2015-05-08 18:43 ` Sébastien Guimmara
2015-05-08 19:00 ` Eric Sunshine
2015-05-04 20:28 ` [PATCH 2/3] generate-cmdlist.sh: parse common group commands Sébastien Guimmara
2015-05-08 3:20 ` Eric Sunshine
2015-05-08 3:39 ` Eric Sunshine
2015-05-08 20:55 ` Sébastien Guimmara
2015-05-04 20:28 ` [PATCH 3/3] git help: group common commands by theme Sébastien Guimmara
2015-05-06 3:16 ` Eric Sunshine
2015-05-06 20:31 ` Sébastien Guimmara [this message]
2015-05-08 21:08 ` Sébastien Guimmara
2015-05-08 21:17 ` Stefan Beller
2015-05-08 21:19 ` Eric Sunshine
2015-05-08 21:20 ` Sébastien Guimmara
2015-05-06 3:08 ` [PATCH 0/3] " Eric Sunshine
2015-05-06 20:26 ` Sébastien Guimmara
2015-05-06 20:49 ` Eric Sunshine
2015-05-06 3:41 ` Junio C Hamano
2015-05-08 18:00 ` Sébastien Guimmara
2015-05-08 18:53 ` Junio C Hamano
2015-05-06 7:59 ` Matthieu Moy
2015-05-06 17:42 ` Junio C Hamano
2015-05-07 8:42 ` Matthieu Moy
2015-05-07 18:44 ` Junio C Hamano
2015-05-08 8:18 ` Matthieu Moy
2015-05-08 16:19 ` Junio C Hamano
2015-05-07 9:31 ` Emma Jane Hogbin Westby
2015-05-08 18:21 ` Sébastien Guimmara
2015-05-08 18:58 ` Junio C Hamano
2015-05-08 20:08 ` Sébastien Guimmara
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=554A7A31.1080604@gmail.com \
--to=sebastien.guimmara@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sunshine@sunshineco.com \
/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).