Merge branch 'ab/generate-command-list'
Build optimization. * ab/generate-command-list: generate-cmdlist.sh: don't parse command-list.txt thrice generate-cmdlist.sh: replace "grep' invocation with a shell version generate-cmdlist.sh: do not shell out to "sed" generate-cmdlist.sh: stop sorting category lines generate-cmdlist.sh: replace for loop by printf's auto-repeat feature generate-cmdlist.sh: run "grep | sort", not "sort | grep" generate-cmdlist.sh: don't call get_categories() from category_list() generate-cmdlist.sh: spawn fewer processes generate-cmdlist.sh: trivial whitespace change command-list.txt: sort with "LC_ALL=C sort"
This commit is contained in:
@ -43,7 +43,7 @@
|
|||||||
# specified here, which can only have "guide" attribute and nothing
|
# specified here, which can only have "guide" attribute and nothing
|
||||||
# else.
|
# else.
|
||||||
#
|
#
|
||||||
### command list (do not change this line, also do not change alignment)
|
### command list (do not change this line)
|
||||||
# command name category [category] [category]
|
# command name category [category] [category]
|
||||||
git-add mainporcelain worktree
|
git-add mainporcelain worktree
|
||||||
git-am mainporcelain
|
git-am mainporcelain
|
||||||
@ -60,9 +60,9 @@ git-cat-file plumbinginterrogators
|
|||||||
git-check-attr purehelpers
|
git-check-attr purehelpers
|
||||||
git-check-ignore purehelpers
|
git-check-ignore purehelpers
|
||||||
git-check-mailmap purehelpers
|
git-check-mailmap purehelpers
|
||||||
|
git-check-ref-format purehelpers
|
||||||
git-checkout mainporcelain
|
git-checkout mainporcelain
|
||||||
git-checkout-index plumbingmanipulators
|
git-checkout-index plumbingmanipulators
|
||||||
git-check-ref-format purehelpers
|
|
||||||
git-cherry plumbinginterrogators complete
|
git-cherry plumbinginterrogators complete
|
||||||
git-cherry-pick mainporcelain
|
git-cherry-pick mainporcelain
|
||||||
git-citool mainporcelain
|
git-citool mainporcelain
|
||||||
@ -111,7 +111,6 @@ git-index-pack plumbingmanipulators
|
|||||||
git-init mainporcelain init
|
git-init mainporcelain init
|
||||||
git-instaweb ancillaryinterrogators complete
|
git-instaweb ancillaryinterrogators complete
|
||||||
git-interpret-trailers purehelpers
|
git-interpret-trailers purehelpers
|
||||||
gitk mainporcelain
|
|
||||||
git-log mainporcelain info
|
git-log mainporcelain info
|
||||||
git-ls-files plumbinginterrogators
|
git-ls-files plumbinginterrogators
|
||||||
git-ls-remote plumbinginterrogators
|
git-ls-remote plumbinginterrogators
|
||||||
@ -124,11 +123,11 @@ git-merge-base plumbinginterrogators
|
|||||||
git-merge-file plumbingmanipulators
|
git-merge-file plumbingmanipulators
|
||||||
git-merge-index plumbingmanipulators
|
git-merge-index plumbingmanipulators
|
||||||
git-merge-one-file purehelpers
|
git-merge-one-file purehelpers
|
||||||
git-mergetool ancillarymanipulators complete
|
|
||||||
git-merge-tree ancillaryinterrogators
|
git-merge-tree ancillaryinterrogators
|
||||||
git-multi-pack-index plumbingmanipulators
|
git-mergetool ancillarymanipulators complete
|
||||||
git-mktag plumbingmanipulators
|
git-mktag plumbingmanipulators
|
||||||
git-mktree plumbingmanipulators
|
git-mktree plumbingmanipulators
|
||||||
|
git-multi-pack-index plumbingmanipulators
|
||||||
git-mv mainporcelain worktree
|
git-mv mainporcelain worktree
|
||||||
git-name-rev plumbinginterrogators
|
git-name-rev plumbinginterrogators
|
||||||
git-notes mainporcelain
|
git-notes mainporcelain
|
||||||
@ -154,23 +153,23 @@ git-request-pull foreignscminterface complete
|
|||||||
git-rerere ancillaryinterrogators
|
git-rerere ancillaryinterrogators
|
||||||
git-reset mainporcelain history
|
git-reset mainporcelain history
|
||||||
git-restore mainporcelain worktree
|
git-restore mainporcelain worktree
|
||||||
git-revert mainporcelain
|
|
||||||
git-rev-list plumbinginterrogators
|
git-rev-list plumbinginterrogators
|
||||||
git-rev-parse plumbinginterrogators
|
git-rev-parse plumbinginterrogators
|
||||||
|
git-revert mainporcelain
|
||||||
git-rm mainporcelain worktree
|
git-rm mainporcelain worktree
|
||||||
git-send-email foreignscminterface complete
|
git-send-email foreignscminterface complete
|
||||||
git-send-pack synchingrepositories
|
git-send-pack synchingrepositories
|
||||||
|
git-sh-i18n purehelpers
|
||||||
|
git-sh-setup purehelpers
|
||||||
git-shell synchelpers
|
git-shell synchelpers
|
||||||
git-shortlog mainporcelain
|
git-shortlog mainporcelain
|
||||||
git-show mainporcelain info
|
git-show mainporcelain info
|
||||||
git-show-branch ancillaryinterrogators complete
|
git-show-branch ancillaryinterrogators complete
|
||||||
git-show-index plumbinginterrogators
|
git-show-index plumbinginterrogators
|
||||||
git-show-ref plumbinginterrogators
|
git-show-ref plumbinginterrogators
|
||||||
git-sh-i18n purehelpers
|
|
||||||
git-sh-setup purehelpers
|
|
||||||
git-sparse-checkout mainporcelain
|
git-sparse-checkout mainporcelain
|
||||||
git-stash mainporcelain
|
|
||||||
git-stage complete
|
git-stage complete
|
||||||
|
git-stash mainporcelain
|
||||||
git-status mainporcelain info
|
git-status mainporcelain info
|
||||||
git-stripspace purehelpers
|
git-stripspace purehelpers
|
||||||
git-submodule mainporcelain
|
git-submodule mainporcelain
|
||||||
@ -189,7 +188,6 @@ git-var plumbinginterrogators
|
|||||||
git-verify-commit ancillaryinterrogators
|
git-verify-commit ancillaryinterrogators
|
||||||
git-verify-pack plumbinginterrogators
|
git-verify-pack plumbinginterrogators
|
||||||
git-verify-tag ancillaryinterrogators
|
git-verify-tag ancillaryinterrogators
|
||||||
gitweb ancillaryinterrogators
|
|
||||||
git-whatchanged ancillaryinterrogators complete
|
git-whatchanged ancillaryinterrogators complete
|
||||||
git-worktree mainporcelain
|
git-worktree mainporcelain
|
||||||
git-write-tree plumbingmanipulators
|
git-write-tree plumbingmanipulators
|
||||||
@ -204,6 +202,7 @@ gitfaq guide
|
|||||||
gitglossary guide
|
gitglossary guide
|
||||||
githooks guide
|
githooks guide
|
||||||
gitignore guide
|
gitignore guide
|
||||||
|
gitk mainporcelain
|
||||||
gitmailmap guide
|
gitmailmap guide
|
||||||
gitmodules guide
|
gitmodules guide
|
||||||
gitnamespaces guide
|
gitnamespaces guide
|
||||||
@ -211,6 +210,7 @@ gitremote-helpers guide
|
|||||||
gitrepository-layout guide
|
gitrepository-layout guide
|
||||||
gitrevisions guide
|
gitrevisions guide
|
||||||
gitsubmodules guide
|
gitsubmodules guide
|
||||||
gittutorial-2 guide
|
|
||||||
gittutorial guide
|
gittutorial guide
|
||||||
|
gittutorial-2 guide
|
||||||
|
gitweb ancillaryinterrogators
|
||||||
gitworkflows guide
|
gitworkflows guide
|
||||||
|
@ -6,37 +6,38 @@ die () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
command_list () {
|
command_list () {
|
||||||
eval "grep -ve '^#' $exclude_programs" <"$1"
|
while read cmd rest
|
||||||
}
|
do
|
||||||
|
case "$cmd" in
|
||||||
get_categories () {
|
"#"* | '')
|
||||||
tr ' ' '\012'|
|
# Ignore comments and allow empty lines
|
||||||
grep -v '^$' |
|
continue
|
||||||
sort |
|
;;
|
||||||
uniq
|
*)
|
||||||
|
case "$exclude_programs" in
|
||||||
|
*":$cmd:"*)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "$cmd $rest"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
esac
|
||||||
|
done <"$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
category_list () {
|
category_list () {
|
||||||
command_list "$1" |
|
echo "$1" |
|
||||||
cut -c 40- |
|
cut -d' ' -f2- |
|
||||||
get_categories
|
tr ' ' '\012' |
|
||||||
}
|
grep -v '^$' |
|
||||||
|
LC_ALL=C sort -u
|
||||||
get_synopsis () {
|
|
||||||
sed -n '
|
|
||||||
/^NAME/,/'"$1"'/H
|
|
||||||
${
|
|
||||||
x
|
|
||||||
s/.*'"$1"' - \(.*\)/N_("\1")/
|
|
||||||
p
|
|
||||||
}' "Documentation/$1.txt"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
define_categories () {
|
define_categories () {
|
||||||
echo
|
echo
|
||||||
echo "/* Command categories */"
|
echo "/* Command categories */"
|
||||||
bit=0
|
bit=0
|
||||||
category_list "$1" |
|
echo "$1" |
|
||||||
while read cat
|
while read cat
|
||||||
do
|
do
|
||||||
echo "#define CAT_$cat (1UL << $bit)"
|
echo "#define CAT_$cat (1UL << $bit)"
|
||||||
@ -50,7 +51,7 @@ define_category_names () {
|
|||||||
echo "/* Category names */"
|
echo "/* Category names */"
|
||||||
echo "static const char *category_names[] = {"
|
echo "static const char *category_names[] = {"
|
||||||
bit=0
|
bit=0
|
||||||
category_list "$1" |
|
echo "$1" |
|
||||||
while read cat
|
while read cat
|
||||||
do
|
do
|
||||||
echo " \"$cat\", /* (1UL << $bit) */"
|
echo " \"$cat\", /* (1UL << $bit) */"
|
||||||
@ -63,27 +64,38 @@ define_category_names () {
|
|||||||
print_command_list () {
|
print_command_list () {
|
||||||
echo "static struct cmdname_help command_list[] = {"
|
echo "static struct cmdname_help command_list[] = {"
|
||||||
|
|
||||||
command_list "$1" |
|
echo "$1" |
|
||||||
while read cmd rest
|
while read cmd rest
|
||||||
do
|
do
|
||||||
printf " { \"$cmd\", $(get_synopsis $cmd), 0"
|
synopsis=
|
||||||
for cat in $(echo "$rest" | get_categories)
|
while read line
|
||||||
do
|
do
|
||||||
printf " | CAT_$cat"
|
case "$line" in
|
||||||
done
|
"$cmd - "*)
|
||||||
|
synopsis=${line#$cmd - }
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done <"Documentation/$cmd.txt"
|
||||||
|
|
||||||
|
printf '\t{ "%s", N_("%s"), 0' "$cmd" "$synopsis"
|
||||||
|
printf " | CAT_%s" $rest
|
||||||
echo " },"
|
echo " },"
|
||||||
done
|
done
|
||||||
echo "};"
|
echo "};"
|
||||||
}
|
}
|
||||||
|
|
||||||
exclude_programs=
|
exclude_programs=:
|
||||||
while test "--exclude-program" = "$1"
|
while test "--exclude-program" = "$1"
|
||||||
do
|
do
|
||||||
shift
|
shift
|
||||||
exclude_programs="$exclude_programs -e \"^$1 \""
|
exclude_programs="$exclude_programs$1:"
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
commands="$(command_list "$1")"
|
||||||
|
categories="$(category_list "$commands")"
|
||||||
|
|
||||||
echo "/* Automatically generated by generate-cmdlist.sh */
|
echo "/* Automatically generated by generate-cmdlist.sh */
|
||||||
struct cmdname_help {
|
struct cmdname_help {
|
||||||
const char *name;
|
const char *name;
|
||||||
@ -91,8 +103,8 @@ struct cmdname_help {
|
|||||||
uint32_t category;
|
uint32_t category;
|
||||||
};
|
};
|
||||||
"
|
"
|
||||||
define_categories "$1"
|
define_categories "$categories"
|
||||||
echo
|
echo
|
||||||
define_category_names "$1"
|
define_category_names "$categories"
|
||||||
echo
|
echo
|
||||||
print_command_list "$1"
|
print_command_list "$commands"
|
||||||
|
Reference in New Issue
Block a user