Fix crash when opening a repo with no commits and a remote#497
Open
evanrichter wants to merge 1 commit intoaltsem:masterfrom
Open
Fix crash when opening a repo with no commits and a remote#497evanrichter wants to merge 1 commit intoaltsem:masterfrom
evanrichter wants to merge 1 commit intoaltsem:masterfrom
Conversation
The status parser crashed when opening a repo with no commits but with a remote configured, where git outputs: ## No commits yet on main...origin/main [gone] Updated parse_no_commits to handle the optional remote and ahead/behind info, matching the behavior of parse_branch_status.
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.
I found an edge case that crashes gitu on startup when run in a fresh clone of a new/empty repo.
When a git repository has no commits but has a remote configured,
git status --porcelain --branchoutputs:The status parser only handled the simple case (## No commits yet on main) and failed to parse the remote and [gone] suffix, causing a panic at src/git/mod.rs:174.
This PR updates
parse_no_commitsto handle the optional remote branch and ahead/behind info (like [gone]), following the same logic asparse_branch_status.Steps to reproduce:
Error:
Checklist
make testis passing (this is what CI runs).feat:/fix:/style:/perf:. Or e.g.perf(highlighting):.See https://github.com/altsem/gitu/blob/master/docs/dev-tooling.md