git: 431944fb5fff - main - etcupdate: Don't rotate trees for a dry run.

From: John Baldwin <jhb_at_FreeBSD.org>
Date: Wed, 25 May 2022 21:03:02 UTC
The branch main has been updated by jhb:

URL: https://cgit.FreeBSD.org/src/commit/?id=431944fb5ffff5ad56e720b75b7beecdc4878e0e

commit 431944fb5ffff5ad56e720b75b7beecdc4878e0e
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2022-05-25 21:02:51 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2022-05-25 21:02:51 +0000

    etcupdate: Don't rotate trees for a dry run.
    
    When performing a dry run, remove the temporary tree created rather
    than rotating the trees.  Rotating the trees meant that etcupdate
    thought the latest changes were already merged and would not merge
    them on the next real run.
    
    PR:             260281
    Reported by:    Tomoaki AOKI <junchoon@dec.sakura.ne.jp>
    Fixes:          0611aec3cf3a etcupdate: Always extract to a temporary tree.
    MFC after:      1 week
---
 usr.sbin/etcupdate/etcupdate.sh | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/usr.sbin/etcupdate/etcupdate.sh b/usr.sbin/etcupdate/etcupdate.sh
index 40868fe6586e..1618fab59fe6 100755
--- a/usr.sbin/etcupdate/etcupdate.sh
+++ b/usr.sbin/etcupdate/etcupdate.sh
@@ -1612,6 +1612,18 @@ EOF
 		cat $WARNINGS
 	fi
 
+	# If this was a dryrun, remove the temporary tree if we built
+	# a new one.
+	if [ -n "$dryrun" ]; then
+		if [ -n "$dir" ]; then
+			if [ -n "$rerun" ]; then
+				panic "Should not have a temporary directory"
+			fi
+			remove_tree $dir
+		fi
+		return
+	fi
+
 	# Finally, rotate any needed trees.
 	if [ "$new" != "$NEWTREE" ]; then
 		if [ -n "$rerun" ]; then