Skip to content

Commit bd4d9d9

Browse files
peffgitster
authored andcommitted
t/interop: add test of old clients against modern git-daemon
This test just checks that old clients can clone and fetch from a newer git-daemon. The opposite should also be true, but it's hard to test ancient versions of git-daemon because they lack basic options like "--listen". Note that we have to make a slight tweak to the lib-git-daemon helper from the regular tests, so that it starts the daemon with our correct git.a version. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3d89361 commit bd4d9d9

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

t/interop/i5500-git-daemon.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/sh
2+
3+
VERSION_A=.
4+
VERSION_B=v1.0.0
5+
6+
: ${LIB_GIT_DAEMON_PORT:=5500}
7+
LIB_GIT_DAEMON_COMMAND='git.a daemon'
8+
9+
test_description='clone and fetch by older client'
10+
. ./interop-lib.sh
11+
. "$TEST_DIRECTORY"/lib-git-daemon.sh
12+
13+
start_git_daemon --export-all
14+
15+
repo=$GIT_DAEMON_DOCUMENT_ROOT_PATH/repo
16+
17+
test_expect_success "create repo served by $VERSION_A" '
18+
git.a init "$repo" &&
19+
git.a -C "$repo" commit --allow-empty -m one
20+
'
21+
22+
test_expect_success "clone with $VERSION_B" '
23+
git.b clone "$GIT_DAEMON_URL/repo" child &&
24+
echo one >expect &&
25+
git.a -C child log -1 --format=%s >actual &&
26+
test_cmp expect actual
27+
'
28+
29+
test_expect_success "fetch with $VERSION_B" '
30+
git.a -C "$repo" commit --allow-empty -m two &&
31+
(
32+
cd child &&
33+
git.b fetch
34+
) &&
35+
echo two >expect &&
36+
git.a -C child log -1 --format=%s FETCH_HEAD >actual &&
37+
test_cmp expect actual
38+
'
39+
40+
stop_git_daemon
41+
test_done

t/lib-git-daemon.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ start_git_daemon() {
4646

4747
say >&3 "Starting git daemon ..."
4848
mkfifo git_daemon_output
49-
git daemon --listen=127.0.0.1 --port="$LIB_GIT_DAEMON_PORT" \
49+
${LIB_GIT_DAEMON_COMMAND:-git daemon} \
50+
--listen=127.0.0.1 --port="$LIB_GIT_DAEMON_PORT" \
5051
--reuseaddr --verbose \
5152
--base-path="$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
5253
"$@" "$GIT_DAEMON_DOCUMENT_ROOT_PATH" \

0 commit comments

Comments
 (0)