{"thread":{"id":"16550","subject":"[PATCH] Modifies the default git help message to be grouped by topic","startedAt":"2008-12-02T06:05:09Z","lastAt":"2008-12-02T17:28:49Z","messageCount":3,"participants":["Scott Chacon","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"96928","messageId":"20081202060509.GA48796@agadorsparticus","threadId":"16550","inReplyTo":null,"subject":"[PATCH] Modifies the default git help message to be grouped by topic","fromName":"Scott Chacon","fromEmail":"schacon@gmail.com","sentAt":"2008-12-02T06:05:09Z","receivedAt":"2008-12-02T06:05:09Z","isPatch":true,"sender":{"key":"schacon@gmail.com","avatar":"https://gravatar.com/avatar/9b13a8a078e1dcf8588c4eea9554445d51ebed6c41b51f56f4d96738130b05c6?d=mp&s=160"},"body":"It's difficult to process 21 commands (which is what is output\nby default for git when no command is given).  They have been\nre-grouped into 4 groups of 5-6 commands each, which is clearer\nand easier for new users to process.\n\nAlso removes the common-cmd.h generation process, including\nparts of the Makefile and the generate-cmdlist.sh file.\n\nAs discussed at the GitTogether.\n\nSigned-off-by: Scott Chacon <schacon@gmail.com>\n---\n\nThis is a followup patch based on Junio and Jeffs feedback. \nIt also should apply cleanly which the other one would no \nlonger to, since it was from the GitTogether and then resent.\n\n Makefile            |   13 ++++---------\n builtin-help.c      |   40 ++++++++++++++++++++++++++--------------\n generate-cmdlist.sh |   24 ------------------------\n 3 files changed, 30 insertions(+), 47 deletions(-)\n delete mode 100755 generate-cmdlist.sh\n\ndiff --git a/Makefile b/Makefile\nindex 649cfb8..9a564cb 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -1117,7 +1117,7 @@ shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell\n strip: $(PROGRAMS) git$X\n \t$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X\n \n-git.o: git.c common-cmds.h GIT-CFLAGS\n+git.o: git.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -DGIT_VERSION='\"$(GIT_VERSION)\"' \\\n \t\t$(ALL_CFLAGS) -c $(filter %.c,$^)\n \n@@ -1125,7 +1125,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)\n \t$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \\\n \t\t$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)\n \n-builtin-help.o: builtin-help.c common-cmds.h GIT-CFLAGS\n+builtin-help.o: builtin-help.c GIT-CFLAGS\n \t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \\\n \t\t'-DGIT_HTML_PATH=\"$(htmldir_SQ)\"' \\\n \t\t'-DGIT_MAN_PATH=\"$(mandir_SQ)\"' \\\n@@ -1137,11 +1137,6 @@ $(BUILT_INS): git$X\n \tln -s git$X $@ 2>/dev/null || \\\n \tcp git$X $@\n \n-common-cmds.h: ./generate-cmdlist.sh command-list.txt\n-\n-common-cmds.h: $(wildcard Documentation/git-*.txt)\n-\t$(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@\n-\n $(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh\n \t$(QUIET_GEN)$(RM) $@ $@+ && \\\n \tsed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \\\n@@ -1363,7 +1358,7 @@ test-%$X: test-%.o $(GITLIBS)\n check-sha1:: test-sha1$X\n \t./test-sha1.sh\n \n-check: common-cmds.h\n+check: \n \tif sparse; \\\n \tthen \\\n \t\tfor i in *.c; \\\n@@ -1498,7 +1493,7 @@ clean:\n \t\t$(LIB_FILE) $(XDIFF_LIB)\n \t$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X\n \t$(RM) $(TEST_PROGRAMS)\n-\t$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*\n+\t$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo TAGS tags cscope*\n \t$(RM) -r autom4te.cache\n \t$(RM) config.log config.mak.autogen config.mak.append config.status config.cache\n \t$(RM) -r $(GIT_TARNAME) .doc-tmp-dir\ndiff --git a/builtin-help.c b/builtin-help.c\nindex f076efa..537534a 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -6,7 +6,6 @@\n #include \"cache.h\"\n #include \"builtin.h\"\n #include \"exec_cmd.h\"\n-#include \"common-cmds.h\"\n #include \"parse-options.h\"\n #include \"run-command.h\"\n #include \"help.h\"\n@@ -277,19 +276,32 @@ static struct cmdnames main_cmds, other_cmds;\n \n void list_common_cmds_help(void)\n {\n-\tint i, longest = 0;\n-\n-\tfor (i = 0; i < ARRAY_SIZE(common_cmds); i++) {\n-\t\tif (longest < strlen(common_cmds[i].name))\n-\t\t\tlongest = strlen(common_cmds[i].name);\n-\t}\n-\n-\tputs(\"The most commonly used git commands are:\");\n-\tfor (i = 0; i < ARRAY_SIZE(common_cmds); i++) {\n-\t\tprintf(\"   %s   \", common_cmds[i].name);\n-\t\tmput_char(' ', longest - strlen(common_cmds[i].name));\n-\t\tputs(common_cmds[i].help);\n-\t}\n+  puts(\"The most commonly used git commands are:\\n\\\n+\\n\\\n+Basic Commands\\n\\\n+  init       Create an empty git repository or reinitialize an existing one\\n\\\n+  add        Add file contents to the staging area\\n\\\n+  status     Show the working tree and staging area status\\n\\\n+  commit     Record changes in the staging area to the repository\\n\\\n+\\n\\\n+History Commands\\n\\\n+  log        Show commit log history\\n\\\n+  diff       Show changes between commits, commit and working tree, etc\\n\\\n+  reset      Reset your staging area or working directory to a specified state\\n\\\n+  show       Show various types of objects\\n\\\n+\\n\\\n+Branch Commands\\n\\\n+  checkout   Checkout a branch or paths to the working tree\\n\\\n+  branch     List, create, or delete branches\\n\\\n+  merge      Join two or more development histories together\\n\\\n+  rebase     Apply changes introduced in one branch onto another\\n\\\n+  tag        Create, list, delete or verify a tag object signed with GPG\\n\\\n+\\n\\\n+Remote Commands\\n\\\n+  clone      Clone a repository into a new directory\\n\\\n+  fetch      Download objects and refs from another repository\\n\\\n+  pull       Fetch from and merge with another repository or a local branch\\n\\\n+  push       Update remote refs along with associated objects\");\n }\n \n static int is_git_command(const char *s)\ndiff --git a/generate-cmdlist.sh b/generate-cmdlist.sh\ndeleted file mode 100755\nindex a2913c2..0000000\n--- a/generate-cmdlist.sh\n+++ /dev/null\n@@ -1,24 +0,0 @@\n-#!/bin/sh\n-\n-echo \"/* Automatically generated by $0 */\n-struct cmdname_help\n-{\n-    char name[16];\n-    char help[80];\n-};\n-\n-static struct cmdname_help common_cmds[] = {\"\n-\n-sed -n -e 's/^git-\\([^ \t]*\\)[ \t].* common.*/\\1/p' command-list.txt |\n-sort |\n-while read cmd\n-do\n-     sed -n '\n-     /NAME/,/git-'\"$cmd\"'/H\n-     ${\n-            x\n-            s/.*git-'\"$cmd\"' - \\(.*\\)/  {\"'\"$cmd\"'\", \"\\1\"},/\n-\t    p\n-     }' \"Documentation/git-$cmd.txt\"\n-done\n-echo \"};\"\n-- \n1.6.0.8.gc9c8\n"},{"id":"96968","messageId":"20081202172025.GB15826@coredump.intra.peff.net","threadId":"16550","inReplyTo":"20081202060509.GA48796@agadorsparticus","subject":"Re: [PATCH] Modifies the default git help message to be grouped by topic","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-12-02T17:20:25Z","receivedAt":"2008-12-02T17:20:25Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Dec 01, 2008 at 10:05:09PM -0800, Scott Chacon wrote:\n\n> -     sed -n '\n> -     /NAME/,/git-'\"$cmd\"'/H\n> -     ${\n> -            x\n> -            s/.*git-'\"$cmd\"' - \\(.*\\)/  {\"'\"$cmd\"'\", \"\\1\"},/\n> -\t    p\n> -     }' \"Documentation/git-$cmd.txt\"\n\nSorry to reverse direction after you resubmitted, but my earlier comment\non \"this list shouldn't change frequently\" didn't take into account that\nthe _synopsis_ might change, which is much more likely. So maybe rather\nthan ditching the auto-generation, it makes sense to just hardcode the\norder and categorization, but pull the rest from autogeneration.\n\nSomething like the patch below (though it makes the 'common' tag in\ncommand-list.txt somewhat redundant, so we should probably just remove\nthat):\n\ndiff --git a/builtin-help.c b/builtin-help.c\nindex f076efa..b5eafb7 100644\n--- a/builtin-help.c\n+++ b/builtin-help.c\n@@ -275,6 +275,15 @@ static int git_help_config(const char *var, const char *value, void *cb)\n \n static struct cmdnames main_cmds, other_cmds;\n \n+static const char *find_cmdname_help(const char *name)\n+{\n+\tint i;\n+\tfor (i = 0; i < ARRAY_SIZE(common_cmds); i++)\n+\t\tif (!strcmp(common_cmds[i].name, name))\n+\t\t\treturn common_cmds[i].help;\n+\treturn \"\";\n+}\n+\n void list_common_cmds_help(void)\n {\n \tint i, longest = 0;\n@@ -285,11 +294,43 @@ void list_common_cmds_help(void)\n \t}\n \n \tputs(\"The most commonly used git commands are:\");\n-\tfor (i = 0; i < ARRAY_SIZE(common_cmds); i++) {\n-\t\tprintf(\"   %s   \", common_cmds[i].name);\n-\t\tmput_char(' ', longest - strlen(common_cmds[i].name));\n-\t\tputs(common_cmds[i].help);\n-\t}\n+\n+#define COMMON(x) \\\n+do { \\\n+\tprintf(\"   %s   \", x); \\\n+\tmput_char(' ', longest - strlen(x)); \\\n+\tputs(find_cmdname_help(x)); \\\n+} while(0)\n+\n+\tputs(\"Basic Commands\");\n+\tCOMMON(\"init\");\n+\tCOMMON(\"add\");\n+\tCOMMON(\"status\");\n+\tCOMMON(\"commit\");\n+\tputs(\"\");\n+\n+\tputs(\"History Commands\");\n+\tCOMMON(\"log\");\n+\tCOMMON(\"diff\");\n+\tCOMMON(\"reset\");\n+\tCOMMON(\"show\");\n+\tputs(\"\");\n+\n+\tputs(\"Branch Commands\");\n+\tCOMMON(\"checkout\");\n+\tCOMMON(\"branch\");\n+\tCOMMON(\"merge\");\n+\tCOMMON(\"rebase\");\n+\tCOMMON(\"tag\");\n+\tputs(\"\");\n+\n+\tputs(\"Remote Commands\");\n+\tCOMMON(\"clone\");\n+\tCOMMON(\"fetch\");\n+\tCOMMON(\"pull\");\n+\tCOMMON(\"push\");\n+\n+#undef COMMON\n }\n \n static int is_git_command(const char *s)\n"},{"id":"96969","messageId":"20081202172848.GA19876@coredump.intra.peff.net","threadId":"16550","inReplyTo":"20081202172025.GB15826@coredump.intra.peff.net","subject":"Re: [PATCH] Modifies the default git help message to be grouped by topic","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-12-02T17:28:49Z","receivedAt":"2008-12-02T17:28:49Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Dec 02, 2008 at 12:20:25PM -0500, Jeff King wrote:\n\n> Sorry to reverse direction after you resubmitted, but my earlier comment\n> on \"this list shouldn't change frequently\" didn't take into account that\n> the _synopsis_ might change, which is much more likely. So maybe rather\n> than ditching the auto-generation, it makes sense to just hardcode the\n> order and categorization, but pull the rest from autogeneration.\n\nNote also that one could of course just use \"common:basic\" or something\nlike that in command-list.txt. But to handle arbitrary ordering, we\nwould have to reorder command-list as appropriate (which currently gets\nsorted), or do something awful like common:basic1, common:basic2, etc. I\ntried to choose the most straightforward approach that didn't involve\nduplication of information.\n\n-Peff\n"}]}