Fix read-tree merging more than 3 trees using 3-way merge
[gitweb.git] / builtin-pack-objects.c
index a43d6040cad5077c811aab4555ef4d32c504aab9..51a850e1113f6d89cbd7730949a444b330231b1c 100644 (file)
@@ -586,7 +586,7 @@ static off_t write_one(struct sha1file *f,
 static int open_object_dir_tmp(const char *path)
 {
     snprintf(tmpname, sizeof(tmpname), "%s/%s", get_object_directory(), path);
-    return mkstemp(tmpname);
+    return xmkstemp(tmpname);
 }
 
 /* forward declaration for write_pack_file */
@@ -612,8 +612,6 @@ static void write_pack_file(void)
                        f = sha1fd(1, "<stdout>");
                } else {
                        int fd = open_object_dir_tmp("tmp_pack_XXXXXX");
-                       if (fd < 0)
-                               die("unable to create %s: %s\n", tmpname, strerror(errno));
                        pack_tmp_name = xstrdup(tmpname);
                        f = sha1fd(fd, pack_tmp_name);
                }
@@ -1431,6 +1429,7 @@ static void free_unpacked(struct unpacked *n)
                window_memory_usage -= n->entry->size;
        }
        n->entry = NULL;
+       n->depth = 0;
 }
 
 static void find_deltas(struct object_entry **list, int window, int depth)