Skip to content

Conversation

@stefanhaller
Copy link
Collaborator

  • PR Description

In #4546 a user reported a crash in refresh when the repository is corrupt. It would be good not to crash, but to handle this gracefully. This PR does that.

However, this is probably not a good enough solution, because we only log the error (in RefreshHelper.refreshBranches) and don't communicate it otherwise to users. This is true for all errors that happen during refresh, though.

It is unclear how we could report refresh errors to users; showing them in a popup doesn't seem right. As long as we don't have a solution for this, it might actually be better to crash, so that users can file an issue and we tell them how to sort it out. Leaving as draft for the time being.

This is probably not a good enough solution, because we only log the error (in
RefreshHelper.refreshBranches) and don't communicate it otherwise to users. This
is true for all errors that happen during refresh, though.
@stefanhaller stefanhaller added the bug Something isn't working label May 9, 2025
@codacy-production
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for e6bd9d01 62.50%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (e6bd9d0) Report Missing Report Missing Report Missing
Head commit (c5a2a56) 56008 48624 86.82%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#4547) 8 5 62.50%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@stefanhaller stefanhaller added blocks-release Must be addressed before we can cut the next release and removed blocks-release Must be addressed before we can cut the next release labels Jul 5, 2025
@efussi
Copy link
Contributor

efussi commented Oct 5, 2025

I hit a similar error with lazygit 0.55.1, although the error message is a bit different:

panic: fatal: unknown error occurred while reading the configuration files
                                                               
                                                               
goroutine 500 [running]:                                
github.com/jesseduffield/lazygit/pkg/commands/git_commands.(*BranchLoader).obtainBranches(0xc0000a4140)
        /home/runner/work/lazygit/lazygit/pkg/commands/git_commands/branch_loader.go:238 +0x1c9
github.com/jesseduffield/lazygit/pkg/commands/git_commands.(*BranchLoader).Load(0xc0000a4140, {0xc00005ea08, 0x462, 0x49f}, 0xc00016e640, {0xc00190e180, 0x3, 0x68?}, 0x1, 0xc001b49ef0, ...)
        /home/runner/work/lazygit/lazygit/pkg/commands/git_commands/branch_loader.go:75 +0x65
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).refreshBranches(0xc0000a5640, 0x0, 0x0, 0x1)
        /home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:456 +0x246
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.3()
        /home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:131 +0x25
github.com/jesseduffield/lazygit/pkg/gui/controllers/helpers.(*RefreshHelper).Refresh.func2.1.1({0x4110c0?, 0xc000247dc0?})
        /home/runner/work/lazygit/lazygit/pkg/gui/controllers/helpers/refresh_helper.go:106 +0x13
github.com/jesseduffield/gocui.(*Gui).onWorkerAux(0xc0000ac000, 0x44c772?, {0x110c380?, 0xc001530740?})
        /home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:721 +0x65                                                                                                                                                              
github.com/jesseduffield/gocui.(*Gui).OnWorker.func1()  
        /home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:708 +0x2b
created by github.com/jesseduffield/gocui.(*Gui).OnWorker in goroutine 492
        /home/runner/work/lazygit/lazygit/vendor/github.com/jesseduffield/gocui/gui.go:707 +0x90

It would be helpful to know which configuration file it tried to read when the error occured. I successfully created and pushed a feature branch a few hours ago and wanted to update my local repo after the PR was merged when this happened. After the crash the remotes were gone -- git remote -v would return nothing. I tried git fsck, but it just reported a bunch of dangling objects (which I'd assume is harmless):

$ git fsck                                              
Checking ref database: 100% (1/1), done.              
Checking object directories: 100% (256/256), done.      
Checking objects: 100% (1616/1616), done.             
Checking connectivity: 4773, done.                      
dangling blob 2dc0bfc9c14300345e0a2ff4b5de569e3985689e  
dangling commit a180346e0bab1b81113a44cf36febe2276f49fda
: 

@stefanhaller
Copy link
Collaborator Author

@efussi This is an error from git, it is talking about your repository's config file (.git/config). If you can't figure out what's wrong with it by looking at it in a text editor, post it here and we can help figure it out.

@efussi
Copy link
Contributor

efussi commented Oct 5, 2025

Thanks for looking at this, @stefanhaller! Something must have messed up my .git/config and I assume lazygit tripped over the missing remotes in there. I have no indication lazygit is to blame for the corruption, and it works fine after I fixed the config file. So please ignore my previous message, it's just a similar stack trace that led me here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants