mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-05-30 08:34:59 +00:00
optimize<LFS>: do NOT test LFS filter when LFS is not enabled
This commit is contained in:
parent
2cb93d5a86
commit
9d6a411887
10 changed files with 67 additions and 33 deletions
|
@ -17,6 +17,7 @@ namespace SourceGit.Views.Widgets {
|
|||
private List<Models.Change> cachedChanges = new List<Models.Change>();
|
||||
private string filter = null;
|
||||
private bool isSelecting = false;
|
||||
private bool isLFSEnabled = false;
|
||||
|
||||
public class ChangeNode {
|
||||
public string Path { get; set; } = "";
|
||||
|
@ -34,6 +35,7 @@ namespace SourceGit.Views.Widgets {
|
|||
this.repo = repo;
|
||||
this.range = range;
|
||||
this.cachedChanges = changes;
|
||||
this.isLFSEnabled = new Commands.LFS(repo).IsEnabled();
|
||||
|
||||
UpdateVisible();
|
||||
}
|
||||
|
@ -214,7 +216,8 @@ namespace SourceGit.Views.Widgets {
|
|||
diffViewer.Diff(repo, new DiffViewer.Option() {
|
||||
RevisionRange = revisions,
|
||||
Path = change.Path,
|
||||
OrgPath = change.OriginalPath
|
||||
OrgPath = change.OriginalPath,
|
||||
UseLFS = isLFSEnabled,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ namespace SourceGit.Views.Widgets {
|
|||
public string Path = "";
|
||||
public string OrgPath = null;
|
||||
public string ExtraArgs = "";
|
||||
public bool UseLFS = false;
|
||||
}
|
||||
|
||||
public class Block {
|
||||
|
@ -112,15 +113,17 @@ namespace SourceGit.Views.Widgets {
|
|||
if (!string.IsNullOrEmpty(opt.OrgPath)) args += $"\"{opt.OrgPath}\" ";
|
||||
args += $"\"{opt.Path}\"";
|
||||
|
||||
var isLFSObject = new Commands.IsLFSFiltered(repo, opt.Path).Result();
|
||||
if (isLFSObject) {
|
||||
var lc = new Commands.QueryLFSObjectChange(repo, args).Result();
|
||||
if (lc.IsValid) {
|
||||
SetLFSChange(lc, dummy);
|
||||
} else {
|
||||
SetSame(dummy);
|
||||
if (opt.UseLFS) {
|
||||
var isLFSObject = new Commands.LFS(repo).IsFiltered(opt.Path);
|
||||
if (isLFSObject) {
|
||||
var lc = new Commands.QueryLFSObjectChange(repo, args).Result();
|
||||
if (lc.IsValid) {
|
||||
SetLFSChange(lc, dummy);
|
||||
} else {
|
||||
SetSame(dummy);
|
||||
}
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var rs = new Commands.Diff(repo, args).Result();
|
||||
|
|
|
@ -17,6 +17,7 @@ namespace SourceGit.Views.Widgets {
|
|||
public partial class RevisionFiles : UserControl {
|
||||
private string repo = null;
|
||||
private string sha = null;
|
||||
private bool isLFSEnabled = false;
|
||||
|
||||
/// <summary>
|
||||
/// 文件列表树节点
|
||||
|
@ -37,6 +38,7 @@ namespace SourceGit.Views.Widgets {
|
|||
public void SetData(string repo, string sha, Commands.Context cancelToken) {
|
||||
this.repo = repo;
|
||||
this.sha = sha;
|
||||
this.isLFSEnabled = new Commands.LFS(repo).IsEnabled();
|
||||
|
||||
var cmd = new Commands.RevisionObjects(repo, sha) { Ctx = cancelToken };
|
||||
Task.Run(() => {
|
||||
|
@ -220,7 +222,7 @@ namespace SourceGit.Views.Widgets {
|
|||
|
||||
layerImagePreview.Visibility = Visibility.Visible;
|
||||
imgPreviewData.Source = new BitmapImage(new Uri(tmp, UriKind.Absolute));
|
||||
} else if (new Commands.IsLFSFiltered(repo, node.Path).Result()) {
|
||||
} else if (isLFSEnabled && new Commands.LFS(repo).IsFiltered(node.Path)) {
|
||||
var lfs = new Commands.QueryLFSObject(repo, sha, node.Path).Result();
|
||||
layerRevisionPreview.Visibility = Visibility.Visible;
|
||||
iconRevisionPreview.Data = FindResource("Icon.LFS") as Geometry;
|
||||
|
|
|
@ -12,9 +12,11 @@ namespace SourceGit.Views.Widgets {
|
|||
public partial class Stashes : UserControl {
|
||||
private string repo = null;
|
||||
private string selected = null;
|
||||
private bool isLFSEnabled = false;
|
||||
|
||||
public Stashes(string repo) {
|
||||
this.repo = repo;
|
||||
this.isLFSEnabled = new Commands.LFS(repo).IsEnabled();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
@ -44,7 +46,8 @@ namespace SourceGit.Views.Widgets {
|
|||
diffViewer.Diff(repo, new DiffViewer.Option() {
|
||||
RevisionRange = new string[] { selected + "^", selected },
|
||||
Path = change.Path,
|
||||
OrgPath = change.OriginalPath
|
||||
OrgPath = change.OriginalPath,
|
||||
UseLFS = isLFSEnabled,
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,11 +11,13 @@ namespace SourceGit.Views.Widgets {
|
|||
/// </summary>
|
||||
public partial class WorkingCopy : UserControl {
|
||||
private Models.Repository repo = null;
|
||||
private bool isLFSEnabled = false;
|
||||
|
||||
public string CommitMessage { get; set; }
|
||||
|
||||
public WorkingCopy(Models.Repository repo) {
|
||||
this.repo = repo;
|
||||
this.isLFSEnabled = new Commands.LFS(repo.Path).IsEnabled();
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
|
@ -136,13 +138,15 @@ namespace SourceGit.Views.Widgets {
|
|||
diffViewer.Diff(repo.Path, new DiffViewer.Option() {
|
||||
ExtraArgs = "--no-index",
|
||||
Path = change.Path,
|
||||
OrgPath = "/dev/null"
|
||||
OrgPath = "/dev/null",
|
||||
UseLFS = isLFSEnabled
|
||||
});
|
||||
break;
|
||||
default:
|
||||
diffViewer.Diff(repo.Path, new DiffViewer.Option() {
|
||||
Path = change.Path,
|
||||
OrgPath = change.OriginalPath
|
||||
OrgPath = change.OriginalPath,
|
||||
UseLFS = isLFSEnabled
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
@ -150,7 +154,8 @@ namespace SourceGit.Views.Widgets {
|
|||
diffViewer.Diff(repo.Path, new DiffViewer.Option() {
|
||||
ExtraArgs = "--cached",
|
||||
Path = change.Path,
|
||||
OrgPath = change.OriginalPath
|
||||
OrgPath = change.OriginalPath,
|
||||
UseLFS = isLFSEnabled
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue