Skip to content

Commit bc71dc3

Browse files
Martin Ågrengitster
authored andcommitted
doc-diff: let render_tree() take an explicit directory name
In `render_tree()`, `$1` is documented to be the commit-ish/oid and we use it as that with `git checkout`, but we mostly use it to form the name of various directories. To separate these concerns, and because we are about to construct the directory names a bit differently, take two distinct arguments instead. Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9a71722 commit bc71dc3

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

Documentation/doc-diff

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,9 @@ then
7979
ln -s "$dots/config.mak" "$tmp/worktree/config.mak"
8080
fi
8181

82+
from_dir=$from_oid &&
83+
to_dir=$to_oid &&
84+
8285
# generate_render_makefile <srcdir> <dstdir>
8386
generate_render_makefile () {
8487
find "$1" -type f |
@@ -94,36 +97,39 @@ generate_render_makefile () {
9497
done
9598
}
9699

97-
# render_tree <committish_oid>
100+
# render_tree <committish_oid> <directory_name>
98101
render_tree () {
99102
# Skip install-man entirely if we already have an installed directory.
100103
# We can't rely on make here, since "install-man" unconditionally
101104
# copies the files (spending effort, but also updating timestamps that
102105
# we then can't rely on during the render step). We use "mv" to make
103106
# sure we don't get confused by a previous run that failed partway
104107
# through.
105-
if ! test -d "$tmp/installed/$1"
108+
oid=$1 &&
109+
dname=$2 &&
110+
if ! test -d "$tmp/installed/$dname"
106111
then
107-
git -C "$tmp/worktree" checkout --detach "$1" &&
112+
git -C "$tmp/worktree" checkout --detach "$oid" &&
108113
make -j$parallel -C "$tmp/worktree" \
109114
GIT_VERSION=omitted \
110115
SOURCE_DATE_EPOCH=0 \
111-
DESTDIR="$tmp/installed/$1+" \
116+
DESTDIR="$tmp/installed/$dname+" \
112117
install-man &&
113-
mv "$tmp/installed/$1+" "$tmp/installed/$1"
118+
mv "$tmp/installed/$dname+" "$tmp/installed/$dname"
114119
fi &&
115120

116121
# As with "installed" above, we skip the render if it's already been
117122
# done. So using make here is primarily just about running in
118123
# parallel.
119-
if ! test -d "$tmp/rendered/$1"
124+
if ! test -d "$tmp/rendered/$dname"
120125
then
121-
generate_render_makefile "$tmp/installed/$1" "$tmp/rendered/$1+" |
126+
generate_render_makefile "$tmp/installed/$dname" \
127+
"$tmp/rendered/$dname+" |
122128
make -j$parallel -f - &&
123-
mv "$tmp/rendered/$1+" "$tmp/rendered/$1"
129+
mv "$tmp/rendered/$dname+" "$tmp/rendered/$dname"
124130
fi
125131
}
126132

127-
render_tree $from_oid &&
128-
render_tree $to_oid &&
129-
git -C $tmp/rendered diff --no-index "$@" $from_oid $to_oid
133+
render_tree $from_oid $from_dir &&
134+
render_tree $to_oid $to_dir &&
135+
git -C $tmp/rendered diff --no-index "$@" $from_dir $to_dir

0 commit comments

Comments
 (0)