@@ -324,6 +324,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
324324 struct string_list partial ;
325325 struct pathspec pathspec ;
326326 int refresh_flags = REFRESH_QUIET ;
327+ const char * ret ;
327328
328329 if (is_status )
329330 refresh_flags |= REFRESH_UNMERGED ;
@@ -344,7 +345,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
344345 die (_ ("unable to create temporary index" ));
345346
346347 old_index_env = getenv (INDEX_ENVIRONMENT );
347- setenv (INDEX_ENVIRONMENT , index_lock . filename . buf , 1 );
348+ setenv (INDEX_ENVIRONMENT , get_lock_file_path ( & index_lock ) , 1 );
348349
349350 if (interactive_add (argc , argv , prefix , patch_interactive ) != 0 )
350351 die (_ ("interactive add failed" ));
@@ -355,7 +356,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
355356 unsetenv (INDEX_ENVIRONMENT );
356357
357358 discard_cache ();
358- read_cache_from (index_lock . filename . buf );
359+ read_cache_from (get_lock_file_path ( & index_lock ) );
359360 if (update_main_cache_tree (WRITE_TREE_SILENT ) == 0 ) {
360361 if (reopen_lock_file (& index_lock ) < 0 )
361362 die (_ ("unable to write index file" ));
@@ -365,7 +366,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
365366 warning (_ ("Failed to update main cache tree" ));
366367
367368 commit_style = COMMIT_NORMAL ;
368- return index_lock . filename . buf ;
369+ return get_lock_file_path ( & index_lock ) ;
369370 }
370371
371372 /*
@@ -388,7 +389,7 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
388389 if (write_locked_index (& the_index , & index_lock , CLOSE_LOCK ))
389390 die (_ ("unable to write new_index file" ));
390391 commit_style = COMMIT_NORMAL ;
391- return index_lock . filename . buf ;
392+ return get_lock_file_path ( & index_lock ) ;
392393 }
393394
394395 /*
@@ -475,9 +476,9 @@ static const char *prepare_index(int argc, const char **argv, const char *prefix
475476 die (_ ("unable to write temporary index file" ));
476477
477478 discard_cache ();
478- read_cache_from ( false_lock . filename . buf );
479-
480- return false_lock . filename . buf ;
479+ ret = get_lock_file_path ( & false_lock );
480+ read_cache_from ( ret );
481+ return ret ;
481482}
482483
483484static int run_status (FILE * fp , const char * index_file , const char * prefix , int nowarn ,
0 commit comments