diff options
author | Alexandr Miloslavskiy <alexandr.miloslavskiy@syntevo.com> | 2020-03-10 14:11:23 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-03-10 19:41:40 +0100 |
commit | 4530a85b4c34f009b5f190eb2dc8367801de5028 (patch) | |
tree | 8e6a4c01147521978d89637b87d50ab75546d647 /worktree.c | |
parent | real_path: remove unsafe API (diff) | |
download | git-4530a85b4c34f009b5f190eb2dc8367801de5028.tar.xz git-4530a85b4c34f009b5f190eb2dc8367801de5028.zip |
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.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/worktree.c b/worktree.c index e7bbf716f6..543472f0c7 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; } |