aboutsummaryrefslogtreecommitdiffstats
path: root/worktree.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-09-17 13:53:59 -0700
committerJunio C Hamano <gitster@pobox.com>2018-09-17 13:53:59 -0700
commit1c515bf7e2b395509a122fb92cd6f925bf09a6fe (patch)
tree8e4410c4163d6d8c985f7aef742efab8cb563ef6 /worktree.c
parentMerge branch 'sg/doc-trace-appends' (diff)
parentdoc-diff: force worktree add (diff)
downloadgit-1c515bf7e2b395509a122fb92cd6f925bf09a6fe.tar.gz
git-1c515bf7e2b395509a122fb92cd6f925bf09a6fe.zip
Merge branch 'es/worktree-forced-ops-fix'
Fix a bug in which the same path could be registered under multiple worktree entries if the path was missing (for instance, was removed manually). Also, as a convenience, expand the number of cases in which --force is applicable. * es/worktree-forced-ops-fix: doc-diff: force worktree add worktree: delete .git/worktrees if empty after 'remove' worktree: teach 'remove' to override lock when --force given twice worktree: teach 'move' to override lock when --force given twice worktree: teach 'add' to respect --force for registered but missing path worktree: disallow adding same path multiple times worktree: prepare for more checks of whether path can become worktree worktree: generalize delete_git_dir() to reduce code duplication worktree: move delete_git_dir() earlier in file for upcoming new callers worktree: don't die() in library function find_worktree()
Diffstat (limited to 'worktree.c')
-rw-r--r--worktree.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/worktree.c b/worktree.c
index 97cda5f97b..b0d0b5426d 100644
--- a/worktree.c
+++ b/worktree.c
@@ -217,7 +217,11 @@ struct worktree *find_worktree(struct worktree **list,
if (prefix)
arg = to_free = prefix_filename(prefix, arg);
- path = real_pathdup(arg, 1);
+ path = real_pathdup(arg, 0);
+ if (!path) {
+ free(to_free);
+ return NULL;
+ }
for (; *list; list++)
if (!fspathcmp(path, real_path((*list)->path)))
break;