Skip to content

Commit 2be39bb

Browse files
Martin Ågrengitster
authored andcommitted
doc-diff: support diffing from/to AsciiDoc(tor)
Provide `--from-asciidoctor` and `--to-asciidoctor` to select that the "from" resp. "to" commit should be built with Asciidoctor, and provide an `--asciidoctor` shortcut for giving both. Similarly, provide --{from-,to-,}asciidoc for explicitly selecting AsciiDoc. Implement this using the USE_ASCIIDOCTOR flag. Let's not enforce a default here, but instead just let the Makefile fall back on whatever is in config.mak, so that `./doc-diff foo bar` without any of of these new options behaves exactly like it did before this commit. Encode the choice into the directory names of our "installed" and "rendered" files, so that we can run `./doc-diff --from-asciidoc --to-asciidoctor HEAD HEAD` without our two runs stomping on each other. Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bc71dc3 commit 2be39bb

File tree

1 file changed

+45
-8
lines changed

1 file changed

+45
-8
lines changed

Documentation/doc-diff

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@ OPTIONS_SPEC="\
1212
doc-diff [options] <from> <to> [-- <diff-options>]
1313
doc-diff (-c|--clean)
1414
--
15-
j=n parallel argument to pass to make
16-
f force rebuild; do not rely on cached results
17-
c,clean cleanup temporary working files
15+
j=n parallel argument to pass to make
16+
f force rebuild; do not rely on cached results
17+
c,clean cleanup temporary working files
18+
from-asciidoc use asciidoc with the 'from'-commit
19+
from-asciidoctor use asciidoctor with the 'from'-commit
20+
asciidoc use asciidoc with both commits
21+
to-asciidoc use asciidoc with the 'to'-commit
22+
to-asciidoctor use asciidoctor with the 'to'-commit
23+
asciidoctor use asciidoctor with both commits
1824
"
1925
SUBDIRECTORY_OK=1
2026
. "$(git --exec-path)/git-sh-setup"
2127

2228
parallel=
2329
force=
2430
clean=
31+
from_program=
32+
to_program=
2533
while test $# -gt 0
2634
do
2735
case "$1" in
@@ -31,6 +39,20 @@ do
3139
clean=t ;;
3240
-f)
3341
force=t ;;
42+
--from-asciidoctor)
43+
from_program=-asciidoctor ;;
44+
--to-asciidoctor)
45+
to_program=-asciidoctor ;;
46+
--asciidoctor)
47+
from_program=-asciidoctor
48+
to_program=-asciidoctor ;;
49+
--from-asciidoc)
50+
from_program=-asciidoc ;;
51+
--to-asciidoc)
52+
to_program=-asciidoc ;;
53+
--asciidoc)
54+
from_program=-asciidoc
55+
to_program=-asciidoc ;;
3456
--)
3557
shift; break ;;
3658
*)
@@ -79,8 +101,21 @@ then
79101
ln -s "$dots/config.mak" "$tmp/worktree/config.mak"
80102
fi
81103

82-
from_dir=$from_oid &&
83-
to_dir=$to_oid &&
104+
construct_makemanflags () {
105+
if test "$1" = "-asciidoc"
106+
then
107+
echo USE_ASCIIDOCTOR=
108+
elif test "$1" = "-asciidoctor"
109+
then
110+
echo USE_ASCIIDOCTOR=YesPlease
111+
fi
112+
}
113+
114+
from_makemanflags=$(construct_makemanflags "$from_program") &&
115+
to_makemanflags=$(construct_makemanflags "$to_program") &&
116+
117+
from_dir=$from_oid$from_program &&
118+
to_dir=$to_oid$to_program &&
84119

85120
# generate_render_makefile <srcdir> <dstdir>
86121
generate_render_makefile () {
@@ -97,7 +132,7 @@ generate_render_makefile () {
97132
done
98133
}
99134

100-
# render_tree <committish_oid> <directory_name>
135+
# render_tree <committish_oid> <directory_name> <makemanflags>
101136
render_tree () {
102137
# Skip install-man entirely if we already have an installed directory.
103138
# We can't rely on make here, since "install-man" unconditionally
@@ -107,10 +142,12 @@ render_tree () {
107142
# through.
108143
oid=$1 &&
109144
dname=$2 &&
145+
makemanflags=$3 &&
110146
if ! test -d "$tmp/installed/$dname"
111147
then
112148
git -C "$tmp/worktree" checkout --detach "$oid" &&
113149
make -j$parallel -C "$tmp/worktree" \
150+
$makemanflags \
114151
GIT_VERSION=omitted \
115152
SOURCE_DATE_EPOCH=0 \
116153
DESTDIR="$tmp/installed/$dname+" \
@@ -130,6 +167,6 @@ render_tree () {
130167
fi
131168
}
132169

133-
render_tree $from_oid $from_dir &&
134-
render_tree $to_oid $to_dir &&
170+
render_tree $from_oid $from_dir $from_makemanflags &&
171+
render_tree $to_oid $to_dir $to_makemanflags &&
135172
git -C $tmp/rendered diff --no-index "$@" $from_dir $to_dir

0 commit comments

Comments
 (0)