git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / code / Atom feed
f70cbcc9cabf6499de57529cbfa095ed9eff73e3 blob 5511 bytes (raw)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
 
#!/bin/sh

test_description='test skipping fetch negotiator'
. ./test-lib.sh

have_sent () {
	while test "$#" -ne 0
	do
		grep "fetch> have $(git -C client rev-parse $1)" trace
		if test $? -ne 0
		then
			echo "No have $(git -C client rev-parse $1) ($1)"
			return 1
		fi
		shift
	done
}

have_not_sent () {
	while test "$#" -ne 0
	do
		grep "fetch> have $(git -C client rev-parse $1)" trace
		if test $? -eq 0
		then
			return 1
		fi
		shift
	done
}

# trace_fetch <client_dir> <server_dir> [args]
#
# Trace the packet output of fetch, but make sure we disable the variable
# in the child upload-pack, so we don't combine the results in the same file.
trace_fetch () {
	client=$1; shift
	server=$1; shift
	GIT_TRACE_PACKET="$(pwd)/trace" \
	git -C "$client" fetch \
	  --upload-pack 'unset GIT_TRACE_PACKET; git-upload-pack' \
	  "$server" "$@"
}

test_expect_success 'commits with no parents are sent regardless of skip distance' '
	git init server &&
	test_commit -C server to_fetch &&

	git init client &&
	for i in $(test_seq 7)
	do
		test_commit -C client c$i
	done &&

	# We send: "c7" (skip 1) "c5" (skip 2) "c2" (skip 4). After that, since
	# "c1" has no parent, it is still sent as "have" even though it would
	# normally be skipped.
	test_config -C client fetch.negotiationalgorithm skipping &&
	trace_fetch client "$(pwd)/server" &&
	have_sent c7 c5 c2 c1 &&
	have_not_sent c6 c4 c3
'

test_expect_success 'when two skips collide, favor the larger one' '
	rm -rf server client trace &&
	git init server &&
	test_commit -C server to_fetch &&

	git init client &&
	for i in $(test_seq 11)
	do
		test_commit -C client c$i
	done &&
	git -C client checkout c5 &&
	test_commit -C client c5side &&

	# Before reaching c5, we send "c5side" (skip 1) and "c11" (skip 1) "c9"
	# (skip 2) "c6" (skip 4). The larger skip (skip 4) takes precedence, so
	# the next "have" sent will be "c1" (from "c6" skip 4) and not "c4"
	# (from "c5side" skip 1).
	test_config -C client fetch.negotiationalgorithm skipping &&
	trace_fetch client "$(pwd)/server" &&
	have_sent c5side c11 c9 c6 c1 &&
	have_not_sent c10 c8 c7 c5 c4 c3 c2
'

test_expect_success 'use ref advertisement to filter out commits' '
	rm -rf server client trace &&
	git init server &&
	test_commit -C server c1 &&
	test_commit -C server c2 &&
	test_commit -C server c3 &&
	git -C server tag -d c1 c2 c3 &&

	git clone server client &&
	test_commit -C client c4 &&
	test_commit -C client c5 &&
	git -C client checkout c4^^ &&
	test_commit -C client c2side &&

	git -C server checkout --orphan anotherbranch &&
	test_commit -C server to_fetch &&

	# The server advertising "c3" (as "refs/heads/master") means that we do
	# not need to send any ancestors of "c3", but we still need to send "c3"
	# itself.
	test_config -C client fetch.negotiationalgorithm skipping &&

	# The ref advertisement itself is filtered when protocol v2 is used, so
	# use v0.
	GIT_TEST_PROTOCOL_VERSION= trace_fetch client origin to_fetch &&
	have_sent c5 c4^ c2side &&
	have_not_sent c4 c4^^ c4^^^
'

test_expect_success 'handle clock skew' '
	rm -rf server client trace &&
	git init server &&
	test_commit -C server to_fetch &&

	git init client &&

	# 2 regular commits
	test_tick=2000000000 &&
	test_commit -C client c1 &&
	test_commit -C client c2 &&

	# 4 old commits
	test_tick=1000000000 &&
	git -C client checkout c1 &&
	test_commit -C client old1 &&
	test_commit -C client old2 &&
	test_commit -C client old3 &&
	test_commit -C client old4 &&

	# "c2" and "c1" are popped first, then "old4" to "old1". "old1" would
	# normally be skipped, but is treated as a commit without a parent here
	# and sent, because (due to clock skew) its only parent has already been
	# popped off the priority queue.
	test_config -C client fetch.negotiationalgorithm skipping &&
	trace_fetch client "$(pwd)/server" &&
	have_sent c2 c1 old4 old2 old1 &&
	have_not_sent old3
'

test_expect_success 'do not send "have" with ancestors of commits that server ACKed' '
	rm -rf server client trace &&
	git init server &&
	test_commit -C server to_fetch &&

	git init client &&
	for i in $(test_seq 8)
	do
		git -C client checkout --orphan b$i &&
		test_commit -C client b$i.c0
	done &&
	for j in $(test_seq 19)
	do
		for i in $(test_seq 8)
		do
			git -C client checkout b$i &&
			test_commit -C client b$i.c$j
		done
	done &&

	# Copy this branch over to the server and add a commit on it so that it
	# is reachable but not advertised.
	git -C server fetch --no-tags "$(pwd)/client" b1:refs/heads/b1 &&
	git -C server checkout b1 &&
	test_commit -C server commit-on-b1 &&

	test_config -C client fetch.negotiationalgorithm skipping &&
	trace_fetch client "$(pwd)/server" to_fetch &&
	grep "  fetch" trace &&

	# fetch-pack sends 2 requests each containing 16 "have" lines before
	# processing the first response. In these 2 requests, 4 commits from
	# each branch are sent. Just check the first branch.
	have_sent b1.c19 b1.c17 b1.c14 b1.c9 &&
	have_not_sent b1.c18 b1.c16 b1.c15 b1.c13 b1.c12 b1.c11 b1.c10 &&

	# While fetch-pack is processing the first response, it should read that
	# the server ACKs b1.c19 and b1.c17.
	grep "fetch< ACK $(git -C client rev-parse b1.c19) common" trace &&
	grep "fetch< ACK $(git -C client rev-parse b1.c17) common" trace &&

	# fetch-pack should thus not send any more commits in the b1 branch, but
	# should still send the others (in this test, just check b2).
	for i in $(test_seq 0 8)
	do
		have_not_sent b1.c$i
	done &&
	have_sent b2.c1 b2.c0
'

test_done
debug log:

solving f70cbcc9ca ...
found f70cbcc9ca in git.git.git

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://7fh6tueqddpjyxjmgtdiueylzoqt6pt7hec3pukyptlmohoowvhde4yd.onion/inbox.comp.version-control.git
	nntp://ie5yzdi7fg72h7s4sdcztq5evakq23rdt33mfyfcddc5u3ndnw24ogqd.onion/inbox.comp.version-control.git
	nntp://4uok3hntl7oi7b4uf4rtfwefqeexfzil2w6kgk2jn5z2f764irre7byd.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git