Skip to content

Commit 75ba897

Browse files
pcloudsgitster
authored andcommitted
generate-cmds.sh: factor out synopsis extract code
This makes it easier to reuse the same code in another place (very soon). Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fe0a9ea commit 75ba897

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

generate-cmdlist.sh

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
#!/bin/sh
22

3+
get_synopsis () {
4+
sed -n '
5+
/^NAME/,/'"$1"'/H
6+
${
7+
x
8+
s/.*'"$1"' - \(.*\)/N_("\1")/
9+
p
10+
}' "Documentation/$1.txt"
11+
}
12+
313
echo "/* Automatically generated by generate-cmdlist.sh */
414
struct cmdname_help {
515
char name[16];
@@ -39,12 +49,6 @@ sort |
3949
while read cmd tags
4050
do
4151
tag=$(echo "$tags" | sed "$substnum; s/[^0-9]//g")
42-
sed -n '
43-
/^NAME/,/git-'"$cmd"'/H
44-
${
45-
x
46-
s/.*git-'"$cmd"' - \(.*\)/ {"'"$cmd"'", N_("\1"), '$tag'},/
47-
p
48-
}' "Documentation/git-$cmd.txt"
52+
echo " {\"$cmd\", $(get_synopsis git-$cmd), $tag},"
4953
done
5054
echo "};"

0 commit comments

Comments
 (0)