Merge branch 'mh/import-transport-fd-fix'
authorJunio C Hamano <gitster@pobox.com>
Thu, 13 Jun 2019 20:19:43 +0000 (13:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 13 Jun 2019 20:19:43 +0000 (13:19 -0700)
The ownership rule for the file descriptor to fast-import remote
backend was mixed up, leading to unrelated file descriptor getting
closed, which has been fixed.

* mh/import-transport-fd-fix:
Use xmmap_gently instead of xmmap in use_pack
dup() the input fd for fast-import used for remote helpers

packfile.c
transport-helper.c
index 49c8544ff4591e71e1845cd1b275d5fdb898b400..d786ec731202e5d623a7558bec2168194db11514 100644 (file)
@@ -640,7 +640,7 @@ unsigned char *use_pack(struct packed_git *p,
                        while (packed_git_limit < pack_mapped
                                && unuse_one_window(p))
                                ; /* nothing */
-                       win->base = xmmap(NULL, win->len,
+                       win->base = xmmap_gently(NULL, win->len,
                                PROT_READ, MAP_PRIVATE,
                                p->pack_fd, win->offset);
                        if (win->base == MAP_FAILED)
index cec83bd663d0f27589bd09176e38b084270f56c4..c7e17ec9cb61e6782bc255e6b90381054255c269 100644 (file)
@@ -423,7 +423,7 @@ static int get_importer(struct transport *transport, struct child_process *fasti
        struct helper_data *data = transport->data;
        int cat_blob_fd, code;
        child_process_init(fastimport);
-       fastimport->in = helper->out;
+       fastimport->in = xdup(helper->out);
        argv_array_push(&fastimport->args, "fast-import");
        argv_array_push(&fastimport->args, debug ? "--stats" : "--quiet");