Skip to content

Commit 969560b

Browse files
committed
Merge branch 'sg/help-group' into maint
We rewrote one of the build scripts in Perl but this reimplements in Bourne shell. * sg/help-group: generate-cmdlist: re-implement as shell script
2 parents d11448f + 82aec45 commit 969560b

File tree

3 files changed

+52
-52
lines changed

3 files changed

+52
-52
lines changed

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1696,10 +1696,10 @@ $(BUILT_INS): git$X
16961696
ln -s $< $@ 2>/dev/null || \
16971697
cp $< $@
16981698

1699-
common-cmds.h: generate-cmdlist.perl command-list.txt
1699+
common-cmds.h: generate-cmdlist.sh command-list.txt
17001700

17011701
common-cmds.h: $(wildcard Documentation/git-*.txt)
1702-
$(QUIET_GEN)$(PERL_PATH) generate-cmdlist.perl command-list.txt > $@+ && mv $@+ $@
1702+
$(QUIET_GEN)./generate-cmdlist.sh command-list.txt >$@+ && mv $@+ $@
17031703

17041704
SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\
17051705
$(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\

generate-cmdlist.perl

Lines changed: 0 additions & 50 deletions
This file was deleted.

generate-cmdlist.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
3+
echo "/* Automatically generated by $0 */
4+
struct cmdname_help {
5+
char name[16];
6+
char help[80];
7+
unsigned char group;
8+
};
9+
10+
static const char *common_cmd_groups[] = {"
11+
12+
grps=grps$$.tmp
13+
match=match$$.tmp
14+
trap "rm -f '$grps' '$match'" 0 1 2 3 15
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'
25+
26+
n=0
27+
substnum=
28+
while read grp
29+
do
30+
echo "^git-..*[ ]$grp"
31+
substnum="$substnum${substnum:+;}s/[ ]$grp/$n/"
32+
n=$(($n+1))
33+
done <"$grps" >"$match"
34+
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
40+
do
41+
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"
49+
done
50+
echo "};"

0 commit comments

Comments
 (0)