@@ -2002,8 +2002,8 @@ static int write_graph_chunk_base(struct hashfile *f,
20022002static int write_commit_graph_file (struct write_commit_graph_context * ctx )
20032003{
20042004 uint32_t i ;
2005- int fd ;
20062005 struct hashfile * f ;
2006+ struct tempfile * graph_layer ; /* when ctx->split is non-zero */
20072007 struct lock_file lk = LOCK_INIT ;
20082008 const unsigned hashsz = the_hash_algo -> rawsz ;
20092009 struct strbuf progress_title = STRBUF_INIT ;
@@ -2035,24 +2035,23 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
20352035 LOCK_DIE_ON_ERROR , 0444 );
20362036 free (lock_name );
20372037
2038- fd = git_mkstemp_mode (ctx -> graph_name , 0444 );
2039- if (fd < 0 ) {
2038+ graph_layer = mks_tempfile_m (ctx -> graph_name , 0444 );
2039+ if (! graph_layer ) {
20402040 error (_ ("unable to create temporary graph layer" ));
20412041 return -1 ;
20422042 }
20432043
2044- if (adjust_shared_perm (ctx -> graph_name )) {
2044+ if (adjust_shared_perm (get_tempfile_path ( graph_layer ) )) {
20452045 error (_ ("unable to adjust shared permissions for '%s'" ),
2046- ctx -> graph_name );
2046+ get_tempfile_path ( graph_layer ) );
20472047 return -1 ;
20482048 }
20492049
2050- f = hashfd (fd , ctx -> graph_name );
2050+ f = hashfd (get_tempfile_fd ( graph_layer ), get_tempfile_path ( graph_layer ) );
20512051 } else {
20522052 hold_lock_file_for_update_mode (& lk , ctx -> graph_name ,
20532053 LOCK_DIE_ON_ERROR , 0444 );
2054- fd = get_lock_file_fd (& lk );
2055- f = hashfd (fd , get_lock_file_path (& lk ));
2054+ f = hashfd (get_lock_file_fd (& lk ), get_lock_file_path (& lk ));
20562055 }
20572056
20582057 cf = init_chunkfile (f );
@@ -2133,8 +2132,6 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
21332132 char * final_graph_name ;
21342133 int result ;
21352134
2136- close (fd );
2137-
21382135 if (!chainf ) {
21392136 error (_ ("unable to open commit-graph chain file" ));
21402137 return -1 ;
@@ -2169,7 +2166,7 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
21692166 free (ctx -> commit_graph_filenames_after [ctx -> num_commit_graphs_after - 1 ]);
21702167 ctx -> commit_graph_filenames_after [ctx -> num_commit_graphs_after - 1 ] = final_graph_name ;
21712168
2172- result = rename ( ctx -> graph_name , final_graph_name );
2169+ result = rename_tempfile ( & graph_layer , final_graph_name );
21732170
21742171 for (i = 0 ; i < ctx -> num_commit_graphs_after ; i ++ )
21752172 fprintf (get_lock_file_fp (& lk ), "%s\n" , ctx -> commit_graph_hash_after [i ]);
0 commit comments