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

[PATCH] Add a test for git-daemon and clone via git:// protocol

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 10, 2008, 13:45 UTC
Message-ID
<alpine.LSU.1.00.0802101343480.11591@racer.site>
In-Reply-To
<alpine.LSU.1.00.0802101210340.11591@racer.site>

The new test, t5703-daemon.sh, sets up a simple git-daemon at port 8111 (you can override it with the environment variable GIT_DAEMON_TEST_PORT), and then tries to clone via git:// from it, first without the git-daemon-export-ok file (which should fail), and then with it (which should succeed).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
	On Sun, 10 Feb 2008, Johannes Schindelin wrote:
	> On Sat, 9 Feb 2008, Junio C Hamano wrote:
	> 
	> > Thanks.  The patch makes sense.
	> > 
	> > I wonder this deserves a new test case to protect the fix from 
	> > future regressions.
	> 
	> It would probably make sense; this would also exercise 
	> git-daemon for the first time in our test suite.
	How's this?
 t/t5703-daemon.sh |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 55 insertions(+), 0 deletions(-)
 create mode 100755 t/t5703-daemon.sh
diff --git a/t/t5703-daemon.sh b/t/t5703-daemon.sh
new file mode 100755
index 0000000..10696a1
--- /dev/null
+++ b/t/t5703-daemon.sh
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+test_description='git daemon and cloning via git:// protocol'
+. ./test-lib.sh
+
+test_expect_success 'setup' '
+
+	mkdir first &&
+	(cd first &&
+	 git init &&
+	 echo biomimicry > ted &&
+	 git add ted &&
+	 test_tick &&
+	 git commit -m initial &&
+	 git gc)
+
+'
+
+PORT=${GIT_DAEMON_TEST_PORT:-8111}
+
+start_daemon () {
+	trap 'kill "$DAEMON_PID"' 0
+	git daemon --base-path="$(pwd)" \
+		--port="$PORT" \
+		--detach \
+		--pid-file=pid-file \
+		-- "$(pwd)/first"
+	DAEMON_PID=$(cat pid-file)
+}
+
+test_expect_success 'daemon' '
+
+	start_daemon &&
+	test -f pid-file
+
+'
+
+test_expect_success 'clone fails without export-ok' '
+
+	! git clone git://127.0.0.1:"$PORT"/first second
+
+'
+
+test_expect_success 'clone succeeds with export-ok' '
+
+	: > first/.git/git-daemon-export-ok &&
+	git clone git://127.0.0.1:"$PORT"/first second &&
+	for f in refs/heads/master objects/pack/*.pack
+	do
+		cmp first/.git/$f second/.git/$f || break
+	done
+
+'
+
+test_done
-- 
1.5.4.1264.gb53928
Previous: Johannes Schindelin
Message 8 of 8 in “Fix "git clone" for git:// protocol”
  1. Fix "git clone" for git:// protocolJohannes Schindelin, Feb 9, 2008
  2. Daniel BarkalowFeb 9, 2008
  3. Johannes SchindelinFeb 9, 2008
  4. Fix "git clone" for git:// protocolJohannes Schindelin, Feb 10, 2008
  5. Daniel BarkalowFeb 10, 2008
  6. Junio C HamanoFeb 10, 2008
  7. Johannes SchindelinFeb 10, 2008
  8. Add a test for git-daemon and clone via git:// protocolJohannes Schindelin, Feb 10, 2008

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.