diff options
author | Caleb White <cdwhite3@pm.me> | 2024-11-29 23:22:47 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-12-02 01:36:17 +0100 |
commit | 4dac9e3c01cf056edd315e0ed26e6df1c4d94571 (patch) | |
tree | 090dffaff7ae9cd4aca2f4ec64d48b855f704690 /worktree.h | |
parent | worktree: refactor infer_backlink return (diff) | |
download | git-4dac9e3c01cf056edd315e0ed26e6df1c4d94571.tar.xz git-4dac9e3c01cf056edd315e0ed26e6df1c4d94571.zip |
worktree: add `write_worktree_linking_files()` function
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 <cdwhite3@pm.me>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.h')
-rw-r--r-- | worktree.h | 13 |
1 files changed, 13 insertions, 0 deletions
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 |