<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/fetch-pack.c, branch v2.22.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.22.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.22.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2019-05-30T17:50:46Z</updated>
<entry>
<title>Merge branch 'jt/clone-server-option'</title>
<updated>2019-05-30T17:50:46Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-05-30T17:50:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=0e5387cd02482a0b7d42e78900cf3c0b13a39ee2'/>
<id>urn:sha1:0e5387cd02482a0b7d42e78900cf3c0b13a39ee2</id>
<content type='text'>
A brown-paper-bag bugfix to a change already in 'master'.

* jt/clone-server-option:
  fetch-pack: send server options after command
</content>
</entry>
<entry>
<title>fetch-pack: send server options after command</title>
<updated>2019-05-28T18:01:07Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2019-05-22T20:08:22Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=5b204b7df3ed7e97040d40db9d7c31a0a645af15'/>
<id>urn:sha1:5b204b7df3ed7e97040d40db9d7c31a0a645af15</id>
<content type='text'>
Currently, if any server options are specified during a protocol v2
fetch, server options will be sent before "command=fetch". Write server
options to the request buffer in send_fetch_request() so that the
components of the request are sent in the correct order.

The protocol documentation states that the command must come first. The
Git server implementation in serve.c (see process_request() in that
file) tolerates any order of command and capability, which is perhaps
why we haven't noticed this. This was noticed when testing against a
JGit server implementation, which follows the documentation in this
regard.

Signed-off-by: Jonathan Tan &lt;jonathantanmy@google.com&gt;
Acked-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'jk/fetch-reachability-error-fix'</title>
<updated>2019-04-25T07:41:23Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-25T07:41:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=57a6b93236f3b1667a1947d3fc83f6e942d3bfca'/>
<id>urn:sha1:57a6b93236f3b1667a1947d3fc83f6e942d3bfca</id>
<content type='text'>
Code clean-up and a fix for "git fetch" by an explicit object name
(as opposed to fetching refs by name).

* jk/fetch-reachability-error-fix:
  fetch: do not consider peeled tags as advertised tips
  remote.c: make singular free_ref() public
  fetch: use free_refs()
  pkt-line: prepare buffer before handling ERR packets
  upload-pack: send ERR packet for non-tip objects
  t5530: check protocol response for "not our ref"
  t5516: drop ok=sigpipe from unreachable-want tests
</content>
</entry>
<entry>
<title>Merge branch 'jt/fetch-no-update-shallow-in-proto-v2'</title>
<updated>2019-04-25T07:41:16Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-25T07:41:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=732ce7aaca15d32c1284d85498a0f2bda7406b95'/>
<id>urn:sha1:732ce7aaca15d32c1284d85498a0f2bda7406b95</id>
<content type='text'>
Fix for protocol v2 support in "git fetch-pack" of shallow clones.

* jt/fetch-no-update-shallow-in-proto-v2:
  fetch-pack: respect --no-update-shallow in v2
  fetch-pack: call prepare_shallow_info only if v0
</content>
</entry>
<entry>
<title>Merge branch 'jt/fetch-pack-wanted-refs-optim'</title>
<updated>2019-04-25T07:41:16Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-04-25T07:41:16Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=abd7ccdd4ddcc2d2ce1d51943051c071902b159a'/>
<id>urn:sha1:abd7ccdd4ddcc2d2ce1d51943051c071902b159a</id>
<content type='text'>
Performance fix around "git fetch" that grabs many refs.

* jt/fetch-pack-wanted-refs-optim:
  fetch-pack: binary search when storing wanted-refs
</content>
</entry>
<entry>
<title>fetch: do not consider peeled tags as advertised tips</title>
<updated>2019-04-15T05:00:52Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-04-13T05:57:37Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=34066f06614d6dbc1955c92ba0c3a17dbfeb0077'/>
<id>urn:sha1:34066f06614d6dbc1955c92ba0c3a17dbfeb0077</id>
<content type='text'>
Our filter_refs() function accidentally considers the target of a peeled
tag to be advertised by the server, even though upload-pack on the
server side does not consider it so. This can result in the client
making a bogus fetch to the server, which will end with the server
complaining "not our ref". Whereas the correct behavior is for the
client to notice that the server will not allow the request and error
out immediately.

So as bugs go, this is not very serious (the outcome is the same either
way -- the fetch fails). But it's worth making the logic here correct
and consistent with other related cases (e.g., fetching an oid that the
server did not mention at all).

The crux of the issue comes from fdb69d33c4 (fetch-pack: always allow
fetching of literal SHA1s, 2017-05-15). After that, the strategy of
filter_refs() is basically:

  - for each advertised ref, try to match it with a "sought" ref
    provided by the user. Skip any malformed refs (which includes
    peeled values like "refs/tags/foo^{}"), and place any unmatched
    items onto the unmatched list.

  - if there are unmatched sought refs, then put all of the advertised
    tips into an oidset, including the unmatched ones.

  - for each sought ref, see if it's in the oidset, in which case it's
    legal for us to ask the server for it

The problem is in the second step. Our list of unmatched refs includes
the peeled refs, even though upload-pack does not allow them to be
directly fetched. So the simplest fix would be to exclude them during
that step.

However, we can observe that the unmatched list isn't used for anything
else, and is freed at the end. We can just free those malformed refs
immediately. That saves us having to check each ref a second time to see
if it's malformed.

Note that this code only kicks in when "strict" is in effect. I.e., if
we are using the v0 protocol and uploadpack.allowReachableSHA1InWant is
not in effect. With v2, all oids are allowed, and we do not bother
creating or consulting the oidset at all. To future-proof our test
against the upcoming GIT_TEST_PROTOCOL_VERSION flag, we'll manually mark
it as a v0-only test.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fetch: use free_refs()</title>
<updated>2019-04-15T05:00:51Z</updated>
<author>
<name>Jeff King</name>
<email>peff@peff.net</email>
</author>
<published>2019-04-13T05:54:09Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=259eddde6a861cbff8186f37170f09566730f8eb'/>
<id>urn:sha1:259eddde6a861cbff8186f37170f09566730f8eb</id>
<content type='text'>
There's no need for us to write this loop manually when a helper
function can already do it.

Signed-off-by: Jeff King &lt;peff@peff.net&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fetch-pack: binary search when storing wanted-refs</title>
<updated>2019-04-01T06:51:05Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2019-03-27T21:11:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b7643009123216792aa158d3b2ca64a79adc01e2'/>
<id>urn:sha1:b7643009123216792aa158d3b2ca64a79adc01e2</id>
<content type='text'>
In do_fetch_pack_v2(), the "sought" array is sorted by name, and it is
not subsequently reordered (within the function). Therefore,
receive_wanted_refs() can assume that "sought" is sorted, and can thus
use a binary search when storing wanted-refs retrieved from the server.

Replace the existing linear search with a binary search. This improves
performance significantly when mirror cloning a repository with more
than 1 million refs.

Signed-off-by: Jonathan Tan &lt;jonathantanmy@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fetch-pack: respect --no-update-shallow in v2</title>
<updated>2019-04-01T06:35:56Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2019-03-26T19:31:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1339078f5e670e5eb084a4a64c81a0d0b5f1e223'/>
<id>urn:sha1:1339078f5e670e5eb084a4a64c81a0d0b5f1e223</id>
<content type='text'>
In protocol v0, when sending "shallow" lines, the server distinguishes
between lines caused by the remote repo being shallow and lines caused
by client-specified depth settings. Unless "--update-shallow" is
specified, there is a difference in behavior: refs that reach the former
"shallow" lines, but not the latter, are rejected. But in v2, the server
does not, and the client treats all "shallow" lines like lines caused by
client-specified depth settings.

Full restoration of v0 functionality is not possible without protocol
change, but we can implement a heuristic: if we specify any depth
setting, treat all "shallow" lines like lines caused by client-specified
depth settings (that is, unaffected by "--no-update-shallow"), but
otherwise, treat them like lines caused by the remote repo being shallow
(that is, affected by "--no-update-shallow"). This restores most of v0
behavior, except in the case where a client fetches from a shallow
repository with depth settings.

This patch causes a test that previously failed with
GIT_TEST_PROTOCOL_VERSION=2 to pass.

Signed-off-by: Jonathan Tan &lt;jonathantanmy@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>fetch-pack: call prepare_shallow_info only if v0</title>
<updated>2019-04-01T06:35:54Z</updated>
<author>
<name>Jonathan Tan</name>
<email>jonathantanmy@google.com</email>
</author>
<published>2019-03-26T19:31:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=1e7d440b0a07ec8e71c107d0950ed1dc43b4d20c'/>
<id>urn:sha1:1e7d440b0a07ec8e71c107d0950ed1dc43b4d20c</id>
<content type='text'>
In fetch_pack(), be clearer that there is no shallow information before
the fetch when v2 is used - memset the struct shallow_info to 0 instead
of calling prepare_shallow_info().

This patch is in preparation for a future patch in which a v2 fetch
might call prepare_shallow_info() after shallow info has been retrieved
during the fetch, so I needed to ensure that prepare_shallow_info() is
not called before the fetch.

Signed-off-by: Jonathan Tan &lt;jonathantanmy@google.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
