THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

Browse Source

Merge branch 'nd/corrupt-worktrees'

"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
tags/v2.23.0-rc0
Junio C Hamano 5 months ago
parent
commit
000bce0ee4
2 changed files with 17 additions and 2 deletions
  1. +12
    -0
      t/t2400-worktree-add.sh
  2. +5
    -2
      worktree.c

+ 12
- 0
t/t2400-worktree-add.sh View File

@@ -575,4 +575,16 @@ test_expect_success FUNNYNAMES 'sanitize generated worktree name' '
test -d .git/worktrees/---weird-.-
'

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

+ 5
- 2
worktree.c View File

@@ -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;

Loading…
Cancel
Save