Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Commands/IsBinary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public IsBinary(string repo, string commit, string path)
{
WorkingDirectory = repo;
Context = repo;
Args = $"diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904 {commit} --numstat -- \"{path}\"";
Args = $"diff {Models.Commit.EmptyTreeSHA1} {commit} --numstat -- \"{path}\"";
RaiseError = false;
}

Expand Down
3 changes: 3 additions & 0 deletions src/Models/Commit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ public enum CommitSearchMethod

public class Commit
{
// As retrieved by: git mktree </dev/null
public static readonly string EmptyTreeSHA1 = "4b825dc642cb6eb9a060e54bf8d69288fbee4904";

public static double OpacityForNotMerged
{
get;
Expand Down
4 changes: 2 additions & 2 deletions src/Models/DiffOption.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public DiffOption(Change change, bool isUnstaged)
/// <param name="change"></param>
public DiffOption(Commit commit, Change change)
{
var baseRevision = commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : $"{commit.SHA}^";
var baseRevision = commit.Parents.Count == 0 ? Models.Commit.EmptyTreeSHA1 : $"{commit.SHA}^";
_revisions.Add(baseRevision);
_revisions.Add(commit.SHA);
_path = change.Path;
Expand All @@ -79,7 +79,7 @@ public DiffOption(Commit commit, Change change)
/// <param name="file"></param>
public DiffOption(Commit commit, string file)
{
var baseRevision = commit.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : $"{commit.SHA}^";
var baseRevision = commit.Parents.Count == 0 ? Models.Commit.EmptyTreeSHA1 : $"{commit.SHA}^";
_revisions.Add(baseRevision);
_revisions.Add(commit.SHA);
_path = file;
Expand Down
4 changes: 2 additions & 2 deletions src/ViewModels/CommitDetail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public ContextMenu CreateChangeContextMenu(Models.Change change)
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)
{
Expand Down Expand Up @@ -595,7 +595,7 @@ private void Refresh()

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;
Expand Down
6 changes: 3 additions & 3 deletions src/ViewModels/StashesPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public Models.Stash SelectedStash
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)
Expand Down Expand Up @@ -107,7 +107,7 @@ public Models.Change SelectedChange
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);
}
Expand Down Expand Up @@ -182,7 +182,7 @@ public ContextMenu MakeContextMenu(Models.Stash stash)
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));
}
Expand Down
2 changes: 1 addition & 1 deletion src/ViewModels/WorkingCopy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1528,7 +1528,7 @@ public ContextMenu CreateContextForOpenAI()
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>();
Expand Down