Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'worktree.c')
-rw-r--r--worktree.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/worktree.c b/worktree.c
index 33c2655534..52971f7082 100644
--- a/worktree.c
+++ b/worktree.c
@@ -211,7 +211,6 @@ struct worktree *find_worktree(struct worktree **list,
const char *arg)
{
struct worktree *wt;
- char *path;
char *to_free = NULL;
if ((wt = find_worktree_by_suffix(list, arg)))
@@ -219,11 +218,17 @@ struct worktree *find_worktree(struct worktree **list,
if (prefix)
arg = to_free = prefix_filename(prefix, arg);
- path = real_pathdup(arg, 0);
- if (!path) {
- free(to_free);
+ wt = find_worktree_by_path(list, arg);
+ free(to_free);
+ return wt;
+}
+
+struct worktree *find_worktree_by_path(struct worktree **list, const char *p)
+{
+ char *path = real_pathdup(p, 0);
+
+ if (!path)
return NULL;
- }
for (; *list; list++) {
const char *wt_path = real_path_if_valid((*list)->path);
@@ -231,7 +236,6 @@ struct worktree *find_worktree(struct worktree **list,
break;
}
free(path);
- free(to_free);
return *list;
}