]> git.ipfire.org Git - thirdparty/git.git/blobdiff - shallow.c
make the sender advertise shallow commits to the receiver
[thirdparty/git.git] / shallow.c
index cdf37d694de175adcce10fa2e2a79c6579603b0b..f2c04b28dca0404fe00cdd6f2e2f9424d28aed32 100644 (file)
--- a/shallow.c
+++ b/shallow.c
@@ -220,3 +220,18 @@ void setup_alternate_shallow(struct lock_file *shallow_lock,
                *alternate_shallow_file = "";
        strbuf_release(&sb);
 }
+
+static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *cb)
+{
+       int fd = *(int *)cb;
+       if (graft->nr_parent == -1)
+               packet_write(fd, "shallow %s\n", sha1_to_hex(graft->sha1));
+       return 0;
+}
+
+void advertise_shallow_grafts(int fd)
+{
+       if (!is_repository_shallow())
+               return;
+       for_each_commit_graft(advertise_shallow_grafts_cb, &fd);
+}