fix: no changes were displayed when try to amend a commit without parent (branch first commit) (#1231)

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2025-04-22 19:04:40 +08:00
parent 87ebe3741d
commit 78f4809875
No known key found for this signature in database
2 changed files with 6 additions and 3 deletions

View file

@ -1524,7 +1524,10 @@ namespace SourceGit.ViewModels
private List<Models.Change> GetStagedChanges()
{
if (_useAmend)
return new Commands.QueryStagedChangesWithAmend(_repo.FullPath).Result();
{
var head = new Commands.QuerySingleCommit(_repo.FullPath, "HEAD").Result();
return new Commands.QueryStagedChangesWithAmend(_repo.FullPath, head.Parents.Count == 0 ? "4b825dc642cb6eb9a060e54bf8d69288fbee4904" : "HEAD^").Result();
}
var rs = new List<Models.Change>();
foreach (var c in _cached)