Repository navigation
fix: crash on startup when MERGE_HEAD points to an annotated tag - #2904
Merged
JC-Chung merged 1 commit intoNov 27, 2026
Merged
Conversation
Merging an annotated tag (e.g. `git merge v1.2.3`) writes the tag object's
SHA to MERGE_HEAD. `git show <tag-sha>` 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 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When a repository has an in-progress merge of an annotated tag (e.g.
git merge v1.2.3),MERGE_HEADcontains the tag object's SHA rather than a commit SHA. Opening that repository crashes SourceGit, and because the repository is reopened on launch, the app crashes again immediately on every restart.git show <tag-sha>prints the tag header (tag ...,Tagger: ..., message) before the commit. That shifts the formatted lines, soulong.Parse(lines[4])gets the commit SHA instead of the author timestamp.Steps to reproduce
MERGE_HEADholds the tag object, not a commit:git cat-file -t $(cat .git/MERGE_HEAD)printstag.FormatExceptionbelow, and crashes again on every restart while the repo stays open.Fix
QuerySingleCommitnow asks for<sha>^{commit}, so tags are peeled to their commit. This also covers the other callers that can pass a tag SHA.TryParse. Unexpected output now returnsnull, which all callers already handle, instead of throwing on the UI thread.Testing
MERGE_HEADpointing at an annotated tag: before the fix the app crashed on launch, after the fix it opens normally.git show ... <tag-sha>^{commit}returns the commit fields in the expected order.🤖 Generated with Claude Code