@@ -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 );
@@ -685,7 +685,7 @@ static void repair_gitfile(struct worktree *wt,
685685
686686 if (repair ) {
687687 fn (0 , wt -> path , repair , cb_data );
688- write_worktree_linking_files (dotgit , gitdir , use_relative_paths );
688+ write_worktree_linking_files (dotgit . buf , gitdir . buf , use_relative_paths );
689689 }
690690
691691done :
@@ -743,7 +743,7 @@ void repair_worktree_after_gitdir_move(struct worktree *wt, const char *old_path
743743 if (!file_exists (dotgit .buf ))
744744 goto done ;
745745
746- write_worktree_linking_files (dotgit , gitdir , is_relative_path );
746+ write_worktree_linking_files (dotgit . buf , gitdir . buf , is_relative_path );
747747done :
748748 strbuf_release (& gitdir );
749749 strbuf_release (& dotgit );
@@ -915,7 +915,7 @@ void repair_worktree_at_path(const char *path,
915915
916916 if (repair ) {
917917 fn (0 , gitdir .buf , repair , cb_data );
918- write_worktree_linking_files (dotgit , gitdir , use_relative_paths );
918+ write_worktree_linking_files (dotgit . buf , gitdir . buf , use_relative_paths );
919919 }
920920done :
921921 free (dotgit_contents );
@@ -1089,17 +1089,17 @@ int init_worktree_config(struct repository *r)
10891089 return res ;
10901090}
10911091
1092- void write_worktree_linking_files (struct strbuf dotgit , struct strbuf gitdir ,
1092+ void write_worktree_linking_files (const char * dotgit , const char * gitdir ,
10931093 int use_relative_paths )
10941094{
10951095 struct strbuf path = STRBUF_INIT ;
10961096 struct strbuf repo = STRBUF_INIT ;
10971097 struct strbuf tmp = STRBUF_INIT ;
10981098
1099- strbuf_addbuf (& path , & dotgit );
1099+ strbuf_addstr (& path , dotgit );
11001100 strbuf_strip_suffix (& path , "/.git" );
11011101 strbuf_realpath (& path , path .buf , 1 );
1102- strbuf_addbuf (& repo , & gitdir );
1102+ strbuf_addstr (& repo , gitdir );
11031103 strbuf_strip_suffix (& repo , "/gitdir" );
11041104 strbuf_realpath (& repo , repo .buf , 1 );
11051105
@@ -1112,11 +1112,11 @@ void write_worktree_linking_files(struct strbuf dotgit, struct strbuf gitdir,
11121112 }
11131113
11141114 if (use_relative_paths ) {
1115- write_file (gitdir . buf , "%s/.git" , relative_path (path .buf , repo .buf , & tmp ));
1116- write_file (dotgit . buf , "gitdir: %s" , relative_path (repo .buf , path .buf , & tmp ));
1115+ write_file (gitdir , "%s/.git" , relative_path (path .buf , repo .buf , & tmp ));
1116+ write_file (dotgit , "gitdir: %s" , relative_path (repo .buf , path .buf , & tmp ));
11171117 } else {
1118- write_file (gitdir . buf , "%s/.git" , path .buf );
1119- write_file (dotgit . buf , "gitdir: %s" , repo .buf );
1118+ write_file (gitdir , "%s/.git" , path .buf );
1119+ write_file (dotgit , "gitdir: %s" , repo .buf );
11201120 }
11211121
11221122 strbuf_release (& path );
0 commit comments