-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Add fallback to detecting main branches for fresh repositories #5079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
4cedcf9 to
17352fb
Compare
All other attempts to determine the main branch fail on a fresh repository right after `git init` because there are no actual commits that these branches point to.
17352fb to
05411e7
Compare
|
Converted to draft while I fix up the test failures |
|
I don't think this is the best approach; it doesn't address the root cause. There are other situations where the main branches get stale, for example if you rename your master branch to main; you'll have to restart lazygit for it to pick up that change, too. I'd prefer a solution that takes care of all these situations. The real issue is that we cache the determined main branch refs and then never forget them again (unless the user config changes). The challenge is to find the right conditions under which to drop the cache; an easy and straightforward solution would be to drop the cache at the beginning of refresh whenever the refresh scope includes commits or branches, but I'm not sure we want to afford that. Maybe it's good enough (it won't affect the timing of starting up lazygit, which is the most important), but we'd have to take some measurements to see if we want to incur the cost on every refresh. Investigating this didn't have high priority for me so far because the situations in which it is buggy are so rare, and easily fixed by restarting lazygit. |
I don't consider this bug report a matter of staleness, and do think this is a root cause fix. This bug occurs on fresh repositories right after a: because none of the previous 3 methods of detection of main branches work without an associated commit (all
If the primary objection is that this would add a few ms potentially to startup times as we reach this 4th fallback for non-relevant branches like |
Yes, and the reason is that a branch without commits doesn't really exist yet (it's what git calls an "unborn branch"). It doesn't show up in the output of
Yes, and the reason is that we need to re-determine the existing main branches at that point, because the main branch now exists when it didn't before.
No, that's not my objection to your fix. I was talking about the performance implications of the other (better) fix, which adds time to every refresh except the one at startup.
I wasn't suggesting to close it as won't-fix, I was suggesting to use a different fix instead. |
PR Description
All other attempts to determine the main branch fail on a fresh repository right after
git initbecause there are no actual commits that these branches point to.Fixes #5058
Please check if the PR fulfills these requirements
go generate ./...)