git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
e4fe3ea608d6e72d585d58581812526e7ffcfc41 blob 2011 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
 
#!/bin/sh

if ! echo abc | sed 's/(ab)c/\1/' >/dev/null 2>&1
then
	alias sed='sed -E'
fi

die () {
	echo "$@" >&2
	exit 1
}

command_list () {
	eval "grep -ve '^#' $exclude_programs" <"$1"
}

get_categories () {
	tr ' ' '\012'|
	grep -v '^$' |
	sort |
	uniq
}

category_list () {
	command_list "$1" |
	awk '{ print substr($0, 40) }' |
	get_categories
}

get_synopsis () {
	sed -n '
		/^NAME/,/'"$1"'/h
		${
			x
			s/.*'"$1"' - (.*)/N_("\1")/
			p
		}' "Documentation/$1.txt"
}

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?"
}

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 "};"
}

if test -z "$(echo -n)"
then
	alias print='echo -n'
else
	alias print='printf %s'
fi

print_command_list () {
	echo "static struct cmdname_help command_list[] = {"

	command_list "$1" |
	while read cmd rest
	do
		print "	{ \"$cmd\", $(get_synopsis $cmd), 0"
		for cat in $(echo "$rest" | get_categories)
		do
			print " | CAT_$cat"
		done
		echo " },"
	done
	echo "};"
}

print_config_list () {
	cat <<EOF
static const char *config_name_list[] = {
EOF
	grep -h '^[a-zA-Z].*\..*::$' Documentation/*config.txt Documentation/config/*.txt |
	sed '/deprecated/d; s/::$//; s/,  */\n/g' |
	sort |
	while read line
	do
		echo "	\"$line\","
	done
	cat <<EOF
	NULL,
};
EOF
}

exclude_programs=
while test "--exclude-program" = "$1"
do
	shift
	exclude_programs="$exclude_programs -e \"^$1 \""
	shift
done

echo "/* Automatically generated by generate-cmdlist.sh */
struct cmdname_help {
	const char *name;
	const char *help;
	uint32_t category;
};
"
define_categories "$1"
echo
define_category_names "$1"
echo
print_command_list "$1"
echo
print_config_list
debug log:

solving e4fe3ea608 ...
found e4fe3ea608 in https://public-inbox.org/git/7505e85fc5508edd65a67eb9f4a57ebf41e9074c.1566913575.git.gitgitgadget@gmail.com/
found 71158f7d8b in https://80x24.org/mirrors/git.git
preparing index
index prepared:
100755 71158f7d8ba9c774ca6790ea8594e96accb17fce	generate-cmdlist.sh

applying [1/1] https://public-inbox.org/git/7505e85fc5508edd65a67eb9f4a57ebf41e9074c.1566913575.git.gitgitgadget@gmail.com/
diff --git a/generate-cmdlist.sh b/generate-cmdlist.sh
index 71158f7d8b..e4fe3ea608 100755

Checking patch generate-cmdlist.sh...
Applied patch generate-cmdlist.sh cleanly.

index at:
100755 e4fe3ea608d6e72d585d58581812526e7ffcfc41	generate-cmdlist.sh

Code repositories for project(s) associated with this 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).