expose a helper function peel_to_type().
[gitweb.git] / bundle.c
index 316aa7420d8bd647e304d21c6ca4a9b9cbe5548a..bd12ec8537781c5c82e77637312ccabb708d5040 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -128,7 +128,8 @@ int verify_bundle(struct bundle_header *header, int verbose)
                add_object_array(e->item, e->name, &refs);
        }
 
-       prepare_revision_walk(&revs);
+       if (prepare_revision_walk(&revs))
+               die("revision walk setup failed");
 
        i = req_nr;
        while (i && (commit = get_revision(&revs)))
@@ -317,6 +318,14 @@ int create_bundle(struct bundle_header *header, const char *path,
        rls.git_cmd = 1;
        if (start_command(&rls))
                return error("Could not spawn pack-objects");
+
+       /*
+        * start_command closed bundle_fd if it was > 1
+        * so set the lock fd to -1 so commit_lock_file()
+        * won't fail trying to close it.
+        */
+       lock.fd = -1;
+
        for (i = 0; i < revs.pending.nr; i++) {
                struct object *object = revs.pending.objects[i].item;
                if (object->flags & UNINTERESTING)
@@ -326,10 +335,8 @@ int create_bundle(struct bundle_header *header, const char *path,
        }
        if (finish_command(&rls))
                return error ("pack-objects died");
-       close(bundle_fd);
-       if (!bundle_to_stdout)
-               commit_lock_file(&lock);
-       return 0;
+
+       return bundle_to_stdout ? close(bundle_fd) : commit_lock_file(&lock);
 }
 
 int unbundle(struct bundle_header *header, int bundle_fd)