]> asedeno.scripts.mit.edu Git - git.git/blobdiff - bundle.c
Merge git://git.kernel.org/pub/scm/gitk/gitk
[git.git] / bundle.c
index be204d8a228ab5218a603cdcf3ebd17e95ad8d90..5c95eca07d19a6d3ed4e9000b5bb47eef90ff66e 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -317,19 +317,25 @@ 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)
-                       write(rls.in, "^", 1);
-               write(rls.in, sha1_to_hex(object->sha1), 40);
-               write(rls.in, "\n", 1);
+                       write_or_die(rls.in, "^", 1);
+               write_or_die(rls.in, sha1_to_hex(object->sha1), 40);
+               write_or_die(rls.in, "\n", 1);
        }
        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)