Skip to content

Commit fd4bd1e

Browse files
committed
TO-SPLIT
A proof-of-concept how to test for `git push` via `git://`, intended as a starter patch for git-for-windows#2375. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent e900821 commit fd4bd1e

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

daemon.c

+14
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ static enum log_destination {
1515
LOG_DESTINATION_STDERR = 1,
1616
LOG_DESTINATION_SYSLOG = 2,
1717
} log_destination = LOG_DESTINATION_UNSET;
18+
static FILE *log_tee_file;
1819
static int verbose;
1920
static int reuseaddr;
2021
static int informative_errors;
@@ -88,6 +89,13 @@ static void logreport(int priority, const char *err, va_list params)
8889
break;
8990
}
9091
case LOG_DESTINATION_STDERR:
92+
if (log_tee_file) {
93+
fprintf(log_tee_file, "[%"PRIuMAX"] ",
94+
(uintmax_t)getpid());
95+
vfprintf(log_tee_file, err, params);
96+
fputc('\n', log_tee_file);
97+
fflush(log_tee_file);
98+
}
9199
/*
92100
* Since stderr is set to buffered mode, the
93101
* logging of different processes will not overlap
@@ -1317,6 +1325,12 @@ int cmd_main(int argc, const char **argv)
13171325
} else if (!strcmp(v, "stderr")) {
13181326
log_destination = LOG_DESTINATION_STDERR;
13191327
continue;
1328+
} else if (skip_prefix(v, "tee:", &v)) {
1329+
log_destination = LOG_DESTINATION_STDERR;
1330+
if (log_tee_file)
1331+
fclose(log_tee_file);
1332+
log_tee_file = xfopen(v, "a");
1333+
continue;
13201334
} else if (!strcmp(v, "none")) {
13211335
log_destination = LOG_DESTINATION_NONE;
13221336
continue;

t/lib-git-daemon.sh

+10-13
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,6 @@ then
2121
test_done
2222
fi
2323

24-
if test_have_prereq !PIPE
25-
then
26-
test_skip_or_die GIT_TEST_GIT_DAEMON "file system does not support FIFOs"
27-
fi
28-
2924
test_set_port LIB_GIT_DAEMON_PORT
3025

3126
GIT_DAEMON_PID=
@@ -52,21 +47,23 @@ start_git_daemon() {
5247
fi
5348

5449
say >&3 "Starting git daemon ..."
55-
mkfifo git_daemon_output
5650
${LIB_GIT_DAEMON_COMMAND:-git daemon} \
5751
--listen=127.0.0.1 --port="$LIB_GIT_DAEMON_PORT" \
5852
--reuseaddr --verbose --pid-file="$GIT_DAEMON_PIDFILE" \
53+
--log-destination=tee:git_daemon_output \
5954
--base-path="$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
6055
"$@" "$GIT_DAEMON_DOCUMENT_ROOT_PATH" \
61-
>&3 2>git_daemon_output &
56+
>&3 2>&4 &
6257
GIT_DAEMON_PID=$!
63-
{
64-
read -r line <&7
65-
printf "%s\n" "$line" >&4
66-
cat <&7 >&4 &
67-
} 7<git_daemon_output &&
58+
59+
# Wait for the first line in the output
60+
while test ! -s git_daemon_output
61+
do
62+
sleep 1
63+
done
6864

6965
# Check expected output
66+
read -r line <git_daemon_output
7067
if test x"$(expr "$line" : "\[[0-9]*\] \(.*\)")" != x"Ready to rumble"
7168
then
7269
kill "$GIT_DAEMON_PID"
@@ -88,7 +85,7 @@ stop_git_daemon() {
8885
kill "$GIT_DAEMON_PID"
8986
wait "$GIT_DAEMON_PID" >&3 2>&4
9087
ret=$?
91-
if ! test_match_signal 15 $ret
88+
if ! test_match_signal 15 $ret && test 127 != $ret
9289
then
9390
error "git daemon exited with status: $ret"
9491
fi

t/t5700-protocol-v1.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ test_expect_success 'pull with git:// using protocol v1' '
6767
test_expect_success 'push with git:// using protocol v1' '
6868
test_commit -C daemon_child three &&
6969
70+
if test_have_prereq MINGW
71+
then
72+
test_config -C daemon_child sendpack.sideband false
73+
fi &&
74+
7075
# Push to another branch, as the target repository has the
7176
# master branch checked out and we cannot push into it.
7277
GIT_TRACE_PACKET=1 git -C daemon_child -c protocol.version=1 \
@@ -169,7 +174,7 @@ test_expect_success 'create repo to be served by ssh:// transport' '
169174

170175
test_expect_success 'clone with ssh:// using protocol v1' '
171176
GIT_TRACE_PACKET=1 git -c protocol.version=1 \
172-
clone "ssh://myhost:$(pwd)/ssh_parent" ssh_child 2>log &&
177+
clone "ssh://myhost:$PWD/ssh_parent" ssh_child 2>log &&
173178
expect_ssh git-upload-pack &&
174179
175180
git -C ssh_child log -1 --format=%s >actual &&

0 commit comments

Comments
 (0)