summaryrefslogtreecommitdiff
path: root/worktree.c
diff options
context:
space:
mode:
authorAlexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com>2020-03-10 13:11:23 (GMT)
committerJunio C Hamano <gitster@pobox.com>2020-03-10 18:41:40 (GMT)
commit4530a85b4c34f009b5f190eb2dc8367801de5028 (patch)
tree8e6a4c01147521978d89637b87d50ab75546d647 /worktree.c
parent3d7747e318532a36a263c61cdf92f2decb6424ff (diff)
downloadgit-4530a85b4c34f009b5f190eb2dc8367801de5028.zip
git-4530a85b4c34f009b5f190eb2dc8367801de5028.tar.gz
git-4530a85b4c34f009b5f190eb2dc8367801de5028.tar.bz2
real_path_if_valid(): remove unsafe API
This commit continues the work started with previous commit. Signed-off-by: Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'worktree.c')
-rw-r--r--worktree.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/worktree.c b/worktree.c
index e7bbf71..543472f 100644
--- a/worktree.c
+++ b/worktree.c
@@ -226,17 +226,20 @@ struct worktree *find_worktree(struct worktree **list,
struct worktree *find_worktree_by_path(struct worktree **list, const char *p)
{
+ struct strbuf wt_path = STRBUF_INIT;
char *path = real_pathdup(p, 0);
if (!path)
return NULL;
for (; *list; list++) {
- const char *wt_path = real_path_if_valid((*list)->path);
+ if (!strbuf_realpath(&wt_path, (*list)->path, 0))
+ continue;
- if (wt_path && !fspathcmp(path, wt_path))
+ if (!fspathcmp(path, wt_path.buf))
break;
}
free(path);
+ strbuf_release(&wt_path);
return *list;
}