Skip to content

Commit 27bd8ee

Browse files
committed
Merge branch 'ps/fewer-perl'
Reduce requirement for Perl in our documentation build and a few scripts. * ps/fewer-perl: Documentation: stop depending on Perl to generate command list Documentation: stop depending on Perl to massage user manual request-pull: stop depending on Perl filter-branch: stop depending on Perl
2 parents a819a3d + a7fa5b2 commit 27bd8ee

File tree

10 files changed

+191
-160
lines changed

10 files changed

+191
-160
lines changed

Documentation/Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ cmds_txt = cmds-ancillaryinterrogators.adoc \
317317

318318
$(cmds_txt): cmd-list.made
319319

320-
cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
321-
$(QUIET_GEN)$(PERL_PATH) ./cmd-list.perl .. . $(cmds_txt) && \
320+
cmd-list.made: cmd-list.sh ../command-list.txt $(MAN1_TXT)
321+
$(QUIET_GEN)$(SHELL_PATH) ./cmd-list.sh .. . $(cmds_txt) && \
322322
date >$@
323323

324324
mergetools-%.adoc: generate-mergetool-list.sh ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
@@ -398,9 +398,9 @@ user-manual.html: user-manual.xml $(XSLT)
398398
git.info: user-manual.texi
399399
$(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
400400

401-
user-manual.texi: user-manual.xml
401+
user-manual.texi: user-manual.xml fix-texi.sh
402402
$(QUIET_DB2TEXI)$(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@+ && \
403-
$(PERL_PATH) fix-texi.perl <$@+ >$@ && \
403+
$(SHELL_PATH) fix-texi.sh <$@+ >$@ && \
404404
$(RM) $@+
405405

406406
user-manual.pdf: user-manual.xml

Documentation/cmd-list.perl

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

Documentation/cmd-list.sh

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/bin/sh
2+
3+
set -e
4+
5+
format_one () {
6+
source_dir="$1"
7+
command="$2"
8+
attributes="$3"
9+
10+
path="$source_dir/Documentation/$command.adoc"
11+
if ! test -f "$path"
12+
then
13+
echo >&2 "No such file $path"
14+
exit 1
15+
fi
16+
17+
state=0
18+
while read line
19+
do
20+
case "$state" in
21+
0)
22+
case "$line" in
23+
git*\(*\)|scalar*\(*\))
24+
mansection="${line##*\(}"
25+
mansection="${mansection%\)}"
26+
;;
27+
NAME)
28+
state=1;;
29+
esac
30+
;;
31+
1)
32+
if test "$line" = "----"
33+
then
34+
state=2
35+
fi
36+
;;
37+
2)
38+
description="$line"
39+
break
40+
;;
41+
esac
42+
done <"$path"
43+
44+
if test -z "$mansection"
45+
then
46+
echo "No man section found in $path" >&2
47+
exit 1
48+
fi
49+
50+
if test -z "$description"
51+
then
52+
echo >&2 "No description found in $path"
53+
exit 1
54+
fi
55+
56+
case "$description" in
57+
"$command - "*)
58+
text="${description#$command - }"
59+
60+
printf "linkgit:%s[%s]::\n\t" "$command" "$mansection"
61+
case "$attributes" in
62+
*" deprecated "*)
63+
printf "(deprecated) "
64+
;;
65+
esac
66+
printf "$text.\n\n"
67+
;;
68+
*)
69+
echo >&2 "Description does not match $command: $description"
70+
exit 1
71+
;;
72+
esac
73+
}
74+
75+
source_dir="$1"
76+
build_dir="$2"
77+
shift 2
78+
79+
for out
80+
do
81+
category="${out#cmds-}"
82+
category="${category%.adoc}"
83+
path="$build_dir/$out"
84+
85+
while read command command_category attributes
86+
do
87+
case "$command" in
88+
"#"*)
89+
continue;;
90+
esac
91+
92+
case "$command_category" in
93+
"$category")
94+
format_one "$source_dir" "$command" " $attributes ";;
95+
esac
96+
done <"$source_dir/command-list.txt" >"$build_dir/$out+"
97+
98+
if cmp "$build_dir/$out+" "$build_dir/$out" >/dev/null 2>&1
99+
then
100+
rm "$build_dir/$out+"
101+
else
102+
mv "$build_dir/$out+" "$build_dir/$out"
103+
fi
104+
done

Documentation/fix-texi.perl

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

Documentation/fix-texi.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/sh
2+
3+
awk '
4+
/^@setfilename/{
5+
print "@setfilename git.info"
6+
next
7+
}
8+
/^@direntry/{
9+
direntry=1
10+
print "@dircategory Development"
11+
print "@direntry"
12+
print "* Git: (git). A fast distributed revision control system"
13+
print "@end direntry"
14+
next
15+
}
16+
/^@end direntry/{
17+
direntry=0
18+
next
19+
}
20+
!direntry
21+
'

Documentation/meson.build

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,12 +335,12 @@ cmd_lists = [
335335

336336
documentation_deps += custom_target(
337337
command: [
338-
perl,
338+
shell,
339339
'@INPUT@',
340340
meson.project_source_root(),
341341
meson.current_build_dir(),
342342
] + cmd_lists,
343-
input: 'cmd-list.perl',
343+
input: 'cmd-list.sh',
344344
output: cmd_lists
345345
)
346346

git-filter-branch.sh

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -295,15 +295,18 @@ then
295295
if test -n "$state_commit"
296296
then
297297
echo "Populating map from $state_branch ($state_commit)" 1>&2
298-
perl -e'open(MAP, "-|", "git show $ARGV[0]:filter.map") or die;
299-
while (<MAP>) {
300-
m/(.*):(.*)/ or die;
301-
open F, ">../map/$1" or die;
302-
print F "$2" or die;
303-
close(F) or die;
304-
}
305-
close(MAP) or die;' "$state_commit" \
306-
|| die "Unable to load state from $state_branch:filter.map"
298+
299+
git show "$state_commit:filter.map" >"$tempdir"/filter-map ||
300+
die "Unable to load state from $state_branch:filter.map"
301+
while read line
302+
do
303+
case "$line" in
304+
*:*)
305+
echo "${line%:*}" >../map/"${line#*:}";;
306+
*)
307+
die "Unable to load state from $state_branch:filter.map";;
308+
esac
309+
done <"$tempdir"/filter-map
307310
else
308311
echo "Branch $state_branch does not exist. Will create" 1>&2
309312
fi
@@ -633,15 +636,13 @@ if test -n "$state_branch"
633636
then
634637
echo "Saving rewrite state to $state_branch" 1>&2
635638
state_blob=$(
636-
perl -e'opendir D, "../map" or die;
637-
open H, "|-", "git hash-object -w --stdin" or die;
638-
foreach (sort readdir(D)) {
639-
next if m/^\.\.?$/;
640-
open F, "<../map/$_" or die;
641-
chomp($f = <F>);
642-
print H "$_:$f\n" or die;
643-
}
644-
close(H) or die;' || die "Unable to save state")
639+
for file in ../map/*
640+
do
641+
from_commit=$(basename "$file")
642+
to_commit=$(cat "$file")
643+
echo "$from_commit:$to_commit"
644+
done | git hash-object -w --stdin || die "Unable to save state"
645+
)
645646
state_tree=$(printf '100644 blob %s\tfilter.map\n' "$state_blob" | git mktree)
646647
if test -n "$state_commit"
647648
then

git-request-pull.sh

Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -78,41 +78,47 @@ fi
7878
merge_base=$(git merge-base $baserev $headrev) ||
7979
die "fatal: No commits in common between $base and $head"
8080

81-
# $head is the refname from the command line.
82-
# Find a ref with the same name as $head that exists at the remote
81+
find_matching_ref () {
82+
while read sha1 ref
83+
do
84+
case "$ref" in
85+
*"^"?*)
86+
ref="${ref%"^"*}"
87+
deref=true
88+
;;
89+
*)
90+
deref=
91+
;;
92+
esac
93+
94+
if test "$sha1" = "${remote:-HEAD}"
95+
then
96+
echo "$sha1 $sha1"
97+
break
98+
fi
99+
100+
case "$ref" in
101+
"${remote:-HEAD}"|*"/${remote:-HEAD}")
102+
if test -z "$deref"
103+
then
104+
# Remember the matching unpeeled object on the
105+
# remote side.
106+
remote_sha1="$sha1"
107+
fi
108+
109+
if test "$sha1" = "$headrev"
110+
then
111+
echo "${remote_sha1:-$headrev} $ref"
112+
break
113+
fi
114+
;;
115+
esac
116+
done
117+
}
118+
119+
# Find a ref with the same name as $remote that exists at the remote
83120
# and points to the same commit as the local object.
84-
find_matching_ref='
85-
my ($head,$headrev) = (@ARGV);
86-
my $pattern = qr{/\Q$head\E$};
87-
my ($remote_sha1, $found);
88-
89-
while (<STDIN>) {
90-
chomp;
91-
my ($sha1, $ref, $deref) = /^(\S+)\s+([^^]+)(\S*)$/;
92-
93-
if ($sha1 eq $head) {
94-
$found = $remote_sha1 = $sha1;
95-
break;
96-
}
97-
98-
if ($ref eq $head || $ref =~ $pattern) {
99-
if ($deref eq "") {
100-
# Remember the matching object on the remote side
101-
$remote_sha1 = $sha1;
102-
}
103-
if ($sha1 eq $headrev) {
104-
$found = $ref;
105-
break;
106-
}
107-
}
108-
}
109-
if ($found) {
110-
$remote_sha1 = $headrev if ! defined $remote_sha1;
111-
print "$remote_sha1 $found\n";
112-
}
113-
'
114-
115-
set fnord $(git ls-remote "$url" | @PERL_PATH@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev")
121+
set fnord $(git ls-remote "$url" | find_matching_ref)
116122
remote_sha1=$2
117123
ref=$3
118124

0 commit comments

Comments
 (0)