mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-21 20:24:59 +00:00
refactor: it's not necessary to store untracked file list for selected stash
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
891e1b2ec8
commit
65dbfd336d
2 changed files with 8 additions and 18 deletions
|
@ -10,7 +10,6 @@ namespace SourceGit.Models
|
||||||
public List<string> Parents { get; set; } = [];
|
public List<string> Parents { get; set; } = [];
|
||||||
public ulong Time { get; set; } = 0;
|
public ulong Time { get; set; } = 0;
|
||||||
public string Message { get; set; } = "";
|
public string Message { get; set; } = "";
|
||||||
public bool HasUntracked => Parents.Count == 3;
|
|
||||||
|
|
||||||
public string TimeStr => DateTime.UnixEpoch.AddSeconds(Time).ToLocalTime().ToString(DateTimeFormat.Actived.DateTime);
|
public string TimeStr => DateTime.UnixEpoch.AddSeconds(Time).ToLocalTime().ToString(DateTimeFormat.Actived.DateTime);
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,24 +59,16 @@ namespace SourceGit.ViewModels
|
||||||
Task.Run(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
var changes = new Commands.CompareRevisions(_repo.FullPath, $"{value.SHA}^", value.SHA).Result();
|
var changes = new Commands.CompareRevisions(_repo.FullPath, $"{value.SHA}^", value.SHA).Result();
|
||||||
var untracked = new HashSet<string>();
|
if (value.Parents.Count == 3)
|
||||||
if (value.HasUntracked)
|
|
||||||
{
|
{
|
||||||
var untrackedChanges = new Commands.CompareRevisions(_repo.FullPath, "4b825dc642cb6eb9a060e54bf8d69288fbee4904", value.Parents[2]).Result();
|
var untracked = new Commands.CompareRevisions(_repo.FullPath, "4b825dc642cb6eb9a060e54bf8d69288fbee4904", value.Parents[2]).Result();
|
||||||
foreach (var c in untrackedChanges)
|
foreach (var c in untracked)
|
||||||
{
|
|
||||||
untracked.Add(c.Path);
|
|
||||||
changes.Add(c);
|
changes.Add(c);
|
||||||
}
|
|
||||||
|
changes.Sort((l, r) => string.Compare(l.Path, r.Path, StringComparison.Ordinal));
|
||||||
}
|
}
|
||||||
|
|
||||||
changes.Sort((l, r) => Models.NumericSort.Compare(l.Path, r.Path));
|
Dispatcher.UIThread.Invoke(() => Changes = changes);
|
||||||
|
|
||||||
Dispatcher.UIThread.Invoke(() =>
|
|
||||||
{
|
|
||||||
Changes = changes;
|
|
||||||
_untrackedChanges = untracked;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -102,7 +94,7 @@ namespace SourceGit.ViewModels
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
DiffContext = null;
|
DiffContext = null;
|
||||||
else if (_untrackedChanges.Contains(value.Path))
|
else if (value.Index == Models.ChangeState.Added && _selectedStash.Parents.Count == 3)
|
||||||
DiffContext = new DiffContext(_repo.FullPath, new Models.DiffOption("4b825dc642cb6eb9a060e54bf8d69288fbee4904", _selectedStash.Parents[2], value), _diffContext);
|
DiffContext = new DiffContext(_repo.FullPath, new Models.DiffOption("4b825dc642cb6eb9a060e54bf8d69288fbee4904", _selectedStash.Parents[2], value), _diffContext);
|
||||||
else
|
else
|
||||||
DiffContext = new DiffContext(_repo.FullPath, new Models.DiffOption(_selectedStash.Parents[0], _selectedStash.SHA, value), _diffContext);
|
DiffContext = new DiffContext(_repo.FullPath, new Models.DiffOption(_selectedStash.Parents[0], _selectedStash.SHA, value), _diffContext);
|
||||||
|
@ -178,7 +170,7 @@ namespace SourceGit.ViewModels
|
||||||
var opts = new List<Models.DiffOption>();
|
var opts = new List<Models.DiffOption>();
|
||||||
foreach (var c in _changes)
|
foreach (var c in _changes)
|
||||||
{
|
{
|
||||||
if (_untrackedChanges.Contains(c.Path))
|
if (c.Index == Models.ChangeState.Added && _selectedStash.Parents.Count == 3)
|
||||||
opts.Add(new Models.DiffOption("4b825dc642cb6eb9a060e54bf8d69288fbee4904", _selectedStash.Parents[2], c));
|
opts.Add(new Models.DiffOption("4b825dc642cb6eb9a060e54bf8d69288fbee4904", _selectedStash.Parents[2], c));
|
||||||
else
|
else
|
||||||
opts.Add(new Models.DiffOption(_selectedStash.Parents[0], _selectedStash.SHA, c));
|
opts.Add(new Models.DiffOption(_selectedStash.Parents[0], _selectedStash.SHA, c));
|
||||||
|
@ -303,7 +295,6 @@ namespace SourceGit.ViewModels
|
||||||
private List<Models.Stash> _visibleStashes = new List<Models.Stash>();
|
private List<Models.Stash> _visibleStashes = new List<Models.Stash>();
|
||||||
private string _searchFilter = string.Empty;
|
private string _searchFilter = string.Empty;
|
||||||
private Models.Stash _selectedStash = null;
|
private Models.Stash _selectedStash = null;
|
||||||
private HashSet<string> _untrackedChanges = new HashSet<string>();
|
|
||||||
private List<Models.Change> _changes = null;
|
private List<Models.Change> _changes = null;
|
||||||
private Models.Change _selectedChange = null;
|
private Models.Change _selectedChange = null;
|
||||||
private DiffContext _diffContext = null;
|
private DiffContext _diffContext = null;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue