Merge branch 'nd/corrupt-worktrees' into maint

"git worktree add" used to fail when another worktree connected to
the same repository was corrupt, which has been corrected.

* nd/corrupt-worktrees:
  worktree add: be tolerant of corrupt worktrees
This commit is contained in:
Junio C Hamano 2019-07-25 14:27:07 -07:00
Родитель 35d771591f 105df73e71
Коммит 933f294877
2 изменённых файлов: 17 добавлений и 2 удалений

Просмотреть файл

@ -570,4 +570,16 @@ test_expect_success '"add" an existing locked but missing worktree' '
git worktree add --force --force --detach gnoo
'
test_expect_success '"add" should not fail because of another bad worktree' '
git init add-fail &&
(
cd add-fail &&
test_commit first &&
mkdir sub &&
git worktree add sub/to-be-deleted &&
rm -rf sub &&
git worktree add second
)
'
test_done

Просмотреть файл

@ -228,9 +228,12 @@ struct worktree *find_worktree(struct worktree **list,
free(to_free);
return NULL;
}
for (; *list; list++)
if (!fspathcmp(path, real_path((*list)->path)))
for (; *list; list++) {
const char *wt_path = real_path_if_valid((*list)->path);
if (wt_path && !fspathcmp(path, wt_path))
break;
}
free(path);
free(to_free);
return *list;