diff options
Diffstat (limited to 'src/repository.c')
-rw-r--r-- | src/repository.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/repository.c b/src/repository.c index 692f71861..790dc161b 100644 --- a/src/repository.c +++ b/src/repository.c @@ -2339,6 +2339,12 @@ int git_repository_foreach_worktree(git_repository *repo, int error; size_t i; + /* apply operation to repository supplied when commondir is empty, implying there's + * no linked worktrees to iterate, which can occur when using custom odb/refdb + */ + if (!repo->commondir) + return cb(repo, payload); + if ((error = git_repository_open(&worktree_repo, repo->commondir)) < 0 || (error = cb(worktree_repo, payload) != 0)) goto out; |