From 4dac9e3c01cf056edd315e0ed26e6df1c4d94571 Mon Sep 17 00:00:00 2001 From: Caleb White Date: Fri, 29 Nov 2024 22:22:47 +0000 Subject: worktree: add `write_worktree_linking_files()` function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A new helper function, `write_worktree_linking_files()`, centralizes the logic for computing and writing either relative or absolute paths, based on the provided configuration. This function accepts `strbuf` pointers to both the worktree’s `.git` link and the repository’s `gitdir`, and then writes the appropriate path to each. The `relativeWorktrees` extension is automatically set when a worktree is linked with relative paths. Signed-off-by: Caleb White Signed-off-by: Junio C Hamano --- worktree.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'worktree.h') diff --git a/worktree.h b/worktree.h index e961186216..fd040f5d99 100644 --- a/worktree.h +++ b/worktree.h @@ -215,4 +215,17 @@ void strbuf_worktree_ref(const struct worktree *wt, */ int init_worktree_config(struct repository *r); +/** + * Write the .git file and gitdir file that links the worktree to the repository. + * + * The `dotgit` parameter is the path to the worktree's .git file, and `gitdir` + * is the path to the repository's `gitdir` file. + * + * Example + * dotgit: "/path/to/foo/.git" + * gitdir: "/path/to/repo/worktrees/foo/gitdir" + */ +void write_worktree_linking_files(struct strbuf dotgit, struct strbuf gitdir, + int use_relative_paths); + #endif -- cgit v1.2.3