]> git.ipfire.org Git - thirdparty/git.git/blobdiff - bundle.c
The sixth batch
[thirdparty/git.git] / bundle.c
index b45666c49b1c19a63d816527a761d0177d9633ce..99439e07a1064ae6420ca9c5a821ecec8022aef7 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -142,6 +142,9 @@ int verify_bundle(struct repository *r,
        int i, ret = 0, req_nr;
        const char *message = _("Repository lacks these prerequisite commits:");
 
+       if (!r || !r->objects || !r->objects->odb)
+               return error(_("need a repository to verify a bundle"));
+
        repo_init_revisions(r, &revs, NULL);
        for (i = 0; i < p->nr; i++) {
                struct ref_list_entry *e = p->list + i;
@@ -246,15 +249,16 @@ out:
 
 
 /* Write the pack data to bundle_fd */
-static int write_pack_data(int bundle_fd, struct rev_info *revs)
+static int write_pack_data(int bundle_fd, struct rev_info *revs, struct argv_array *pack_options)
 {
        struct child_process pack_objects = CHILD_PROCESS_INIT;
        int i;
 
        argv_array_pushl(&pack_objects.args,
-                        "pack-objects", "--all-progress-implied",
+                        "pack-objects",
                         "--stdout", "--thin", "--delta-base-offset",
                         NULL);
+       argv_array_pushv(&pack_objects.args, pack_options->argv);
        pack_objects.in = -1;
        pack_objects.out = bundle_fd;
        pack_objects.git_cmd = 1;
@@ -279,7 +283,7 @@ static int write_pack_data(int bundle_fd, struct rev_info *revs)
                struct object *object = revs->pending.objects[i].item;
                if (object->flags & UNINTERESTING)
                        write_or_die(pack_objects.in, "^", 1);
-               write_or_die(pack_objects.in, oid_to_hex(&object->oid), GIT_SHA1_HEXSZ);
+               write_or_die(pack_objects.in, oid_to_hex(&object->oid), the_hash_algo->hexsz);
                write_or_die(pack_objects.in, "\n", 1);
        }
        close(pack_objects.in);
@@ -411,7 +415,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
                }
 
                ref_count++;
-               write_or_die(bundle_fd, oid_to_hex(&e->item->oid), 40);
+               write_or_die(bundle_fd, oid_to_hex(&e->item->oid), the_hash_algo->hexsz);
                write_or_die(bundle_fd, " ", 1);
                write_or_die(bundle_fd, display_ref, strlen(display_ref));
                write_or_die(bundle_fd, "\n", 1);
@@ -425,7 +429,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
 }
 
 int create_bundle(struct repository *r, const char *path,
-                 int argc, const char **argv)
+                 int argc, const char **argv, struct argv_array *pack_options)
 {
        struct lock_file lock = LOCK_INIT;
        int bundle_fd = -1;
@@ -467,7 +471,7 @@ int create_bundle(struct repository *r, const char *path,
                goto err;
 
        /* write pack */
-       if (write_pack_data(bundle_fd, &revs))
+       if (write_pack_data(bundle_fd, &revs, pack_options))
                goto err;
 
        if (!bundle_to_stdout) {