From 053e6cb50e474214d43ed598a3f4e55a1534a3cc Mon Sep 17 00:00:00 2001 From: Bert Verhelst Date: Thu, 26 Nov 2026 13:59:07 +0100 Subject: [PATCH] fix: crash on startup when MERGE_HEAD points to an annotated tag Merging an annotated tag (e.g. `git merge v1.2.3`) writes the tag object's SHA to MERGE_HEAD. `git show ` then prints the tag header before the commit, shifting every line, and `QuerySingleCommit.Parse` threw a FormatException trying to parse a SHA as the author timestamp. Because the in-progress state is read on repository load, the app crashed every time it was reopened. Peel the revision to its commit with `^{commit}`, and parse the timestamps with TryParse so unexpected output returns null instead of crashing. Co-Authored-By: Claude Opus 5.5 --- src/Commands/QuerySingleCommit.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Commands/QuerySingleCommit.cs b/src/Commands/QuerySingleCommit.cs index 822f5c4a59..b2c106ebe5 100644 --- a/src/Commands/QuerySingleCommit.cs +++ b/src/Commands/QuerySingleCommit.cs @@ -9,7 +9,7 @@ public QuerySingleCommit(string repo, string sha) { WorkingDirectory = repo; Context = repo; - Args = $"show --no-show-signature --decorate=full --format=%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s -s {sha}"; + Args = $"show --no-show-signature --decorate=full --format=%H%n%P%n%D%n%aN±%aE%n%at%n%cN±%cE%n%ct%n%s -s {sha}^{{commit}}"; } public Models.Commit GetResult() @@ -39,10 +39,13 @@ private Models.Commit Parse(Result rs) commit.Parents.AddRange(lines[1].Split(' ', StringSplitOptions.RemoveEmptyEntries)); if (!string.IsNullOrEmpty(lines[2])) commit.ParseDecorators(lines[2]); + if (!ulong.TryParse(lines[4], out var authorTime) || !ulong.TryParse(lines[6], out var committerTime)) + return null; + commit.Author = Models.User.FindOrAdd(lines[3]); - commit.AuthorTime = ulong.Parse(lines[4]); + commit.AuthorTime = authorTime; commit.Committer = Models.User.FindOrAdd(lines[5]); - commit.CommitterTime = ulong.Parse(lines[6]); + commit.CommitterTime = committerTime; commit.Subject = lines[7]; return commit;