@matheusbsbs / matheus-bagliano / commits / 3082acfa7c
Fork 0

Use GIT_OBJECT_DIR for temporary files of pack-objects

Signed-off-by: Alex Riesen <raa.lkml@gmail.com> Signed-off-by: Junio C Hamano <junkio@cox.net>

Alex Riesen committed May 7, 2007 at 19:33 UTC 3082acfa7c626a34aa419a163585051c2df2bf09
1 file changed +8 -6
builtin-pack-objects.c
+8 -6
@@ -559,6 +559,12 @@ static off_t write_one(struct sha1file *f,
559 return offset + size;
560 }
561
562 +static int open_object_dir_tmp(const char *path)
563 +{
564 + snprintf(tmpname, sizeof(tmpname), "%s/%s", get_object_directory(), path);
565 + return mkstemp(tmpname);
566 +}
567 +
568 static off_t write_pack_file(void)
569 {
570 uint32_t i;
@@ -571,9 +577,7 @@ static off_t write_pack_file(void)
577 f = sha1fd(1, "<stdout>");
578 do_progress >>= 1;
579 } else {
574 - int fd;
575 - snprintf(tmpname, sizeof(tmpname), "tmp_pack_XXXXXX");
576 - fd = mkstemp(tmpname);
580 + int fd = open_object_dir_tmp("tmp_pack_XXXXXX");
581 if (fd < 0)
582 die("unable to create %s: %s\n", tmpname, strerror(errno));
583 pack_tmp_name = xstrdup(tmpname);
@@ -623,10 +627,8 @@ static void write_index_file(off_t last_obj_offset, unsigned char *sha1)
627 uint32_t array[256];
628 uint32_t i, index_version;
629 SHA_CTX ctx;
626 - int fd;
630
628 - snprintf(tmpname, sizeof(tmpname), "tmp_idx_XXXXXX");
629 - fd = mkstemp(tmpname);
631 + int fd = open_object_dir_tmp("tmp_idx_XXXXXX");
632 if (fd < 0)
633 die("unable to create %s: %s\n", tmpname, strerror(errno));
634 idx_tmp_name = xstrdup(tmpname);