Subject: Re: What's cooking in git.git (Dec 2010, #05; Thu, 16)

From: Ramsay Jones <[email-masked]>
Date: Sat, 18 Dec 2010 22:00:26 +0000

Junio C Hamano wrote:
> 
> --------------------------------------------------
> [New Topics]
> 
> * rj/maint-difftool-cygwin-workaround (2010-12-14) 1 commit
>  - difftool: Fix failure on Cygwin
> 
> * rj/maint-test-fixes (2010-12-14) 5 commits
>  - t9501-*.sh: Fix a test failure on Cygwin
>  - lib-git-svn.sh: Add check for mis-configured web server variables

This lib-git-svn.sh patch (above) has a quite serious fault :(

I'm very annoyed with myself, because I was trying so hard to be
conservative and safe! :-P

The original branch containing these lib-git-svn.sh patches (#3-5 in the
original series) had another commit with the highly informative commit
message: WIP. I could not remember what this commit was about, or if it
was complete (but I thought not), so I didn't send it along with the
others ... Well, this evening I remembered what it was about, along
with the fact that it fixed a problem with the above and that I had
intended to squash all of these patches into one.

The problem with the above is this: because lib-git-svn.sh is sourced
by 57 test files, only four of which even remotely care about using
apache, if SVN_HTTPD_PORT is set and your apache install cannot be
found, then *all* 57 tests will be skipped.

Sorry about that ...

I've added a diff of the additional commit below (well, I changed a
couple of "test ! -e" to "test ! -f", given your comment on patch
04/14) so you can see that the fix will involve moving the code used
to check your apache installation into a separate function which will
only be called from start_httpd; ie only tests that want to use the
web-server will execute this code.

I'll send a proper patch soon. Again, I must apologize for messing up!

ATB,
Ramsay Jones

--- >8 ---
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 5acc0ec..d48fe6b 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -68,8 +68,7 @@ svn_cmd () {
 	svn "$orig_svncmd" --config-dir "$svnconf" "$@"
 }
 
-if test -n "$SVN_HTTPD_PORT"
-then
+prepare_httpd () {
 	for d in \
 		"$SVN_HTTPD_PATH" \
 		/usr/sbin/apache2 \
@@ -83,8 +82,8 @@ then
 	done
 	if test -z "$SVN_HTTPD_PATH"
 	then
-		skip_all='skipping git svn tests, Apache not found'
-		test_done
+		echo >&2 'Apache not found'
+		return 1
 	fi
 	for d in \
 		"$SVN_HTTPD_MODULE_PATH" \
@@ -99,10 +98,15 @@ then
 	done
 	if test -z "$SVN_HTTPD_MODULE_PATH"
 	then
-		skip_all='skipping git svn tests, Apache module dir not found'
-		test_done
+		echo >&2 'Apache module dir not found'
+		return 1
 	fi
-fi
+	if test ! -f "$SVN_HTTPD_MODULE_PATH/mod_dav_svn.so"
+	then
+		echo >&2 'Apache module "mod_dav_svn.so" not found'
+		return 1
+	fi
+}
 
 start_httpd () {
 	repo_base_path="$1"
@@ -111,11 +115,9 @@ start_httpd () {
 		echo >&2 'SVN_HTTPD_PORT is not defined!'
 		return
 	fi
-	if test ! -e "$SVN_HTTPD_MODULE_PATH/mod_dav_svn.so"
-	then
-		echo >&2 'Apache module "mod_dav_svn.so" not found'
-		return 1
-	fi
+
+	prepare_httpd || return 1
+
 	if test -z "$repo_base_path"
 	then
 		repo_base_path=svn
@@ -143,7 +145,7 @@ EOF
 
 stop_httpd () {
 	test -z "$SVN_HTTPD_PORT" && return
-	test ! -e "$GIT_DIR/httpd.conf" && return
+	test ! -f "$GIT_DIR/httpd.conf" && return
 	"$SVN_HTTPD_PATH" -f "$GIT_DIR"/httpd.conf -k stop
 }
 
--- 8< ---