diff options
author | Patrick Steinhardt <ps@pks.im> | 2024-08-13 11:13:37 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2024-08-13 10:01:01 -0700 |
commit | a973f60dc7c178828e351ec4e68886ffecfbcadc (patch) | |
tree | 1dc78a861d10f3df03ffee3ea0210be5985fd36d /path.c | |
parent | 78f2210b3c8605144d62a90b58e888312f64efc8 (diff) |
path: stop relying on `the_repository` in `worktree_git_path()`
When not provided a worktree, then `worktree_git_path()` will fall back
to returning a path relative to the main repository. In this case, we
implicitly rely on `the_repository` to derive the path. Remove this
dependency by passing a `struct repository` as parameter.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'path.c')
-rw-r--r-- | path.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -512,12 +512,17 @@ const char *mkpath(const char *fmt, ...) return cleanup_path(pathname->buf); } -const char *worktree_git_path(const struct worktree *wt, const char *fmt, ...) +const char *worktree_git_path(struct repository *r, + const struct worktree *wt, const char *fmt, ...) { struct strbuf *pathname = get_pathname(); va_list args; + + if (wt && wt->repo != r) + BUG("worktree not connected to expected repository"); + va_start(args, fmt); - repo_git_pathv(the_repository, wt, pathname, fmt, args); + repo_git_pathv(r, wt, pathname, fmt, args); va_end(args); return pathname->buf; } |