diff --git a/src/Commands/QueryLocalChanges.cs b/src/Commands/QueryLocalChanges.cs index 385a95f2..d1bd30a2 100644 --- a/src/Commands/QueryLocalChanges.cs +++ b/src/Commands/QueryLocalChanges.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Diagnostics; +using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -9,13 +10,21 @@ namespace SourceGit.Commands { [GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")] private static partial Regex REG_FORMAT(); - private static readonly string[] UNTRACKED = ["no", "all"]; - public QueryLocalChanges(string repo, bool includeUntracked = true) + public QueryLocalChanges(string repo, bool includeUntracked = true, bool noOptionalLocks = true) { WorkingDirectory = repo; Context = repo; - Args = $"--no-optional-locks status -u{UNTRACKED[includeUntracked ? 1 : 0]} --ignore-submodules=dirty --porcelain"; + + var builder = new StringBuilder(); + if (noOptionalLocks) + builder.Append("--no-optional-locks "); + if (includeUntracked) + builder.Append("-c core.untrackedCache=true -c status.showUntrackedFiles=all status -uall --ignore-submodules=dirty --porcelain"); + else + builder.Append("status -uno --ignore-submodules=dirty --porcelain"); + + Args = builder.ToString(); } public async Task> GetResultAsync() diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 5ab2d1c2..088be4f1 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -1305,10 +1305,11 @@ namespace SourceGit.ViewModels _cancellationRefreshWorkingCopyChanges = new CancellationTokenSource(); var token = _cancellationRefreshWorkingCopyChanges.Token; + var noOptionalLocks = Interlocked.Add(ref _queryLocalChangesTimes, 1) > 1; Task.Run(async () => { - var changes = await new Commands.QueryLocalChanges(FullPath, _settings.IncludeUntrackedInLocalChanges) + var changes = await new Commands.QueryLocalChanges(FullPath, _settings.IncludeUntrackedInLocalChanges, noOptionalLocks) .GetResultAsync() .ConfigureAwait(false); @@ -1901,6 +1902,7 @@ namespace SourceGit.ViewModels private Models.HistoryFilterCollection _historyFilterCollection = null; private Models.FilterMode _historyFilterMode = Models.FilterMode.None; private bool _hasAllowedSignersFile = false; + private ulong _queryLocalChangesTimes = 0; private Models.Watcher _watcher = null; private Histories _histories = null;