generate-cmdlist: re-implement as shell script
527ec39 (generate-cmdlist: parse common group commands, 2015-05-21)
replaced generate-cmdlist.sh with a more functional Perl version,
generate-cmdlist.perl. The Perl version gleans named tags from a new
"common groups" section in command-list.txt and recognizes those
tags in "command list" section entries in place of the old 'common'
tag. This allows git-help to, not only recognize, but also group
common commands.
Although the tests require Perl, 527ec39 creates an unconditional
dependence upon Perl in the build system itself, which can not be
overridden with NO_PERL. Such a dependency may be undesirable; for
instance, the 'git-lite' package in the FreeBSD ports tree is
intended as a minimal Git installation (which may, for example, be
useful on servers needing only local clone and update capability),
which, historically, has not depended upon Perl[1].
Therefore, revive generate-cmdlist.sh and extend it to recognize
"common groups" and its named tags. Retire generate-cmdlist.perl.
[1]: http://thread.gmane.org/gmane.comp.version-control.git/275905/focus=276132
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-23 23:31:09 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2018-05-10 10:46:41 +02:00
|
|
|
die () {
|
|
|
|
echo "$@" >&2
|
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
|
|
|
command_list () {
|
2019-04-18 15:16:40 +02:00
|
|
|
eval "grep -ve '^#' $exclude_programs" <"$1"
|
2018-05-10 10:46:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
get_categories () {
|
|
|
|
tr ' ' '\n'|
|
|
|
|
grep -v '^$' |
|
|
|
|
sort |
|
|
|
|
uniq
|
|
|
|
}
|
|
|
|
|
|
|
|
category_list () {
|
|
|
|
command_list "$1" |
|
|
|
|
cut -c 40- |
|
|
|
|
get_categories
|
|
|
|
}
|
|
|
|
|
2018-05-10 10:46:40 +02:00
|
|
|
get_synopsis () {
|
|
|
|
sed -n '
|
|
|
|
/^NAME/,/'"$1"'/H
|
|
|
|
${
|
|
|
|
x
|
|
|
|
s/.*'"$1"' - \(.*\)/N_("\1")/
|
|
|
|
p
|
|
|
|
}' "Documentation/$1.txt"
|
|
|
|
}
|
|
|
|
|
2018-05-10 10:46:41 +02:00
|
|
|
define_categories () {
|
|
|
|
echo
|
|
|
|
echo "/* Command categories */"
|
|
|
|
bit=0
|
|
|
|
category_list "$1" |
|
|
|
|
while read cat
|
|
|
|
do
|
|
|
|
echo "#define CAT_$cat (1UL << $bit)"
|
|
|
|
bit=$(($bit+1))
|
|
|
|
done
|
|
|
|
test "$bit" -gt 32 && die "Urgh.. too many categories?"
|
|
|
|
}
|
|
|
|
|
2018-05-20 20:40:00 +02:00
|
|
|
define_category_names () {
|
|
|
|
echo
|
|
|
|
echo "/* Category names */"
|
|
|
|
echo "static const char *category_names[] = {"
|
|
|
|
bit=0
|
|
|
|
category_list "$1" |
|
|
|
|
while read cat
|
|
|
|
do
|
|
|
|
echo " \"$cat\", /* (1UL << $bit) */"
|
|
|
|
bit=$(($bit+1))
|
|
|
|
done
|
|
|
|
echo " NULL"
|
|
|
|
echo "};"
|
|
|
|
}
|
|
|
|
|
2018-05-10 10:46:41 +02:00
|
|
|
print_command_list () {
|
|
|
|
echo "static struct cmdname_help command_list[] = {"
|
|
|
|
|
|
|
|
command_list "$1" |
|
|
|
|
while read cmd rest
|
|
|
|
do
|
|
|
|
printf " { \"$cmd\", $(get_synopsis $cmd), 0"
|
|
|
|
for cat in $(echo "$rest" | get_categories)
|
|
|
|
do
|
|
|
|
printf " | CAT_$cat"
|
|
|
|
done
|
|
|
|
echo " },"
|
|
|
|
done
|
|
|
|
echo "};"
|
|
|
|
}
|
|
|
|
|
2018-05-26 15:55:24 +02:00
|
|
|
print_config_list () {
|
|
|
|
cat <<EOF
|
|
|
|
static const char *config_name_list[] = {
|
|
|
|
EOF
|
2018-10-27 08:22:34 +02:00
|
|
|
grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
|
2018-05-26 15:55:24 +02:00
|
|
|
sed '/deprecated/d; s/::$//; s/, */\n/g' |
|
|
|
|
sort |
|
|
|
|
while read line
|
|
|
|
do
|
|
|
|
echo " \"$line\","
|
|
|
|
done
|
|
|
|
cat <<EOF
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
EOF
|
|
|
|
}
|
|
|
|
|
2019-04-18 15:16:40 +02:00
|
|
|
exclude_programs=
|
|
|
|
while test "--exclude-program" = "$1"
|
|
|
|
do
|
|
|
|
shift
|
|
|
|
exclude_programs="$exclude_programs -e \"^$1 \""
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2016-07-02 02:32:00 +02:00
|
|
|
echo "/* Automatically generated by generate-cmdlist.sh */
|
generate-cmdlist: re-implement as shell script
527ec39 (generate-cmdlist: parse common group commands, 2015-05-21)
replaced generate-cmdlist.sh with a more functional Perl version,
generate-cmdlist.perl. The Perl version gleans named tags from a new
"common groups" section in command-list.txt and recognizes those
tags in "command list" section entries in place of the old 'common'
tag. This allows git-help to, not only recognize, but also group
common commands.
Although the tests require Perl, 527ec39 creates an unconditional
dependence upon Perl in the build system itself, which can not be
overridden with NO_PERL. Such a dependency may be undesirable; for
instance, the 'git-lite' package in the FreeBSD ports tree is
intended as a minimal Git installation (which may, for example, be
useful on servers needing only local clone and update capability),
which, historically, has not depended upon Perl[1].
Therefore, revive generate-cmdlist.sh and extend it to recognize
"common groups" and its named tags. Retire generate-cmdlist.perl.
[1]: http://thread.gmane.org/gmane.comp.version-control.git/275905/focus=276132
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-23 23:31:09 +02:00
|
|
|
struct cmdname_help {
|
2018-05-10 10:46:41 +02:00
|
|
|
const char *name;
|
|
|
|
const char *help;
|
2018-05-10 10:46:42 +02:00
|
|
|
uint32_t category;
|
generate-cmdlist: re-implement as shell script
527ec39 (generate-cmdlist: parse common group commands, 2015-05-21)
replaced generate-cmdlist.sh with a more functional Perl version,
generate-cmdlist.perl. The Perl version gleans named tags from a new
"common groups" section in command-list.txt and recognizes those
tags in "command list" section entries in place of the old 'common'
tag. This allows git-help to, not only recognize, but also group
common commands.
Although the tests require Perl, 527ec39 creates an unconditional
dependence upon Perl in the build system itself, which can not be
overridden with NO_PERL. Such a dependency may be undesirable; for
instance, the 'git-lite' package in the FreeBSD ports tree is
intended as a minimal Git installation (which may, for example, be
useful on servers needing only local clone and update capability),
which, historically, has not depended upon Perl[1].
Therefore, revive generate-cmdlist.sh and extend it to recognize
"common groups" and its named tags. Retire generate-cmdlist.perl.
[1]: http://thread.gmane.org/gmane.comp.version-control.git/275905/focus=276132
Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2015-08-23 23:31:09 +02:00
|
|
|
};
|
2018-05-10 10:46:41 +02:00
|
|
|
"
|
2018-05-10 10:46:43 +02:00
|
|
|
define_categories "$1"
|
|
|
|
echo
|
2018-05-20 20:40:00 +02:00
|
|
|
define_category_names "$1"
|
|
|
|
echo
|
2018-05-10 10:46:43 +02:00
|
|
|
print_command_list "$1"
|
2018-05-26 15:55:24 +02:00
|
|
|
echo
|
|
|
|
print_config_list
|