Skip to content

Commit 8e765be

Browse files
committed
feature: enable core.untrackedCache=true and status.showUntrackedFiles=all while querying local changes include untracked files (#2016)
Signed-off-by: leo <[email protected]>
1 parent 85ce03e commit 8e765be

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/Commands/QueryLocalChanges.cs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using System.Diagnostics;
3+
using System.Text;
34
using System.Text.RegularExpressions;
45
using System.Threading.Tasks;
56

@@ -9,13 +10,21 @@ public partial class QueryLocalChanges : Command
910
{
1011
[GeneratedRegex(@"^(\s?[\w\?]{1,4})\s+(.+)$")]
1112
private static partial Regex REG_FORMAT();
12-
private static readonly string[] UNTRACKED = ["no", "all"];
1313

14-
public QueryLocalChanges(string repo, bool includeUntracked = true)
14+
public QueryLocalChanges(string repo, bool includeUntracked = true, bool noOptionalLocks = true)
1515
{
1616
WorkingDirectory = repo;
1717
Context = repo;
18-
Args = $"--no-optional-locks status -u{UNTRACKED[includeUntracked ? 1 : 0]} --ignore-submodules=dirty --porcelain";
18+
19+
var builder = new StringBuilder();
20+
if (noOptionalLocks)
21+
builder.Append("--no-optional-locks ");
22+
if (includeUntracked)
23+
builder.Append("-c core.untrackedCache=true -c status.showUntrackedFiles=all status -uall --ignore-submodules=dirty --porcelain");
24+
else
25+
builder.Append("status -uno --ignore-submodules=dirty --porcelain");
26+
27+
Args = builder.ToString();
1928
}
2029

2130
public async Task<List<Models.Change>> GetResultAsync()

src/ViewModels/Repository.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1305,10 +1305,11 @@ public void RefreshWorkingCopyChanges()
13051305

13061306
_cancellationRefreshWorkingCopyChanges = new CancellationTokenSource();
13071307
var token = _cancellationRefreshWorkingCopyChanges.Token;
1308+
var noOptionalLocks = Interlocked.Add(ref _queryLocalChangesTimes, 1) > 1;
13081309

13091310
Task.Run(async () =>
13101311
{
1311-
var changes = await new Commands.QueryLocalChanges(FullPath, _settings.IncludeUntrackedInLocalChanges)
1312+
var changes = await new Commands.QueryLocalChanges(FullPath, _settings.IncludeUntrackedInLocalChanges, noOptionalLocks)
13121313
.GetResultAsync()
13131314
.ConfigureAwait(false);
13141315

@@ -1901,6 +1902,7 @@ private async Task AutoFetchOnUIThread()
19011902
private Models.HistoryFilterCollection _historyFilterCollection = null;
19021903
private Models.FilterMode _historyFilterMode = Models.FilterMode.None;
19031904
private bool _hasAllowedSignersFile = false;
1905+
private ulong _queryLocalChangesTimes = 0;
19041906

19051907
private Models.Watcher _watcher = null;
19061908
private Histories _histories = null;

0 commit comments

Comments
 (0)