]> git.ipfire.org Git - thirdparty/git.git/commit - fetch-pack.c
fetch-pack: respect --no-update-shallow in v2
authorJonathan Tan <jonathantanmy@google.com>
Tue, 26 Mar 2019 19:31:21 +0000 (12:31 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 1 Apr 2019 06:35:56 +0000 (15:35 +0900)
commit1339078f5e670e5eb084a4a64c81a0d0b5f1e223
treed5aa57d8e3b2a959bb9ff4343db877c9875e4893
parent1e7d440b0a07ec8e71c107d0950ed1dc43b4d20c
fetch-pack: respect --no-update-shallow in v2

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 <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
fetch-pack.c