4 doc-diff [options] <from> <to> [-- <diff-options>]
6 j=n parallel argument to pass to make
7 f force rebuild; do not rely on cached results
10 .
"$(git --exec-path)/git-sh-setup"
29 if test -z "$parallel"
31 parallel
=$
(getconf _NPROCESSORS_ONLN
2>/dev
/null
)
32 if test $?
!= 0 ||
test -z "$parallel"
38 test $# -gt 1 || usage
42 from_oid
=$
(git rev-parse
--verify "$from") ||
exit 1
43 to_oid
=$
(git rev-parse
--verify "$to") ||
exit 1
46 tmp
=Documentation
/tmp-doc-diff
53 # We'll do both builds in a single worktree, which lets "make" reuse
54 # results that don't differ between the two trees.
55 if ! test -d "$tmp/worktree"
57 git worktree add
--detach "$tmp/worktree" "$from" &&
58 dots
=$
(echo "$tmp/worktree" |
sed 's#[^/]*#..#g') &&
59 ln -s "$dots/config.mak" "$tmp/worktree/config.mak"
62 # generate_render_makefile <srcdir> <dstdir>
63 generate_render_makefile
() {
68 printf 'all:: %s\n' "$dst"
69 printf '%s: %s\n' "$dst" "$src"
70 printf '\t@echo >&2 " RENDER $(notdir $@)" && \\\n'
71 printf '\tmkdir -p $(dir $@) && \\\n'
72 printf '\tMANWIDTH=80 man -l $< >$@+ && \\\n'
73 printf '\tmv $@+ $@\n'
77 # render_tree <dirname> <committish>
79 # Skip install-man entirely if we already have an installed directory.
80 # We can't rely on make here, since "install-man" unconditionally
81 # copies the files (spending effort, but also updating timestamps that
82 # we then can't rely on during the render step). We use "mv" to make
83 # sure we don't get confused by a previous run that failed partway
85 if ! test -d "$tmp/installed/$1"
87 git
-C "$tmp/worktree" checkout
"$2" &&
88 make -j$parallel -C "$tmp/worktree" \
91 DESTDIR
="$PWD/$tmp/installed/$1+" \
93 mv "$tmp/installed/$1+" "$tmp/installed/$1"
96 # As with "installed" above, we skip the render if it's already been
97 # done. So using make here is primarily just about running in
99 if ! test -d "$tmp/rendered/$1"
101 generate_render_makefile
"$tmp/installed/$1" "$tmp/rendered/$1+" |
102 make -j$parallel -f - &&
103 mv "$tmp/rendered/$1+" "$tmp/rendered/$1"
107 render_tree
$from_oid "$from" &&
108 render_tree
$to_oid "$to" &&
109 git
-C $tmp/rendered
diff --no-index "$@" $from_oid $to_oid