* [PATCH v8 0/5] group common commands by theme
@ 2015-05-18 19:18 Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 1/5] command-list: prepare machinery for upcoming "common groups" section Sébastien Guimmara
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Sébastien Guimmara @ 2015-05-18 19:18 UTC (permalink / raw
To: git; +Cc: sunshine, Sébastien Guimmara
No major improvement over v7 [1], this v8 drops the [common] and
[commands] headers, instead relying on commented headers
"### command list" and "### common groups." to avoid ulgy looking
sed/awk parsing.
generate-cmdlist.awk: slight modification to allow parsing of those
headers.
git help: the colon at the end of each group is dropped.
Summary: to help unfamiliar users grok the Git workflow, rework the
output of 'git help' by grouping the commands by theme:
The typical Git workflow includes:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize an [...]
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
[...]
This series depends on bf990a2 (command-list: fix whitespace
inconsistency)[2]
[1] http://thread.gmane.org/gmane.comp.version-control.git/269167
[2] http://thread.gmane.org/gmane.comp.version-control.git/268649
Eric Sunshine (2):
command-list: prepare machinery for upcoming "common groups" section
generate-cmdlist: parse common group commands
Sébastien Guimmara (3):
command-list.txt: add the common groups block
command-list.txt: drop the "common" tag
help: respect new common command grouping
Documentation/cmd-list.perl | 4 ++++
Makefile | 9 ++++----
command-list.txt | 53 +++++++++++++++++++++++++++------------------
generate-cmdlist.awk | 39 +++++++++++++++++++++++++++++++++
generate-cmdlist.sh | 23 --------------------
help.c | 24 +++++++++++++++++++-
6 files changed, 103 insertions(+), 49 deletions(-)
create mode 100644 generate-cmdlist.awk
delete mode 100755 generate-cmdlist.sh
--
2.4.0.GIT
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH v8 1/5] command-list: prepare machinery for upcoming "common groups" section
2015-05-18 19:18 [PATCH v8 0/5] group common commands by theme Sébastien Guimmara
@ 2015-05-18 19:18 ` Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 2/5] command-list.txt: add the common groups block Sébastien Guimmara
` (3 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Sébastien Guimmara @ 2015-05-18 19:18 UTC (permalink / raw
To: git; +Cc: sunshine, Sébastien Guimmara
From: Eric Sunshine <sunshine@sunshineco.com>
The ultimate goal is for "git help" to classify common commands by
group. Toward this end, a subsequent patch will add a new "common
groups" section to command-list.txt preceding the actual command list.
As preparation, teach existing command-list.txt parsing machinery, which
doesn't care about grouping, to skip over this upcoming "common groups"
section.
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
---
Documentation/cmd-list.perl | 4 ++++
Makefile | 5 +++--
command-list.txt | 3 ++-
3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl
index 04f9977..5aa73cf 100755
--- a/Documentation/cmd-list.perl
+++ b/Documentation/cmd-list.perl
@@ -38,6 +38,10 @@ sub format_one {
}
}
+while (<>) {
+ last if /^### command list/;
+}
+
my %cmds = ();
for (sort <>) {
next if /^#/;
diff --git a/Makefile b/Makefile
index 25a453b..5ed0acf 100644
--- a/Makefile
+++ b/Makefile
@@ -2454,7 +2454,7 @@ check-docs::
esac ; \
test -f "Documentation/$$v.txt" || \
echo "no doc: $$v"; \
- sed -e '/^#/d' command-list.txt | \
+ sed -e '1,/^### command list/d' -e '/^#/d' command-list.txt | \
grep -q "^$$v[ ]" || \
case "$$v" in \
git) ;; \
@@ -2462,7 +2462,8 @@ check-docs::
esac ; \
done; \
( \
- sed -e '/^#/d' \
+ sed -e '1,/^### command list/d' \
+ -e '/^#/d' \
-e 's/[ ].*//' \
-e 's/^/listed /' command-list.txt; \
$(MAKE) -C Documentation print-man1 | \
diff --git a/command-list.txt b/command-list.txt
index 54d8d21..609b344 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -1,4 +1,5 @@
-# List of known git commands.
+# do not molest the next line
+### command list
# command name category [deprecated] [common]
git-add mainporcelain common
git-am mainporcelain
--
2.4.0.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v8 2/5] command-list.txt: add the common groups block
2015-05-18 19:18 [PATCH v8 0/5] group common commands by theme Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 1/5] command-list: prepare machinery for upcoming "common groups" section Sébastien Guimmara
@ 2015-05-18 19:18 ` Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 3/5] generate-cmdlist: parse common group commands Sébastien Guimmara
` (2 subsequent siblings)
4 siblings, 0 replies; 12+ messages in thread
From: Sébastien Guimmara @ 2015-05-18 19:18 UTC (permalink / raw
To: git; +Cc: sunshine, Sébastien Guimmara
The ultimate goal is for "git help" to display common commands in
groups rather than alphabetically. As a first step, define the
groups in a new block, and then assign a group to each
common command.
Add a block at the beginning of command-list.txt:
init start a working area (see also: git help tutorial)
worktree work on the current change (see also:[...]
info examine the history and state (see also: git [...]
history grow, mark and tweak your history
remote collaborate (see also: git help workflows)
storing information about common commands group, then map each common
command to a group:
git-add mainporcelain common worktree
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Emma Jane Hogbin Westby <emma.westby@gmail.com>
Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
---
command-list.txt | 50 ++++++++++++++++++++++++++++++--------------------
1 file changed, 30 insertions(+), 20 deletions(-)
diff --git a/command-list.txt b/command-list.txt
index 609b344..c2bbdc1 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -1,3 +1,13 @@
+# common commands are grouped by themes output by 'git help'
+# map each common command in the command list to one of these groups.
+### common groups
+init start a working area (see also: git help tutorial)
+worktree work on the current change (see also: git help everyday)
+info examine the history and state (see also: git help revisions)
+history grow, mark and tweak your common history
+remote collaborate (see also: git help workflows)
+
+# List of known git commands.
# do not molest the next line
### command list
# command name category [deprecated] [common]
@@ -7,24 +17,24 @@ git-annotate ancillaryinterrogators
git-apply plumbingmanipulators
git-archimport foreignscminterface
git-archive mainporcelain
-git-bisect mainporcelain common
+git-bisect mainporcelain common info
git-blame ancillaryinterrogators
-git-branch mainporcelain common
+git-branch mainporcelain common history
git-bundle mainporcelain
git-cat-file plumbinginterrogators
git-check-attr purehelpers
git-check-ignore purehelpers
git-check-mailmap purehelpers
-git-checkout mainporcelain common
+git-checkout mainporcelain common history
git-checkout-index plumbingmanipulators
git-check-ref-format purehelpers
git-cherry ancillaryinterrogators
git-cherry-pick mainporcelain
git-citool mainporcelain
git-clean mainporcelain
-git-clone mainporcelain common
+git-clone mainporcelain common init
git-column purehelpers
-git-commit mainporcelain common
+git-commit mainporcelain common history
git-commit-tree plumbingmanipulators
git-config ancillarymanipulators
git-count-objects ancillaryinterrogators
@@ -36,14 +46,14 @@ git-cvsimport foreignscminterface
git-cvsserver foreignscminterface
git-daemon synchingrepositories
git-describe mainporcelain
-git-diff mainporcelain common
+git-diff mainporcelain common history
git-diff-files plumbinginterrogators
git-diff-index plumbinginterrogators
git-diff-tree plumbinginterrogators
git-difftool ancillaryinterrogators
git-fast-export ancillarymanipulators
git-fast-import ancillarymanipulators
-git-fetch mainporcelain common
+git-fetch mainporcelain common remote
git-fetch-pack synchingrepositories
git-filter-branch ancillarymanipulators
git-fmt-merge-msg purehelpers
@@ -52,7 +62,7 @@ git-format-patch mainporcelain
git-fsck ancillaryinterrogators
git-gc mainporcelain
git-get-tar-commit-id ancillaryinterrogators
-git-grep mainporcelain common
+git-grep mainporcelain common info
git-gui mainporcelain
git-hash-object plumbingmanipulators
git-help ancillaryinterrogators
@@ -61,17 +71,17 @@ git-http-fetch synchelpers
git-http-push synchelpers
git-imap-send foreignscminterface
git-index-pack plumbingmanipulators
-git-init mainporcelain common
+git-init mainporcelain common init
git-instaweb ancillaryinterrogators
git-interpret-trailers purehelpers
gitk mainporcelain
-git-log mainporcelain common
+git-log mainporcelain common info
git-ls-files plumbinginterrogators
git-ls-remote plumbinginterrogators
git-ls-tree plumbinginterrogators
git-mailinfo purehelpers
git-mailsplit purehelpers
-git-merge mainporcelain common
+git-merge mainporcelain common history
git-merge-base plumbinginterrogators
git-merge-file plumbingmanipulators
git-merge-index plumbingmanipulators
@@ -80,7 +90,7 @@ git-mergetool ancillarymanipulators
git-merge-tree ancillaryinterrogators
git-mktag plumbingmanipulators
git-mktree plumbingmanipulators
-git-mv mainporcelain common
+git-mv mainporcelain common worktree
git-name-rev plumbinginterrogators
git-notes mainporcelain
git-p4 foreignscminterface
@@ -91,11 +101,11 @@ git-parse-remote synchelpers
git-patch-id purehelpers
git-prune ancillarymanipulators
git-prune-packed plumbingmanipulators
-git-pull mainporcelain common
-git-push mainporcelain common
+git-pull mainporcelain common remote
+git-push mainporcelain common remote
git-quiltimport foreignscminterface
git-read-tree plumbingmanipulators
-git-rebase mainporcelain common
+git-rebase mainporcelain common history
git-receive-pack synchelpers
git-reflog ancillarymanipulators
git-relink ancillarymanipulators
@@ -104,28 +114,28 @@ git-repack ancillarymanipulators
git-replace ancillarymanipulators
git-request-pull foreignscminterface
git-rerere ancillaryinterrogators
-git-reset mainporcelain common
+git-reset mainporcelain common worktree
git-revert mainporcelain
git-rev-list plumbinginterrogators
git-rev-parse ancillaryinterrogators
-git-rm mainporcelain common
+git-rm mainporcelain common worktree
git-send-email foreignscminterface
git-send-pack synchingrepositories
git-shell synchelpers
git-shortlog mainporcelain
-git-show mainporcelain common
+git-show mainporcelain common info
git-show-branch ancillaryinterrogators
git-show-index plumbinginterrogators
git-show-ref plumbinginterrogators
git-sh-i18n purehelpers
git-sh-setup purehelpers
git-stash mainporcelain
-git-status mainporcelain common
+git-status mainporcelain common info
git-stripspace purehelpers
git-submodule mainporcelain
git-svn foreignscminterface
git-symbolic-ref plumbingmanipulators
-git-tag mainporcelain common
+git-tag mainporcelain common history
git-unpack-file plumbinginterrogators
git-unpack-objects plumbingmanipulators
git-update-index plumbingmanipulators
--
2.4.0.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v8 3/5] generate-cmdlist: parse common group commands
2015-05-18 19:18 [PATCH v8 0/5] group common commands by theme Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 1/5] command-list: prepare machinery for upcoming "common groups" section Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 2/5] command-list.txt: add the common groups block Sébastien Guimmara
@ 2015-05-18 19:18 ` Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 4/5] command-list.txt: drop the "common" tag Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 5/5] help: respect new common command grouping Sébastien Guimmara
4 siblings, 0 replies; 12+ messages in thread
From: Sébastien Guimmara @ 2015-05-18 19:18 UTC (permalink / raw
To: git; +Cc: sunshine, Sébastien Guimmara
From: Eric Sunshine <sunshine@sunshineco.com>
Parse the group block to create the array of group descriptions:
static char *common_cmd_groups[] = {
N_("starting a working area"),
N_("working on the current change"),
N_("working with others"),
N_("examining the history and state"),
N_("growing, marking and tweaking your history"),
};
then map each element of common_cmds[] to a group via its index:
static struct cmdname_help common_cmds[] = {
{"add", N_("Add file contents to the index"), 1},
{"branch", N_("List, create, or delete branches"), 4},
{"checkout", N_("Checkout a branch or paths to the ..."), 4},
{"clone", N_("Clone a repository into a new directory"), 0},
{"commit", N_("Record changes to the repository"), 4},
...
};
so that 'git help' can print those commands grouped by theme.
Only commands tagged with an attribute from the group block are emitted to
common_cmds[].
[commit message by Sébastien Guimmara <sebastien.guimmara@gmail.com>]
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
---
Makefile | 4 ++--
generate-cmdlist.awk | 39 +++++++++++++++++++++++++++++++++++++++
generate-cmdlist.sh | 23 -----------------------
3 files changed, 41 insertions(+), 25 deletions(-)
create mode 100644 generate-cmdlist.awk
delete mode 100755 generate-cmdlist.sh
diff --git a/Makefile b/Makefile
index 5ed0acf..9da8687 100644
--- a/Makefile
+++ b/Makefile
@@ -1693,10 +1693,10 @@ $(BUILT_INS): git$X
ln -s $< $@ 2>/dev/null || \
cp $< $@
-common-cmds.h: ./generate-cmdlist.sh command-list.txt
+common-cmds.h: generate-cmdlist.awk command-list.txt
common-cmds.h: $(wildcard Documentation/git-*.txt)
- $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
+ $(QUIET_GEN)awk -f generate-cmdlist.awk command-list.txt > $@+ && mv $@+ $@
SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
$(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
diff --git a/generate-cmdlist.awk b/generate-cmdlist.awk
new file mode 100644
index 0000000..dbf1e6b
--- /dev/null
+++ b/generate-cmdlist.awk
@@ -0,0 +1,39 @@
+BEGIN {
+ print "/* Automatically generated by generate-cmdlist.awk */\n"
+ print "struct cmdname_help {"
+ print "\tchar name[16];"
+ print "\tchar help[80];"
+ print "\tunsigned char group;"
+ print "};\n"
+ print "static char *common_cmd_groups[] = {"
+}
+/### common groups/ {
+ state = 1
+}
+/### command list/ {
+ print "};\n\nstatic struct cmdname_help common_cmds[] = {"
+ state = 2
+}
+/^#/ || /^[ ]*$/ { next }
+state == 2 {
+ for (i = 2; i <= NF; i++)
+ if (grp[$i]) {
+ f = "Documentation/"$1".txt"
+ while (getline s <f > 0)
+ if (match(s, $1" - ")) {
+ t = substr(s, length($1" - ") + 1)
+ break
+ }
+ close(f)
+ printf "\t{\"%s\", N_(\"%s\"), %s},\n",
+ substr($1, length("git-") + 1), t, grp[$i] - 1
+ break
+ }
+}
+state == 1 {
+ grp[$1] = ++n
+ sub($1"[ ][ ]*", "")
+ printf "\tN_(\"%s\"),\n", $0
+}
+
+END { print "};" }
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
deleted file mode 100755
index 9a4c9b9..0000000
--- a/generate-cmdlist.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-echo "/* Automatically generated by $0 */
-struct cmdname_help {
- char name[16];
- char help[80];
-};
-
-static struct cmdname_help common_cmds[] = {"
-
-sed -n -e 's/^git-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt |
-sort |
-while read cmd
-do
- sed -n '
- /^NAME/,/git-'"$cmd"'/H
- ${
- x
- s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", N_("\1")},/
- p
- }' "Documentation/git-$cmd.txt"
-done
-echo "};"
--
2.4.0.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v8 4/5] command-list.txt: drop the "common" tag
2015-05-18 19:18 [PATCH v8 0/5] group common commands by theme Sébastien Guimmara
` (2 preceding siblings ...)
2015-05-18 19:18 ` [PATCH v8 3/5] generate-cmdlist: parse common group commands Sébastien Guimmara
@ 2015-05-18 19:18 ` Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 5/5] help: respect new common command grouping Sébastien Guimmara
4 siblings, 0 replies; 12+ messages in thread
From: Sébastien Guimmara @ 2015-05-18 19:18 UTC (permalink / raw
To: git; +Cc: sunshine, Sébastien Guimmara
command-list.sh, retired in the previous patch, was the only
consumer of the "common" tag, so drop this now-unnecessary
attribute.
before:
git-add mainporcelain common worktree
after:
git-add mainporcelain worktree
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
---
command-list.txt | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/command-list.txt b/command-list.txt
index c2bbdc1..080d6d9 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -11,30 +11,30 @@ remote collaborate (see also: git help workflows)
# do not molest the next line
### command list
# command name category [deprecated] [common]
-git-add mainporcelain common
+git-add mainporcelain worktree
git-am mainporcelain
git-annotate ancillaryinterrogators
git-apply plumbingmanipulators
git-archimport foreignscminterface
git-archive mainporcelain
-git-bisect mainporcelain common info
+git-bisect mainporcelain info
git-blame ancillaryinterrogators
-git-branch mainporcelain common history
+git-branch mainporcelain history
git-bundle mainporcelain
git-cat-file plumbinginterrogators
git-check-attr purehelpers
git-check-ignore purehelpers
git-check-mailmap purehelpers
-git-checkout mainporcelain common history
+git-checkout mainporcelain history
git-checkout-index plumbingmanipulators
git-check-ref-format purehelpers
git-cherry ancillaryinterrogators
git-cherry-pick mainporcelain
git-citool mainporcelain
git-clean mainporcelain
-git-clone mainporcelain common init
+git-clone mainporcelain init
git-column purehelpers
-git-commit mainporcelain common history
+git-commit mainporcelain history
git-commit-tree plumbingmanipulators
git-config ancillarymanipulators
git-count-objects ancillaryinterrogators
@@ -46,14 +46,14 @@ git-cvsimport foreignscminterface
git-cvsserver foreignscminterface
git-daemon synchingrepositories
git-describe mainporcelain
-git-diff mainporcelain common history
+git-diff mainporcelain history
git-diff-files plumbinginterrogators
git-diff-index plumbinginterrogators
git-diff-tree plumbinginterrogators
git-difftool ancillaryinterrogators
git-fast-export ancillarymanipulators
git-fast-import ancillarymanipulators
-git-fetch mainporcelain common remote
+git-fetch mainporcelain remote
git-fetch-pack synchingrepositories
git-filter-branch ancillarymanipulators
git-fmt-merge-msg purehelpers
@@ -62,7 +62,7 @@ git-format-patch mainporcelain
git-fsck ancillaryinterrogators
git-gc mainporcelain
git-get-tar-commit-id ancillaryinterrogators
-git-grep mainporcelain common info
+git-grep mainporcelain info
git-gui mainporcelain
git-hash-object plumbingmanipulators
git-help ancillaryinterrogators
@@ -71,17 +71,17 @@ git-http-fetch synchelpers
git-http-push synchelpers
git-imap-send foreignscminterface
git-index-pack plumbingmanipulators
-git-init mainporcelain common init
+git-init mainporcelain init
git-instaweb ancillaryinterrogators
git-interpret-trailers purehelpers
gitk mainporcelain
-git-log mainporcelain common info
+git-log mainporcelain info
git-ls-files plumbinginterrogators
git-ls-remote plumbinginterrogators
git-ls-tree plumbinginterrogators
git-mailinfo purehelpers
git-mailsplit purehelpers
-git-merge mainporcelain common history
+git-merge mainporcelain history
git-merge-base plumbinginterrogators
git-merge-file plumbingmanipulators
git-merge-index plumbingmanipulators
@@ -90,7 +90,7 @@ git-mergetool ancillarymanipulators
git-merge-tree ancillaryinterrogators
git-mktag plumbingmanipulators
git-mktree plumbingmanipulators
-git-mv mainporcelain common worktree
+git-mv mainporcelain worktree
git-name-rev plumbinginterrogators
git-notes mainporcelain
git-p4 foreignscminterface
@@ -101,11 +101,11 @@ git-parse-remote synchelpers
git-patch-id purehelpers
git-prune ancillarymanipulators
git-prune-packed plumbingmanipulators
-git-pull mainporcelain common remote
-git-push mainporcelain common remote
+git-pull mainporcelain remote
+git-push mainporcelain remote
git-quiltimport foreignscminterface
git-read-tree plumbingmanipulators
-git-rebase mainporcelain common history
+git-rebase mainporcelain history
git-receive-pack synchelpers
git-reflog ancillarymanipulators
git-relink ancillarymanipulators
@@ -114,28 +114,28 @@ git-repack ancillarymanipulators
git-replace ancillarymanipulators
git-request-pull foreignscminterface
git-rerere ancillaryinterrogators
-git-reset mainporcelain common worktree
+git-reset mainporcelain worktree
git-revert mainporcelain
git-rev-list plumbinginterrogators
git-rev-parse ancillaryinterrogators
-git-rm mainporcelain common worktree
+git-rm mainporcelain worktree
git-send-email foreignscminterface
git-send-pack synchingrepositories
git-shell synchelpers
git-shortlog mainporcelain
-git-show mainporcelain common info
+git-show mainporcelain info
git-show-branch ancillaryinterrogators
git-show-index plumbinginterrogators
git-show-ref plumbinginterrogators
git-sh-i18n purehelpers
git-sh-setup purehelpers
git-stash mainporcelain
-git-status mainporcelain common info
+git-status mainporcelain info
git-stripspace purehelpers
git-submodule mainporcelain
git-svn foreignscminterface
git-symbolic-ref plumbingmanipulators
-git-tag mainporcelain common history
+git-tag mainporcelain history
git-unpack-file plumbinginterrogators
git-unpack-objects plumbingmanipulators
git-update-index plumbingmanipulators
--
2.4.0.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH v8 5/5] help: respect new common command grouping
2015-05-18 19:18 [PATCH v8 0/5] group common commands by theme Sébastien Guimmara
` (3 preceding siblings ...)
2015-05-18 19:18 ` [PATCH v8 4/5] command-list.txt: drop the "common" tag Sébastien Guimmara
@ 2015-05-18 19:18 ` Sébastien Guimmara
2015-05-18 21:39 ` Junio C Hamano
4 siblings, 1 reply; 12+ messages in thread
From: Sébastien Guimmara @ 2015-05-18 19:18 UTC (permalink / raw
To: git; +Cc: sunshine, Sébastien Guimmara
'git help' shows common commands in alphabetical order:
The most commonly used git commands are:
add Add file contents to the index
bisect Find by binary search the change that introduced a bug
branch List, create, or delete branches
checkout Checkout a branch or paths to the working tree
clone Clone a repository into a new directory
commit Record changes to the repository
[...]
without any indication of how commands relate to high-level
concepts or each other. Revise the output to explain their relationship
with the typical Git workflow:
The typical Git workflow includes:
start a working area (see also: git help tutorial)
clone Clone a repository into a new directory
init Create an empty Git repository or reinitialize [...]
work on the current change (see also: git help everyday)
add Add file contents to the index
mv Move or rename a file, a directory, or a symlink
reset Reset current HEAD to the specified state
rm Remove files from the working tree and from the index
examine the history and state (see also: git help revisions)
log Show commit logs
status Show the working tree status
[...]
Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
---
help.c | 24 +++++++++++++++++++++++-
1 file changed, 23 insertions(+), 1 deletion(-)
diff --git a/help.c b/help.c
index 2072a87..71027b7 100644
--- a/help.c
+++ b/help.c
@@ -218,17 +218,39 @@ void list_commands(unsigned int colopts,
}
}
+int cmd_group_cmp(const void *elem1, const void *elem2)
+{
+ const struct cmdname_help *e1 = elem1;
+ const struct cmdname_help *e2 = elem2;
+
+ if (e1->group < e2->group)
+ return -1;
+ if (e1->group > e2->group)
+ return 1;
+ return strcmp(e1->name, e2->name);
+}
+
void list_common_cmds_help(void)
{
int i, longest = 0;
+ int current_grp = -1;
for (i = 0; i < ARRAY_SIZE(common_cmds); i++) {
if (longest < strlen(common_cmds[i].name))
longest = strlen(common_cmds[i].name);
}
- puts(_("The most commonly used git commands are:"));
+ qsort(common_cmds, ARRAY_SIZE(common_cmds),
+ sizeof(common_cmds[0]), cmd_group_cmp);
+
+ puts(_("The typical Git workflow includes:"));
+
for (i = 0; i < ARRAY_SIZE(common_cmds); 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;
+ }
+
printf(" %s ", common_cmds[i].name);
mput_char(' ', longest - strlen(common_cmds[i].name));
puts(_(common_cmds[i].help));
--
2.4.0.GIT
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v8 5/5] help: respect new common command grouping
2015-05-18 19:18 ` [PATCH v8 5/5] help: respect new common command grouping Sébastien Guimmara
@ 2015-05-18 21:39 ` Junio C Hamano
2015-05-19 0:43 ` Eric Sunshine
2015-05-19 17:57 ` Sébastien Guimmara
0 siblings, 2 replies; 12+ messages in thread
From: Junio C Hamano @ 2015-05-18 21:39 UTC (permalink / raw
To: Sébastien Guimmara; +Cc: git, sunshine
Sébastien Guimmara <sebastien.guimmara@gmail.com> writes:
> 'git help' shows common commands in alphabetical order:
>
> The most commonly used git commands are:
> add Add file contents to the index
> bisect Find by binary search the change that introduced a bug
> branch List, create, or delete branches
> checkout Checkout a branch or paths to the working tree
> clone Clone a repository into a new directory
> commit Record changes to the repository
> [...]
>
> without any indication of how commands relate to high-level
> concepts or each other. Revise the output to explain their relationship
> with the typical Git workflow:
>
> The typical Git workflow includes:
>
> start a working area (see also: git help tutorial)
> clone Clone a repository into a new directory
> init Create an empty Git repository or reinitialize [...]
>
> work on the current change (see also: git help everyday)
> add Add file contents to the index
> mv Move or rename a file, a directory, or a symlink
> reset Reset current HEAD to the specified state
> rm Remove files from the working tree and from the index
>
> examine the history and state (see also: git help revisions)
> log Show commit logs
> status Show the working tree status
>
> [...]
>
> Helped-by: Eric Sunshine <sunshine@sunshineco.com>
> Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
> ---
I cannot exactly pinpoint what bothers me, but "The typical Git
workflow includes:" sounds a bit awkward.
What does a workflow "include"? What are components included in a
workflow? Are "starting a repository", "working on a single thing",
"collabolating", etc. components that are incuded in a workflow?
If so, the fact that "clone", "init", etc. are "commands that are
commonly used in each component of the workflow" is a more important
thing to say; in other words, the header does not explain what list
it is presenting the user.
Or does a workflow consists of "clone", "init", "add", "mv", etc.
that are included in it? Then it is left unexplained what the
section headings stand for.
Perhaps something like
These are common Git commands used in various situations:
may lessen the uneasiness I felt above. I dunno.
Other than that, this round looks ready for 'next'.
I am not absolutely sure if new dependency on "awk" will not present
portability issues, though. So far we only used it in scripts in
the fringes and only a few tests.
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v8 5/5] help: respect new common command grouping
2015-05-18 21:39 ` Junio C Hamano
@ 2015-05-19 0:43 ` Eric Sunshine
2015-05-19 16:09 ` Junio C Hamano
2015-05-19 17:57 ` Sébastien Guimmara
1 sibling, 1 reply; 12+ messages in thread
From: Eric Sunshine @ 2015-05-19 0:43 UTC (permalink / raw
To: Junio C Hamano; +Cc: Sébastien Guimmara, git
On Mon, May 18, 2015 at 02:39:42PM -0700, Junio C Hamano wrote:
> Sébastien Guimmara <sebastien.guimmara@gmail.com> writes:
> > 'git help' shows common commands in alphabetical order:
> > [...]
> > without any indication of how commands relate to high-level
> > concepts or each other. Revise the output to explain their relationship
> > with the typical Git workflow:
> > [...]
> > The typical Git workflow includes:
> >
> > Helped-by: Eric Sunshine <sunshine@sunshineco.com>
> > Signed-off-by: Sébastien Guimmara <sebastien.guimmara@gmail.com>
>
> I cannot exactly pinpoint what bothers me, but "The typical Git
> workflow includes:" sounds a bit awkward.
> What does a workflow "include"? [...]
>
> Other than that, this round looks ready for 'next'.
I came to the same conclusion. FWIW, the entire series is:
Reviewed-by: Eric Sunshine <sunshine@sunshineco.com>
> I am not absolutely sure if new dependency on "awk" will not present
> portability issues, though. So far we only used it in scripts in
> the fringes and only a few tests.
The awk script restricts itself to POSIX, and I did test it on Linux,
Mac OS X, and FreeBSD, so it seems pretty portable. However, if it
worries you sufficiently, here's the equivalent Perl version:
--- >8 ---
From: Eric Sunshine <sunshine@sunshineco.com>
Subject: [PATCH 3/5] generate-cmdlist: parse common group commands
Parse the group block to create the array of group descriptions:
static char *common_cmd_groups[] = {
N_("starting a working area"),
N_("working on the current change"),
N_("working with others"),
N_("examining the history and state"),
N_("growing, marking and tweaking your history"),
};
then map each element of common_cmds[] to a group via its index:
static struct cmdname_help common_cmds[] = {
{"add", N_("Add file contents to the index"), 1},
{"branch", N_("List, create, or delete branches"), 4},
{"checkout", N_("Checkout a branch or paths to the ..."), 4},
{"clone", N_("Clone a repository into a new directory"), 0},
{"commit", N_("Record changes to the repository"), 4},
...
};
so that 'git help' can print those commands grouped by theme.
Only commands tagged with an attribute from the group block are emitted to
common_cmds[].
[commit message by Sébastien Guimmara <sebastien.guimmara@gmail.com>]
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
---
Makefile | 4 ++--
generate-cmdlist.perl | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
generate-cmdlist.sh | 23 -----------------------
3 files changed, 52 insertions(+), 25 deletions(-)
create mode 100755 generate-cmdlist.perl
delete mode 100755 generate-cmdlist.sh
diff --git a/Makefile b/Makefile
index 5ed0acf..c133a96 100644
--- a/Makefile
+++ b/Makefile
@@ -1693,10 +1693,10 @@ $(BUILT_INS): git$X
ln -s $< $@ 2>/dev/null || \
cp $< $@
-common-cmds.h: ./generate-cmdlist.sh command-list.txt
+common-cmds.h: generate-cmdlist.perl command-list.txt
common-cmds.h: $(wildcard Documentation/git-*.txt)
- $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
+ $(QUIET_GEN)$(PERL_PATH) generate-cmdlist.perl command-list.txt > $@+ && mv $@+ $@
SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
$(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\
diff --git a/generate-cmdlist.perl b/generate-cmdlist.perl
new file mode 100755
index 0000000..31516e3
--- /dev/null
+++ b/generate-cmdlist.perl
@@ -0,0 +1,50 @@
+#!/usr/bin/perl
+use strict;
+use warnings;
+
+print <<"EOT";
+/* Automatically generated by $0 */
+
+struct cmdname_help {
+ char name[16];
+ char help[80];
+ unsigned char group;
+};
+
+static char *common_cmd_groups[] = {
+EOT
+
+my $n = 0;
+my %grp;
+while (<>) {
+ last if /^### command list/;
+ next if (1../^### common groups/) || /^#/ || /^\s*$/;
+ chop;
+ my ($k, $v) = split ' ', $_, 2;
+ $grp{$k} = $n++;
+ print "\tN_(\"$v\"),\n";
+}
+
+print "};\n\nstatic struct cmdname_help common_cmds[] = {\n";
+
+while (<>) {
+ next if /^#/ || /^\s*$/;
+ my @tags = split;
+ my $cmd = shift @tags;
+ for my $t (@tags) {
+ if (exists $grp{$t}) {
+ my $s;
+ open my $f, '<', "Documentation/$cmd.txt" or die;
+ while (<$f>) {
+ ($s) = /^$cmd - (.+)$/;
+ last if $s;
+ }
+ close $f;
+ $cmd =~ s/^git-//;
+ print "\t{\"$cmd\", N_(\"$s\"), $grp{$t}},\n";
+ last;
+ }
+ }
+}
+
+print "};\n";
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
deleted file mode 100755
index 9a4c9b9..0000000
--- a/generate-cmdlist.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/sh
-
-echo "/* Automatically generated by $0 */
-struct cmdname_help {
- char name[16];
- char help[80];
-};
-
-static struct cmdname_help common_cmds[] = {"
-
-sed -n -e 's/^git-\([^ ]*\)[ ].* common.*/\1/p' command-list.txt |
-sort |
-while read cmd
-do
- sed -n '
- /^NAME/,/git-'"$cmd"'/H
- ${
- x
- s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", N_("\1")},/
- p
- }' "Documentation/git-$cmd.txt"
-done
-echo "};"
--
2.4.1.260.ga2776d4
--- >8 ---
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH v8 5/5] help: respect new common command grouping
2015-05-19 0:43 ` Eric Sunshine
@ 2015-05-19 16:09 ` Junio C Hamano
2015-05-19 16:35 ` Eric Sunshine
0 siblings, 1 reply; 12+ messages in thread
From: Junio C Hamano @ 2015-05-19 16:09 UTC (permalink / raw
To: Eric Sunshine; +Cc: Sébastien Guimmara, git
Eric Sunshine <sunshine@sunshineco.com> writes:
> The awk script restricts itself to POSIX, and I did test it on Linux,
> Mac OS X, and FreeBSD, so it seems pretty portable.
I was worried more about some people only having gawk while others
with mawk and yet others nawk, etc., without having one of them
under the canonical name "awk". It's nothing what
$ make AWK=mawk
or its config.mak equivalent cannot fix, but still bothers me a bit.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v8 5/5] help: respect new common command grouping
2015-05-19 16:09 ` Junio C Hamano
@ 2015-05-19 16:35 ` Eric Sunshine
2015-05-19 18:20 ` Junio C Hamano
0 siblings, 1 reply; 12+ messages in thread
From: Eric Sunshine @ 2015-05-19 16:35 UTC (permalink / raw
To: Junio C Hamano; +Cc: Sébastien Guimmara, Git List
On Tue, May 19, 2015 at 12:09 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Eric Sunshine <sunshine@sunshineco.com> writes:
>
>> The awk script restricts itself to POSIX, and I did test it on Linux,
>> Mac OS X, and FreeBSD, so it seems pretty portable.
>
> I was worried more about some people only having gawk while others
> with mawk and yet others nawk, etc., without having one of them
> under the canonical name "awk". It's nothing what
>
> $ make AWK=mawk
>
> or its config.mak equivalent cannot fix, but still bothers me a bit.
In that case, perhaps we should go with the Perl version, which, given
that more people (these days) are familiar with Perl than awk, is less
likely to be a maintenance burden.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v8 5/5] help: respect new common command grouping
2015-05-18 21:39 ` Junio C Hamano
2015-05-19 0:43 ` Eric Sunshine
@ 2015-05-19 17:57 ` Sébastien Guimmara
1 sibling, 0 replies; 12+ messages in thread
From: Sébastien Guimmara @ 2015-05-19 17:57 UTC (permalink / raw
To: Junio C Hamano; +Cc: Eric Sunshine, Git Users
On 05/18/2015 11:39 PM, Junio C Hamano wrote:
> I cannot exactly pinpoint what bothers me, but "The typical Git
> workflow includes:" sounds a bit awkward.
>
> What does a workflow "include"? What are components included in a
> workflow? Are "starting a repository", "working on a single thing",
> "collabolating", etc. components that are incuded in a workflow?
>
> If so, the fact that "clone", "init", etc. are "commands that are
> commonly used in each component of the workflow" is a more important
> thing to say; in other words, the header does not explain what list
> it is presenting the user.
>
> Or does a workflow consists of "clone", "init", "add", "mv", etc.
> that are included in it? Then it is left unexplained what the
> section headings stand for.
>
> Perhaps something like
>
> These are common Git commands used in various situations:
>
> may lessen the uneasiness I felt above. I dunno.
This sounds better indeed.
>
> Other than that, this round looks ready for 'next'.
>
> I am not absolutely sure if new dependency on "awk" will not present
> portability issues, though. So far we only used it in scripts in
> the fringes and only a few tests.
>
> Thanks.
>
We can use Eric's perl version instead of the awk one.
Should I make another series or amend this one ?
Thank you.
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH v8 5/5] help: respect new common command grouping
2015-05-19 16:35 ` Eric Sunshine
@ 2015-05-19 18:20 ` Junio C Hamano
0 siblings, 0 replies; 12+ messages in thread
From: Junio C Hamano @ 2015-05-19 18:20 UTC (permalink / raw
To: Eric Sunshine; +Cc: Sébastien Guimmara, Git List
Eric Sunshine <sunshine@sunshineco.com> writes:
> On Tue, May 19, 2015 at 12:09 PM, Junio C Hamano <gitster@pobox.com> wrote:
>> Eric Sunshine <sunshine@sunshineco.com> writes:
>>
>>> The awk script restricts itself to POSIX, and I did test it on Linux,
>>> Mac OS X, and FreeBSD, so it seems pretty portable.
>>
>> I was worried more about some people only having gawk while others
>> with mawk and yet others nawk, etc., without having one of them
>> under the canonical name "awk". It's nothing what
>>
>> $ make AWK=mawk
>>
>> or its config.mak equivalent cannot fix, but still bothers me a bit.
>
> In that case, perhaps we should go with the Perl version, which, given
> that more people (these days) are familiar with Perl than awk, is less
> likely to be a maintenance burden.
As long as we all can agree that the long-term direction we want to
go in is to remove dependency on awk, that's fine by me.
That means a small awk scriptlets in t/ and elsewhere need to be
rethought, though.
Thanks.
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2015-05-19 18:20 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-18 19:18 [PATCH v8 0/5] group common commands by theme Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 1/5] command-list: prepare machinery for upcoming "common groups" section Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 2/5] command-list.txt: add the common groups block Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 3/5] generate-cmdlist: parse common group commands Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 4/5] command-list.txt: drop the "common" tag Sébastien Guimmara
2015-05-18 19:18 ` [PATCH v8 5/5] help: respect new common command grouping Sébastien Guimmara
2015-05-18 21:39 ` Junio C Hamano
2015-05-19 0:43 ` Eric Sunshine
2015-05-19 16:09 ` Junio C Hamano
2015-05-19 16:35 ` Eric Sunshine
2015-05-19 18:20 ` Junio C Hamano
2015-05-19 17:57 ` Sébastien Guimmara
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).