Skip to content

Commit 3addb79

Browse files
authored
Merge pull request libgit2#5943 from kcsaul/fix/5851
Fix worktree iteration when repository has no common directory
2 parents 4e8840f + e71505b commit 3addb79

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/repository.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,12 @@ int git_repository_foreach_worktree(git_repository *repo,
23352335
int error;
23362336
size_t i;
23372337

2338+
/* apply operation to repository supplied when commondir is empty, implying there's
2339+
* no linked worktrees to iterate, which can occur when using custom odb/refdb
2340+
*/
2341+
if (!repo->commondir)
2342+
return cb(repo, payload);
2343+
23382344
if ((error = git_repository_open(&worktree_repo, repo->commondir)) < 0 ||
23392345
(error = cb(worktree_repo, payload) != 0))
23402346
goto out;

0 commit comments

Comments
 (0)