From d4238ab1a43028f0c0efbf0b0fa736bab4ef8d6b Mon Sep 17 00:00:00 2001 From: Kevin Willford Date: Mon, 4 Mar 2019 09:44:05 -0700 Subject: [PATCH 1/3] fixup! send-pack: do not check for sha1 file when GVFS_MISSING_OK set --- send-pack.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/send-pack.c b/send-pack.c index 4cce09534509e6..9ff928e2f77bf0 100644 --- a/send-pack.c +++ b/send-pack.c @@ -15,7 +15,6 @@ #include "sha1-array.h" #include "gpg-interface.h" #include "cache.h" -#include "gvfs.h" int option_parse_push_signed(const struct option *opt, const char *arg, int unset) @@ -51,7 +50,7 @@ static int send_pack_config(const char *var, const char *value, void *unused) static void feed_object(const struct object_id *oid, FILE *fh, int negative) { - if (negative && !gvfs_config_is_set(GVFS_MISSING_OK) && !has_sha1_file(oid->hash)) + if (negative && !has_sha1_file(oid->hash)) return; if (negative) From 2f0749533d6a1501d681d9c6ebd7b638fd3cf580 Mon Sep 17 00:00:00 2001 From: Kevin Willford Date: Mon, 19 Nov 2018 15:29:11 -0700 Subject: [PATCH 2/3] send-pack: build list of oids to sent to pack-objects --- send-pack.c | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) diff --git a/send-pack.c b/send-pack.c index 9ff928e2f77bf0..e08c1115b774f4 100644 --- a/send-pack.c +++ b/send-pack.c @@ -59,6 +59,17 @@ static void feed_object(const struct object_id *oid, FILE *fh, int negative) putc('\n', fh); } +static void add_to_oid_list(const struct object_id *oid, struct string_list *list, int negative) +{ + if (negative && !has_sha1_file(oid->hash)) + return; + + if (negative) + string_list_append(list, xstrfmt("^%s", oid_to_hex(oid))); + else + string_list_append(list, oid_to_hex(oid)); +} + /* * Make a pack stream and spit it out into file descriptor fd */ @@ -73,6 +84,19 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc FILE *po_in; int i; int rc; + struct string_list oid_list = STRING_LIST_INIT_NODUP; + struct string_list_item *item; + + for (i = 0; i < extra->nr; i++) + add_to_oid_list(&extra->oid[i], &oid_list, 1); + + while (refs) { + if (!is_null_oid(&refs->old_oid)) + add_to_oid_list(&refs->old_oid, &oid_list, 1); + if (!is_null_oid(&refs->new_oid)) + add_to_oid_list(&refs->new_oid, &oid_list, 0); + refs = refs->next; + } argv_array_push(&po.args, "pack-objects"); argv_array_push(&po.args, "--all-progress-implied"); @@ -99,15 +123,10 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc * parameters by writing to the pipe. */ po_in = xfdopen(po.in, "w"); - for (i = 0; i < extra->nr; i++) - feed_object(&extra->oid[i], po_in, 1); - - while (refs) { - if (!is_null_oid(&refs->old_oid)) - feed_object(&refs->old_oid, po_in, 1); - if (!is_null_oid(&refs->new_oid)) - feed_object(&refs->new_oid, po_in, 0); - refs = refs->next; + + for_each_string_list_item(item, &oid_list) { + fputs(item->string, po_in); + putc('\n', po_in); } fflush(po_in); @@ -129,6 +148,7 @@ static int pack_objects(int fd, struct ref *refs, struct oid_array *extra, struc } rc = finish_command(&po); + string_list_clear(&oid_list, 0); if (rc) { /* * For a normal non-zero exit, we assume pack-objects wrote From f4e7e490247e057a5595d2136a04195e012dd504 Mon Sep 17 00:00:00 2001 From: Kevin Willford Date: Mon, 19 Nov 2018 15:30:27 -0700 Subject: [PATCH 3/3] send-pack: remove unused method feed_object --- send-pack.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/send-pack.c b/send-pack.c index e08c1115b774f4..dfc4a1f898367c 100644 --- a/send-pack.c +++ b/send-pack.c @@ -48,17 +48,6 @@ static int send_pack_config(const char *var, const char *value, void *unused) return 0; } -static void feed_object(const struct object_id *oid, FILE *fh, int negative) -{ - if (negative && !has_sha1_file(oid->hash)) - return; - - if (negative) - putc('^', fh); - fputs(oid_to_hex(oid), fh); - putc('\n', fh); -} - static void add_to_oid_list(const struct object_id *oid, struct string_list *list, int negative) { if (negative && !has_sha1_file(oid->hash))