git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/4] doc-diff: let `render_tree()` take an explicit directory name

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Mar 17, 2019, 18:36 UTC
Message-ID
<249372bed148417dcc77423f53e7f5f7d7a67757.1552838239.git.martin.agren@gmail.com>
In-Reply-To
<cover.1552838239.git.martin.agren@gmail.com>

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 <martin.agren@gmail.com>
---
 Documentation/doc-diff | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/Documentation/doc-diff b/Documentation/doc-diff
index 32c83dd26f..3e975d3c5d 100755
--- a/Documentation/doc-diff
+++ b/Documentation/doc-diff
@@ -79,6 +79,9 @@ then
 	ln -s "$dots/config.mak" "$tmp/worktree/config.mak"
 fi
 
+from_dir=$from_oid &&
+to_dir=$to_oid &&
+
 # generate_render_makefile <srcdir> <dstdir>
 generate_render_makefile () {
 	find "$1" -type f |
@@ -94,7 +97,7 @@ generate_render_makefile () {
 	done
 }
 
-# render_tree <committish_oid>
+# render_tree <committish_oid> <directory_name>
 render_tree () {
 	# Skip install-man entirely if we already have an installed directory.
 	# We can't rely on make here, since "install-man" unconditionally
@@ -102,28 +105,31 @@ render_tree () {
 	# we then can't rely on during the render step). We use "mv" to make
 	# sure we don't get confused by a previous run that failed partway
 	# through.
-	if ! test -d "$tmp/installed/$1"
+	oid=$1 &&
+	dname=$2 &&
+	if ! test -d "$tmp/installed/$dname"
 	then
-		git -C "$tmp/worktree" checkout --detach "$1" &&
+		git -C "$tmp/worktree" checkout --detach "$oid" &&
 		make -j$parallel -C "$tmp/worktree" \
 			GIT_VERSION=omitted \
 			SOURCE_DATE_EPOCH=0 \
-			DESTDIR="$tmp/installed/$1+" \
+			DESTDIR="$tmp/installed/$dname+" \
 			install-man &&
-		mv "$tmp/installed/$1+" "$tmp/installed/$1"
+		mv "$tmp/installed/$dname+" "$tmp/installed/$dname"
 	fi &&
 
 	# As with "installed" above, we skip the render if it's already been
 	# done.  So using make here is primarily just about running in
 	# parallel.
-	if ! test -d "$tmp/rendered/$1"
+	if ! test -d "$tmp/rendered/$dname"
 	then
-		generate_render_makefile "$tmp/installed/$1" "$tmp/rendered/$1+" |
+		generate_render_makefile "$tmp/installed/$dname" \
+			"$tmp/rendered/$dname+" |
 		make -j$parallel -f - &&
-		mv "$tmp/rendered/$1+" "$tmp/rendered/$1"
+		mv "$tmp/rendered/$dname+" "$tmp/rendered/$dname"
 	fi
 }
 
-render_tree $from_oid &&
-render_tree $to_oid &&
-git -C $tmp/rendered diff --no-index "$@" $from_oid $to_oid
+render_tree $from_oid $from_dir &&
+render_tree $to_oid $to_dir &&
+git -C $tmp/rendered diff --no-index "$@" $from_dir $to_dir
-- 
2.21.0
Previous: Martin ÅgrenNext: Martin Ågren
Message 3 of 8 in “doc-diff: support diffing from/to AsciiDoc(tor)”
  1. 0/4 doc-diff: support diffing from/to AsciiDoc(tor)Martin Ågren, Mar 17, 2019
  2. 1/4 Doc: auto-detect changed build flagsMartin Ågren, Mar 17, 2019
  3. 2/4 doc-diff: let `render_tree()` take an explicit directory nameMartin Ågren, Mar 17, 2019
  4. 3/4 doc-diff: support diffing from/to AsciiDoc(tor)Martin Ågren, Mar 17, 2019
  5. 4/4 doc-diff: add `--cut-header-footer`Martin Ågren, Mar 17, 2019
  6. Junio C HamanoMar 18, 2019
  7. Jeff KingMar 19, 2019
  8. Martin ÅgrenMar 20, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.