summaryrefslogtreecommitdiff
path: root/builtin-send-pack.c
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2008-09-25 09:39:24 -0700
committerShawn O. Pearce <spearce@spearce.org>2008-09-25 09:39:24 -0700
commit1ad6d46235d135582d5cbb91ec0186b485c7b5c1 (patch)
treee4a98d08b88862305d9f13ccef82180de33e8bcc /builtin-send-pack.c
parent6ef1daf77202aee71056771d91dd12121c6061fd (diff)
parentd79796bcf05b89774671a75b3285000c43129823 (diff)
downloadgit-1ad6d46235d135582d5cbb91ec0186b485c7b5c1.tar.gz
Merge branch 'jc/alternate-push'
* jc/alternate-push: push: receiver end advertises refs from alternate repositories push: prepare sender to receive extended ref information from the receiver receive-pack: make it a builtin is_directory(): a generic helper function
Diffstat (limited to 'builtin-send-pack.c')
-rw-r--r--builtin-send-pack.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 2af9f29341..910db92b62 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -18,7 +18,7 @@ static struct send_pack_args args = {
/*
* Make a pack stream and spit it out into file descriptor fd
*/
-static int pack_objects(int fd, struct ref *refs)
+static int pack_objects(int fd, struct ref *refs, struct extra_have_objects *extra)
{
/*
* The child becomes pack-objects --revs; we feed
@@ -34,6 +34,8 @@ static int pack_objects(int fd, struct ref *refs)
NULL,
};
struct child_process po;
+ int i;
+ char buf[42];
if (args.use_thin_pack)
argv[4] = "--thin";
@@ -49,9 +51,15 @@ static int pack_objects(int fd, struct ref *refs)
* We feed the pack-objects we just spawned with revision
* parameters by writing to the pipe.
*/
- while (refs) {
- char buf[42];
+ for (i = 0; i < extra->nr; i++) {
+ memcpy(buf + 1, sha1_to_hex(&extra->array[i][0]), 40);
+ buf[0] = '^';
+ buf[41] = '\n';
+ if (!write_or_whine(po.in, buf, 42, "send-pack: send refs"))
+ break;
+ }
+ while (refs) {
if (!is_null_sha1(refs->old_sha1) &&
has_sha1_file(refs->old_sha1)) {
memcpy(buf + 1, sha1_to_hex(refs->old_sha1), 40);
@@ -381,14 +389,17 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
int expect_status_report = 0;
int flags = MATCH_REFS_NONE;
int ret;
+ struct extra_have_objects extra_have;
+ memset(&extra_have, 0, sizeof(extra_have));
if (args.send_all)
flags |= MATCH_REFS_ALL;
if (args.send_mirror)
flags |= MATCH_REFS_MIRROR;
/* No funny business with the matcher */
- remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, REF_NORMAL);
+ remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, REF_NORMAL,
+ &extra_have);
get_local_heads();
/* Does the other end support the reporting? */
@@ -496,7 +507,7 @@ static int do_send_pack(int in, int out, struct remote *remote, const char *dest
packet_flush(out);
if (new_refs && !args.dry_run) {
- if (pack_objects(out, remote_refs) < 0)
+ if (pack_objects(out, remote_refs, &extra_have) < 0)
return -1;
}
else