help: add --config to list all available config

Sometimes it helps to list all available config vars so the user can
search for something they want. The config man page can also be used
but it's harder to search if you want to focus on the variable name,
for example.

This is not the best way to collect the available config since it's
not precise. Ideally we should have a centralized list of config in C
code (pretty much like 'struct option'), but that's a lot more work.
This will do for now.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy
2018-05-26 15:55:24 +02:00
committed by Junio C Hamano
parent a46baac61e
commit 3ac68a93fd
13 changed files with 172 additions and 1 deletions

View File

@ -76,6 +76,23 @@ print_command_list () {
echo "};"
}
print_config_list () {
cat <<EOF
static const char *config_name_list[] = {
EOF
grep '^[a-zA-Z].*\..*::$' Documentation/config.txt |
sed '/deprecated/d; s/::$//; s/, */\n/g' |
sort |
while read line
do
echo " \"$line\","
done
cat <<EOF
NULL,
};
EOF
}
echo "/* Automatically generated by generate-cmdlist.sh */
struct cmdname_help {
const char *name;
@ -88,3 +105,5 @@ echo
define_category_names "$1"
echo
print_command_list "$1"
echo
print_config_list