]> git.ipfire.org Git - thirdparty/git.git/commit - connected.h
fetch-pack: write shallow, then check connectivity
authorJonathan Tan <jonathantanmy@google.com>
Mon, 2 Jul 2018 22:08:43 +0000 (15:08 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Jul 2018 21:57:44 +0000 (14:57 -0700)
commitcf1e7c07705eb21c30d0ee414810e7bc8fdf7d82
treedb2515073445cc5b9fdb89f6472f91ed8505a59c
parent733020517a1baa6f4f76bb7bf48d8d8d14eecd6c
fetch-pack: write shallow, then check connectivity

When fetching, connectivity is checked after the shallow file is
updated. There are 2 issues with this: (1) the connectivity check is
only performed up to ancestors of existing refs (which is not thorough
enough if we were deepening an existing ref in the first place), and (2)
there is no rollback of the shallow file if the connectivity check
fails.

To solve (1), update the connectivity check to check the ancestry chain
completely in the case of a deepening fetch by refraining from passing
"--not --all" when invoking rev-list in connected.c.

To solve (2), have fetch_pack() perform its own connectivity check
before updating the shallow file. To support existing use cases in which
"git fetch-pack" is used to download objects without much regard as to
the connectivity of the resulting objects with respect to the existing
repository, the connectivity check is only done if necessary (that is,
the fetch is not a clone, and the fetch involves shallow/deepen
functionality). "git fetch" still performs its own connectivity check,
preserving correctness but sometimes performing redundant work. This
redundancy is mitigated by the fact that fetch_pack() reports if it has
performed a connectivity check itself, and if the transport supports
connect or stateless-connect, it will bubble up that report so that "git
fetch" knows not to perform the connectivity check in such a case.

This was noticed when a user tried to deepen an existing repository by
fetching with --no-shallow from a server that did not send all necessary
objects - the connectivity check as run by "git fetch" succeeded, but a
subsequent "git fsck" failed.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/fetch.c
connected.c
connected.h
fetch-pack.c
fetch-pack.h
t/t5537-fetch-shallow.sh
transport.c
transport.h