* [PATCH] git help: sort commands by topi
@ 2008-02-17 14:48 Santi Bejar
2008-02-18 10:15 ` Junio C Hamano
0 siblings, 1 reply; 3+ messages in thread
From: Santi Bejar @ 2008-02-17 14:48 UTC (permalink / raw)
To: git
[-- 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] git help: sort commands by topi
2008-02-17 14:48 [PATCH] git help: sort commands by topi Santi Bejar
@ 2008-02-18 10:15 ` Junio C Hamano
2008-02-18 17:16 ` Santi Béjar
0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2008-02-18 10:15 UTC (permalink / raw)
To: Santi Bejar; +Cc: git
"Santi Bejar" <sbejar@gmail.com> writes:
> P.D: Does anyone know how can I know the reason for the drops?
I'd love to know that myself.
It would be interesting to install the kernel's checkpatch.pl
as anti-bogo-style filter on the mailing list ;-)
> 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];
> };
These limits are very magic. If you are generating them in the
script perhaps you would want to count bytes?
I dunno. Honestly, I am not very interested in this patch
myself.
Side Note: my not being interested does not mean I
strongly oppose to its inclusion (I do not even care).
It is just that I won't be the one who will be pushing
for its inclusion, and you would want supporters other
than me to push for it.
> -static struct cmdname_help common_cmds[] = {"
> +struct topicname_help
> +{
> + char name[23];
> + char subtopic[10];
> + char help[80];
> +};
Likewise.
> -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
I do not like this pipeline to send output of sed to an _overly_
loose grep. What happens when we introduce "git-deprecated"
command later?
> do
> sed -n '
> - /NAME/,/git-'"$cmd"'/H
> + /^NAME$/,/git-'"$cmd"'/H
Good tightening.
> ${
> x
> - s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> + s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1",/
> p
> }' "Documentation/git-$cmd.txt"
> + echo "\"$topic\", \"$subtopic\" },"
Breaks nicely indented entries like:
{"add", "Add file contents...
> 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)
> ...
> + 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);
> }
Style. A statement comes on its own line, even if it is a
"continue" statement.
> + 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');
Likewise.
> +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,"");
> }
> }
Style. Have a SP before '(' if the previous token is not a
function name.
> 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
> ...
> +synchelpers Synching helper commands
> +purehelpers Internal helper commands
I wonder if this can be shared with the section headings of
Documentation/git.txt; either generate the section headings from
this file, or generate this file from the section headings.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] git help: sort commands by topi
2008-02-18 10:15 ` Junio C Hamano
@ 2008-02-18 17:16 ` Santi Béjar
0 siblings, 0 replies; 3+ messages in thread
From: Santi Béjar @ 2008-02-18 17:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
On Feb 18, 2008 11:15 AM, Junio C Hamano <gitster@pobox.com> wrote:
> "Santi Bejar" <sbejar@gmail.com> writes:
> > 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];
> > };
>
> These limits are very magic. If you are generating them in the
> script perhaps you would want to count bytes?
>
They were already there. Maybe in a cleanup patch.
> I dunno. Honestly, I am not very interested in this patch
> myself.
>
> Side Note: my not being interested does not mean I
> strongly oppose to its inclusion (I do not even care).
> It is just that I won't be the one who will be pushing
> for its inclusion, and you would want supporters other
> than me to push for it.
OK.
>
> > -static struct cmdname_help common_cmds[] = {"
> > +struct topicname_help
> > +{
> > + char name[23];
> > + char subtopic[10];
> > + char help[80];
> > +};
>
> Likewise.
>
> > -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
>
> I do not like this pipeline to send output of sed to an _overly_
> loose grep. What happens when we introduce "git-deprecated"
> command later?
I'll look at it.
[...]
> > ${
> > x
> > - s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> > + s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1",/
> > p
> > }' "Documentation/git-$cmd.txt"
> > + echo "\"$topic\", \"$subtopic\" },"
>
> Breaks nicely indented entries like:
>
> {"add", "Add file contents...
>
Sorry, but I do not undestand this.
[...]
> > 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
> > ...
> > +synchelpers Synching helper commands
> > +purehelpers Internal helper commands
>
> I wonder if this can be shared with the section headings of
> Documentation/git.txt; either generate the section headings from
> this file, or generate this file from the section headings.
I'll look at it.
Thanks for the review.
Santi
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-02-18 17:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-17 14:48 [PATCH] git help: sort commands by topi Santi Bejar
2008-02-18 10:15 ` Junio C Hamano
2008-02-18 17:16 ` Santi Béjar
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).