Skip to content

Commit 6cad70d

Browse files
authored
fix: exclude main worktree by comparing with commonDir in submodules (#1660)
Fixes worktree detection in submodules where worktree.FullPath differs from commonDir path.
1 parent e9bc7fc commit 6cad70d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/ViewModels/Repository.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1219,12 +1219,17 @@ public void RefreshBranches()
12191219
public void RefreshWorktrees()
12201220
{
12211221
var worktrees = new Commands.Worktree(_fullpath).ReadAllAsync().Result;
1222+
string commonDir = null;
1223+
if (worktrees.Count > 0)
1224+
commonDir = new Commands.QueryGitCommonDir(_fullpath).GetResultAsync().Result;
12221225
var cleaned = new List<Models.Worktree>();
12231226

12241227
foreach (var worktree in worktrees)
12251228
{
12261229
if (worktree.IsBare || worktree.FullPath.Equals(_fullpath))
12271230
continue;
1231+
if (!string.IsNullOrEmpty(commonDir) && worktree.FullPath.Equals(commonDir))
1232+
continue;
12281233

12291234
cleaned.Add(worktree);
12301235
}

0 commit comments

Comments
 (0)