mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-21 13:20:30 +08:00
feature: enable core.untrackedCache=true and status.showUntrackedFiles=all while querying local changes include untracked files (#2016)
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -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<List<Models.Change>> GetResultAsync()
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user