Commit dd70695f authored by Duy Nguyen's avatar Duy Nguyen

worktree.c: remove the_repository from get_worktree_git_dir()

parent 7d8693d7
......@@ -739,7 +739,7 @@ static void validate_no_submodules(const struct worktree *wt)
*/
found_submodules = 1;
} else if (read_index_from(&istate, worktree_git_path(wt, "index"),
get_worktree_git_dir(wt)) > 0) {
get_worktree_git_dir(the_repository, wt)) > 0) {
for (i = 0; i < istate.cache_nr; i++) {
struct cache_entry *ce = istate.cache[i];
int err;
......
......@@ -1547,7 +1547,7 @@ void add_index_objects_to_pending(struct rev_info *revs, unsigned int flags)
if (read_index_from(&istate,
worktree_git_path(wt, "index"),
get_worktree_git_dir(wt)) > 0)
get_worktree_git_dir(revs->repo, wt)) > 0)
do_add_index_objects_to_pending(revs, &istate, flags);
discard_index(&istate);
}
......
......@@ -110,7 +110,7 @@ static void mark_current_worktree(struct worktree **worktrees)
for (i = 0; worktrees[i]; i++) {
struct worktree *wt = worktrees[i];
const char *wt_git_dir = get_worktree_git_dir(wt);
const char *wt_git_dir = get_worktree_git_dir(the_repository, wt);
if (!fspathcmp(git_dir, absolute_path(wt_git_dir))) {
wt->is_current = 1;
......@@ -169,14 +169,15 @@ struct worktree **get_worktrees(unsigned flags)
return list;
}
const char *get_worktree_git_dir(const struct worktree *wt)
const char *get_worktree_git_dir(struct repository *r,
const struct worktree *wt)
{
if (!wt)
return get_git_dir();
return r->gitdir;
else if (!wt->id)
return get_git_common_dir();
return r->commondir;
else
return git_common_path("worktrees/%s", wt->id);
return repo_git_common_path(r, "worktrees/%s", wt->id);
}
static struct worktree *find_worktree_by_suffix(struct worktree **list,
......
......@@ -4,6 +4,7 @@
#include "cache.h"
#include "refs.h"
struct repository;
struct strbuf;
struct worktree {
......@@ -41,7 +42,8 @@ extern int submodule_uses_worktrees(const char *path);
* Return git dir of the worktree. Note that the path may be relative.
* If wt is NULL, git dir of current worktree is returned.
*/
extern const char *get_worktree_git_dir(const struct worktree *wt);
extern const char *get_worktree_git_dir(struct repository *r,
const struct worktree *wt);
/*
* Search a worktree that can be unambiguously identified by
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment