From e0d4ec7f3832c0c7c32dc5282772886cff47aa1a Mon Sep 17 00:00:00 2001 From: Gadfly Date: Mon, 4 Aug 2025 17:23:19 +0800 Subject: [PATCH] fix: exclude main worktree by comparing with commonDir in submodules Fixes worktree detection in submodules where worktree.FullPath differs from commonDir path. --- src/ViewModels/Repository.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 5df604da8..1fdccd986 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -1219,12 +1219,17 @@ public void RefreshBranches() public void RefreshWorktrees() { var worktrees = new Commands.Worktree(_fullpath).ReadAllAsync().Result; + string commonDir = null; + if (worktrees.Count > 0) + commonDir = new Commands.QueryGitCommonDir(_fullpath).GetResultAsync().Result; var cleaned = new List(); foreach (var worktree in worktrees) { if (worktree.IsBare || worktree.FullPath.Equals(_fullpath)) continue; + if (!string.IsNullOrEmpty(commonDir) && worktree.FullPath.Equals(commonDir)) + continue; cleaned.Add(worktree); }