On Fri Nov 22, 2024 at 9:58 AM CST, Phillip Wood wrote: > On 01/11/2024 04:39, Caleb White wrote: >> This refactors `repair_worktree_after_gitdir_move()` to use the new >> `write_worktree_linking_files` function. It also preserves the >> relativity of the linking files; e.g., if an existing worktree used >> absolute paths then the repaired paths will be absolute (and visa-versa). > > It would be helpful to give a brief explanation of what this function is > used for as it seems to be called from setup.c rather than as part of > "git worktree repair" I updated the commit message to include a brief explanation of what the function does. >> This also adds a test case for reinitializing a repository that has >> relative worktrees. > > I'm not sure exactly what this is doing - are we breaking something and > then calling "git init" to repair it? Apparently (I didn't know this either, and this is likely a rare use-case), `git init` allows you to "re-initialize" an existing repository which can move the .git directory. After which, git would just repair all the worktrees. This worked fine for absolute paths as the `gitdir` files still contained the absolute paths. However, for relative paths, both of the linking files need to be updated (and I need to know the original location of the `.git` directory to do so). This function was created in the previous topic to handle this case. > My understanding of what this function is trying to do is rather limited > but as far as I can see the conversion looks OK though the strbuf > changes are quite distracting. Yeah, I was able to clean up a lot because of the new `write_worktree_linking_files()` function. >> +++ b/t/t0001-init.sh >> @@ -434,6 +434,12 @@ test_expect_success SYMLINKS 're-init to move gitdir symlink' ' >> sep_git_dir_worktree () { >> test_when_finished "rm -rf mainwt linkwt seprepo" && >> git init mainwt && >> + if test "relative" = $2 >> + then >> + git -C mainwt config worktree.useRelativePaths true > > test_config is your friend here (it accepts -C <repo>) Updated, thanks! Best, Caleb