git@vger.kernel.org mailing list mirror (one of many)
 help / Atom feed
* [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
@ 2018-03-26 16:55 Nguyễn Thái Ngọc Duy
  2018-03-26 16:55 ` [PATCH/RFC 1/5] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
                   ` (7 more replies)
  0 siblings, 8 replies; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-26 16:55 UTC (permalink / raw)
  To: git; +Cc: SZEDER Gábor, Nguyễn Thái Ngọc Duy

This is pretty rough but I'd like to see how people feel about this
first.

I notice we have two places for command classification. One in
command-list.txt, one in __git_list_porcelain_commands() in
git-completion.bash. People who are following nd/parseopt-completion
probably know that I'm try to reduce duplication in this script as
much as possible, this is another step towards that.

By keeping all information of command-list.txt in git binary, we could
provide the porcelain list to git-completion.bash via "git
--list-cmds=porcelain", so we don't neeed a separate command
classification in git-completion.bash anymore.

Because we have all command synopsis as a side effect, we could
now support "git help -a --verbose" which prints something like "git
help", a command name and a description, but we could do it for _all_
recognized commands. This could help people look for a command even if
we don't provide "git appropos".

PS. Elsewhere I introduced --list-builtin-cmds, which should become
--list-cmds=builtin if this series seems like a good idea to move
forward.

Nguyễn Thái Ngọc Duy (5):
  git.c: convert --list-builtins to --list-cmds=builtins
  git.c: implement --list-cmds=all and use it in git-completion.bash
  generate-cmdlist.sh: keep all information in common-cmds.h
  git.c: implement --list-cmds=porcelain
  help: add "-a --verbose" to list all commands with synopsis

 Documentation/git-help.txt             |   4 +-
 builtin/help.c                         |   6 ++
 contrib/completion/git-completion.bash |  94 +-----------------
 generate-cmdlist.sh                    |  46 ++++++---
 git.c                                  |  11 ++-
 help.c                                 | 131 +++++++++++++++++++++++--
 help.h                                 |   3 +
 t/t0012-help.sh                        |   2 +-
 t/t9902-completion.sh                  |   4 +-
 9 files changed, 187 insertions(+), 114 deletions(-)

-- 
2.17.0.rc0.348.gd5a49e0b6f


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH/RFC 1/5] git.c: convert --list-builtins to --list-cmds=builtins
  2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
@ 2018-03-26 16:55 ` Nguyễn Thái Ngọc Duy
  2018-03-26 16:55 ` [PATCH/RFC 2/5] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-26 16:55 UTC (permalink / raw)
  To: git; +Cc: SZEDER Gábor, Nguyễn Thái Ngọc Duy

Even if this is a hidden option, let's make it a bit more generic
since we're introducing more listing types.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 git.c           | 7 +++++--
 t/t0012-help.sh | 2 +-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/git.c b/git.c
index ceaa58ef40..f350002260 100644
--- a/git.c
+++ b/git.c
@@ -205,8 +205,11 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			}
 			(*argv)++;
 			(*argc)--;
-		} else if (!strcmp(cmd, "--list-builtins")) {
-			list_builtins();
+		} else if (skip_prefix(cmd, "--list-cmds=", &cmd)) {
+			if (!strcmp(cmd, "builtins"))
+				list_builtins();
+			else
+				die("unsupported command listing type '%s'", cmd);
 			exit(0);
 		} else {
 			fprintf(stderr, _("unknown option: %s\n"), cmd);
diff --git a/t/t0012-help.sh b/t/t0012-help.sh
index 487b92a5de..fd2a7f27dc 100755
--- a/t/t0012-help.sh
+++ b/t/t0012-help.sh
@@ -50,7 +50,7 @@ test_expect_success "--help does not work for guides" "
 "
 
 test_expect_success 'generate builtin list' '
-	git --list-builtins >builtins
+	git --list-cmds=builtins >builtins
 '
 
 while read builtin
-- 
2.17.0.rc0.348.gd5a49e0b6f


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH/RFC 2/5] git.c: implement --list-cmds=all and use it in git-completion.bash
  2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
  2018-03-26 16:55 ` [PATCH/RFC 1/5] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
@ 2018-03-26 16:55 ` Nguyễn Thái Ngọc Duy
  2018-04-09  3:32   ` Eric Sunshine
  2018-03-26 16:55 ` [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-26 16:55 UTC (permalink / raw)
  To: git; +Cc: SZEDER Gábor, Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash |  2 +-
 git.c                                  |  2 ++
 help.c                                 | 15 +++++++++++++++
 help.h                                 |  1 +
 4 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c7957f0a90..e0f545819d 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -833,7 +833,7 @@ __git_commands () {
 	then
 		printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
 	else
-		git help -a|egrep '^  [a-zA-Z0-9]'
+		git --list-cmds=all
 	fi
 }
 
diff --git a/git.c b/git.c
index f350002260..2e0c5e17e2 100644
--- a/git.c
+++ b/git.c
@@ -208,6 +208,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 		} else if (skip_prefix(cmd, "--list-cmds=", &cmd)) {
 			if (!strcmp(cmd, "builtins"))
 				list_builtins();
+			else if (!strcmp(cmd, "all"))
+				list_all_cmds();
 			else
 				die("unsupported command listing type '%s'", cmd);
 			exit(0);
diff --git a/help.c b/help.c
index 60071a9bea..f3f35dfbb1 100644
--- a/help.c
+++ b/help.c
@@ -228,6 +228,21 @@ void list_common_cmds_help(void)
 	}
 }
 
+void list_all_cmds(void)
+{
+	struct cmdnames main_cmds, other_cmds;
+	int i;
+
+	memset(&main_cmds, 0, sizeof(main_cmds));
+	memset(&other_cmds, 0, sizeof(other_cmds));
+	load_command_list("git-", &main_cmds, &other_cmds);
+
+	for (i = 0; i < main_cmds.cnt; i++)
+		puts(main_cmds.names[i]->name);
+	for (i = 0; i < other_cmds.cnt; i++)
+		puts(other_cmds.names[i]->name);
+}
+
 int is_in_cmdlist(struct cmdnames *c, const char *s)
 {
 	int i;
diff --git a/help.h b/help.h
index b21d7c94e8..0bf29f8dc5 100644
--- a/help.h
+++ b/help.h
@@ -17,6 +17,7 @@ static inline void mput_char(char c, unsigned int num)
 }
 
 extern void list_common_cmds_help(void);
+extern void list_all_cmds(void);
 extern const char *help_unknown_cmd(const char *cmd);
 extern void load_command_list(const char *prefix,
 			      struct cmdnames *main_cmds,
-- 
2.17.0.rc0.348.gd5a49e0b6f


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
  2018-03-26 16:55 ` [PATCH/RFC 1/5] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
  2018-03-26 16:55 ` [PATCH/RFC 2/5] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
@ 2018-03-26 16:55 ` Nguyễn Thái Ngọc Duy
  2018-04-09  4:59   ` Eric Sunshine
  2018-03-26 16:55 ` [PATCH/RFC 4/5] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-26 16:55 UTC (permalink / raw)
  To: git; +Cc: SZEDER Gábor, Nguyễn Thái Ngọc Duy

common-cmds.h is used to extract the list of common commands (by
group) and a one-line summary of each command. Some information is
dropped, for example command category or summary of other commands.
Update generate-cmdlist.sh to keep all the information. The extra info
will be used shortly.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 generate-cmdlist.sh | 46 ++++++++++++++++++++++++++++++++++-----------
 help.c              | 43 ++++++++++++++++++++++++++++++++++++------
 2 files changed, 72 insertions(+), 17 deletions(-)

diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index eeea4b67ea..72235e7296 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -2,9 +2,10 @@
 
 echo "/* Automatically generated by generate-cmdlist.sh */
 struct cmdname_help {
-	char name[16];
+	char name[32];
 	char help[80];
-	unsigned char group;
+	unsigned int category;
+	unsigned int group;
 };
 
 static const char *common_cmd_groups[] = {"
@@ -23,27 +24,50 @@ sed -n '
 	' "$1"
 printf '};\n\n'
 
+echo "#define GROUP_NONE 0xff /* no common group */"
+echo "#define GROUP_ 0xff /* no common group */"
 n=0
-substnum=
 while read grp
 do
-	echo "^git-..*[ 	]$grp"
-	substnum="$substnum${substnum:+;}s/[ 	]$grp/$n/"
+	echo "#define GROUP_$grp $n"
 	n=$(($n+1))
-done <"$grps" >"$match"
+done <"$grps"
+echo
 
-printf 'static struct cmdname_help common_cmds[] = {\n'
-grep -f "$match" "$1" |
+echo '/*'
+printf 'static const char *cmd_categories[] = {\n'
+grep '^git-' "$1" |
+awk '{print $2;}' |
+sort |
+uniq |
+while read category; do
+	printf '\t\"'$category'\",\n'
+done
+printf '\tNULL\n};\n\n'
+echo '*/'
+
+n=0
+grep '^git-' "$1" |
+awk '{print $2;}' |
+sort |
+uniq |
+while read category; do
+	echo "#define CAT_$category $n"
+	n=$(($n+1))
+done
+echo
+
+printf 'static struct cmdname_help command_list[] = {\n'
+grep "^git-" "$1" |
 sed 's/^git-//' |
 sort |
-while read cmd tags
+while read cmd category tags
 do
-	tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
 	sed -n '
 		/^NAME/,/git-'"$cmd"'/H
 		${
 			x
-			s/.*git-'"$cmd"' - \(.*\)/	{"'"$cmd"'", N_("\1"), '$tag'},/
+			s/.*git-'"$cmd"' - \(.*\)/	{"'"$cmd"'", N_("\1"), CAT_'$category', GROUP_'$tags' },/
 			p
 		}' "Documentation/git-$cmd.txt"
 done
diff --git a/help.c b/help.c
index f3f35dfbb1..4d07ea3913 100644
--- a/help.c
+++ b/help.c
@@ -190,6 +190,28 @@ void list_commands(unsigned int colopts,
 	}
 }
 
+static void extract_common_cmds(struct cmdname_help **p_common_cmds,
+				int *p_nr)
+{
+	int i, nr = 0;
+	struct cmdname_help *common_cmds;
+
+	ALLOC_ARRAY(common_cmds, ARRAY_SIZE(command_list));
+
+	for (i = 0; i < ARRAY_SIZE(command_list); i++) {
+		const struct cmdname_help *cmd = command_list + i;
+
+		if (cmd->category != CAT_mainporcelain ||
+		    cmd->group == GROUP_NONE)
+			continue;
+
+		common_cmds[nr++] = *cmd;
+	}
+
+	*p_common_cmds = common_cmds;
+	*p_nr = nr;
+}
+
 static int cmd_group_cmp(const void *elem1, const void *elem2)
 {
 	const struct cmdname_help *e1 = elem1;
@@ -206,17 +228,21 @@ void list_common_cmds_help(void)
 {
 	int i, longest = 0;
 	int current_grp = -1;
+	int nr = 0;
+	struct cmdname_help *common_cmds;
+
+	extract_common_cmds(&common_cmds, &nr);
 
-	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+	for (i = 0; i < nr; i++) {
 		if (longest < strlen(common_cmds[i].name))
 			longest = strlen(common_cmds[i].name);
 	}
 
-	QSORT(common_cmds, ARRAY_SIZE(common_cmds), cmd_group_cmp);
+	QSORT(common_cmds, nr, cmd_group_cmp);
 
 	puts(_("These are common Git commands used in various situations:"));
 
-	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+	for (i = 0; i < nr; i++) {
 		if (common_cmds[i].group != current_grp) {
 			printf("\n%s\n", _(common_cmd_groups[common_cmds[i].group]));
 			current_grp = common_cmds[i].group;
@@ -226,6 +252,7 @@ void list_common_cmds_help(void)
 		mput_char(' ', longest - strlen(common_cmds[i].name));
 		puts(_(common_cmds[i].help));
 	}
+	free(common_cmds);
 }
 
 void list_all_cmds(void)
@@ -298,8 +325,9 @@ static const char bad_interpreter_advice[] =
 
 const char *help_unknown_cmd(const char *cmd)
 {
-	int i, n, best_similarity = 0;
+	int i, n, best_similarity = 0, nr_common;
 	struct cmdnames main_cmds, other_cmds;
+	struct cmdname_help *common_cmds;
 
 	memset(&main_cmds, 0, sizeof(main_cmds));
 	memset(&other_cmds, 0, sizeof(other_cmds));
@@ -314,6 +342,8 @@ const char *help_unknown_cmd(const char *cmd)
 	QSORT(main_cmds.names, main_cmds.cnt, cmdname_compare);
 	uniq(&main_cmds);
 
+	extract_common_cmds(&common_cmds, &nr_common);
+
 	/* This abuses cmdname->len for levenshtein distance */
 	for (i = 0, n = 0; i < main_cmds.cnt; i++) {
 		int cmp = 0; /* avoid compiler stupidity */
@@ -328,10 +358,10 @@ const char *help_unknown_cmd(const char *cmd)
 			die(_(bad_interpreter_advice), cmd, cmd);
 
 		/* Does the candidate appear in common_cmds list? */
-		while (n < ARRAY_SIZE(common_cmds) &&
+		while (n < nr_common &&
 		       (cmp = strcmp(common_cmds[n].name, candidate)) < 0)
 			n++;
-		if ((n < ARRAY_SIZE(common_cmds)) && !cmp) {
+		if ((n < nr_common) && !cmp) {
 			/* Yes, this is one of the common commands */
 			n++; /* use the entry from common_cmds[] */
 			if (starts_with(candidate, cmd)) {
@@ -344,6 +374,7 @@ const char *help_unknown_cmd(const char *cmd)
 		main_cmds.names[i]->len =
 			levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;
 	}
+	FREE_AND_NULL(common_cmds);
 
 	QSORT(main_cmds.names, main_cmds.cnt, levenshtein_compare);
 
-- 
2.17.0.rc0.348.gd5a49e0b6f


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH/RFC 4/5] git.c: implement --list-cmds=porcelain
  2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
                   ` (2 preceding siblings ...)
  2018-03-26 16:55 ` [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
@ 2018-03-26 16:55 ` Nguyễn Thái Ngọc Duy
  2018-03-26 16:55 ` [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-26 16:55 UTC (permalink / raw)
  To: git; +Cc: SZEDER Gábor, Nguyễn Thái Ngọc Duy

This is useful for git-completion.bash because it needs this set of
commands. Right now we have to maintain a separate command category in
there.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash | 94 ++------------------------
 git.c                                  |  2 +
 help.c                                 | 12 ++++
 help.h                                 |  1 +
 t/t9902-completion.sh                  |  4 +-
 5 files changed, 20 insertions(+), 93 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index e0f545819d..d711a9b53a 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -833,14 +833,15 @@ __git_commands () {
 	then
 		printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
 	else
-		git --list-cmds=all
+		git --list-cmds=$1
 	fi
 }
 
 __git_list_all_commands ()
 {
 	local i IFS=" "$'\n'
-	for i in $(__git_commands)
+	local category=${1-all}
+	for i in $(__git_commands $category)
 	do
 		case $i in
 		*--*)             : helper pattern;;
@@ -856,98 +857,11 @@ __git_compute_all_commands ()
 	__git_all_commands=$(__git_list_all_commands)
 }
 
-__git_list_porcelain_commands ()
-{
-	local i IFS=" "$'\n'
-	__git_compute_all_commands
-	for i in $__git_all_commands
-	do
-		case $i in
-		*--*)             : helper pattern;;
-		applymbox)        : ask gittus;;
-		applypatch)       : ask gittus;;
-		archimport)       : import;;
-		cat-file)         : plumbing;;
-		check-attr)       : plumbing;;
-		check-ignore)     : plumbing;;
-		check-mailmap)    : plumbing;;
-		check-ref-format) : plumbing;;
-		checkout-index)   : plumbing;;
-		column)           : internal helper;;
-		commit-tree)      : plumbing;;
-		count-objects)    : infrequent;;
-		credential)       : credentials;;
-		credential-*)     : credentials helper;;
-		cvsexportcommit)  : export;;
-		cvsimport)        : import;;
-		cvsserver)        : daemon;;
-		daemon)           : daemon;;
-		diff-files)       : plumbing;;
-		diff-index)       : plumbing;;
-		diff-tree)        : plumbing;;
-		fast-import)      : import;;
-		fast-export)      : export;;
-		fsck-objects)     : plumbing;;
-		fetch-pack)       : plumbing;;
-		fmt-merge-msg)    : plumbing;;
-		for-each-ref)     : plumbing;;
-		hash-object)      : plumbing;;
-		http-*)           : transport;;
-		index-pack)       : plumbing;;
-		init-db)          : deprecated;;
-		local-fetch)      : plumbing;;
-		ls-files)         : plumbing;;
-		ls-remote)        : plumbing;;
-		ls-tree)          : plumbing;;
-		mailinfo)         : plumbing;;
-		mailsplit)        : plumbing;;
-		merge-*)          : plumbing;;
-		mktree)           : plumbing;;
-		mktag)            : plumbing;;
-		pack-objects)     : plumbing;;
-		pack-redundant)   : plumbing;;
-		pack-refs)        : plumbing;;
-		parse-remote)     : plumbing;;
-		patch-id)         : plumbing;;
-		prune)            : plumbing;;
-		prune-packed)     : plumbing;;
-		quiltimport)      : import;;
-		read-tree)        : plumbing;;
-		receive-pack)     : plumbing;;
-		remote-*)         : transport;;
-		rerere)           : plumbing;;
-		rev-list)         : plumbing;;
-		rev-parse)        : plumbing;;
-		runstatus)        : plumbing;;
-		sh-setup)         : internal;;
-		shell)            : daemon;;
-		show-ref)         : plumbing;;
-		send-pack)        : plumbing;;
-		show-index)       : plumbing;;
-		ssh-*)            : transport;;
-		stripspace)       : plumbing;;
-		symbolic-ref)     : plumbing;;
-		unpack-file)      : plumbing;;
-		unpack-objects)   : plumbing;;
-		update-index)     : plumbing;;
-		update-ref)       : plumbing;;
-		update-server-info) : daemon;;
-		upload-archive)   : plumbing;;
-		upload-pack)      : plumbing;;
-		write-tree)       : plumbing;;
-		var)              : infrequent;;
-		verify-pack)      : infrequent;;
-		verify-tag)       : plumbing;;
-		*) echo $i;;
-		esac
-	done
-}
-
 __git_porcelain_commands=
 __git_compute_porcelain_commands ()
 {
 	test -n "$__git_porcelain_commands" ||
-	__git_porcelain_commands=$(__git_list_porcelain_commands)
+	__git_porcelain_commands=$(__git_list_all_commands porcelain)
 }
 
 # Lists all set config variables starting with the given section prefix,
diff --git a/git.c b/git.c
index 2e0c5e17e2..5b09f77792 100644
--- a/git.c
+++ b/git.c
@@ -210,6 +210,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				list_builtins();
 			else if (!strcmp(cmd, "all"))
 				list_all_cmds();
+			else if (!strcmp(cmd, "porcelain"))
+				list_porcelain_cmds();
 			else
 				die("unsupported command listing type '%s'", cmd);
 			exit(0);
diff --git a/help.c b/help.c
index 4d07ea3913..cacd8249bb 100644
--- a/help.c
+++ b/help.c
@@ -270,6 +270,18 @@ void list_all_cmds(void)
 		puts(other_cmds.names[i]->name);
 }
 
+void list_porcelain_cmds(void)
+{
+	int i, nr = ARRAY_SIZE(command_list);
+	struct cmdname_help *cmds = command_list;
+
+	for (i = 0; i < nr; i++) {
+		if (cmds[i].category != CAT_mainporcelain)
+			continue;
+		puts(cmds[i].name);
+	}
+}
+
 int is_in_cmdlist(struct cmdnames *c, const char *s)
 {
 	int i;
diff --git a/help.h b/help.h
index 0bf29f8dc5..33e2210ebd 100644
--- a/help.h
+++ b/help.h
@@ -18,6 +18,7 @@ static inline void mput_char(char c, unsigned int num)
 
 extern void list_common_cmds_help(void);
 extern void list_all_cmds(void);
+extern void list_porcelain_cmds(void);
 extern const char *help_unknown_cmd(const char *cmd);
 extern void load_command_list(const char *prefix,
 			      struct cmdnames *main_cmds,
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index e6485feb0a..79a2c6d67d 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1208,8 +1208,6 @@ test_expect_success 'basic' '
 	grep -q "^add \$" out &&
 	# script
 	grep -q "^filter-branch \$" out &&
-	# plumbing
-	! grep -q "^ls-files \$" out &&
 
 	run_completion "git f" &&
 	! grep -q -v "^f" out
@@ -1272,7 +1270,7 @@ test_expect_success 'general options' '
 	test_completion "git --no-r" "--no-replace-objects "
 '
 
-test_expect_success 'general options plus command' '
+test_expect_failure 'general options plus command' '
 	test_completion "git --version check" "checkout " &&
 	test_completion "git --paginate check" "checkout " &&
 	test_completion "git --git-dir=foo check" "checkout " &&
-- 
2.17.0.rc0.348.gd5a49e0b6f


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis
  2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
                   ` (3 preceding siblings ...)
  2018-03-26 16:55 ` [PATCH/RFC 4/5] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
@ 2018-03-26 16:55 ` Nguyễn Thái Ngọc Duy
  2018-04-09  5:08   ` Eric Sunshine
  2018-04-09  5:17 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Eric Sunshine
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-03-26 16:55 UTC (permalink / raw)
  To: git; +Cc: SZEDER Gábor, Nguyễn Thái Ngọc Duy

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/git-help.txt |  4 ++-
 builtin/help.c             |  6 ++++
 help.c                     | 61 ++++++++++++++++++++++++++++++++++++++
 help.h                     |  1 +
 4 files changed, 71 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt
index 40d328a4b3..a40fc38d8b 100644
--- a/Documentation/git-help.txt
+++ b/Documentation/git-help.txt
@@ -8,7 +8,7 @@ git-help - Display help information about Git
 SYNOPSIS
 --------
 [verse]
-'git help' [-a|--all] [-g|--guide]
+'git help' [-a|--all [--verbose]] [-g|--guide]
 	   [-i|--info|-m|--man|-w|--web] [COMMAND|GUIDE]
 
 DESCRIPTION
@@ -42,6 +42,8 @@ OPTIONS
 --all::
 	Prints all the available commands on the standard output. This
 	option overrides any given command or guide name.
+	When used with `--verbose` print description for all recognized
+	commands.
 
 -g::
 --guides::
diff --git a/builtin/help.c b/builtin/help.c
index 598867cfea..a371199674 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -36,6 +36,7 @@ static const char *html_path;
 
 static int show_all = 0;
 static int show_guides = 0;
+static int verbose;
 static unsigned int colopts;
 static enum help_format help_format = HELP_FORMAT_NONE;
 static int exclude_guides;
@@ -48,6 +49,7 @@ static struct option builtin_help_options[] = {
 			HELP_FORMAT_WEB),
 	OPT_SET_INT('i', "info", &help_format, N_("show info page"),
 			HELP_FORMAT_INFO),
+	OPT__VERBOSE(&verbose, N_("print command description")),
 	OPT_END(),
 };
 
@@ -463,6 +465,10 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 
 	if (show_all) {
 		git_config(git_help_config, NULL);
+		if (verbose) {
+			list_all_cmds_help();
+			return 0;
+		}
 		printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
 		load_command_list("git-", &main_cmds, &other_cmds);
 		list_commands(colopts, &main_cmds, &other_cmds);
diff --git a/help.c b/help.c
index cacd8249bb..afbf98c241 100644
--- a/help.c
+++ b/help.c
@@ -282,6 +282,67 @@ void list_porcelain_cmds(void)
 	}
 }
 
+static int cmd_category_cmp(const void *elem1, const void *elem2)
+{
+	const struct cmdname_help *e1 = elem1;
+	const struct cmdname_help *e2 = elem2;
+
+	if (e1->category < e2->category)
+		return -1;
+	if (e1->category > e2->category)
+		return 1;
+	return strcmp(e1->name, e2->name);
+}
+
+static const char *get_category_name(unsigned int category)
+{
+	switch (category) {
+	case CAT_ancillaryinterrogators: return _("Ancillary interrogators");
+	case CAT_ancillarymanipulators: return _("Ancillary manipulators");
+	case CAT_foreignscminterface: return _("Foreign SCM interface");
+	case CAT_mainporcelain: return _("Main porcelain");
+	case CAT_plumbinginterrogators: return _("Plumbing interrogators");
+	case CAT_plumbingmanipulators: return _("Plumbing interrogators");
+	case CAT_purehelpers: return _("Pure helpers");
+	case CAT_synchelpers: return _("Sync helpers");
+	case CAT_synchingrepositories: return _("Synching repositories");
+	default:
+		die("BUG: unknown command category %u", category);
+	}
+}
+
+void list_all_cmds_help(void)
+{
+	int i, longest = 0;
+	int current_category = -1;
+	int nr = ARRAY_SIZE(command_list);
+	struct cmdname_help *cmds = command_list;
+
+	for (i = 0; i < nr; i++) {
+		struct cmdname_help *cmd = cmds + i;
+
+		if (longest < strlen(cmd->name))
+			longest = strlen(cmd->name);
+	}
+
+	QSORT(cmds, nr, cmd_category_cmp);
+
+	puts(_("These are all Git commands:"));
+
+	for (i = 0; i < nr; i++) {
+		struct cmdname_help *cmd = cmds + i;
+
+		if (cmd->category != current_category) {
+			current_category = cmd->category;
+			printf("\n%s:\n", get_category_name(current_category));
+		}
+
+		printf("   %s   ", cmd->name);
+		mput_char(' ', longest - strlen(cmd->name));
+		puts(_(cmd->help));
+	}
+}
+
 int is_in_cmdlist(struct cmdnames *c, const char *s)
 {
 	int i;
diff --git a/help.h b/help.h
index 33e2210ebd..62449f1b7e 100644
--- a/help.h
+++ b/help.h
@@ -17,6 +17,7 @@ static inline void mput_char(char c, unsigned int num)
 }
 
 extern void list_common_cmds_help(void);
+extern void list_all_cmds_help(void);
 extern void list_all_cmds(void);
 extern void list_porcelain_cmds(void);
 extern const char *help_unknown_cmd(const char *cmd);
-- 
2.17.0.rc0.348.gd5a49e0b6f


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 2/5] git.c: implement --list-cmds=all and use it in git-completion.bash
  2018-03-26 16:55 ` [PATCH/RFC 2/5] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
@ 2018-04-09  3:32   ` Eric Sunshine
  0 siblings, 0 replies; 42+ messages in thread
From: Eric Sunshine @ 2018-04-09  3:32 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List, SZEDER Gábor

On Mon, Mar 26, 2018 at 12:55 PM, Nguyễn Thái Ngọc Duy
<pclouds@gmail.com> wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/help.c b/help.c
> @@ -228,6 +228,21 @@ void list_common_cmds_help(void)
> +void list_all_cmds(void)
> +{
> +       struct cmdnames main_cmds, other_cmds;
> +       int i;
> +
> +       memset(&main_cmds, 0, sizeof(main_cmds));
> +       memset(&other_cmds, 0, sizeof(other_cmds));
> +       load_command_list("git-", &main_cmds, &other_cmds);
> +
> +       for (i = 0; i < main_cmds.cnt; i++)
> +               puts(main_cmds.names[i]->name);
> +       for (i = 0; i < other_cmds.cnt; i++)
> +               puts(other_cmds.names[i]->name);

clean_cmdnames(&main_cmds);
clean_cmdnames(&other_cmds);

> +}

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-03-26 16:55 ` [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
@ 2018-04-09  4:59   ` Eric Sunshine
  2018-04-09  5:12     ` Eric Sunshine
                       ` (2 more replies)
  0 siblings, 3 replies; 42+ messages in thread
From: Eric Sunshine @ 2018-04-09  4:59 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List, SZEDER Gábor

On Mon, Mar 26, 2018 at 12:55 PM, Nguyễn Thái Ngọc Duy
<pclouds@gmail.com> wrote:
> common-cmds.h is used to extract the list of common commands (by
> group) and a one-line summary of each command. Some information is
> dropped, for example command category or summary of other commands.
> Update generate-cmdlist.sh to keep all the information. The extra info
> will be used shortly.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
> @@ -2,9 +2,10 @@
>  struct cmdname_help {
> -       char name[16];
> +       char name[32];
>         char help[80];
> -       unsigned char group;
> +       unsigned int category;
> +       unsigned int group;
>  };
> @@ -23,27 +24,50 @@ sed -n '
> +echo "#define GROUP_NONE 0xff /* no common group */"
> +echo "#define GROUP_ 0xff /* no common group */"

Meh, this "GROUP_" alias of "GROUP_NONE" isn't so nice.

>  n=0
> -substnum=
>  while read grp
>  do
> -       echo "^git-..*[         ]$grp"
> -       substnum="$substnum${substnum:+;}s/[    ]$grp/$n/"
> +       echo "#define GROUP_$grp $n"
>         n=$(($n+1))
> -done <"$grps" >"$match"
> +done <"$grps"

This patch drops all use of the file $match. Earlier in this script,
not seen in the context, are a couple references to $match which ought
to be adjusted to take its retirement into account:

    match=match$$.tmp
    trap "rm -f '$grps' '$match'" 0 1 2 3 15

However, I'm concerned that this change may be going in the wrong
direction. A line in "### command list" section looks like this:

    command-name  category [deprecated] [common]

Although we don't currently have any commands marked with tag
"deprecated", we very well may have some day. More generally, new
optional or required tags may be added in the future. As such, the
line format is relatively free-form. Current clients don't even care
in what order the tags appears (following 'category') nor how many
tags there are. The new code added by this patch, however, is far less
flexible and accommodating since it assumes hard-coded columns for the
tags (and doesn't even take 'deprecated' into account).

The point of the $match file was to be able to extract only lines
which mentioned one of the "common groups", and the point of the
'substnum' transformation was to transform the group name into a group
number -- both of these operations were done without caring about the
exact column the "common group" tag occupied.

Obviously, one option for addressing this concern would be to change
the definition to make the tag columns fixed and non-optional, which
would allow the simpler implementation used by this patch. Doing so
may require fixing other consumers of command-list.txt (though, I'm
pretty sure existing consumers wouldn't be bothered).

(Perl would be an obvious good choice for retaining the current
relatively free-form line definition without having to jump through
hoops in the shell. Unfortunately, though, a Perl dependency in the
build system can be problematic[1].)

[1]: https://public-inbox.org/git/1440365469-9928-1-git-send-email-sunshine@sunshineco.com/

> -printf 'static struct cmdname_help common_cmds[] = {\n'
> -grep -f "$match" "$1" |
> +echo '/*'
> +printf 'static const char *cmd_categories[] = {\n'
> +grep '^git-' "$1" |

This "grep '^git-'" (and those below) misses some commands, such as
"gitk" and "gitweb". Is that intentional? If not, then you'll probably
need to grab lines following "### command list", as is done earlier in
the script. Same comment for the other couple grep's later in the
patch.

> +awk '{print $2;}' |

At one time, Junio expressed concerns[2] about having an 'awk'
dependency in the build system (in fact, with regards to this same
generation process). Whether he still has such concerns is unknown,
but it should be easy enough to avoid it here (and below).

[2]: https://public-inbox.org/git/20150519004356.GA12854@flurp.local/

> +sort |
> +uniq |
> +while read category; do
> +       printf '\t\"'$category'\",\n'
> +done
> +printf '\tNULL\n};\n\n'
> +echo '*/'
> diff --git a/help.c b/help.c
> @@ -190,6 +190,28 @@ void list_commands(unsigned int colopts,
> +static void extract_common_cmds(struct cmdname_help **p_common_cmds,
> +                               int *p_nr)
> +{
> +       int i, nr = 0;
> +       struct cmdname_help *common_cmds;
> +
> +       ALLOC_ARRAY(common_cmds, ARRAY_SIZE(command_list));
> +
> +       for (i = 0; i < ARRAY_SIZE(command_list); i++) {
> +               const struct cmdname_help *cmd = command_list + i;
> +
> +               if (cmd->category != CAT_mainporcelain ||
> +                   cmd->group == GROUP_NONE)
> +                       continue;

Is the CAT_mainporcelain condition necessary? Before this patch, the
command list would contain only commands with an associated group, so
it seems that you could get by just with the GROUP_NONE condition.

> +
> +               common_cmds[nr++] = *cmd;
> +       }
> +
> +       *p_common_cmds = common_cmds;
> +       *p_nr = nr;
> +}

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis
  2018-03-26 16:55 ` [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
@ 2018-04-09  5:08   ` Eric Sunshine
  2018-04-09  9:47     ` Junio C Hamano
  0 siblings, 1 reply; 42+ messages in thread
From: Eric Sunshine @ 2018-04-09  5:08 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List, SZEDER Gábor

On Mon, Mar 26, 2018 at 12:55 PM, Nguyễn Thái Ngọc Duy
<pclouds@gmail.com> wrote:
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
> diff --git a/help.c b/help.c
> @@ -282,6 +282,67 @@ void list_porcelain_cmds(void)
> +static const char *get_category_name(unsigned int category)
> +{
> +       switch (category) {
> +       case CAT_ancillaryinterrogators: return _("Ancillary interrogators");
> +       case CAT_ancillarymanipulators: return _("Ancillary manipulators");
> +       case CAT_foreignscminterface: return _("Foreign SCM interface");
> +       case CAT_mainporcelain: return _("Main porcelain");
> +       case CAT_plumbinginterrogators: return _("Plumbing interrogators");
> +       case CAT_plumbingmanipulators: return _("Plumbing interrogators");

s/interrogators"/manipulators"/

> +       case CAT_purehelpers: return _("Pure helpers");
> +       case CAT_synchelpers: return _("Sync helpers");
> +       case CAT_synchingrepositories: return _("Synching repositories");
> +       default:
> +               die("BUG: unknown command category %u", category);
> +       }

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-09  4:59   ` Eric Sunshine
@ 2018-04-09  5:12     ` Eric Sunshine
  2018-04-09 16:16     ` Duy Nguyen
  2018-04-15 16:04     ` Duy Nguyen
  2 siblings, 0 replies; 42+ messages in thread
From: Eric Sunshine @ 2018-04-09  5:12 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List, SZEDER Gábor

On Mon, Apr 9, 2018 at 12:59 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> However, I'm concerned that this change may be going in the wrong
> direction. A line in "### command list" section looks like this:
>
>     command-name  category [deprecated] [common]
>
> Although we don't currently have any commands marked with tag
> "deprecated", we very well may have some day. More generally, new
> optional or required tags may be added in the future. As such, the
> line format is relatively free-form. Current clients don't even care
> in what order the tags appears (following 'category') nor how many
> tags there are. The new code added by this patch, however, is far less
> flexible and accommodating since it assumes hard-coded columns for the
> tags (and doesn't even take 'deprecated' into account).
>
> The point of the $match file was to be able to extract only lines
> which mentioned one of the "common groups", and the point of the
> 'substnum' transformation was to transform the group name into a group
> number -- both of these operations were done without caring about the
> exact column the "common group" tag occupied.
>
> Obviously, one option for addressing this concern would be to change
> the definition to make the tag columns fixed and non-optional, which
> would allow the simpler implementation used by this patch. Doing so
> may require fixing other consumers of command-list.txt (though, I'm
> pretty sure existing consumers wouldn't be bothered).

I should follow up by saying that, although the current relatively
free-form line definition is nice due to its flexibility, considering
how infrequently command-list.txt is edited and how much more complex
the script is to support that flexibility, changing to a definition in
which tags are required and at fixed columns seems like the pragmatic
thing to do.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
                   ` (4 preceding siblings ...)
  2018-03-26 16:55 ` [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
@ 2018-04-09  5:17 ` Eric Sunshine
  2018-04-11 22:06   ` Philip Oakley
  2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
  2018-04-19 10:37 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Simon Ruderich
  7 siblings, 1 reply; 42+ messages in thread
From: Eric Sunshine @ 2018-04-09  5:17 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git List, SZEDER Gábor

On Mon, Mar 26, 2018 at 12:55 PM, Nguyễn Thái Ngọc Duy
<pclouds@gmail.com> wrote:
> This is pretty rough but I'd like to see how people feel about this
> first.
>
> I notice we have two places for command classification. One in
> command-list.txt, one in __git_list_porcelain_commands() in
> git-completion.bash. People who are following nd/parseopt-completion
> probably know that I'm try to reduce duplication in this script as
> much as possible, this is another step towards that.
>
> By keeping all information of command-list.txt in git binary, we could
> provide the porcelain list to git-completion.bash via "git
> --list-cmds=porcelain", so we don't neeed a separate command
> classification in git-completion.bash anymore.

I like the direction this series is taking.

> Because we have all command synopsis as a side effect, we could
> now support "git help -a --verbose" which prints something like "git
> help", a command name and a description, but we could do it for _all_
> recognized commands. This could help people look for a command even if
> we don't provide "git appropos".

Nice idea, and you practically get this for free (aside from the the
obvious new code) since generate-cmdlist.sh already plucks the summary
for each command directly from Documentation/git-*.txt.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis
  2018-04-09  5:08   ` Eric Sunshine
@ 2018-04-09  9:47     ` Junio C Hamano
  2018-04-09  9:55       ` Eric Sunshine
  0 siblings, 1 reply; 42+ messages in thread
From: Junio C Hamano @ 2018-04-09  9:47 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Nguyễn Thái Ngọc Duy, Git List, SZEDER Gábor

Eric Sunshine <sunshine@sunshineco.com> writes:

> On Mon, Mar 26, 2018 at 12:55 PM, Nguyễn Thái Ngọc Duy
> <pclouds@gmail.com> wrote:
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>> diff --git a/help.c b/help.c
>> @@ -282,6 +282,67 @@ void list_porcelain_cmds(void)
>> +static const char *get_category_name(unsigned int category)
>> +{
>> +       switch (category) {
>> +       case CAT_ancillaryinterrogators: return _("Ancillary interrogators");
>> +       case CAT_ancillarymanipulators: return _("Ancillary manipulators");
>> +       case CAT_foreignscminterface: return _("Foreign SCM interface");
>> +       case CAT_mainporcelain: return _("Main porcelain");
>> +       case CAT_plumbinginterrogators: return _("Plumbing interrogators");
>> +       case CAT_plumbingmanipulators: return _("Plumbing interrogators");
>
> s/interrogators"/manipulators"/
>
>> +       case CAT_purehelpers: return _("Pure helpers");
>> +       case CAT_synchelpers: return _("Sync helpers");
>> +       case CAT_synchingrepositories: return _("Synching repositories");
>> +       default:
>> +               die("BUG: unknown command category %u", category);
>> +       }

Somehow this screams "an array of strings" at me.  Aren't this
CAT_things small and dense enum?

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis
  2018-04-09  9:47     ` Junio C Hamano
@ 2018-04-09  9:55       ` Eric Sunshine
  2018-04-09 15:15         ` Duy Nguyen
  0 siblings, 1 reply; 42+ messages in thread
From: Eric Sunshine @ 2018-04-09  9:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Nguyễn Thái Ngọc Duy, Git List, SZEDER Gábor

On Mon, Apr 9, 2018 at 5:47 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
>> On Mon, Mar 26, 2018 at 12:55 PM, Nguyễn Thái Ngọc Duy
>> <pclouds@gmail.com> wrote:
>>> +       switch (category) {
>>> +       case CAT_ancillaryinterrogators: return _("Ancillary interrogators");
>>> +       case CAT_ancillarymanipulators: return _("Ancillary manipulators");
>>> +       case CAT_foreignscminterface: return _("Foreign SCM interface");
>>> +       case CAT_mainporcelain: return _("Main porcelain");
>>> +       case CAT_plumbinginterrogators: return _("Plumbing interrogators");
>>> +       case CAT_plumbingmanipulators: return _("Plumbing interrogators");
>>
>> s/interrogators"/manipulators"/
>>
>>> +       case CAT_purehelpers: return _("Pure helpers");
>>> +       case CAT_synchelpers: return _("Sync helpers");
>>> +       case CAT_synchingrepositories: return _("Synching repositories");
>
> Somehow this screams "an array of strings" at me.  Aren't this
> CAT_things small and dense enum?

Duy's modified generate-cmdlist.sh does actually output an array of
strings for these, but the (generated) array is commented out in this
RFC. I suppose the reason it's not presently used is because the array
looks like this:

static const char *cmd_categories[] = {
    "ancillaryinterrogators",
    "ancillarymanipulators",
    "foreignscminterface",
    "mainporcelain",
    "plumbinginterrogators",
    "plumbingmanipulators",
    "purehelpers",
    "synchelpers",
    "synchingrepositories",
     NULL
};

which doesn't give quite the human-friendly output he'd like. The
series is RFC, after all.

A possible approach to fix it would be to add a new "### categories"
section to command-list.txt which associates those category tags
("ancillaryinterrogators") with human-readable counterparts
("Ancillary interrogators").

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis
  2018-04-09  9:55       ` Eric Sunshine
@ 2018-04-09 15:15         ` Duy Nguyen
  0 siblings, 0 replies; 42+ messages in thread
From: Duy Nguyen @ 2018-04-09 15:15 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Junio C Hamano, Git List, SZEDER Gábor

On Mon, Apr 9, 2018 at 11:55 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Mon, Apr 9, 2018 at 5:47 AM, Junio C Hamano <gitster@pobox.com> wrote:
>> Eric Sunshine <sunshine@sunshineco.com> writes:
>>> On Mon, Mar 26, 2018 at 12:55 PM, Nguyễn Thái Ngọc Duy
>>> <pclouds@gmail.com> wrote:
>>>> +       switch (category) {
>>>> +       case CAT_ancillaryinterrogators: return _("Ancillary interrogators");
>>>> +       case CAT_ancillarymanipulators: return _("Ancillary manipulators");
>>>> +       case CAT_foreignscminterface: return _("Foreign SCM interface");
>>>> +       case CAT_mainporcelain: return _("Main porcelain");
>>>> +       case CAT_plumbinginterrogators: return _("Plumbing interrogators");
>>>> +       case CAT_plumbingmanipulators: return _("Plumbing interrogators");
>>>
>>> s/interrogators"/manipulators"/
>>>
>>>> +       case CAT_purehelpers: return _("Pure helpers");
>>>> +       case CAT_synchelpers: return _("Sync helpers");
>>>> +       case CAT_synchingrepositories: return _("Synching repositories");
>>
>> Somehow this screams "an array of strings" at me.  Aren't this
>> CAT_things small and dense enum?
>
> Duy's modified generate-cmdlist.sh does actually output an array of
> strings for these, but the (generated) array is commented out in this
> RFC. I suppose the reason it's not presently used is because the array
> looks like this:
>
> static const char *cmd_categories[] = {
>     "ancillaryinterrogators",
>     "ancillarymanipulators",
>     "foreignscminterface",
>     "mainporcelain",
>     "plumbinginterrogators",
>     "plumbingmanipulators",
>     "purehelpers",
>     "synchelpers",
>     "synchingrepositories",
>      NULL
> };
>
> which doesn't give quite the human-friendly output he'd like. The
> series is RFC, after all.

Yep.

> A possible approach to fix it would be to add a new "### categories"
> section to command-list.txt which associates those category tags
> ("ancillaryinterrogators") with human-readable counterparts
> ("Ancillary interrogators").

Or extract the headlines from git.txt but that's not easy since it's
not consistent. We could manually recreate the same grouping as in
git.txt too, it's probably nicer than just printing groups sorted by
category id.
-- 
Duy

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-09  4:59   ` Eric Sunshine
  2018-04-09  5:12     ` Eric Sunshine
@ 2018-04-09 16:16     ` Duy Nguyen
  2018-04-15 16:04     ` Duy Nguyen
  2 siblings, 0 replies; 42+ messages in thread
From: Duy Nguyen @ 2018-04-09 16:16 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git List, SZEDER Gábor

On Mon, Apr 9, 2018 at 6:59 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> On Mon, Mar 26, 2018 at 12:55 PM, Nguyễn Thái Ngọc Duy
> <pclouds@gmail.com> wrote:
>> common-cmds.h is used to extract the list of common commands (by
>> group) and a one-line summary of each command. Some information is
>> dropped, for example command category or summary of other commands.
>> Update generate-cmdlist.sh to keep all the information. The extra info
>> will be used shortly.
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>> diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
>> @@ -2,9 +2,10 @@
>>  struct cmdname_help {
>> -       char name[16];
>> +       char name[32];
>>         char help[80];
>> -       unsigned char group;
>> +       unsigned int category;
>> +       unsigned int group;
>>  };
>> @@ -23,27 +24,50 @@ sed -n '
>> +echo "#define GROUP_NONE 0xff /* no common group */"
>> +echo "#define GROUP_ 0xff /* no common group */"
>
> Meh, this "GROUP_" alias of "GROUP_NONE" isn't so nice.

Yeah. I don't want to mess too much with shell script. I wonder if we
should instead kill this script and extend Documentation/cmd-list.perl
to handle this task too. It would be much nicer to write and maintain
the script. The downside is NO_PERL builds will have no commands in
"git help".
-- 
Duy

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-09  5:17 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Eric Sunshine
@ 2018-04-11 22:06   ` Philip Oakley
  2018-04-14 15:44     ` Duy Nguyen
  0 siblings, 1 reply; 42+ messages in thread
From: Philip Oakley @ 2018-04-11 22:06 UTC (permalink / raw)
  To: Eric Sunshine, Nguyễn Thái Ngọc Duy; +Cc: Git List, SZEDER Gábor

From: "Eric Sunshine" <sunshine@sunshineco.com> Monday, April 09, 2018 6:17 
AM
On Mon, Mar 26, 2018 at 12:55 PM, Nguyễn Thái Ngọc Duy
<pclouds@gmail.com> wrote:
> This is pretty rough but I'd like to see how people feel about this
> first.
>
> I notice we have two places for command classification. One in
> command-list.txt, one in __git_list_porcelain_commands() in
> git-completion.bash. People who are following nd/parseopt-completion
> probably know that I'm try to reduce duplication in this script as
> much as possible, this is another step towards that.
>
> By keeping all information of command-list.txt in git binary, we could
> provide the porcelain list to git-completion.bash via "git
> --list-cmds=porcelain", so we don't neeed a separate command
> classification in git-completion.bash anymore.

I like the direction this series is taking.

> Because we have all command synopsis as a side effect, we could
> now support "git help -a --verbose" which prints something like "git
> help", a command name and a description, but we could do it for _all_
> recognized commands. This could help people look for a command even if
> we don't provide "git appropos".

Nice idea, and you practically get this for free (aside from the the
obvious new code) since generate-cmdlist.sh already plucks the summary
for each command directly from Documentation/git-*.txt.

I'm only just catching up, but does/can this series also capture the 
non-command guides that are available in git so that the 'git help -g' can 
begin to list them all?

It was something I looked at some years ago (when I added the -g option) but 
at the time the idea of updating the command-list.txt was too invasive.

Just a thought.

Philip


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-11 22:06   ` Philip Oakley
@ 2018-04-14 15:44     ` Duy Nguyen
  2018-04-15 21:21       ` Philip Oakley
  0 siblings, 1 reply; 42+ messages in thread
From: Duy Nguyen @ 2018-04-14 15:44 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Eric Sunshine, Git List, SZEDER Gábor

On Thu, Apr 12, 2018 at 12:06 AM, Philip Oakley <philipoakley@iee.org> wrote:
> I'm only just catching up, but does/can this series also capture the
> non-command guides that are available in git so that the 'git help -g' can
> begin to list them all?

It currently does not. But I don't see why it should not. This should
allow git.txt to list all the guides too, for people who skip "git
help" and go hard core mode with "man git". Thanks for bringing this
up.
-- 
Duy

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-09  4:59   ` Eric Sunshine
  2018-04-09  5:12     ` Eric Sunshine
  2018-04-09 16:16     ` Duy Nguyen
@ 2018-04-15 16:04     ` Duy Nguyen
  2 siblings, 0 replies; 42+ messages in thread
From: Duy Nguyen @ 2018-04-15 16:04 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Git List, SZEDER Gábor

On Mon, Apr 9, 2018 at 6:59 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
>> +awk '{print $2;}' |
>
> At one time, Junio expressed concerns[2] about having an 'awk'
> dependency in the build system (in fact, with regards to this same
> generation process). Whether he still has such concerns is unknown,
> but it should be easy enough to avoid it here (and below).
>
> [2]: https://public-inbox.org/git/20150519004356.GA12854@flurp.local/

I'll stick with awk to avoid too much headache with regular
expressions (replacements are welcome though). We do use awk in our
test suite so it should be ok (who builds git and runs it without
testing?)
-- 
Duy

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH v2 0/6] Keep all info in command-list.txt in git binary
  2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
                   ` (5 preceding siblings ...)
  2018-04-09  5:17 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Eric Sunshine
@ 2018-04-15 16:42 ` " Nguyễn Thái Ngọc Duy
  2018-04-15 16:42   ` [PATCH v2 1/6] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
                     ` (5 more replies)
  2018-04-19 10:37 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Simon Ruderich
  7 siblings, 6 replies; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-04-15 16:42 UTC (permalink / raw)
  To: pclouds; +Cc: git, szeder.dev, Eric Sunshine, philipoakley, Junio C Hamano

v2 changes

- bug fixes spotted by Eric
- keep 'git help -av' layout close to what's in git.txt
- enable pager for 'git help -av' because it's usually long
- move guide list (aka 'help -g') to command-list.txt

Nguyễn Thái Ngọc Duy (6):
  git.c: convert --list-builtins to --list-cmds=builtins
  git.c: implement --list-cmds=all and use it in git-completion.bash
  generate-cmdlist.sh: keep all information in common-cmds.h
  git.c: implement --list-cmds=porcelain
  help: add "-a --verbose" to list all commands with synopsis
  help: use command-list.txt for the source of guides

 Documentation/git-help.txt             |   4 +-
 Documentation/gitattributes.txt        |   2 +-
 Documentation/gitmodules.txt           |   2 +-
 Documentation/gitrevisions.txt         |   2 +-
 builtin/help.c                         |  39 ++----
 command-list.txt                       |   8 ++
 contrib/completion/git-completion.bash |  96 +--------------
 generate-cmdlist.sh                    |  65 +++++++---
 git.c                                  |  16 ++-
 help.c                                 | 163 ++++++++++++++++++++++++-
 help.h                                 |   4 +
 t/t0012-help.sh                        |   2 +-
 t/t9902-completion.sh                  |   4 +-
 13 files changed, 249 insertions(+), 158 deletions(-)

-- 
2.17.0.367.g5dd2e386c3


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH v2 1/6] git.c: convert --list-builtins to --list-cmds=builtins
  2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
@ 2018-04-15 16:42   ` Nguyễn Thái Ngọc Duy
  2018-04-15 16:42   ` [PATCH v2 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-04-15 16:42 UTC (permalink / raw)
  To: pclouds; +Cc: git, szeder.dev, Eric Sunshine, philipoakley, Junio C Hamano

Even if this is a hidden option, let's make it a bit more generic
since we're introducing more listing types.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash |  2 +-
 git.c                                  | 12 +++++++-----
 t/t0012-help.sh                        |  2 +-
 3 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a757073945..3556838759 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -3049,7 +3049,7 @@ __git_complete_common () {
 __git_cmds_with_parseopt_helper=
 __git_support_parseopt_helper () {
 	test -n "$__git_cmds_with_parseopt_helper" ||
-		__git_cmds_with_parseopt_helper="$(__git --list-parseopt-builtins)"
+		__git_cmds_with_parseopt_helper="$(__git --list-cmds=parseopt)"
 
 	case " $__git_cmds_with_parseopt_helper " in
 	*" $1 "*)
diff --git a/git.c b/git.c
index 3a89893712..28bfa96d87 100644
--- a/git.c
+++ b/git.c
@@ -223,11 +223,13 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 			}
 			(*argv)++;
 			(*argc)--;
-		} else if (!strcmp(cmd, "--list-builtins")) {
-			list_builtins(0, '\n');
-			exit(0);
-		} else if (!strcmp(cmd, "--list-parseopt-builtins")) {
-			list_builtins(NO_PARSEOPT, ' ');
+		} else if (skip_prefix(cmd, "--list-cmds=", &cmd)) {
+			if (!strcmp(cmd, "builtins"))
+				list_builtins(0, '\n');
+			else if (!strcmp(cmd, "parseopt"))
+				list_builtins(NO_PARSEOPT, ' ');
+			else
+				die("unsupported command listing type '%s'", cmd);
 			exit(0);
 		} else {
 			fprintf(stderr, _("unknown option: %s\n"), cmd);
diff --git a/t/t0012-help.sh b/t/t0012-help.sh
index 487b92a5de..fd2a7f27dc 100755
--- a/t/t0012-help.sh
+++ b/t/t0012-help.sh
@@ -50,7 +50,7 @@ test_expect_success "--help does not work for guides" "
 "
 
 test_expect_success 'generate builtin list' '
-	git --list-builtins >builtins
+	git --list-cmds=builtins >builtins
 '
 
 while read builtin
-- 
2.17.0.367.g5dd2e386c3


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH v2 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash
  2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
  2018-04-15 16:42   ` [PATCH v2 1/6] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
@ 2018-04-15 16:42   ` Nguyễn Thái Ngọc Duy
  2018-04-16  2:30     ` Junio C Hamano
  2018-04-15 16:42   ` [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-04-15 16:42 UTC (permalink / raw)
  To: pclouds; +Cc: git, szeder.dev, Eric Sunshine, philipoakley, Junio C Hamano

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash |  2 +-
 git.c                                  |  2 ++
 help.c                                 | 18 ++++++++++++++++++
 help.h                                 |  1 +
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 3556838759..a5f13ade20 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -839,7 +839,7 @@ __git_commands () {
 	then
 		printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
 	else
-		git help -a|egrep '^  [a-zA-Z0-9]'
+		git --list-cmds=all
 	fi
 }
 
diff --git a/git.c b/git.c
index 28bfa96d87..64f67e7f7f 100644
--- a/git.c
+++ b/git.c
@@ -228,6 +228,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				list_builtins(0, '\n');
 			else if (!strcmp(cmd, "parseopt"))
 				list_builtins(NO_PARSEOPT, ' ');
+			else if (!strcmp(cmd, "all"))
+				list_all_cmds();
 			else
 				die("unsupported command listing type '%s'", cmd);
 			exit(0);
diff --git a/help.c b/help.c
index 60071a9bea..e155c39870 100644
--- a/help.c
+++ b/help.c
@@ -228,6 +228,24 @@ void list_common_cmds_help(void)
 	}
 }
 
+void list_all_cmds(void)
+{
+	struct cmdnames main_cmds, other_cmds;
+	int i;
+
+	memset(&main_cmds, 0, sizeof(main_cmds));
+	memset(&other_cmds, 0, sizeof(other_cmds));
+	load_command_list("git-", &main_cmds, &other_cmds);
+
+	for (i = 0; i < main_cmds.cnt; i++)
+		puts(main_cmds.names[i]->name);
+	for (i = 0; i < other_cmds.cnt; i++)
+		puts(other_cmds.names[i]->name);
+
+	clean_cmdnames(&main_cmds);
+	clean_cmdnames(&other_cmds);
+}
+
 int is_in_cmdlist(struct cmdnames *c, const char *s)
 {
 	int i;
diff --git a/help.h b/help.h
index b21d7c94e8..0bf29f8dc5 100644
--- a/help.h
+++ b/help.h
@@ -17,6 +17,7 @@ static inline void mput_char(char c, unsigned int num)
 }
 
 extern void list_common_cmds_help(void);
+extern void list_all_cmds(void);
 extern const char *help_unknown_cmd(const char *cmd);
 extern void load_command_list(const char *prefix,
 			      struct cmdnames *main_cmds,
-- 
2.17.0.367.g5dd2e386c3


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
  2018-04-15 16:42   ` [PATCH v2 1/6] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
  2018-04-15 16:42   ` [PATCH v2 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
@ 2018-04-15 16:42   ` Nguyễn Thái Ngọc Duy
  2018-04-16  2:38     ` Junio C Hamano
                       ` (2 more replies)
  2018-04-15 16:42   ` [PATCH v2 4/6] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
                     ` (2 subsequent siblings)
  5 siblings, 3 replies; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-04-15 16:42 UTC (permalink / raw)
  To: pclouds; +Cc: git, szeder.dev, Eric Sunshine, philipoakley, Junio C Hamano

common-cmds.h is used to extract the list of common commands (by
group) and a one-line summary of each command. Some information is
dropped, for example command category or summary of other commands.
Update generate-cmdlist.sh to keep all the information. The extra info
will be used shortly.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 generate-cmdlist.sh | 61 +++++++++++++++++++++++++++++++++------------
 help.c              | 42 ++++++++++++++++++++++++++-----
 2 files changed, 81 insertions(+), 22 deletions(-)

diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index eeea4b67ea..e0893e979a 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -1,17 +1,30 @@
 #!/bin/sh
 
+# Don't let locale affect this script.
+LC_ALL=C
+LANG=C
+export LC_ALL LANG
+
+command_list () {
+	sed '1,/^### command list/d;/^#/d' "$1"
+}
+
+category_list () {
+	command_list "$1" | awk '{print $2;}' | sort | uniq
+}
+
 echo "/* Automatically generated by generate-cmdlist.sh */
 struct cmdname_help {
-	char name[16];
+	char name[32];
 	char help[80];
-	unsigned char group;
+	unsigned int category;
+	unsigned int group;
 };
 
 static const char *common_cmd_groups[] = {"
 
 grps=grps$$.tmp
-match=match$$.tmp
-trap "rm -f '$grps' '$match'" 0 1 2 3 15
+trap "rm -f '$grps'" 0 1 2 3 15
 
 sed -n '
 	1,/^### common groups/b
@@ -23,28 +36,44 @@ sed -n '
 	' "$1"
 printf '};\n\n'
 
+echo "#define GROUP_NONE 0xff /* no common group */"
 n=0
-substnum=
 while read grp
 do
-	echo "^git-..*[ 	]$grp"
-	substnum="$substnum${substnum:+;}s/[ 	]$grp/$n/"
+	echo "#define GROUP_${grp:-NONE} $n"
 	n=$(($n+1))
-done <"$grps" >"$match"
+done <"$grps"
+echo
+
+echo '/*'
+printf 'static const char *cmd_categories[] = {\n'
+category_list "$1" |
+while read category; do
+	printf '\t\"'$category'\",\n'
+done
+printf '\tNULL\n};\n\n'
+echo '*/'
+
+n=0
+category_list "$1" |
+while read category; do
+	echo "#define CAT_$category $n"
+	n=$(($n+1))
+done
+echo
 
-printf 'static struct cmdname_help common_cmds[] = {\n'
-grep -f "$match" "$1" |
-sed 's/^git-//' |
+printf 'static struct cmdname_help command_list[] = {\n'
+command_list "$1" |
 sort |
-while read cmd tags
+while read cmd category tags
 do
-	tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
+	name=${cmd/git-}
 	sed -n '
-		/^NAME/,/git-'"$cmd"'/H
+		/^NAME/,/'"$cmd"'/H
 		${
 			x
-			s/.*git-'"$cmd"' - \(.*\)/	{"'"$cmd"'", N_("\1"), '$tag'},/
+			s/.*'"$cmd"' - \(.*\)/	{"'"$name"'", N_("\1"), CAT_'$category', GROUP_'${tags:-NONE}' },/
 			p
-		}' "Documentation/git-$cmd.txt"
+		}' "Documentation/$cmd.txt"
 done
 echo "};"
diff --git a/help.c b/help.c
index e155c39870..b5da7fa013 100644
--- a/help.c
+++ b/help.c
@@ -190,6 +190,27 @@ void list_commands(unsigned int colopts,
 	}
 }
 
+static void extract_common_cmds(struct cmdname_help **p_common_cmds,
+				int *p_nr)
+{
+	int i, nr = 0;
+	struct cmdname_help *common_cmds;
+
+	ALLOC_ARRAY(common_cmds, ARRAY_SIZE(command_list));
+
+	for (i = 0; i < ARRAY_SIZE(command_list); i++) {
+		const struct cmdname_help *cmd = command_list + i;
+
+		if (cmd->category != CAT_mainporcelain)
+			continue;
+
+		common_cmds[nr++] = *cmd;
+	}
+
+	*p_common_cmds = common_cmds;
+	*p_nr = nr;
+}
+
 static int cmd_group_cmp(const void *elem1, const void *elem2)
 {
 	const struct cmdname_help *e1 = elem1;
@@ -206,17 +227,21 @@ void list_common_cmds_help(void)
 {
 	int i, longest = 0;
 	int current_grp = -1;
+	int nr = 0;
+	struct cmdname_help *common_cmds;
+
+	extract_common_cmds(&common_cmds, &nr);
 
-	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+	for (i = 0; i < nr; i++) {
 		if (longest < strlen(common_cmds[i].name))
 			longest = strlen(common_cmds[i].name);
 	}
 
-	QSORT(common_cmds, ARRAY_SIZE(common_cmds), cmd_group_cmp);
+	QSORT(common_cmds, nr, cmd_group_cmp);
 
 	puts(_("These are common Git commands used in various situations:"));
 
-	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
+	for (i = 0; i < nr; i++) {
 		if (common_cmds[i].group != current_grp) {
 			printf("\n%s\n", _(common_cmd_groups[common_cmds[i].group]));
 			current_grp = common_cmds[i].group;
@@ -226,6 +251,7 @@ void list_common_cmds_help(void)
 		mput_char(' ', longest - strlen(common_cmds[i].name));
 		puts(_(common_cmds[i].help));
 	}
+	free(common_cmds);
 }
 
 void list_all_cmds(void)
@@ -301,8 +327,9 @@ static const char bad_interpreter_advice[] =
 
 const char *help_unknown_cmd(const char *cmd)
 {
-	int i, n, best_similarity = 0;
+	int i, n, best_similarity = 0, nr_common;
 	struct cmdnames main_cmds, other_cmds;
+	struct cmdname_help *common_cmds;
 
 	memset(&main_cmds, 0, sizeof(main_cmds));
 	memset(&other_cmds, 0, sizeof(other_cmds));
@@ -317,6 +344,8 @@ const char *help_unknown_cmd(const char *cmd)
 	QSORT(main_cmds.names, main_cmds.cnt, cmdname_compare);
 	uniq(&main_cmds);
 
+	extract_common_cmds(&common_cmds, &nr_common);
+
 	/* This abuses cmdname->len for levenshtein distance */
 	for (i = 0, n = 0; i < main_cmds.cnt; i++) {
 		int cmp = 0; /* avoid compiler stupidity */
@@ -331,10 +360,10 @@ const char *help_unknown_cmd(const char *cmd)
 			die(_(bad_interpreter_advice), cmd, cmd);
 
 		/* Does the candidate appear in common_cmds list? */
-		while (n < ARRAY_SIZE(common_cmds) &&
+		while (n < nr_common &&
 		       (cmp = strcmp(common_cmds[n].name, candidate)) < 0)
 			n++;
-		if ((n < ARRAY_SIZE(common_cmds)) && !cmp) {
+		if ((n < nr_common) && !cmp) {
 			/* Yes, this is one of the common commands */
 			n++; /* use the entry from common_cmds[] */
 			if (starts_with(candidate, cmd)) {
@@ -347,6 +376,7 @@ const char *help_unknown_cmd(const char *cmd)
 		main_cmds.names[i]->len =
 			levenshtein(cmd, candidate, 0, 2, 1, 3) + 1;
 	}
+	FREE_AND_NULL(common_cmds);
 
 	QSORT(main_cmds.names, main_cmds.cnt, levenshtein_compare);
 
-- 
2.17.0.367.g5dd2e386c3


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH v2 4/6] git.c: implement --list-cmds=porcelain
  2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
                     ` (2 preceding siblings ...)
  2018-04-15 16:42   ` [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
@ 2018-04-15 16:42   ` Nguyễn Thái Ngọc Duy
  2018-04-15 16:42   ` [PATCH v2 5/6] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
  2018-04-15 16:42   ` [PATCH v2 6/6] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
  5 siblings, 0 replies; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-04-15 16:42 UTC (permalink / raw)
  To: pclouds; +Cc: git, szeder.dev, Eric Sunshine, philipoakley, Junio C Hamano

This is useful for git-completion.bash because it needs this set of
commands. Right now we have to maintain a separate command category in
there.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 contrib/completion/git-completion.bash | 94 ++------------------------
 git.c                                  |  2 +
 help.c                                 | 12 ++++
 help.h                                 |  1 +
 t/t9902-completion.sh                  |  4 +-
 5 files changed, 20 insertions(+), 93 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index a5f13ade20..9f17703aa7 100644
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -839,14 +839,15 @@ __git_commands () {
 	then
 		printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
 	else
-		git --list-cmds=all
+		git --list-cmds=$1
 	fi
 }
 
 __git_list_all_commands ()
 {
 	local i IFS=" "$'\n'
-	for i in $(__git_commands)
+	local category=${1-all}
+	for i in $(__git_commands $category)
 	do
 		case $i in
 		*--*)             : helper pattern;;
@@ -862,98 +863,11 @@ __git_compute_all_commands ()
 	__git_all_commands=$(__git_list_all_commands)
 }
 
-__git_list_porcelain_commands ()
-{
-	local i IFS=" "$'\n'
-	__git_compute_all_commands
-	for i in $__git_all_commands
-	do
-		case $i in
-		*--*)             : helper pattern;;
-		applymbox)        : ask gittus;;
-		applypatch)       : ask gittus;;
-		archimport)       : import;;
-		cat-file)         : plumbing;;
-		check-attr)       : plumbing;;
-		check-ignore)     : plumbing;;
-		check-mailmap)    : plumbing;;
-		check-ref-format) : plumbing;;
-		checkout-index)   : plumbing;;
-		column)           : internal helper;;
-		commit-tree)      : plumbing;;
-		count-objects)    : infrequent;;
-		credential)       : credentials;;
-		credential-*)     : credentials helper;;
-		cvsexportcommit)  : export;;
-		cvsimport)        : import;;
-		cvsserver)        : daemon;;
-		daemon)           : daemon;;
-		diff-files)       : plumbing;;
-		diff-index)       : plumbing;;
-		diff-tree)        : plumbing;;
-		fast-import)      : import;;
-		fast-export)      : export;;
-		fsck-objects)     : plumbing;;
-		fetch-pack)       : plumbing;;
-		fmt-merge-msg)    : plumbing;;
-		for-each-ref)     : plumbing;;
-		hash-object)      : plumbing;;
-		http-*)           : transport;;
-		index-pack)       : plumbing;;
-		init-db)          : deprecated;;
-		local-fetch)      : plumbing;;
-		ls-files)         : plumbing;;
-		ls-remote)        : plumbing;;
-		ls-tree)          : plumbing;;
-		mailinfo)         : plumbing;;
-		mailsplit)        : plumbing;;
-		merge-*)          : plumbing;;
-		mktree)           : plumbing;;
-		mktag)            : plumbing;;
-		pack-objects)     : plumbing;;
-		pack-redundant)   : plumbing;;
-		pack-refs)        : plumbing;;
-		parse-remote)     : plumbing;;
-		patch-id)         : plumbing;;
-		prune)            : plumbing;;
-		prune-packed)     : plumbing;;
-		quiltimport)      : import;;
-		read-tree)        : plumbing;;
-		receive-pack)     : plumbing;;
-		remote-*)         : transport;;
-		rerere)           : plumbing;;
-		rev-list)         : plumbing;;
-		rev-parse)        : plumbing;;
-		runstatus)        : plumbing;;
-		sh-setup)         : internal;;
-		shell)            : daemon;;
-		show-ref)         : plumbing;;
-		send-pack)        : plumbing;;
-		show-index)       : plumbing;;
-		ssh-*)            : transport;;
-		stripspace)       : plumbing;;
-		symbolic-ref)     : plumbing;;
-		unpack-file)      : plumbing;;
-		unpack-objects)   : plumbing;;
-		update-index)     : plumbing;;
-		update-ref)       : plumbing;;
-		update-server-info) : daemon;;
-		upload-archive)   : plumbing;;
-		upload-pack)      : plumbing;;
-		write-tree)       : plumbing;;
-		var)              : infrequent;;
-		verify-pack)      : infrequent;;
-		verify-tag)       : plumbing;;
-		*) echo $i;;
-		esac
-	done
-}
-
 __git_porcelain_commands=
 __git_compute_porcelain_commands ()
 {
 	test -n "$__git_porcelain_commands" ||
-	__git_porcelain_commands=$(__git_list_porcelain_commands)
+	__git_porcelain_commands=$(__git_list_all_commands porcelain)
 }
 
 # Lists all set config variables starting with the given section prefix,
diff --git a/git.c b/git.c
index 64f67e7f7f..153f56fb95 100644
--- a/git.c
+++ b/git.c
@@ -230,6 +230,8 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
 				list_builtins(NO_PARSEOPT, ' ');
 			else if (!strcmp(cmd, "all"))
 				list_all_cmds();
+			else if (!strcmp(cmd, "porcelain"))
+				list_porcelain_cmds();
 			else
 				die("unsupported command listing type '%s'", cmd);
 			exit(0);
diff --git a/help.c b/help.c
index b5da7fa013..1523ca175c 100644
--- a/help.c
+++ b/help.c
@@ -272,6 +272,18 @@ void list_all_cmds(void)
 	clean_cmdnames(&other_cmds);
 }
 
+void list_porcelain_cmds(void)
+{
+	int i, nr = ARRAY_SIZE(command_list);
+	struct cmdname_help *cmds = command_list;
+
+	for (i = 0; i < nr; i++) {
+		if (cmds[i].category != CAT_mainporcelain)
+			continue;
+		puts(cmds[i].name);
+	}
+}
+
 int is_in_cmdlist(struct cmdnames *c, const char *s)
 {
 	int i;
diff --git a/help.h b/help.h
index 0bf29f8dc5..33e2210ebd 100644
--- a/help.h
+++ b/help.h
@@ -18,6 +18,7 @@ static inline void mput_char(char c, unsigned int num)
 
 extern void list_common_cmds_help(void);
 extern void list_all_cmds(void);
+extern void list_porcelain_cmds(void);
 extern const char *help_unknown_cmd(const char *cmd);
 extern void load_command_list(const char *prefix,
 			      struct cmdnames *main_cmds,
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index 1b34caa1e1..4bfd26ddf9 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -1208,8 +1208,6 @@ test_expect_success 'basic' '
 	grep -q "^add \$" out &&
 	# script
 	grep -q "^filter-branch \$" out &&
-	# plumbing
-	! grep -q "^ls-files \$" out &&
 
 	run_completion "git f" &&
 	! grep -q -v "^f" out
@@ -1272,7 +1270,7 @@ test_expect_success 'general options' '
 	test_completion "git --no-r" "--no-replace-objects "
 '
 
-test_expect_success 'general options plus command' '
+test_expect_failure 'general options plus command' '
 	test_completion "git --version check" "checkout " &&
 	test_completion "git --paginate check" "checkout " &&
 	test_completion "git --git-dir=foo check" "checkout " &&
-- 
2.17.0.367.g5dd2e386c3


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH v2 5/6] help: add "-a --verbose" to list all commands with synopsis
  2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
                     ` (3 preceding siblings ...)
  2018-04-15 16:42   ` [PATCH v2 4/6] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
@ 2018-04-15 16:42   ` Nguyễn Thái Ngọc Duy
  2018-04-15 16:42   ` [PATCH v2 6/6] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
  5 siblings, 0 replies; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-04-15 16:42 UTC (permalink / raw)
  To: pclouds; +Cc: git, szeder.dev, Eric Sunshine, philipoakley, Junio C Hamano

This lists all recognized commands [1] by category. The group order
follows closely git.txt.

[1] We may actually show commands that are not built (e.g. if you set
NO_PERL you don't have git-instaweb but it's still listed here). I
ignore the problem because on Linux a git package could be split
anyway. The "git-core" package may not contain git-instaweb even if
it's built because it may end up in a separate package. We can't know
anyway.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/git-help.txt |  4 ++-
 builtin/help.c             |  7 ++++
 help.c                     | 69 ++++++++++++++++++++++++++++++++++++++
 help.h                     |  1 +
 4 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/Documentation/git-help.txt b/Documentation/git-help.txt
index 40d328a4b3..a40fc38d8b 100644
--- a/Documentation/git-help.txt
+++ b/Documentation/git-help.txt
@@ -8,7 +8,7 @@ git-help - Display help information about Git
 SYNOPSIS
 --------
 [verse]
-'git help' [-a|--all] [-g|--guide]
+'git help' [-a|--all [--verbose]] [-g|--guide]
 	   [-i|--info|-m|--man|-w|--web] [COMMAND|GUIDE]
 
 DESCRIPTION
@@ -42,6 +42,8 @@ OPTIONS
 --all::
 	Prints all the available commands on the standard output. This
 	option overrides any given command or guide name.
+	When used with `--verbose` print description for all recognized
+	commands.
 
 -g::
 --guides::
diff --git a/builtin/help.c b/builtin/help.c
index 598867cfea..0e0af8426a 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -36,6 +36,7 @@ static const char *html_path;
 
 static int show_all = 0;
 static int show_guides = 0;
+static int verbose;
 static unsigned int colopts;
 static enum help_format help_format = HELP_FORMAT_NONE;
 static int exclude_guides;
@@ -48,6 +49,7 @@ static struct option builtin_help_options[] = {
 			HELP_FORMAT_WEB),
 	OPT_SET_INT('i', "info", &help_format, N_("show info page"),
 			HELP_FORMAT_INFO),
+	OPT__VERBOSE(&verbose, N_("print command description")),
 	OPT_END(),
 };
 
@@ -463,6 +465,11 @@ int cmd_help(int argc, const char **argv, const char *prefix)
 
 	if (show_all) {
 		git_config(git_help_config, NULL);
+		if (verbose) {
+			setup_pager();
+			list_all_cmds_help();
+			return 0;
+		}
 		printf(_("usage: %s%s"), _(git_usage_string), "\n\n");
 		load_command_list("git-", &main_cmds, &other_cmds);
 		list_commands(colopts, &main_cmds, &other_cmds);
diff --git a/help.c b/help.c
index 1523ca175c..7f72051641 100644
--- a/help.c
+++ b/help.c
@@ -284,6 +284,75 @@ void list_porcelain_cmds(void)
 	}
 }
 
+static int cmd_category_cmp(const void *elem1, const void *elem2)
+{
+	const struct cmdname_help *e1 = elem1;
+	const struct cmdname_help *e2 = elem2;
+
+	if (e1->category < e2->category)
+		return -1;
+	if (e1->category > e2->category)
+		return 1;
+	return strcmp(e1->name, e2->name);
+}
+
+static void list_commands_by_category(int cat, struct cmdname_help *cmds,
+				      int nr, int longest)
+{
+	int i;
+
+	for (i = 0; i < nr; i++) {
+		struct cmdname_help *cmd = cmds + i;
+
+		if (cmd->category != cat)
+			continue;
+
+		printf("   %s   ", cmd->name);
+		mput_char(' ', longest - strlen(cmd->name));
+		puts(_(cmd->help));
+	}
+}
+
+void list_all_cmds_help(void)
+{
+	int i, longest = 0;
+	int nr = ARRAY_SIZE(command_list);
+	struct cmdname_help *cmds = command_list;
+
+	for (i = 0; i < nr; i++) {
+		struct cmdname_help *cmd = cmds + i;
+
+		if (longest < strlen(cmd->name))
+			longest = strlen(cmd->name);
+	}
+
+	QSORT(cmds, nr, cmd_category_cmp);
+
+	printf("%s\n\n", _("Main Porcelain Commands"));
+	list_commands_by_category(CAT_mainporcelain, cmds, nr, longest);
+
+	printf("\n%s\n\n", _("Ancillary Commands / Manipulators"));
+	list_commands_by_category(CAT_ancillarymanipulators, cmds, nr, longest);
+
+	printf("\n%s\n\n", _("Ancillary Commands / Interrogators"));
+	list_commands_by_category(CAT_ancillaryinterrogators, cmds, nr, longest);
+
+	printf("\n%s\n\n", _("Interacting with Others"));
+	list_commands_by_category(CAT_foreignscminterface, cmds, nr, longest);
+
+	printf("\n%s\n\n", _("Low-level Commands / Manipulators"));
+	list_commands_by_category(CAT_plumbingmanipulators, cmds, nr, longest);
+
+	printf("\n%s\n\n", _("Low-level Commands / Interrogators"));
+	list_commands_by_category(CAT_plumbinginterrogators, cmds, nr, longest);
+
+	printf("\n%s\n\n", _("Low-level Commands / Synching Repositories"));
+	list_commands_by_category(CAT_synchingrepositories, cmds, nr, longest);
+
+	printf("\n%s\n\n", _("Low-level Commands / Internal Helpers"));
+	list_commands_by_category(CAT_purehelpers, cmds, nr, longest);
+}
+
 int is_in_cmdlist(struct cmdnames *c, const char *s)
 {
 	int i;
diff --git a/help.h b/help.h
index 33e2210ebd..62449f1b7e 100644
--- a/help.h
+++ b/help.h
@@ -17,6 +17,7 @@ static inline void mput_char(char c, unsigned int num)
 }
 
 extern void list_common_cmds_help(void);
+extern void list_all_cmds_help(void);
 extern void list_all_cmds(void);
 extern void list_porcelain_cmds(void);
 extern const char *help_unknown_cmd(const char *cmd);
-- 
2.17.0.367.g5dd2e386c3


^ permalink raw reply	[flat|nested] 42+ messages in thread

* [PATCH v2 6/6] help: use command-list.txt for the source of guides
  2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
                     ` (4 preceding siblings ...)
  2018-04-15 16:42   ` [PATCH v2 5/6] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
@ 2018-04-15 16:42   ` Nguyễn Thái Ngọc Duy
  5 siblings, 0 replies; 42+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2018-04-15 16:42 UTC (permalink / raw)
  To: pclouds; +Cc: git, szeder.dev, Eric Sunshine, philipoakley, Junio C Hamano

The help command currently hard codes the list of guides and their
summary in C. Let's move this list to command-list.txt. This lets us
extract summary lines from Documentation/git*.txt. This also
potentially lets us lists guides in git.txt, but I'll leave that for
now.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 Documentation/gitattributes.txt |  2 +-
 Documentation/gitmodules.txt    |  2 +-
 Documentation/gitrevisions.txt  |  2 +-
 builtin/help.c                  | 32 --------------------------------
 command-list.txt                |  8 ++++++++
 generate-cmdlist.sh             |  6 +++++-
 help.c                          | 22 ++++++++++++++++++++++
 help.h                          |  1 +
 8 files changed, 39 insertions(+), 36 deletions(-)

diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 1094fe2b5b..083c2f380d 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -3,7 +3,7 @@ gitattributes(5)
 
 NAME
 ----
-gitattributes - defining attributes per path
+gitattributes - Defining attributes per path
 
 SYNOPSIS
 --------
diff --git a/Documentation/gitmodules.txt b/Documentation/gitmodules.txt
index db5d47eb19..4d63def206 100644
--- a/Documentation/gitmodules.txt
+++ b/Documentation/gitmodules.txt
@@ -3,7 +3,7 @@ gitmodules(5)
 
 NAME
 ----
-gitmodules - defining submodule properties
+gitmodules - Defining submodule properties
 
 SYNOPSIS
 --------
diff --git a/Documentation/gitrevisions.txt b/Documentation/gitrevisions.txt
index 27dec5b91d..1f6cceaefb 100644
--- a/Documentation/gitrevisions.txt
+++ b/Documentation/gitrevisions.txt
@@ -3,7 +3,7 @@ gitrevisions(7)
 
 NAME
 ----
-gitrevisions - specifying revisions and ranges for Git
+gitrevisions - Specifying revisions and ranges for Git
 
 SYNOPSIS
 --------
diff --git a/builtin/help.c b/builtin/help.c
index 0e0af8426a..5727fb5e51 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -402,38 +402,6 @@ static void show_html_page(const char *git_cmd)
 	open_html(page_path.buf);
 }
 
-static struct {
-	const char *name;
-	const char *help;
-} common_guides[] = {
-	{ "attributes", N_("Defining attributes per path") },
-	{ "everyday", N_("Everyday Git With 20 Commands Or So") },
-	{ "glossary", N_("A Git glossary") },
-	{ "ignore", N_("Specifies intentionally untracked files to ignore") },
-	{ "modules", N_("Defining submodule properties") },
-	{ "revisions", N_("Specifying revisions and ranges for Git") },
-	{ "tutorial", N_("A tutorial introduction to Git (for version 1.5.1 or newer)") },
-	{ "workflows", N_("An overview of recommended workflows with Git") },
-};
-
-static void list_common_guides_help(void)
-{
-	int i, longest = 0;
-
-	for (i = 0; i < ARRAY_SIZE(common_guides); i++) {
-		if (longest < strlen(common_guides[i].name))
-			longest = strlen(common_guides[i].name);
-	}
-
-	puts(_("The common Git guides are:\n"));
-	for (i = 0; i < ARRAY_SIZE(common_guides); i++) {
-		printf("   %s   ", common_guides[i].name);
-		mput_char(' ', longest - strlen(common_guides[i].name));
-		puts(_(common_guides[i].help));
-	}
-	putchar('\n');
-}
-
 static const char *check_git_cmd(const char* cmd)
 {
 	char *alias;
diff --git a/command-list.txt b/command-list.txt
index a1fad28fd8..0809a19184 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -149,3 +149,11 @@ gitweb                                  ancillaryinterrogators
 git-whatchanged                         ancillaryinterrogators
 git-worktree                            mainporcelain
 git-write-tree                          plumbingmanipulators
+gitattributes                           guide
+giteveryday                             guide
+gitglossary                             guide
+gitignore                               guide
+gitmodules                              guide
+gitrevisions                            guide
+gittutorial                             guide
+gitworkflows                            guide
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index e0893e979a..e35f3e357b 100755
--- a/generate-cmdlist.sh
+++ b/generate-cmdlist.sh
@@ -67,7 +67,11 @@ command_list "$1" |
 sort |
 while read cmd category tags
 do
-	name=${cmd/git-}
+	if [ "$category" = guide ]; then
+		name=${cmd/git}
+	else
+		name=${cmd/git-}
+	fi
 	sed -n '
 		/^NAME/,/'"$cmd"'/H
 		${
diff --git a/help.c b/help.c
index 7f72051641..a44f4a113e 100644
--- a/help.c
+++ b/help.c
@@ -313,6 +313,28 @@ static void list_commands_by_category(int cat, struct cmdname_help *cmds,
 	}
 }
 
+void list_common_guides_help(void)
+{
+	int i, longest = 0;
+	int nr = ARRAY_SIZE(command_list);
+	struct cmdname_help *cmds = command_list;
+
+	QSORT(cmds, nr, cmd_category_cmp);
+
+	for (i = 0; i < nr; i++) {
+		struct cmdname_help *cmd = cmds + i;
+
+		if (cmd->category != CAT_guide)
+			continue;
+		if (longest < strlen(cmd->name))
+			longest = strlen(cmd->name);
+	}
+
+	puts(_("The common Git guides are:\n"));
+	list_commands_by_category(CAT_guide, cmds, nr, longest);
+	putchar('\n');
+}
+
 void list_all_cmds_help(void)
 {
 	int i, longest = 0;
diff --git a/help.h b/help.h
index 62449f1b7e..de094e9e65 100644
--- a/help.h
+++ b/help.h
@@ -18,6 +18,7 @@ static inline void mput_char(char c, unsigned int num)
 
 extern void list_common_cmds_help(void);
 extern void list_all_cmds_help(void);
+extern void list_common_guides_help(void);
 extern void list_all_cmds(void);
 extern void list_porcelain_cmds(void);
 extern const char *help_unknown_cmd(const char *cmd);
-- 
2.17.0.367.g5dd2e386c3


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-14 15:44     ` Duy Nguyen
@ 2018-04-15 21:21       ` Philip Oakley
  2018-04-17 16:24         ` Duy Nguyen
  0 siblings, 1 reply; 42+ messages in thread
From: Philip Oakley @ 2018-04-15 21:21 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Eric Sunshine, Git List, SZEDER Gábor

From: "Duy Nguyen" <pclouds@gmail.com> : Saturday, April 14, 2018 4:44 PM
> On Thu, Apr 12, 2018 at 12:06 AM, Philip Oakley <philipoakley@iee.org>
> wrote:
>> I'm only just catching up, but does/can this series also capture the
>> non-command guides that are available in git so that the 'git help -g'
>> can
>> begin to list them all?
>
> It currently does not. But I don't see why it should not. This should
> allow git.txt to list all the guides too, for people who skip "git
> help" and go hard core mode with "man git". Thanks for bringing this
> up.
> -- 
> Duy
>
Is that something I should add to my todo to add a 'guide' category etc.?

A quick search of public-inbox suggests
https://public-inbox.org/git/1361660761-1932-1-git-send-email-philipoakley@iee.org/
as being where I first made the suggestions, but it got trimmed back to not
update (be embedded in) the command-list.txt

Philip


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash
  2018-04-15 16:42   ` [PATCH v2 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
@ 2018-04-16  2:30     ` Junio C Hamano
  0 siblings, 0 replies; 42+ messages in thread
From: Junio C Hamano @ 2018-04-16  2:30 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, szeder.dev, Eric Sunshine, philipoakley

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  contrib/completion/git-completion.bash |  2 +-
>  git.c                                  |  2 ++
>  help.c                                 | 18 ++++++++++++++++++
>  help.h                                 |  1 +
>  4 files changed, 22 insertions(+), 1 deletion(-)
>
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 3556838759..a5f13ade20 100644
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -839,7 +839,7 @@ __git_commands () {
>  	then
>  		printf "%s" "${GIT_TESTING_COMMAND_COMPLETION}"
>  	else
> -		git help -a|egrep '^  [a-zA-Z0-9]'
> +		git --list-cmds=all
>  	fi
>  }

To those of us who install a copy of git-completion.bash somewhere
in $HOME and forget about it, while installing different versions of
Git all the time for testing, may see breakage caused by an invalid
combination of having new completion script with Git that does not
know about --list=cmds=<all> option.  I do not think it matters too
much, though ;-)

> +void list_all_cmds(void)
> +{
> +	struct cmdnames main_cmds, other_cmds;
> +	int i;
> +
> +	memset(&main_cmds, 0, sizeof(main_cmds));
> +	memset(&other_cmds, 0, sizeof(other_cmds));
> +	load_command_list("git-", &main_cmds, &other_cmds);
> +
> +	for (i = 0; i < main_cmds.cnt; i++)
> +		puts(main_cmds.names[i]->name);
> +	for (i = 0; i < other_cmds.cnt; i++)
> +		puts(other_cmds.names[i]->name);
> +
> +	clean_cmdnames(&main_cmds);
> +	clean_cmdnames(&other_cmds);
> +}
> +

OK.

By reusing load_command_list(), the duplicate-removal logic at its
end that is used for "help -a" kicks in; the above looks good.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-15 16:42   ` [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
@ 2018-04-16  2:38     ` Junio C Hamano
  2018-04-16  6:28     ` Junio C Hamano
  2018-04-16 15:43     ` SZEDER Gábor
  2 siblings, 0 replies; 42+ messages in thread
From: Junio C Hamano @ 2018-04-16  2:38 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, szeder.dev, Eric Sunshine, philipoakley

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> +category_list () {
> +	command_list "$1" | awk '{print $2;}' | sort | uniq
> +}

Piping output of awk to sort/uniq, instead of processing all inside
awk within the END block of the script, means that we are wasting
two processes---I do not think we care too much about it, but some
people might.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-15 16:42   ` [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
  2018-04-16  2:38     ` Junio C Hamano
@ 2018-04-16  6:28     ` Junio C Hamano
  2018-04-16 15:43       ` Duy Nguyen
  2018-04-16 15:43     ` SZEDER Gábor
  2 siblings, 1 reply; 42+ messages in thread
From: Junio C Hamano @ 2018-04-16  6:28 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, szeder.dev, Eric Sunshine, philipoakley

Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:

> @@ -23,28 +36,44 @@ sed -n '
>  	' "$1"
>  printf '};\n\n'
>  
> +echo "#define GROUP_NONE 0xff /* no common group */"

Some later code forgets about this value, and causes "git<ENTER>" to
segfault at the end of this entire series.

Namely, here:

> -	for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
> +	for (i = 0; i < nr; i++) {
>  		if (common_cmds[i].group != current_grp) {
>  			printf("\n%s\n", _(common_cmd_groups[common_cmds[i].group]));
>  			current_grp = common_cmds[i].group;

where common_cmd_groups[] gets overrun.

Here is a squash I'll queue on top to keep the tip of 'pu' at least
buildable.

 help.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/help.c b/help.c
index a44f4a113e..74591d5ebc 100644
--- a/help.c
+++ b/help.c
@@ -242,7 +242,9 @@ void list_common_cmds_help(void)
 	puts(_("These are common Git commands used in various situations:"));
 
 	for (i = 0; i < nr; i++) {
-		if (common_cmds[i].group != current_grp) {
+		if (ARRAY_SIZE(common_cmd_groups) <= common_cmds[i].group)
+			; /* skip */
+		else if (common_cmds[i].group != current_grp) {
 			printf("\n%s\n", _(common_cmd_groups[common_cmds[i].group]));
 			current_grp = common_cmds[i].group;
 		}



^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-15 16:42   ` [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
  2018-04-16  2:38     ` Junio C Hamano
  2018-04-16  6:28     ` Junio C Hamano
@ 2018-04-16 15:43     ` SZEDER Gábor
  2018-04-16 16:25       ` Ramsay Jones
  2018-04-16 22:42       ` Junio C Hamano
  2 siblings, 2 replies; 42+ messages in thread
From: SZEDER Gábor @ 2018-04-16 15:43 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: Git mailing list, Eric Sunshine, Philip Oakley, Junio C Hamano

On Sun, Apr 15, 2018 at 6:42 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
> common-cmds.h is used to extract the list of common commands (by
> group) and a one-line summary of each command. Some information is
> dropped, for example command category or summary of other commands.
> Update generate-cmdlist.sh to keep all the information. The extra info
> will be used shortly.
>
> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
> ---
>  generate-cmdlist.sh | 61 +++++++++++++++++++++++++++++++++------------
>  help.c              | 42 ++++++++++++++++++++++++++-----
>  2 files changed, 81 insertions(+), 22 deletions(-)
>
> diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
> index eeea4b67ea..e0893e979a 100755
> --- a/generate-cmdlist.sh
> +++ b/generate-cmdlist.sh

> -printf 'static struct cmdname_help common_cmds[] = {\n'
> -grep -f "$match" "$1" |
> -sed 's/^git-//' |
> +printf 'static struct cmdname_help command_list[] = {\n'
> +command_list "$1" |
>  sort |
> -while read cmd tags
> +while read cmd category tags
>  do
> -       tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
> +       name=${cmd/git-}

There are two issues with this line:

- This is a "regular" shell script, therefore it must not use pattern
  substitution.

- The pattern substitution would remove the string "git-" in the middle of
  the variable as well; I suspect this is undesired.

I think that the remove matching prefix pattern substitution should be
used here.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-16  6:28     ` Junio C Hamano
@ 2018-04-16 15:43       ` Duy Nguyen
  0 siblings, 0 replies; 42+ messages in thread
From: Duy Nguyen @ 2018-04-16 15:43 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, SZEDER Gábor, Eric Sunshine, Philip Oakley

On Mon, Apr 16, 2018 at 8:28 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:
>
>> @@ -23,28 +36,44 @@ sed -n '
>>       ' "$1"
>>  printf '};\n\n'
>>
>> +echo "#define GROUP_NONE 0xff /* no common group */"
>
> Some later code forgets about this value, and causes "git<ENTER>" to
> segfault at the end of this entire series.
>
> Namely, here:
>
>> -     for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
>> +     for (i = 0; i < nr; i++) {
>>               if (common_cmds[i].group != current_grp) {
>>                       printf("\n%s\n", _(common_cmd_groups[common_cmds[i].group]));
>>                       current_grp = common_cmds[i].group;
>
> where common_cmd_groups[] gets overrun.

Argh!! I thought I tested everything. Sorry for the sloppy quality.

>
> Here is a squash I'll queue on top to keep the tip of 'pu' at least
> buildable.

Thanks. It's actually interesting that we have main porcelain commands
that belong to no group. I'll try to classify them so that they show
up as well.


-- 
Duy

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-16 15:43     ` SZEDER Gábor
@ 2018-04-16 16:25       ` Ramsay Jones
  2018-04-16 22:42       ` Junio C Hamano
  1 sibling, 0 replies; 42+ messages in thread
From: Ramsay Jones @ 2018-04-16 16:25 UTC (permalink / raw)
  To: SZEDER Gábor, Nguyễn Thái Ngọc Duy; +Cc: Git mailing list, Eric Sunshine, Philip Oakley, Junio C Hamano



On 16/04/18 16:43, SZEDER Gábor wrote:
> On Sun, Apr 15, 2018 at 6:42 PM, Nguyễn Thái Ngọc Duy <pclouds@gmail.com> wrote:
>> common-cmds.h is used to extract the list of common commands (by
>> group) and a one-line summary of each command. Some information is
>> dropped, for example command category or summary of other commands.
>> Update generate-cmdlist.sh to keep all the information. The extra info
>> will be used shortly.
>>
>> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
>> ---
>>  generate-cmdlist.sh | 61 +++++++++++++++++++++++++++++++++------------
>>  help.c              | 42 ++++++++++++++++++++++++++-----
>>  2 files changed, 81 insertions(+), 22 deletions(-)
>>
>> diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
>> index eeea4b67ea..e0893e979a 100755
>> --- a/generate-cmdlist.sh
>> +++ b/generate-cmdlist.sh
> 
>> -printf 'static struct cmdname_help common_cmds[] = {\n'
>> -grep -f "$match" "$1" |
>> -sed 's/^git-//' |
>> +printf 'static struct cmdname_help command_list[] = {\n'
>> +command_list "$1" |
>>  sort |
>> -while read cmd tags
>> +while read cmd category tags
>>  do
>> -       tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
>> +       name=${cmd/git-}
> 
> There are two issues with this line:
> 
> - This is a "regular" shell script, therefore it must not use pattern
>   substitution.
> 
> - The pattern substitution would remove the string "git-" in the middle of
>   the variable as well; I suspect this is undesired.
> 
> I think that the remove matching prefix pattern substitution should be
> used here.


This also, apparently, doesn't work with dash. On cygwin, which has
bash as /bin/sh, this builds common-cmds.h just fine. On linux, which
has dash as /bin/sh, this fails, leaving a truncated file:

  $ bash generate-cmdlist.sh command-list.txt >zzz
  $ tail -3 zzz
  	{"gitweb", N_("Git web interface (web frontend to Git repositories)"), CAT_ancillaryinterrogators, GROUP_NONE },
  	{"workflows", N_("An overview of recommended workflows with Git"), CAT_guide, GROUP_NONE },
  };

  $ dash generate-cmdlist.sh command-list.txt >zzz
  generate-cmdlist.sh: 73: generate-cmdlist.sh: Bad substitution
  $ tail -3 zzz

  static struct cmdname_help command_list[] = {
  };
  $ 

This leads to a very broken 'git help'.

ATB,
Ramsay Jones



^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h
  2018-04-16 15:43     ` SZEDER Gábor
  2018-04-16 16:25       ` Ramsay Jones
@ 2018-04-16 22:42       ` Junio C Hamano
  1 sibling, 0 replies; 42+ messages in thread
From: Junio C Hamano @ 2018-04-16 22:42 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: Nguyễn Thái Ngọc Duy, Git mailing list, Eric Sunshine, Philip Oakley

SZEDER Gábor <szeder.dev@gmail.com> writes:

>> +while read cmd category tags
>>  do
>> -       tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
>> +       name=${cmd/git-}
>
> There are two issues with this line:
>
> - This is a "regular" shell script, therefore it must not use pattern
>   substitution.

Oops.  I missed that.  Thanks.

>
> - The pattern substitution would remove the string "git-" in the middle of
>   the variable as well; I suspect this is undesired.
>
> I think that the remove matching prefix pattern substitution should be
> used here.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-15 21:21       ` Philip Oakley
@ 2018-04-17 16:24         ` Duy Nguyen
  2018-04-17 16:48           ` Duy Nguyen
  0 siblings, 1 reply; 42+ messages in thread
From: Duy Nguyen @ 2018-04-17 16:24 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Eric Sunshine, Git List, SZEDER Gábor

On Sun, Apr 15, 2018 at 11:21 PM, Philip Oakley <philipoakley@iee.org> wrote:
> From: "Duy Nguyen" <pclouds@gmail.com> : Saturday, April 14, 2018 4:44 PM
>
>> On Thu, Apr 12, 2018 at 12:06 AM, Philip Oakley <philipoakley@iee.org>
>> wrote:
>>>
>>> I'm only just catching up, but does/can this series also capture the
>>> non-command guides that are available in git so that the 'git help -g'
>>> can
>>> begin to list them all?
>>
>>
>> It currently does not. But I don't see why it should not. This should
>> allow git.txt to list all the guides too, for people who skip "git
>> help" and go hard core mode with "man git". Thanks for bringing this
>> up.
>> --
>> Duy
>>
> Is that something I should add to my todo to add a 'guide' category etc.?

I added it too [1]. Not sure if you want anything more on top though.

[1] https://public-inbox.org/git/20180415164238.9107-7-pclouds@gmail.com/T/#u
-- 
Duy

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-17 16:24         ` Duy Nguyen
@ 2018-04-17 16:48           ` Duy Nguyen
  2018-04-17 22:47             ` Philip Oakley
  0 siblings, 1 reply; 42+ messages in thread
From: Duy Nguyen @ 2018-04-17 16:48 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Eric Sunshine, Git List, SZEDER Gábor

On Tue, Apr 17, 2018 at 06:24:41PM +0200, Duy Nguyen wrote:
> On Sun, Apr 15, 2018 at 11:21 PM, Philip Oakley <philipoakley@iee.org> wrote:
> > From: "Duy Nguyen" <pclouds@gmail.com> : Saturday, April 14, 2018 4:44 PM
> >
> >> On Thu, Apr 12, 2018 at 12:06 AM, Philip Oakley <philipoakley@iee.org>
> >> wrote:
> >>>
> >>> I'm only just catching up, but does/can this series also capture the
> >>> non-command guides that are available in git so that the 'git help -g'
> >>> can
> >>> begin to list them all?
> >>
> >>
> >> It currently does not. But I don't see why it should not. This should
> >> allow git.txt to list all the guides too, for people who skip "git
> >> help" and go hard core mode with "man git". Thanks for bringing this
> >> up.
> >> --
> >> Duy
> >>
> > Is that something I should add to my todo to add a 'guide' category etc.?
> 
> I added it too [1]. Not sure if you want anything more on top though.

The "anything more" that at least I had in mind was something like
this. Though I'm not sure if it's a good thing to replace a hand
crafted section with an automatedly generated one. This patch on top
combines the "SEE ALSO" and "FURTHER DOCUMENT" into one with most of
documents/guides are extracted from command-list.txt

-- 8< --
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 6232143cb9..3e0ecd2e11 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -292,6 +292,7 @@ doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
 
 cmds_txt = cmds-ancillaryinterrogators.txt \
 	cmds-ancillarymanipulators.txt \
+	cmds-guide.txt \
 	cmds-mainporcelain.txt \
 	cmds-plumbinginterrogators.txt \
 	cmds-plumbingmanipulators.txt \
diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
index 5aa73cfe45..e158bd9b96 100755
--- a/Documentation/cmd-list.perl
+++ b/Documentation/cmd-list.perl
@@ -54,6 +54,7 @@ for (sort <>) {
 
 for my $cat (qw(ancillaryinterrogators
 		ancillarymanipulators
+		guide
 		mainporcelain
 		plumbinginterrogators
 		plumbingmanipulators
diff --git a/Documentation/git.txt b/Documentation/git.txt
index 4767860e72..d60d2ae0c7 100644
--- a/Documentation/git.txt
+++ b/Documentation/git.txt
@@ -808,29 +808,6 @@ The index is also capable of storing multiple entries (called "stages")
 for a given pathname.  These stages are used to hold the various
 unmerged version of a file when a merge is in progress.
 
-FURTHER DOCUMENTATION
----------------------
-
-See the references in the "description" section to get started
-using Git.  The following is probably more detail than necessary
-for a first-time user.
-
-The link:user-manual.html#git-concepts[Git concepts chapter of the
-user-manual] and linkgit:gitcore-tutorial[7] both provide
-introductions to the underlying Git architecture.
-
-See linkgit:gitworkflows[7] for an overview of recommended workflows.
-
-See also the link:howto-index.html[howto] documents for some useful
-examples.
-
-The internals are documented in the
-link:technical/api-index.html[Git API documentation].
-
-Users migrating from CVS may also want to
-read linkgit:gitcvs-migration[7].
-
-
 Authors
 -------
 Git was started by Linus Torvalds, and is currently maintained by Junio
@@ -854,11 +831,16 @@ the Git Security mailing list <git-security@googlegroups.com>.
 
 SEE ALSO
 --------
-linkgit:gittutorial[7], linkgit:gittutorial-2[7],
-linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
-linkgit:gitglossary[7], linkgit:gitcore-tutorial[7],
-linkgit:gitcli[7], link:user-manual.html[The Git User's Manual],
-linkgit:gitworkflows[7]
+
+See the references in the "description" section to get started
+using Git.  The following is probably more detail than necessary
+for a first-time user.
+
+include::cmds-guide.txt[]
+
+See also the link:howto-index.html[howto] documents for some useful
+examples. The internals are documented in the
+link:technical/api-index.html[Git API documentation].
 
 GIT
 ---
diff --git a/command-list.txt b/command-list.txt
index 1835f1a928..f26b8acd52 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -150,10 +150,14 @@ git-whatchanged                         ancillaryinterrogators
 git-worktree                            mainporcelain
 git-write-tree                          plumbingmanipulators
 gitattributes                           guide
+gitcvs-migration                        guide
+gitcli                                  guide
+gitcore-tutorial                        guide
 giteveryday                             guide
 gitglossary                             guide
 gitignore                               guide
 gitmodules                              guide
 gitrevisions                            guide
 gittutorial                             guide
+gittutorial-2                           guide
 gitworkflows                            guide
-- 8< --

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-17 16:48           ` Duy Nguyen
@ 2018-04-17 22:47             ` Philip Oakley
  2018-04-18  6:38               ` Philip Oakley
  2018-04-18 15:33               ` Duy Nguyen
  0 siblings, 2 replies; 42+ messages in thread
From: Philip Oakley @ 2018-04-17 22:47 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Eric Sunshine, Git List, SZEDER Gábor

From: "Duy Nguyen" <pclouds@gmail.com> : Tuesday, April 17, 2018 5:48 PM
> On Tue, Apr 17, 2018 at 06:24:41PM +0200, Duy Nguyen wrote:
>> On Sun, Apr 15, 2018 at 11:21 PM, Philip Oakley <philipoakley@iee.org> 
>> wrote:
>> > From: "Duy Nguyen" <pclouds@gmail.com> : Saturday, April 14, 2018 4:44 
>> > PM
>> >
>> >> On Thu, Apr 12, 2018 at 12:06 AM, Philip Oakley <philipoakley@iee.org>
>> >> wrote:
>> >>>
>> >>> I'm only just catching up, but does/can this series also capture the
>> >>> non-command guides that are available in git so that the 'git 
>> >>> help -g'
>> >>> can
>> >>> begin to list them all?
>> >>
>> >>
>> >> It currently does not. But I don't see why it should not. This should
>> >> allow git.txt to list all the guides too, for people who skip "git
>> >> help" and go hard core mode with "man git". Thanks for bringing this
>> >> up.
>> >> --
>> >> Duy
>> >>
>> > Is that something I should add to my todo to add a 'guide' category 
>> > etc.?
>>
>> I added it too [1]. Not sure if you want anything more on top though.

What I've seen is looking good - I've not had as much time as I'd like..

I'm not sure of the status of the git/generate-cmdlist.sh though. Should 
that also be updated, or did I miss that?
--
Philip

>
> The "anything more" that at least I had in mind was something like
> this. Though I'm not sure if it's a good thing to replace a hand
> crafted section with an automatedly generated one. This patch on top
> combines the "SEE ALSO" and "FURTHER DOCUMENT" into one with most of
> documents/guides are extracted from command-list.txt
>
> -- 8< --
> diff --git a/Documentation/Makefile b/Documentation/Makefile
> index 6232143cb9..3e0ecd2e11 100644
> --- a/Documentation/Makefile
> +++ b/Documentation/Makefile
> @@ -292,6 +292,7 @@ doc.dep : $(docdep_prereqs) $(wildcard *.txt) 
> build-docdep.perl
>
> cmds_txt = cmds-ancillaryinterrogators.txt \
>  cmds-ancillarymanipulators.txt \
> + cmds-guide.txt \
>  cmds-mainporcelain.txt \
>  cmds-plumbinginterrogators.txt \
>  cmds-plumbingmanipulators.txt \
> diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
> index 5aa73cfe45..e158bd9b96 100755
> --- a/Documentation/cmd-list.perl
> +++ b/Documentation/cmd-list.perl
> @@ -54,6 +54,7 @@ for (sort <>) {
>
> for my $cat (qw(ancillaryinterrogators
>  ancillarymanipulators
> + guide
>  mainporcelain
>  plumbinginterrogators
>  plumbingmanipulators
> diff --git a/Documentation/git.txt b/Documentation/git.txt
> index 4767860e72..d60d2ae0c7 100644
> --- a/Documentation/git.txt
> +++ b/Documentation/git.txt
> @@ -808,29 +808,6 @@ The index is also capable of storing multiple entries 
> (called "stages")
> for a given pathname.  These stages are used to hold the various
> unmerged version of a file when a merge is in progress.
>
> -FURTHER DOCUMENTATION
> ----------------------
> -
> -See the references in the "description" section to get started
> -using Git.  The following is probably more detail than necessary
> -for a first-time user.
> -
> -The link:user-manual.html#git-concepts[Git concepts chapter of the
> -user-manual] and linkgit:gitcore-tutorial[7] both provide
> -introductions to the underlying Git architecture.
> -
> -See linkgit:gitworkflows[7] for an overview of recommended workflows.
> -
> -See also the link:howto-index.html[howto] documents for some useful
> -examples.
> -
> -The internals are documented in the
> -link:technical/api-index.html[Git API documentation].
> -
> -Users migrating from CVS may also want to
> -read linkgit:gitcvs-migration[7].
> -
> -
> Authors
> -------
> Git was started by Linus Torvalds, and is currently maintained by Junio
> @@ -854,11 +831,16 @@ the Git Security mailing list 
> <git-security@googlegroups.com>.
>
> SEE ALSO
> --------
> -linkgit:gittutorial[7], linkgit:gittutorial-2[7],
> -linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
> -linkgit:gitglossary[7], linkgit:gitcore-tutorial[7],
> -linkgit:gitcli[7], link:user-manual.html[The Git User's Manual],
> -linkgit:gitworkflows[7]
> +
> +See the references in the "description" section to get started
> +using Git.  The following is probably more detail than necessary
> +for a first-time user.
> +
> +include::cmds-guide.txt[]
> +
> +See also the link:howto-index.html[howto] documents for some useful
> +examples. The internals are documented in the
> +link:technical/api-index.html[Git API documentation].
>
> GIT
> ---
> diff --git a/command-list.txt b/command-list.txt
> index 1835f1a928..f26b8acd52 100644
> --- a/command-list.txt
> +++ b/command-list.txt
> @@ -150,10 +150,14 @@ git-whatchanged 
> ancillaryinterrogators
> git-worktree                            mainporcelain
> git-write-tree                          plumbingmanipulators
> gitattributes                           guide
> +gitcvs-migration                        guide
> +gitcli                                  guide
> +gitcore-tutorial                        guide
> giteveryday                             guide
> gitglossary                             guide
> gitignore                               guide
> gitmodules                              guide
> gitrevisions                            guide
> gittutorial                             guide
> +gittutorial-2                           guide
> gitworkflows                            guide
> -- 8< --
> 


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-17 22:47             ` Philip Oakley
@ 2018-04-18  6:38               ` Philip Oakley
  2018-04-18 15:33               ` Duy Nguyen
  1 sibling, 0 replies; 42+ messages in thread
From: Philip Oakley @ 2018-04-18  6:38 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Eric Sunshine, Git List, SZEDER Gábor

From: "Philip Oakley" <philipoakley@iee.org> : Tuesday, April 17, 2018 11:47
PM
> From: "Duy Nguyen" <pclouds@gmail.com> : Tuesday, April 17, 2018 5:48 PM
>> On Tue, Apr 17, 2018 at 06:24:41PM +0200, Duy Nguyen wrote:
>>> On Sun, Apr 15, 2018 at 11:21 PM, Philip Oakley <philipoakley@iee.org>
>>> wrote:
>>> > From: "Duy Nguyen" <pclouds@gmail.com> : Saturday, April 14, 2018 4:44
>>> > PM
>>> >
>>> >> On Thu, Apr 12, 2018 at 12:06 AM, Philip Oakley
>>> >> <philipoakley@iee.org>
>>> >> wrote:
>>> >>>
>>> >>> I'm only just catching up, but does/can this series also capture the
>>> >>> non-command guides that are available in git so that the 'git
>>> >>> help -g'
>>> >>> can
>>> >>> begin to list them all?
>>> >>
>>> >>
>>> >> It currently does not. But I don't see why it should not. This should
>>> >> allow git.txt to list all the guides too, for people who skip "git
>>> >> help" and go hard core mode with "man git". Thanks for bringing this
>>> >> up.
>>> >> --
>>> >> Duy
>>> >>
>>> > Is that something I should add to my todo to add a 'guide' category
>>> > etc.?
>>>
>>> I added it too [1]. Not sure if you want anything more on top though.
>
> What I've seen is looking good - I've not had as much time as I'd like..
>
> I'm not sure of the status of the git/generate-cmdlist.sh though. Should
> that also be updated, or did I miss that?
> --
> Philip

I may be miss-remembering the order that the `git help` determines the list
of commands and guides. There was at least one place where the list of
commands was generated programatically that I may be confused with (I've not
had time to delve into the code :-(
--


>
>>
>> The "anything more" that at least I had in mind was something like
>> this. Though I'm not sure if it's a good thing to replace a hand
>> crafted section with an automatedly generated one. This patch on top
>> combines the "SEE ALSO" and "FURTHER DOCUMENT" into one with most of
>> documents/guides are extracted from command-list.txt
>>
>> -- 8< --
>> diff --git a/Documentation/Makefile b/Documentation/Makefile
>> index 6232143cb9..3e0ecd2e11 100644
>> --- a/Documentation/Makefile
>> +++ b/Documentation/Makefile
>> @@ -292,6 +292,7 @@ doc.dep : $(docdep_prereqs) $(wildcard *.txt)
>> build-docdep.perl
>>
>> cmds_txt = cmds-ancillaryinterrogators.txt \
>>  cmds-ancillarymanipulators.txt \
>> + cmds-guide.txt \
>>  cmds-mainporcelain.txt \
>>  cmds-plumbinginterrogators.txt \
>>  cmds-plumbingmanipulators.txt \
>> diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
>> index 5aa73cfe45..e158bd9b96 100755
>> --- a/Documentation/cmd-list.perl
>> +++ b/Documentation/cmd-list.perl
>> @@ -54,6 +54,7 @@ for (sort <>) {
>>
>> for my $cat (qw(ancillaryinterrogators
>>  ancillarymanipulators
>> + guide
>>  mainporcelain
>>  plumbinginterrogators
>>  plumbingmanipulators
>> diff --git a/Documentation/git.txt b/Documentation/git.txt
>> index 4767860e72..d60d2ae0c7 100644
>> --- a/Documentation/git.txt
>> +++ b/Documentation/git.txt
>> @@ -808,29 +808,6 @@ The index is also capable of storing multiple
>> entries (called "stages")
>> for a given pathname.  These stages are used to hold the various
>> unmerged version of a file when a merge is in progress.
>>
>> -FURTHER DOCUMENTATION
>> ----------------------
>> -
>> -See the references in the "description" section to get started
>> -using Git.  The following is probably more detail than necessary
>> -for a first-time user.
>> -
>> -The link:user-manual.html#git-concepts[Git concepts chapter of the
>> -user-manual] and linkgit:gitcore-tutorial[7] both provide
>> -introductions to the underlying Git architecture.
>> -
>> -See linkgit:gitworkflows[7] for an overview of recommended workflows.
>> -
>> -See also the link:howto-index.html[howto] documents for some useful
>> -examples.
>> -
>> -The internals are documented in the
>> -link:technical/api-index.html[Git API documentation].
>> -
>> -Users migrating from CVS may also want to
>> -read linkgit:gitcvs-migration[7].
>> -
>> -
>> Authors
>> -------
>> Git was started by Linus Torvalds, and is currently maintained by Junio
>> @@ -854,11 +831,16 @@ the Git Security mailing list
>> <git-security@googlegroups.com>.
>>
>> SEE ALSO
>> --------
>> -linkgit:gittutorial[7], linkgit:gittutorial-2[7],
>> -linkgit:giteveryday[7], linkgit:gitcvs-migration[7],
>> -linkgit:gitglossary[7], linkgit:gitcore-tutorial[7],
>> -linkgit:gitcli[7], link:user-manual.html[The Git User's Manual],
>> -linkgit:gitworkflows[7]
>> +
>> +See the references in the "description" section to get started
>> +using Git.  The following is probably more detail than necessary
>> +for a first-time user.
>> +
>> +include::cmds-guide.txt[]
>> +
>> +See also the link:howto-index.html[howto] documents for some useful
>> +examples. The internals are documented in the
>> +link:technical/api-index.html[Git API documentation].
>>
>> GIT
>> ---
>> diff --git a/command-list.txt b/command-list.txt
>> index 1835f1a928..f26b8acd52 100644
>> --- a/command-list.txt
>> +++ b/command-list.txt
>> @@ -150,10 +150,14 @@ git-whatchanged ancillaryinterrogators
>> git-worktree                            mainporcelain
>> git-write-tree                          plumbingmanipulators
>> gitattributes                           guide
>> +gitcvs-migration                        guide
>> +gitcli                                  guide
>> +gitcore-tutorial                        guide
>> giteveryday                             guide
>> gitglossary                             guide
>> gitignore                               guide
>> gitmodules                              guide
>> gitrevisions                            guide
>> gittutorial                             guide
>> +gittutorial-2                           guide
>> gitworkflows                            guide
>> -- 8< --
>>
>
>


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-17 22:47             ` Philip Oakley
  2018-04-18  6:38               ` Philip Oakley
@ 2018-04-18 15:33               ` Duy Nguyen
  2018-04-19  7:47                 ` Philip Oakley
  1 sibling, 1 reply; 42+ messages in thread
From: Duy Nguyen @ 2018-04-18 15:33 UTC (permalink / raw)
  To: Philip Oakley; +Cc: Eric Sunshine, Git List, SZEDER Gábor

On Wed, Apr 18, 2018 at 12:47 AM, Philip Oakley <philipoakley@iee.org> wrote:
>>> > Is that something I should add to my todo to add a 'guide' category >
>>> > etc.?
>>>
>>> I added it too [1]. Not sure if you want anything more on top though.
>
>
> What I've seen is looking good - I've not had as much time as I'd like..
>
> I'm not sure of the status of the git/generate-cmdlist.sh though. Should
> that also be updated, or did I miss that?

Yes it's updated by other patches in the same thread.
-- 
Duy

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-18 15:33               ` Duy Nguyen
@ 2018-04-19  7:47                 ` Philip Oakley
  0 siblings, 0 replies; 42+ messages in thread
From: Philip Oakley @ 2018-04-19  7:47 UTC (permalink / raw)
  To: Duy Nguyen; +Cc: Eric Sunshine, Git List, SZEDER Gábor

From: "Duy Nguyen" <pclouds@gmail.com>
> On Wed, Apr 18, 2018 at 12:47 AM, Philip Oakley <philipoakley@iee.org>
> wrote:
>>>> > Is that something I should add to my todo to add a 'guide' category >
>>>> > etc.?
>>>>
>>>> I added it too [1]. Not sure if you want anything more on top though.
>>
>>
>> What I've seen is looking good - I've not had as much time as I'd like..
>>
>> I'm not sure of the status of the git/generate-cmdlist.sh though. Should
>> that also be updated, or did I miss that?
>
> Yes it's updated by other patches in the same thread.
> -- 
Thanks. Hopefully I'll have some time this weekend/coming week as my wife is
away....
Philip


^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
                   ` (6 preceding siblings ...)
  2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
@ 2018-04-19 10:37 ` Simon Ruderich
  2018-04-19 11:26   ` SZEDER Gábor
  7 siblings, 1 reply; 42+ messages in thread
From: Simon Ruderich @ 2018-04-19 10:37 UTC (permalink / raw)
  To: Nguyễn Thái Ngọc Duy; +Cc: git, SZEDER Gábor

Hello,

When running make -j$(nproc) with the current pu f9f8c1f765
(Merge branch 'hn/bisect-first-parent' into pu) I see the
following error:

GIT_VERSION = 2.17.0.732.gf9f8c1f765
    * new build flags
    * new prefix flags
    GEN common-cmds.h
    * new link flags
    CC ident.o
    CC hex.o
    CC json-writer.o
./generate-cmdlist.sh: 73: ./generate-cmdlist.sh: Bad substitution

This doesn't occur on a non-parallel build.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-19 10:37 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Simon Ruderich
@ 2018-04-19 11:26   ` SZEDER Gábor
  2018-04-20  7:05     ` Simon Ruderich
  0 siblings, 1 reply; 42+ messages in thread
From: SZEDER Gábor @ 2018-04-19 11:26 UTC (permalink / raw)
  To: Simon Ruderich; +Cc: Nguyễn Thái Ngọc Duy, Git mailing list

On Thu, Apr 19, 2018 at 12:37 PM, Simon Ruderich <simon@ruderich.org> wrote:
> When running make -j$(nproc) with the current pu f9f8c1f765
> (Merge branch 'hn/bisect-first-parent' into pu) I see the
> following error:
>
> GIT_VERSION = 2.17.0.732.gf9f8c1f765
>     * new build flags
>     * new prefix flags
>     GEN common-cmds.h
>     * new link flags
>     CC ident.o
>     CC hex.o
>     CC json-writer.o
> ./generate-cmdlist.sh: 73: ./generate-cmdlist.sh: Bad substitution
>
> This doesn't occur on a non-parallel build.

It does occur in non-parallel builds, too.

See:

  https://public-inbox.org/git/CAM0VKjkns+AsVyMSe2fxzT8a8oqYdNX3qO8mnw2juOgFC7LHYA@mail.gmail.com/

^ permalink raw reply	[flat|nested] 42+ messages in thread

* Re: [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary
  2018-04-19 11:26   ` SZEDER Gábor
@ 2018-04-20  7:05     ` Simon Ruderich
  0 siblings, 0 replies; 42+ messages in thread
From: Simon Ruderich @ 2018-04-20  7:05 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: Nguyễn Thái Ngọc Duy, Git mailing list

On Thu, Apr 19, 2018 at 01:26:18PM +0200, SZEDER Gábor wrote:
> On Thu, Apr 19, 2018 at 12:37 PM, Simon Ruderich wrote:
>> This doesn't occur on a non-parallel build.
>
> It does occur in non-parallel builds, too.
>
> See:
>
>   https://public-inbox.org/git/CAM0VKjkns+AsVyMSe2fxzT8a8oqYdNX3qO8mnw2juOgFC7LHYA@mail.gmail.com/

Thanks for the correction. I noticed it at the beginning of make
-j run and incorrectly assummed it would occur quickly in the
non-parallel run as well.

Regards
Simon
-- 
+ privacy is necessary
+ using gnupg http://gnupg.org
+ public key id: 0x92FEFDB7E44C32F9

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, back to index

Thread overview: 42+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-26 16:55 [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Nguyễn Thái Ngọc Duy
2018-03-26 16:55 ` [PATCH/RFC 1/5] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
2018-03-26 16:55 ` [PATCH/RFC 2/5] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
2018-04-09  3:32   ` Eric Sunshine
2018-03-26 16:55 ` [PATCH/RFC 3/5] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-09  4:59   ` Eric Sunshine
2018-04-09  5:12     ` Eric Sunshine
2018-04-09 16:16     ` Duy Nguyen
2018-04-15 16:04     ` Duy Nguyen
2018-03-26 16:55 ` [PATCH/RFC 4/5] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
2018-03-26 16:55 ` [PATCH/RFC 5/5] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-09  5:08   ` Eric Sunshine
2018-04-09  9:47     ` Junio C Hamano
2018-04-09  9:55       ` Eric Sunshine
2018-04-09 15:15         ` Duy Nguyen
2018-04-09  5:17 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Eric Sunshine
2018-04-11 22:06   ` Philip Oakley
2018-04-14 15:44     ` Duy Nguyen
2018-04-15 21:21       ` Philip Oakley
2018-04-17 16:24         ` Duy Nguyen
2018-04-17 16:48           ` Duy Nguyen
2018-04-17 22:47             ` Philip Oakley
2018-04-18  6:38               ` Philip Oakley
2018-04-18 15:33               ` Duy Nguyen
2018-04-19  7:47                 ` Philip Oakley
2018-04-15 16:42 ` [PATCH v2 0/6] " Nguyễn Thái Ngọc Duy
2018-04-15 16:42   ` [PATCH v2 1/6] git.c: convert --list-builtins to --list-cmds=builtins Nguyễn Thái Ngọc Duy
2018-04-15 16:42   ` [PATCH v2 2/6] git.c: implement --list-cmds=all and use it in git-completion.bash Nguyễn Thái Ngọc Duy
2018-04-16  2:30     ` Junio C Hamano
2018-04-15 16:42   ` [PATCH v2 3/6] generate-cmdlist.sh: keep all information in common-cmds.h Nguyễn Thái Ngọc Duy
2018-04-16  2:38     ` Junio C Hamano
2018-04-16  6:28     ` Junio C Hamano
2018-04-16 15:43       ` Duy Nguyen
2018-04-16 15:43     ` SZEDER Gábor
2018-04-16 16:25       ` Ramsay Jones
2018-04-16 22:42       ` Junio C Hamano
2018-04-15 16:42   ` [PATCH v2 4/6] git.c: implement --list-cmds=porcelain Nguyễn Thái Ngọc Duy
2018-04-15 16:42   ` [PATCH v2 5/6] help: add "-a --verbose" to list all commands with synopsis Nguyễn Thái Ngọc Duy
2018-04-15 16:42   ` [PATCH v2 6/6] help: use command-list.txt for the source of guides Nguyễn Thái Ngọc Duy
2018-04-19 10:37 ` [PATCH/RFC 0/5] Keep all info in command-list.txt in git binary Simon Ruderich
2018-04-19 11:26   ` SZEDER Gábor
2018-04-20  7:05     ` Simon Ruderich

git@vger.kernel.org mailing list mirror (one of many)

Archives are clonable:
	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.org/gmane.comp.version-control.git

 note: .onion URLs require Tor: https://www.torproject.org/
       or Tor2web: https://www.tor2web.org/

AGPL code for this site: git clone https://public-inbox.org/ public-inbox