Blame SOURCES/t-lib-git-svn-try-harder-to-find-a-port-2.31.1.patch

96a48d
diff -ur b/t/lib-git-svn.sh c/t/lib-git-svn.sh
96a48d
--- b/t/lib-git-svn.sh	2021-03-26 23:03:34.000000000 +0100
96a48d
+++ c/t/lib-git-svn.sh	2023-01-26 13:39:32.822183929 +0100
96a48d
@@ -13,6 +13,7 @@
96a48d
 GIT_DIR=$PWD/.git
96a48d
 GIT_SVN_DIR=$GIT_DIR/svn/refs/remotes/git-svn
96a48d
 SVN_TREE=$GIT_SVN_DIR/svn-tree
96a48d
+SVNSERVE_PIDFILE="$PWD"/daemon.pid
96a48d
 test_set_port SVNSERVE_PORT
96a48d
 
96a48d
 svn >/dev/null 2>&1
96a48d
@@ -115,10 +116,35 @@
96a48d
 }
96a48d
 
96a48d
 start_svnserve () {
96a48d
-	svnserve --listen-port $SVNSERVE_PORT \
96a48d
-		 --root "$rawsvnrepo" \
96a48d
-		 --listen-once \
96a48d
-		 --listen-host 127.0.0.1 &
96a48d
+	test_atexit stop_svnserve
96a48d
+
96a48d
+	i=0
96a48d
+	while test $i -lt ${GIT_TEST_START_SVNSERVE_TRIES:-3}
96a48d
+	do
96a48d
+		say >&3 "Starting svnserve on port $SVNSERVE_PORT ..."
96a48d
+		svnserve --listen-port $SVNSERVE_PORT \
96a48d
+			 --root "$rawsvnrepo" \
96a48d
+			 --daemon --pid-file="$SVNSERVE_PIDFILE" \
96a48d
+			 --listen-host 127.0.0.1
96a48d
+		ret=$?
96a48d
+		# increment port and retry if unsuccessful
96a48d
+		if test $ret -ne 0
96a48d
+		then
96a48d
+			SVNSERVE_PORT=$(($SVNSERVE_PORT + 1))
96a48d
+			export SVNSERVE_PORT
96a48d
+		else
96a48d
+			break
96a48d
+		fi
96a48d
+	done
96a48d
+}
96a48d
+
96a48d
+stop_svnserve () {
96a48d
+	say >&3 "Stopping svnserve ..."
96a48d
+	SVNSERVE_PID="$(cat "$SVNSERVE_PIDFILE")"
96a48d
+	if test -n "$SVNSERVE_PID"
96a48d
+	then
96a48d
+		kill "$SVNSERVE_PID" 2>/dev/null
96a48d
+	fi
96a48d
 }
96a48d
 
96a48d
 prepare_a_utf8_locale () {
96a48d
diff -ur b/t/t9113-git-svn-dcommit-new-file.sh c/t/t9113-git-svn-dcommit-new-file.sh
96a48d
--- b/t/t9113-git-svn-dcommit-new-file.sh	2021-03-26 23:03:34.000000000 +0100
96a48d
+++ c/t/t9113-git-svn-dcommit-new-file.sh	2023-01-26 13:39:30.314168109 +0100
96a48d
@@ -28,7 +28,6 @@
96a48d
 	echo hello > git-new-dir/world &&
96a48d
 	git update-index --add git-new-dir/world &&
96a48d
 	git commit -m hello &&
96a48d
-	start_svnserve &&
96a48d
 	git svn dcommit
96a48d
 	"
96a48d