Visualize local branch heads in commits panel#2737
Visualize local branch heads in commits panel#2737stefanhaller wants to merge 8 commits intomasterfrom
Conversation
efd5125 to
9fdcc64
Compare
|
@jesseduffield I'd be interested in your thoughts on this. The branch conflicts pretty heavily with other work that I have open, so it's going to be painful to carry it around for longer. |
|
@stefanhaller I intend to get around to this: but have yet to find the time to properly read through the issue |
|
I agree, and it does do that for me. I'm using the delta pager, which seems to add this information. I was a bit surprised to see that, I didn't actually know this would be possible, as I thought the pager was purely a post-processor; but I don't see any other config setting that could be responsible for this. Give it a try, delta is awesome anyway. 😄 |
|
Hm, it looks like git bases the decision whether or not to show the branch annotation on whether output goes to a tty; I don't see a git option to influence this. So if you don't like delta, a very crude workaround is to set your pager to I still don't fully understand it, I wonder if it's a bug in git. |
This works great. I do wonder if this should be default for lazygit. |
|
I read the git source code a bit, and found that it's intentional to show ref names when the output is a tty, and don't show them if not. This corresponds to the For lazygit, the best fix is to pass |
9fdcc64 to
64a6341
Compare
|
PR is here: #2748 |
It shows that right now, we take only the first tag if there are multiple. Judging from how the code is written, I'm not sure this was intentional.
We now store all tags in this field if there are several.
These tests not only test the correct handling and display of the updateRef command, but also the visualization of branch heads in the commits panel. Since we are about to change the behavior here, extend the tests so that a master commit is added (we don't want this to be visualized as a branch head), and then a stack of two non-main branches. At the end of this branch we only want to visualize the head commit of the first.
This allow us to check not only whether a given commit has the branch head marker, but also that other commits _don't_ have it, which is important.
Don't visualize branch heads of main branches or remote branches.
It should no longer be needed now, because the (*) marker now only appears for stacks of local branches, and in this situation it is always useful and shouldn't confuse people who create such stacks.
64a6341 to
3cb954c
Compare
jesseduffield
left a comment
There was a problem hiding this comment.
I haven't looked closely at the code but one thing I want to explore is not involving remotes when loading the commits. If these markers are purely presentational we could instead filter out remote branch heads in the presentation package. The reason for this is that it means we don't need to ensure they're loaded by the time we're loading our commits. When I run this PR locally I see the head markers appear briefly and then disappear. I'm not sure why that is but I assume it's due to the remotes and if so, leaving it to the presentation layer should fix the issue
|
Actually something that just occurred to me that could vastly simplify this: we now obtain commit hashes when we load local branches. We could use those when displaying the commits. That would spare much of the complexity of the current solution. That is: in the presentation package, when displaying commits, we pass in branch commit hashes and if a given commit matches the hash, we show the marker. The only extra thing is that we'd need to refresh the commits view after loading branches (trivially easy to do) |
That's a great idea, I'm trying this right now, and indeed it greatly simplifies things. One thing that I'm not sure how to do: I need to read |
|
I agree that we should obtain that info ahead of time to keep the presentation code pure. I'm happy to add the merge head as a field on our Model struct and set that from RefreshHelper (perhaps as part of loading branches or loading commits, or as its own separate thing). |
|
Since the new approach is quite different from this one, I'm opening a new PR for it: #2775. |






This implements the approach suggested in #2735, and removes the
experimentalShowBranchHeadsconfig again because it should no longer be needed.