mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-07 20:04:59 +00:00
refactor: add new constant Models.Commit.EmptyTreeSHA1
(#1360)
This commit is contained in:
parent
f3fe90b2e1
commit
4363b8b6aa
6 changed files with 12 additions and 9 deletions
|
@ -336,7 +336,7 @@ namespace SourceGit.ViewModels
|
|||
options.DefaultExtension = ".patch";
|
||||
options.FileTypeChoices = [new FilePickerFileType("Patch File") { Patterns = ["*.patch"] }];
|
||||
|
||||
var baseRevision = _commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : _commit.Parents[0];
|
||||
var baseRevision = _commit.Parents.Count == 0 ? Models.Commit.EmptyTreeSHA1 : _commit.Parents[0];
|
||||
var storageFile = await storageProvider.SaveFilePickerAsync(options);
|
||||
if (storageFile != null)
|
||||
{
|
||||
|
@ -595,7 +595,7 @@ namespace SourceGit.ViewModels
|
|||
|
||||
Task.Run(() =>
|
||||
{
|
||||
var parent = _commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : _commit.Parents[0];
|
||||
var parent = _commit.Parents.Count == 0 ? Models.Commit.EmptyTreeSHA1 : _commit.Parents[0];
|
||||
var cmd = new Commands.CompareRevisions(_repo.FullPath, parent, _commit.SHA) { CancellationToken = token };
|
||||
var changes = cmd.Result();
|
||||
var visible = changes;
|
||||
|
|
|
@ -69,7 +69,7 @@ namespace SourceGit.ViewModels
|
|||
changes = new Commands.CompareRevisions(_repo.FullPath, $"{value.SHA}^", value.SHA).Result();
|
||||
if (value.Parents.Count == 3)
|
||||
{
|
||||
var untracked = new Commands.CompareRevisions(_repo.FullPath, "4b825dc642cb6eb9a060e54bf8d69288fbee4904", value.Parents[2]).Result();
|
||||
var untracked = new Commands.CompareRevisions(_repo.FullPath, Models.Commit.EmptyTreeSHA1, value.Parents[2]).Result();
|
||||
var needSort = changes.Count > 0;
|
||||
|
||||
foreach (var c in untracked)
|
||||
|
@ -107,7 +107,7 @@ namespace SourceGit.ViewModels
|
|||
if (value == null)
|
||||
DiffContext = null;
|
||||
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(Models.Commit.EmptyTreeSHA1, _selectedStash.Parents[2], value), _diffContext);
|
||||
else
|
||||
DiffContext = new DiffContext(_repo.FullPath, new Models.DiffOption(_selectedStash.Parents[0], _selectedStash.SHA, value), _diffContext);
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ namespace SourceGit.ViewModels
|
|||
foreach (var c in _changes)
|
||||
{
|
||||
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(Models.Commit.EmptyTreeSHA1, _selectedStash.Parents[2], c));
|
||||
else
|
||||
opts.Add(new Models.DiffOption(_selectedStash.Parents[0], _selectedStash.SHA, c));
|
||||
}
|
||||
|
|
|
@ -1528,7 +1528,7 @@ namespace SourceGit.ViewModels
|
|||
if (_useAmend)
|
||||
{
|
||||
var head = new Commands.QuerySingleCommit(_repo.FullPath, "HEAD").Result();
|
||||
return new Commands.QueryStagedChangesWithAmend(_repo.FullPath, head.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : $"{head.SHA}^").Result();
|
||||
return new Commands.QueryStagedChangesWithAmend(_repo.FullPath, head.Parents.Count == 0 ? Models.Commit.EmptyTreeSHA1 : $"{head.SHA}^").Result();
|
||||
}
|
||||
|
||||
var rs = new List<Models.Change>();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue