Merge branch 'sb/transport-report-missing-submodule-on-stderr' into maint
[git/debian.git] / generate-cmdlist.sh
blobab0d1b0c064a72480d7eac454b297ce95a48c8f3
1 #!/bin/sh
3 echo "/* Automatically generated by $0 */
4 struct cmdname_help {
5 char name[16];
6 char help[80];
7 unsigned char group;
8 };
10 static const char *common_cmd_groups[] = {"
12 grps=grps$$.tmp
13 match=match$$.tmp
14 trap "rm -f '$grps' '$match'" 0 1 2 3 15
16 sed -n '
17 1,/^### common groups/b
18 /^### command list/q
19 /^#/b
20 /^[ ]*$/b
21 h;s/^[^ ][^ ]*[ ][ ]*\(.*\)/ N_("\1"),/p
22 g;s/^\([^ ][^ ]*\)[ ].*/\1/w '$grps'
23 ' "$1"
24 printf '};\n\n'
26 n=0
27 substnum=
28 while read grp
30 echo "^git-..*[ ]$grp"
31 substnum="$substnum${substnum:+;}s/[ ]$grp/$n/"
32 n=$(($n+1))
33 done <"$grps" >"$match"
35 printf 'static struct cmdname_help common_cmds[] = {\n'
36 grep -f "$match" "$1" |
37 sed 's/^git-//' |
38 sort |
39 while read cmd tags
41 tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
42 sed -n '
43 /^NAME/,/git-'"$cmd"'/H
46 s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", N_("\1"), '$tag'},/
48 }' "Documentation/git-$cmd.txt"
49 done
50 echo "};"