@@ -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+
562568static 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