From: Scott Chacon <schacon@gmail.com>
To: git list <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH v2] Group the default git help message by topic
Date: Fri, 11 Jun 2010 09:03:44 -0700 [thread overview]
Message-ID: <AANLkTiloErvcWS1hW80cIV9SiWu_7CBdNSx_iAppcGOd@mail.gmail.com> (raw)
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(-)
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
next reply other threads:[~2010-06-11 16:03 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-11 16:03 Scott Chacon [this message]
2010-06-11 16:26 ` [PATCH v2] Group the default git help message by topic Wincent Colaiuta
2010-06-11 22:00 ` A Large Angry SCM
2010-06-11 22:28 ` Ævar Arnfjörð Bjarmason
2010-06-12 16:19 ` Scott Chacon
2010-06-12 16:35 ` Ævar Arnfjörð Bjarmason
2010-06-12 18:44 ` A Large Angry SCM
2010-06-12 16:17 ` Scott Chacon
2010-06-12 17:53 ` Wincent Colaiuta
2010-06-11 16:46 ` Ævar Arnfjörð Bjarmason
2010-06-14 6:30 ` Junio C Hamano
2010-06-14 15:31 ` Scott Chacon
2010-06-14 16:49 ` Tay Ray Chuan
2010-06-14 16:59 ` Scott Chacon
2010-06-14 17:24 ` Junio C Hamano
2010-06-14 7:48 ` Matthieu Moy
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=AANLkTiloErvcWS1hW80cIV9SiWu_7CBdNSx_iAppcGOd@mail.gmail.com \
--to=schacon@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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).