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 <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin Ågren committed Mar 17, 2019 at 19:36 UTC 2be39bb43da52680fbf60b2353033b908bd4eadf
1 file changed +45 -8
Documentation/doc-diff
+45 -8
@@ -12,9 +12,15 @@ OPTIONS_SPEC="\
12 doc-diff [options] <from> <to> [-- <diff-options>]
13 doc-diff (-c|--clean)
14 --
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
24 "
25 SUBDIRECTORY_OK=1
26 . "$(git --exec-path)/git-sh-setup"
@@ -22,6 +28,8 @@ SUBDIRECTORY_OK=1
28 parallel=
29 force=
30 clean=
31 +from_program=
32 +to_program=
33 while test $# -gt 0
34 do
35 case "$1" in
@@ -31,6 +39,20 @@ do
39 clean=t ;;
40 -f)
41 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 ;;
56 --)
57 shift; break ;;
58 *)
@@ -79,8 +101,21 @@ then
101 ln -s "$dots/config.mak" "$tmp/worktree/config.mak"
102 fi
103
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 &&
119
120 # generate_render_makefile <srcdir> <dstdir>
121 generate_render_makefile () {
@@ -97,7 +132,7 @@ generate_render_makefile () {
132 done
133 }
134
100 -# render_tree <committish_oid> <directory_name>
135 +# render_tree <committish_oid> <directory_name> <makemanflags>
136 render_tree () {
137 # Skip install-man entirely if we already have an installed directory.
138 # We can't rely on make here, since "install-man" unconditionally
@@ -107,10 +142,12 @@ render_tree () {
142 # through.
143 oid=$1 &&
144 dname=$2 &&
145 + makemanflags=$3 &&
146 if ! test -d "$tmp/installed/$dname"
147 then
148 git -C "$tmp/worktree" checkout --detach "$oid" &&
149 make -j$parallel -C "$tmp/worktree" \
150 + $makemanflags \
151 GIT_VERSION=omitted \
152 SOURCE_DATE_EPOCH=0 \
153 DESTDIR="$tmp/installed/$dname+" \
@@ -130,6 +167,6 @@ render_tree () {
167 fi
168 }
169
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 &&
172 git -C $tmp/rendered diff --no-index "$@" $from_dir $to_dir