From: "Santi Bejar" <sbejar@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH] git help: sort commands by topi
Date: Sun, 17 Feb 2008 15:48:21 +0100 [thread overview]
Message-ID: <87hcg77i6i.fsf@gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 391 bytes --]
Hi *,
here is a patch that I've sent a lot of times to the list and it has not
arrived, I suppose because the spam filtering, but I've look the filter
applied and I do not find anything. I've also compared this with other
mails I've sent and I don't see anything relevant. I'm sending the
the patch as an attachment.
Santi
P.D: Does anyone know how can I know the reason for the drops?
[-- Attachment #2: 0001-git-help-t-topic-lists-all-the-commands-classifi.patch --]
[-- Type: text/x-diff, Size: 6536 bytes --]
>From 3379f6e84035748fc9d1a14fbfcbc31b20a3582c Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Santi=20B=C3=A9jar?= <sbejar@gmail.com>
Date: Sun, 27 Jan 2008 01:34:57 +0100
Subject: [PATCH] git help -t|--topic: lists all the commands classified by topic
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Additionally shows a hint to get the long list when listing the common commands.
Signed-off-by: Santi Béjar <sbejar@gmail.com>
---
Documentation/git-help.txt | 8 +++++-
Makefile | 2 +-
generate-cmdlist.sh | 28 ++++++++++++++++++------
help.c | 51 ++++++++++++++++++++++++++++++++++++-------
topic-list.txt | 12 ++++++++++
5 files changed, 82 insertions(+), 19 deletions(-)
create mode 100644 topic-list.txt
diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt
index 0926dc1..26998c5 100644
--- a/Documentation/git-help.txt
+++ b/Documentation/git-help.txt
@@ -7,7 +7,7 @@ git-help - display help information about git
SYNOPSIS
--------
-'git help' [-a|--all|-i|--info|-m|--man|-w|--web] [COMMAND]
+'git help' [-a|--all|-i|--info|-m|--man|-t|--topic|-w|--web] [COMMAND]
DESCRIPTION
-----------
@@ -17,7 +17,8 @@ command and a list of the most commonly used git commands are printed
on the standard output.
If the option '--all' or '-a' is given, then all available commands are
-printed on the standard output.
+printed on the standard output. For a list of all git commands classified by
+topic use '--topic' of '-t'.
If a git command is named, a manual page for that command is brought
up. The 'man' program is used by default for this purpose, but this
@@ -41,6 +42,9 @@ OPTIONS
used to override a value set in the 'help.format'
configuration variable.
+-t|--topic::
+ Prints all the commands classified by topic.
+
-w|--web::
Use a web browser to display the HTML manual page, instead of
the 'man' program that is used by default.
diff --git a/Makefile b/Makefile
index 83c359a..64ca31a 100644
--- a/Makefile
+++ b/Makefile
@@ -837,7 +837,7 @@ git-merge-subtree$X: git-merge-recursive$X
$(BUILT_INS): git$X
$(QUIET_BUILT_IN)$(RM) $@ && ln git$X $@
-common-cmds.h: ./generate-cmdlist.sh command-list.txt
+common-cmds.h: ./generate-cmdlist.sh command-list.txt topic-list.txt
common-cmds.h: $(wildcard Documentation/git-*.txt)
$(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index a2913c2..ec623dd 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -3,22 +3,36 @@
echo "/* Automatically generated by $0 */
struct cmdname_help
{
- char name[16];
+ char name[23];
char help[80];
+ char topic[22];
+ char subtopic[10];
};
-static struct cmdname_help common_cmds[] = {"
+struct topicname_help
+{
+ char name[23];
+ char subtopic[10];
+ char help[80];
+};
-sed -n -e 's/^git-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt |
-sort |
-while read cmd
+static struct cmdname_help cmd_list[] = {"
+
+sed -n -e 's/^git-\([^ ]*\)\(.*\)$/\1\2/p' command-list.txt |
+grep -v deprecated | sort |
+while read cmd topic subtopic
do
sed -n '
- /NAME/,/git-'"$cmd"'/H
+ /^NAME$/,/git-'"$cmd"'/H
${
x
- s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
+ s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1",/
p
}' "Documentation/git-$cmd.txt"
+ echo "\"$topic\", \"$subtopic\" },"
done
echo "};"
+
+echo "static struct topicname_help topic_list[] = {"
+sed -n -e 's/^topic-\([^ ]*\) \(common\|\) \(.*\)$/{\"\1\", \"\2\", \"\3\"},/p' topic-list.txt
+echo "};"
diff --git a/help.c b/help.c
index 6e28ad9..0e3a350 100644
--- a/help.c
+++ b/help.c
@@ -262,20 +262,48 @@ static void list_commands(void)
}
}
-void list_common_cmds_help(void)
+void list_topic_cmds_help(const char *topic, const char *subtopic)
{
int i, longest = 0;
- for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
- if (longest < strlen(common_cmds[i].name))
- longest = strlen(common_cmds[i].name);
+ for (i = 0; i < ARRAY_SIZE(topic_list); i++) {
+ if (!strcmp(topic_list[i].name, topic) &&
+ !strcmp(topic_list[i].subtopic, subtopic)) {
+ printf("%s:\n",topic_list[i].help);
+ }
+ }
+
+ for (i = 0; i < ARRAY_SIZE(cmd_list); i++) {
+ if (strcmp(cmd_list[i].topic, topic)) continue;
+ if (!strcmp(topic_list[i].subtopic,"") &&
+ strcmp(cmd_list[i].subtopic, subtopic)) continue;
+ if (longest < strlen(cmd_list[i].name))
+ longest = strlen(cmd_list[i].name);
}
- 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);
+ for (i = 0; i < ARRAY_SIZE(cmd_list); i++) {
+ if (strcmp(cmd_list[i].topic, topic)) continue;
+ if (!strcmp(topic_list[i].subtopic,"") &&
+ strcmp(cmd_list[i].subtopic, subtopic)) continue;
+ printf(" %s ", cmd_list[i].name);
+ mput_char(' ', longest - strlen(cmd_list[i].name));
+ puts(cmd_list[i].help);
+ }
+ putchar('\n');
+}
+
+void list_common_cmds_help(void)
+{
+ list_topic_cmds_help("mainporcelain","common");
+ puts("(use 'git help -t' to get a longer list)");
+}
+
+void list_topics_help()
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(topic_list); i++) {
+ if(strcmp(topic_list[i].subtopic,"")) continue;
+ list_topic_cmds_help(topic_list[i].name,"");
}
}
@@ -391,6 +419,11 @@ int cmd_help(int argc, const char **argv, const char *prefix)
show_man_page(argc > 2 ? argv[2] : NULL);
}
+ else if (!strcmp(help_cmd, "--topic") || !strcmp(help_cmd, "-t")) {
+ setup_pager();
+ list_topics_help();
+ }
+
else {
int nongit;
diff --git a/topic-list.txt b/topic-list.txt
new file mode 100644
index 0000000..2ba11a9
--- /dev/null
+++ b/topic-list.txt
@@ -0,0 +1,12 @@
+# List of known git topics.
+# topic name help
+common The most commonly used commands
+mainporcelain Main porcelain commands
+ancillarymanipulators Interrogators commands
+ancillaryinterrogators Manipulators commands
+foreignscminterface Commands dealing with foreing SCM
+plumbingmanipulators Low-level manipulation commands
+plumbinginterrogators Low-level Interrogation commands
+synchingrepositories Synching repositories
+synchelpers Synching helper commands
+purehelpers Internal helper commands
--
1.5.4.1219.g65b9
next reply other threads:[~2008-02-17 14:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-17 14:48 Santi Bejar [this message]
2008-02-18 10:15 ` [PATCH] git help: sort commands by topi Junio C Hamano
2008-02-18 17:16 ` Santi Béjar
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=87hcg77i6i.fsf@gmail.com \
--to=sbejar@gmail.com \
--cc=git@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.