mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-26 03:40:45 +08:00
code_review: PR #1660
Since `$GIT_DIR` is the same with `$GIT_COMMON_DIR` for submodules, use `$GIT_DIR` directly to ignore submodule's main worktree while querying worktrees Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -1219,25 +1219,32 @@ namespace SourceGit.ViewModels
|
||||
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<Models.Worktree>();
|
||||
|
||||
foreach (var worktree in worktrees)
|
||||
{
|
||||
if (worktree.IsBare || worktree.FullPath.Equals(_fullpath))
|
||||
continue;
|
||||
if (!string.IsNullOrEmpty(commonDir) && worktree.FullPath.Equals(commonDir))
|
||||
continue;
|
||||
var cleaned = new List<Models.Worktree>();
|
||||
var normalizedGitDir = _gitDir.Replace('\\', '/');
|
||||
|
||||
cleaned.Add(worktree);
|
||||
foreach (var worktree in worktrees)
|
||||
{
|
||||
if (worktree.FullPath.Equals(_fullpath, StringComparison.Ordinal) ||
|
||||
worktree.FullPath.Equals(normalizedGitDir, StringComparison.Ordinal))
|
||||
continue;
|
||||
|
||||
cleaned.Add(worktree);
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
Worktrees = cleaned;
|
||||
});
|
||||
}
|
||||
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
else
|
||||
{
|
||||
Worktrees = cleaned;
|
||||
});
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
Worktrees = worktrees;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshTags()
|
||||
|
||||
Reference in New Issue
Block a user