[PATCH] Use GIT_OBJECT_DIR for temporary files of pack-objects

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Alex Riesen <raa.lkml@xxxxxxxxx>
---

I'm not sure about fsck cleaning up after crashed/killed pack-objects:
not sure I _can_ detect if the temp files really are just leftovers.

 builtin-pack-objects.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index b827627..7bff8ea 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -559,6 +559,12 @@ static off_t write_one(struct sha1file *f,
 	return offset + size;
 }
 
+static int open_object_dir_tmp(const char *path)
+{
+    snprintf(tmpname, sizeof(tmpname), "%s/%s", get_object_directory(), path);
+    return mkstemp(tmpname);
+}
+
 static off_t write_pack_file(void)
 {
 	uint32_t i;
@@ -571,9 +577,7 @@ static off_t write_pack_file(void)
 		f = sha1fd(1, "<stdout>");
 		do_progress >>= 1;
 	} else {
-		int fd;
-		snprintf(tmpname, sizeof(tmpname), "tmp_pack_XXXXXX");
-		fd = mkstemp(tmpname);
+		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);
@@ -623,10 +627,8 @@ static void write_index_file(off_t last_obj_offset, unsigned char *sha1)
 	uint32_t array[256];
 	uint32_t i, index_version;
 	SHA_CTX ctx;
-	int fd;
 
-	snprintf(tmpname, sizeof(tmpname), "tmp_idx_XXXXXX");
-	fd = mkstemp(tmpname);
+	int fd = open_object_dir_tmp("tmp_idx_XXXXXX");
 	if (fd < 0)
 		die("unable to create %s: %s\n", tmpname, strerror(errno));
 	idx_tmp_name = xstrdup(tmpname);
-- 
1.5.2.rc2.14.g6f1dd

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]