Skip to content

Commit 3082acf

Browse files
raalkmlJunio C Hamano
authored andcommitted
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>
1 parent 0fc4bae commit 3082acf

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

builtin-pack-objects.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,12 @@ static off_t write_one(struct sha1file *f,
559559
return offset + size;
560560
}
561561

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+
562568
static off_t write_pack_file(void)
563569
{
564570
uint32_t i;
@@ -571,9 +577,7 @@ static off_t write_pack_file(void)
571577
f = sha1fd(1, "<stdout>");
572578
do_progress >>= 1;
573579
} 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");
577581
if (fd < 0)
578582
die("unable to create %s: %s\n", tmpname, strerror(errno));
579583
pack_tmp_name = xstrdup(tmpname);
@@ -623,10 +627,8 @@ static void write_index_file(off_t last_obj_offset, unsigned char *sha1)
623627
uint32_t array[256];
624628
uint32_t i, index_version;
625629
SHA_CTX ctx;
626-
int fd;
627630

628-
snprintf(tmpname, sizeof(tmpname), "tmp_idx_XXXXXX");
629-
fd = mkstemp(tmpname);
631+
int fd = open_object_dir_tmp("tmp_idx_XXXXXX");
630632
if (fd < 0)
631633
die("unable to create %s: %s\n", tmpname, strerror(errno));
632634
idx_tmp_name = xstrdup(tmpname);

0 commit comments

Comments
 (0)