summaryrefslogtreecommitdiff
path: root/help.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-06-01 12:45:18 -0700
committerJunio C Hamano <gitster@pobox.com>2015-06-01 12:45:19 -0700
commit6dec263333417738528089834bd8cda72017aa31 (patch)
tree70e67708b1100262c98206130af057cc0b137fa6 /help.c
parentabcbafedbfbd5994ad604bab141c0ba18f5a19df (diff)
parent224147704a3696d396dae005c280f7a25de407c7 (diff)
downloadgit-6dec263333417738528089834bd8cda72017aa31.tar.gz
Merge branch 'sg/help-group'
Group list of commands shown by "git help" along the workflow elements to help early learners. * sg/help-group: help: respect new common command grouping command-list.txt: drop the "common" tag generate-cmdlist: parse common group commands command-list.txt: add the common groups block command-list: prepare machinery for upcoming "common groups" section
Diffstat (limited to 'help.c')
-rw-r--r--help.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/help.c b/help.c
index 2072a873e2..8f72051ae0 100644
--- a/help.c
+++ b/help.c
@@ -218,17 +218,39 @@ void list_commands(unsigned int colopts,
}
}
+static int cmd_group_cmp(const void *elem1, const void *elem2)
+{
+ const struct cmdname_help *e1 = elem1;
+ const 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);
+}
+
void list_common_cmds_help(void)
{
int i, longest = 0;
+ int 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);
}
- puts(_("The most commonly used git commands are:"));
+ qsort(common_cmds, ARRAY_SIZE(common_cmds),
+ sizeof(common_cmds[0]), cmd_group_cmp);
+
+ puts(_("These are common Git commands used in various situations:"));
+
for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+ if (common_cmds[i].group != current_grp) {
+ printf("\n%s\n", _(common_cmd_groups[common_cmds[i].group]));
+ current_grp = common_cmds[i].group;
+ }
+
printf(" %s ", common_cmds[i].name);
mput_char(' ', longest - strlen(common_cmds[i].name));
puts(_(common_cmds[i].help));