diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2013-12-05 20:02:52 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-12-10 16:14:18 -0800 |
commit | f2c681cf12c54ce3859b36693f8a13c36126577b (patch) | |
tree | ab72b1abe85c0a0dd87fd8a853e19a7e20437be6 /send-pack.c | |
parent | c29a7b8b3f71c1bede1f57626bafe120280aaea3 (diff) | |
download | git-f2c681cf12c54ce3859b36693f8a13c36126577b.tar.gz |
send-pack: support pushing from a shallow clone via http
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 'send-pack.c')
-rw-r--r-- | send-pack.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/send-pack.c b/send-pack.c index cd536b4ed5..848d15e9b5 100644 --- a/send-pack.c +++ b/send-pack.c @@ -175,6 +175,21 @@ static int sideband_demux(int in, int out, void *data) return ret; } +static int advertise_shallow_grafts_cb(const struct commit_graft *graft, void *cb) +{ + struct strbuf *sb = cb; + if (graft->nr_parent == -1) + packet_buf_write(sb, "shallow %s\n", sha1_to_hex(graft->sha1)); + return 0; +} + +void advertise_shallow_grafts_buf(struct strbuf *sb) +{ + if (!is_repository_shallow()) + return; + for_each_commit_graft(advertise_shallow_grafts_cb, sb); +} + int send_pack(struct send_pack_args *args, int fd[], struct child_process *conn, struct ref *remote_refs, @@ -215,7 +230,7 @@ int send_pack(struct send_pack_args *args, } if (!args->dry_run) - advertise_shallow_grafts(out); + advertise_shallow_grafts_buf(&req_buf); /* * Finally, tell the other end! @@ -276,7 +291,7 @@ int send_pack(struct send_pack_args *args, } if (args->stateless_rpc) { - if (!args->dry_run && cmds_sent) { + if (!args->dry_run && (cmds_sent || is_repository_shallow())) { packet_buf_flush(&req_buf); send_sideband(out, -1, req_buf.buf, req_buf.len, LARGE_PACKET_MAX); } |