X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=builtin-send-pack.c;h=910db92b62eb6dd91a4002b2643fef4a76ec8f83;hb=276328ffb87cefdc515bee5f09916aea6e0244ed;hp=d76260c09eef064d8a2862b5d6f0e826d968d643;hpb=c636d0e2bcffdbd55c096944561d9ac470da600e;p=git.git diff --git a/builtin-send-pack.c b/builtin-send-pack.c index d76260c09..910db92b6 100644 --- a/builtin-send-pack.c +++ b/builtin-send-pack.c @@ -8,7 +8,7 @@ #include "send-pack.h" static const char send_pack_usage[] = -"git-send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=] [--verbose] [--thin] [:] [...]\n" +"git send-pack [--all | --mirror] [--dry-run] [--force] [--receive-pack=] [--verbose] [--thin] [:] [...]\n" " --all and explicit specification are mutually exclusive."; static struct send_pack_args args = { @@ -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"; @@ -43,15 +45,21 @@ static int pack_objects(int fd, struct ref *refs) po.out = fd; po.git_cmd = 1; if (start_command(&po)) - die("git-pack-objects failed (%s)", strerror(errno)); + die("git pack-objects failed (%s)", strerror(errno)); /* * 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); @@ -226,8 +234,7 @@ static void update_tracking_ref(struct remote *remote, struct ref *ref) if (args.verbose) fprintf(stderr, "updating local tracking ref '%s'\n", rs.dst); if (ref->deletion) { - if (delete_ref(rs.dst, NULL)) - error("Failed to delete"); + delete_ref(rs.dst, NULL); } else update_ref("update by push", rs.dst, ref->new_sha1, NULL, 0, 0); @@ -382,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? */ @@ -497,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