Merge pull request #2784 from herjarsa/fix/silence-worktree-warning-for-non-git-dirs

fix(git): silence getWorktrees warning when directory is not a repo
This commit is contained in:
Bohdan Triapitsyn
2026-08-28 01:23:51 +03:00
committed by GitHub
2 changed files with 52 additions and 2 deletions
+9 -1
View File
@@ -3898,7 +3898,15 @@ export async function getWorktrees(directory) {
path: entry.worktree,
}));
} catch (error) {
console.warn('Failed to list worktrees, returning empty list:', error?.message || error);
// Worktrees are an optional feature. When the caller passes a directory
// that is not inside any git repository (for example, the managed
// OpenCode's working directory or an unconfigured project path), git
// exits with "fatal: not a git repository ...". Treat that as an
// authoritative empty result so the route handler can still respond
// 200 [] and the desktop main.log stays free of noise.
if (!isNotGitRepositoryError(error)) {
console.warn('Failed to list worktrees, returning empty list:', error?.message || error);
}
return [];
}
}