* [PATCH] Modifies the default git help message to be grouped by topic
@ 2008-12-02 6:05 Scott Chacon
2008-12-02 17:20 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: Scott Chacon @ 2008-12-02 6:05 UTC (permalink / raw)
To: gitster; +Cc: git, peff
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.
Also removes the common-cmd.h generation process, including
parts of the Makefile and the generate-cmdlist.sh file.
As discussed at the GitTogether.
Signed-off-by: Scott Chacon <schacon@gmail.com>
---
This is a followup patch based on Junio and Jeffs feedback.
It also should apply cleanly which the other one would no
longer to, since it was from the GitTogether and then resent.
Makefile | 13 ++++---------
builtin-help.c | 40 ++++++++++++++++++++++++++--------------
generate-cmdlist.sh | 24 ------------------------
3 files changed, 30 insertions(+), 47 deletions(-)
delete mode 100755 generate-cmdlist.sh
diff --git a/Makefile b/Makefile
index 649cfb8..9a564cb 100644
--- a/Makefile
+++ b/Makefile
@@ -1117,7 +1117,7 @@ shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell
strip: $(PROGRAMS) git$X
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
-git.o: git.c common-cmds.h GIT-CFLAGS
+git.o: git.c GIT-CFLAGS
$(QUIET_CC)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
$(ALL_CFLAGS) -c $(filter %.c,$^)
@@ -1125,7 +1125,7 @@ git$X: git.o $(BUILTIN_OBJS) $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
-builtin-help.o: builtin-help.c common-cmds.h GIT-CFLAGS
+builtin-help.o: builtin-help.c GIT-CFLAGS
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) \
'-DGIT_HTML_PATH="$(htmldir_SQ)"' \
'-DGIT_MAN_PATH="$(mandir_SQ)"' \
@@ -1137,11 +1137,6 @@ $(BUILT_INS): git$X
ln -s git$X $@ 2>/dev/null || \
cp git$X $@
-common-cmds.h: ./generate-cmdlist.sh command-list.txt
-
-common-cmds.h: $(wildcard Documentation/git-*.txt)
- $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
-
$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
$(QUIET_GEN)$(RM) $@ $@+ && \
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
@@ -1363,7 +1358,7 @@ test-%$X: test-%.o $(GITLIBS)
check-sha1:: test-sha1$X
./test-sha1.sh
-check: common-cmds.h
+check:
if sparse; \
then \
for i in *.c; \
@@ -1498,7 +1493,7 @@ clean:
$(LIB_FILE) $(XDIFF_LIB)
$(RM) $(ALL_PROGRAMS) $(BUILT_INS) git$X
$(RM) $(TEST_PROGRAMS)
- $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags cscope*
+ $(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo TAGS tags cscope*
$(RM) -r autom4te.cache
$(RM) config.log config.mak.autogen config.mak.append config.status config.cache
$(RM) -r $(GIT_TARNAME) .doc-tmp-dir
diff --git a/builtin-help.c b/builtin-help.c
index f076efa..537534a 100644
--- a/builtin-help.c
+++ b/builtin-help.c
@@ -6,7 +6,6 @@
#include "cache.h"
#include "builtin.h"
#include "exec_cmd.h"
-#include "common-cmds.h"
#include "parse-options.h"
#include "run-command.h"
#include "help.h"
@@ -277,19 +276,32 @@ static struct cmdnames main_cmds, other_cmds;
void list_common_cmds_help(void)
{
- 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);
- }
-
- 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);
- }
+ puts("The most commonly used git commands are:\n\
+\n\
+Basic Commands\n\
+ init Create an empty git repository or reinitialize an existing one\n\
+ add Add file contents to the staging area\n\
+ status Show the working tree and staging area status\n\
+ commit Record changes in the staging area to the repository\n\
+\n\
+History Commands\n\
+ log Show commit log history\n\
+ diff Show changes between commits, commit and working tree, etc\n\
+ reset Reset your staging area or working directory to a specified state\n\
+ show Show various types of objects\n\
+\n\
+Branch Commands\n\
+ checkout Checkout a branch or paths to the working tree\n\
+ branch List, create, or delete branches\n\
+ merge Join two or more development histories together\n\
+ rebase Apply changes introduced in one branch onto another\n\
+ tag Create, list, delete or verify a tag object signed with GPG\n\
+\n\
+Remote Commands\n\
+ clone Clone a repository into a new directory\n\
+ fetch Download objects and refs from another repository\n\
+ pull Fetch from and merge with another repository or a local branch\n\
+ push Update remote refs along with associated objects");
}
static int is_git_command(const char *s)
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
deleted file mode 100755
index a2913c2..0000000
--- a/generate-cmdlist.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/sh
-
-echo "/* Automatically generated by $0 */
-struct cmdname_help
-{
- char name[16];
- char help[80];
-};
-
-static struct cmdname_help common_cmds[] = {"
-
-sed -n -e 's/^git-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt |
-sort |
-while read cmd
-do
- sed -n '
- /NAME/,/git-'"$cmd"'/H
- ${
- x
- s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
- p
- }' "Documentation/git-$cmd.txt"
-done
-echo "};"
--
1.6.0.8.gc9c8
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Modifies the default git help message to be grouped by topic
2008-12-02 6:05 [PATCH] Modifies the default git help message to be grouped by topic Scott Chacon
@ 2008-12-02 17:20 ` Jeff King
2008-12-02 17:28 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2008-12-02 17:20 UTC (permalink / raw)
To: Scott Chacon; +Cc: gitster, git
On Mon, Dec 01, 2008 at 10:05:09PM -0800, Scott Chacon wrote:
> - sed -n '
> - /NAME/,/git-'"$cmd"'/H
> - ${
> - x
> - s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", "\1"},/
> - p
> - }' "Documentation/git-$cmd.txt"
Sorry to reverse direction after you resubmitted, but my earlier comment
on "this list shouldn't change frequently" didn't take into account that
the _synopsis_ might change, which is much more likely. So maybe rather
than ditching the auto-generation, it makes sense to just hardcode the
order and categorization, but pull the rest from autogeneration.
Something like the patch below (though it makes the 'common' tag in
command-list.txt somewhat redundant, so we should probably just remove
that):
diff --git a/builtin-help.c b/builtin-help.c
index f076efa..b5eafb7 100644
--- a/builtin-help.c
+++ b/builtin-help.c
@@ -275,6 +275,15 @@ static int git_help_config(const char *var, const char *value, void *cb)
static struct cmdnames main_cmds, other_cmds;
+static const char *find_cmdname_help(const char *name)
+{
+ int i;
+ for (i = 0; i < ARRAY_SIZE(common_cmds); i++)
+ if (!strcmp(common_cmds[i].name, name))
+ return common_cmds[i].help;
+ return "";
+}
+
void list_common_cmds_help(void)
{
int i, longest = 0;
@@ -285,11 +294,43 @@ void list_common_cmds_help(void)
}
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);
- }
+
+#define COMMON(x) \
+do { \
+ printf(" %s ", x); \
+ mput_char(' ', longest - strlen(x)); \
+ puts(find_cmdname_help(x)); \
+} while(0)
+
+ puts("Basic Commands");
+ COMMON("init");
+ COMMON("add");
+ COMMON("status");
+ COMMON("commit");
+ puts("");
+
+ puts("History Commands");
+ COMMON("log");
+ COMMON("diff");
+ COMMON("reset");
+ COMMON("show");
+ puts("");
+
+ puts("Branch Commands");
+ COMMON("checkout");
+ COMMON("branch");
+ COMMON("merge");
+ COMMON("rebase");
+ COMMON("tag");
+ puts("");
+
+ puts("Remote Commands");
+ COMMON("clone");
+ COMMON("fetch");
+ COMMON("pull");
+ COMMON("push");
+
+#undef COMMON
}
static int is_git_command(const char *s)
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Modifies the default git help message to be grouped by topic
2008-12-02 17:20 ` Jeff King
@ 2008-12-02 17:28 ` Jeff King
0 siblings, 0 replies; 3+ messages in thread
From: Jeff King @ 2008-12-02 17:28 UTC (permalink / raw)
To: Scott Chacon; +Cc: gitster, git
On Tue, Dec 02, 2008 at 12:20:25PM -0500, Jeff King wrote:
> Sorry to reverse direction after you resubmitted, but my earlier comment
> on "this list shouldn't change frequently" didn't take into account that
> the _synopsis_ might change, which is much more likely. So maybe rather
> than ditching the auto-generation, it makes sense to just hardcode the
> order and categorization, but pull the rest from autogeneration.
Note also that one could of course just use "common:basic" or something
like that in command-list.txt. But to handle arbitrary ordering, we
would have to reorder command-list as appropriate (which currently gets
sorted), or do something awful like common:basic1, common:basic2, etc. I
tried to choose the most straightforward approach that didn't involve
duplication of information.
-Peff
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-12-02 17:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-02 6:05 [PATCH] Modifies the default git help message to be grouped by topic Scott Chacon
2008-12-02 17:20 ` Jeff King
2008-12-02 17:28 ` Jeff King
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).