aboutsummaryrefslogtreecommitdiff
path: root/upload-pack.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-12-05 20:02:32 +0700
committerJunio C Hamano <gitster@pobox.com>2013-12-10 16:14:16 -0800
commitad491366de6c883cd04539cb86db31049201dfbd (patch)
treef94ce53d28f70ad6d971c12567d0cb6dbb5d5615 /upload-pack.c
parent606e435a0a11634744282068174240caf2926fec (diff)
downloadgit-ad491366de6c883cd04539cb86db31049201dfbd.tar.gz
git-ad491366de6c883cd04539cb86db31049201dfbd.tar.xz
make the sender advertise shallow commits to the receiver
If either receive-pack or upload-pack is called on a shallow repository, shallow commits (*) will be sent after the ref advertisement (but before the packet flush), so that the receiver has the full "shape" of the sender's commit graph. This will be needed for the receiver to update its .git/shallow if necessary. This breaks the protocol for all clients trying to push to a shallow repo, or fetch from one. Which is basically the same end result as today's "is_repository_shallow() && die()" in receive-pack and upload-pack. New clients will be made aware of shallow upstream and can make use of this information. The sender must send all shallow commits that are sent in the following pack. It may send more shallow commits than necessary. upload-pack for example may choose to advertise no shallow commits if it knows in advance that the pack it's going to send contains no shallow commits. But upload-pack is the server, so we choose the cheaper way, send full .git/shallow and let the client deal with it. Smart HTTP is not affected by this patch. Shallow support on smart-http comes later separately. (*) A shallow commit is a commit that terminates the revision walker. It is usually put in .git/shallow in order to keep the revision walker from going out of bound because there is no guarantee that objects behind this commit is available. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'upload-pack.c')
-rw-r--r--upload-pack.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/upload-pack.c b/upload-pack.c
index c989a737f..38b2a2911 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -758,6 +758,7 @@ static void upload_pack(void)
reset_timeout();
head_ref_namespaced(send_ref, &symref);
for_each_namespaced_ref(send_ref, &symref);
+ advertise_shallow_grafts(1);
packet_flush(1);
} else {
head_ref_namespaced(mark_our_ref, NULL);
@@ -835,8 +836,9 @@ int main(int argc, char **argv)
if (!enter_repo(dir, strict))
die("'%s' does not appear to be a git repository", dir);
- if (is_repository_shallow())
- die("attempt to fetch/clone from a shallow repository");
+ if (is_repository_shallow() && stateless_rpc)
+ die("attempt to push into a shallow repository");
+
git_config(upload_pack_config, NULL);
upload_pack();
return 0;