diff --git a/src/Commands/QueryStagedChangesWithAmend.cs b/src/Commands/QueryStagedChangesWithAmend.cs index 93dcdb37..8f8456c9 100644 --- a/src/Commands/QueryStagedChangesWithAmend.cs +++ b/src/Commands/QueryStagedChangesWithAmend.cs @@ -16,6 +16,7 @@ namespace SourceGit.Commands WorkingDirectory = repo; Context = repo; Args = $"diff-index --cached -M {parent}"; + _parent = parent; } public List Result() @@ -37,6 +38,7 @@ namespace SourceGit.Commands { FileMode = match.Groups[1].Value, ObjectHash = match.Groups[2].Value, + ParentSHA = _parent, }, }; change.Set(Models.ChangeState.Renamed); @@ -54,6 +56,7 @@ namespace SourceGit.Commands { FileMode = match.Groups[1].Value, ObjectHash = match.Groups[2].Value, + ParentSHA = _parent, }, }; @@ -88,5 +91,7 @@ namespace SourceGit.Commands return []; } + + private string _parent = string.Empty; } } diff --git a/src/Models/Change.cs b/src/Models/Change.cs index e9d07181..0c96ec95 100644 --- a/src/Models/Change.cs +++ b/src/Models/Change.cs @@ -26,6 +26,7 @@ namespace SourceGit.Models { public string FileMode { get; set; } = ""; public string ObjectHash { get; set; } = ""; + public string ParentSHA { get; set; } = ""; } public class Change diff --git a/src/Models/DiffOption.cs b/src/Models/DiffOption.cs index 98387e7f..31d83cea 100644 --- a/src/Models/DiffOption.cs +++ b/src/Models/DiffOption.cs @@ -40,7 +40,7 @@ namespace SourceGit.Models else { if (change.DataForAmend != null) - _extra = "--cached HEAD^"; + _extra = $"--cached {change.DataForAmend.ParentSHA}"; else _extra = "--cached"; diff --git a/src/ViewModels/WorkingCopy.cs b/src/ViewModels/WorkingCopy.cs index 906248eb..6402878a 100644 --- a/src/ViewModels/WorkingCopy.cs +++ b/src/ViewModels/WorkingCopy.cs @@ -1526,8 +1526,8 @@ 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^").Result(); - } + return new Commands.QueryStagedChangesWithAmend(_repo.FullPath, head.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : $"{head.SHA}^").Result(); + } var rs = new List(); foreach (var c in _cached)