Skip to content

Commit 71406ed

Browse files
peffgitster
authored andcommitted
t5400: avoid concurrent writes into a trace file
One test in t5400 examines the packet exchange between git-push and git-receive-pack. The latter inherits the GIT_TRACE_PACKET environment variable, so that both processes dump trace data into the same file concurrently. This should not be a problem because the trace file is opened with O_APPEND. On Windows, however, O_APPEND is not atomic as it should be: it is emulated as lseek(SEEK_END) followed by write(). For this reason, the test is unreliable: it can happen that one process overwrites a line that was just written by the other process. As a consequence, the test sometimes does not find one or another line that is expected (and it is also successful occasionally). The test case is actually only interested in the output of git-push. To ensure that only git-push writes to the trace file, override the receive-pack command such that it does not even open the trace file. Reported-by: Johannes Sixt <[email protected]> Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 63d428e commit 71406ed

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

t/t5400-send-pack.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,10 @@ test_expect_success 'receive-pack de-dupes .have lines' '
288288
$shared .have
289289
EOF
290290
291-
GIT_TRACE_PACKET=$(pwd)/trace git push fork HEAD:foo &&
291+
GIT_TRACE_PACKET=$(pwd)/trace \
292+
git push \
293+
--receive-pack="unset GIT_TRACE_PACKET; git-receive-pack" \
294+
fork HEAD:foo &&
292295
extract_ref_advertisement <trace >refs &&
293296
test_cmp expect refs
294297
'

0 commit comments

Comments
 (0)