@@ -445,7 +445,7 @@ void update_worktree_location(struct worktree *wt, const char *path_,
445445 strbuf_realpath (& path , path_ , 1 );
446446 strbuf_addf (& dotgit , "%s/.git" , path .buf );
447447 if (fspathcmp (wt -> path , path .buf )) {
448- write_worktree_linking_files (dotgit , gitdir , use_relative_paths );
448+ write_worktree_linking_files (dotgit . buf , gitdir . buf , use_relative_paths );
449449
450450 free (wt -> path );
451451 wt -> path = strbuf_detach (& path , NULL );
@@ -684,7 +684,7 @@ static void repair_gitfile(struct worktree *wt,
684684
685685 if (repair ) {
686686 fn (0 , wt -> path , repair , cb_data );
687- write_worktree_linking_files (dotgit , gitdir , use_relative_paths );
687+ write_worktree_linking_files (dotgit . buf , gitdir . buf , use_relative_paths );
688688 }
689689
690690done :
@@ -742,7 +742,7 @@ void repair_worktree_after_gitdir_move(struct worktree *wt, const char *old_path
742742 if (!file_exists (dotgit .buf ))
743743 goto done ;
744744
745- write_worktree_linking_files (dotgit , gitdir , is_relative_path );
745+ write_worktree_linking_files (dotgit . buf , gitdir . buf , is_relative_path );
746746done :
747747 strbuf_release (& gitdir );
748748 strbuf_release (& dotgit );
@@ -913,7 +913,7 @@ void repair_worktree_at_path(const char *path,
913913
914914 if (repair ) {
915915 fn (0 , gitdir .buf , repair , cb_data );
916- write_worktree_linking_files (dotgit , gitdir , use_relative_paths );
916+ write_worktree_linking_files (dotgit . buf , gitdir . buf , use_relative_paths );
917917 }
918918done :
919919 free (dotgit_contents );
@@ -1087,17 +1087,17 @@ int init_worktree_config(struct repository *r)
10871087 return res ;
10881088}
10891089
1090- void write_worktree_linking_files (struct strbuf dotgit , struct strbuf gitdir ,
1090+ void write_worktree_linking_files (const char * dotgit , const char * gitdir ,
10911091 int use_relative_paths )
10921092{
10931093 struct strbuf path = STRBUF_INIT ;
10941094 struct strbuf repo = STRBUF_INIT ;
10951095 struct strbuf tmp = STRBUF_INIT ;
10961096
1097- strbuf_addbuf (& path , & dotgit );
1097+ strbuf_addstr (& path , dotgit );
10981098 strbuf_strip_suffix (& path , "/.git" );
10991099 strbuf_realpath (& path , path .buf , 1 );
1100- strbuf_addbuf (& repo , & gitdir );
1100+ strbuf_addstr (& repo , gitdir );
11011101 strbuf_strip_suffix (& repo , "/gitdir" );
11021102 strbuf_realpath (& repo , repo .buf , 1 );
11031103
@@ -1110,11 +1110,11 @@ void write_worktree_linking_files(struct strbuf dotgit, struct strbuf gitdir,
11101110 }
11111111
11121112 if (use_relative_paths ) {
1113- write_file (gitdir . buf , "%s/.git" , relative_path (path .buf , repo .buf , & tmp ));
1114- write_file (dotgit . buf , "gitdir: %s" , relative_path (repo .buf , path .buf , & tmp ));
1113+ write_file (gitdir , "%s/.git" , relative_path (path .buf , repo .buf , & tmp ));
1114+ write_file (dotgit , "gitdir: %s" , relative_path (repo .buf , path .buf , & tmp ));
11151115 } else {
1116- write_file (gitdir . buf , "%s/.git" , path .buf );
1117- write_file (dotgit . buf , "gitdir: %s" , repo .buf );
1116+ write_file (gitdir , "%s/.git" , path .buf );
1117+ write_file (dotgit , "gitdir: %s" , repo .buf );
11181118 }
11191119
11201120 strbuf_release (& path );
0 commit comments