Skip to content
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

allow commit interaction binds on commit list within branch detail view #4263

Open
KiaraGrouwstra opened this issue Feb 14, 2025 · 3 comments
Labels
enhancement New feature or request

Comments

@KiaraGrouwstra
Copy link

Is your feature request related to a problem? Please describe.
when i use lazygit without thinking, i have on different occasions found myself navigating the 'local branches' panel, selecting a branch to enter its commit list, then feeling confused about the binds to interact with them being unavailable.
this would include actions Squash: s | Fixup: f | Reword: r | Drop: d | Edit: e | Amend: A | Checkout: <space>.

Describe the solution you'd like
have the commit interaction commands be available in the 'local branches' pane's commit list view as well, even if (in case of technical limitations) just for the checked out branch.

Describe alternatives you've considered
thinking harder about what i'm doing and realizing i'm using it wrong

Additional context
i don't know if this request makes sense, much less if it's elegant from technical or UX perspectives.
i just know i'm an oblivious user occasionally finding myself confused while using lazygit - and for all i know, this might be not just me.

@KiaraGrouwstra KiaraGrouwstra added the enhancement New feature or request label Feb 14, 2025
@ChrisMcD1
Copy link
Contributor

I've found myself in that situation before as well!

However, I'm not sure that the code easily lends itself to expanding the functionality of that view. What you are seeing there is the SubCommits context, which is filled by SubCommitsHelper.ViewSubCommits defined here:

func (self *SubCommitsHelper) ViewSubCommits(opts ViewSubCommitsOpts) error {
commits, err := self.c.Git().Loaders.CommitLoader.GetCommits(
git_commands.GetCommitsOptions{
Limit: true,
FilterPath: self.c.Modes().Filtering.GetPath(),
FilterAuthor: self.c.Modes().Filtering.GetAuthor(),
IncludeRebaseCommits: false,
RefName: opts.Ref.FullRefName(),
RefForPushedStatus: opts.Ref.FullRefName(),
RefToShowDivergenceFrom: opts.RefToShowDivergenceFrom,
MainBranches: self.c.Model().MainBranches,
},
)
if err != nil {
return err
}
self.setSubCommits(commits)
self.refreshHelper.RefreshAuthors(commits)
subCommitsContext := self.c.Contexts().SubCommits
subCommitsContext.SetSelection(0)
subCommitsContext.SetParentContext(opts.Context)
subCommitsContext.SetWindowName(opts.Context.GetWindowName())
subCommitsContext.SetTitleRef(utils.TruncateWithEllipsis(opts.TitleRef, 50))
subCommitsContext.SetRef(opts.Ref)
subCommitsContext.SetRefToShowDivergenceFrom(opts.RefToShowDivergenceFrom)
subCommitsContext.SetLimitCommits(true)
subCommitsContext.SetShowBranchHeads(opts.ShowBranchHeads)
subCommitsContext.ClearSearchString()
subCommitsContext.GetView().ClearSearch()
subCommitsContext.GetView().TitlePrefix = opts.Context.GetView().TitlePrefix
self.c.PostRefreshUpdate(self.c.Contexts().SubCommits)
self.c.Context().Push(self.c.Contexts().SubCommits)
return nil
}

which is a totally distinct context from the LocalCommits context where the squash, fixup, reword, etc commands are handled.

Additionally, several other top level contexts allow you to visit SubCommits. We would probably want the behavior to be consistent across all instances, but there would be no way to have consistent behavior for things like RemoteBranches.

for _, context := range []controllers.CanSwitchToSubCommits{
gui.State.Contexts.Branches,
gui.State.Contexts.RemoteBranches,
gui.State.Contexts.Tags,
gui.State.Contexts.ReflogCommits,
} {
controllers.AttachControllers(context, controllers.NewSwitchToSubCommitsController(
common, context,
))
}

As you point out, there is some logically consistent version of this where it behaves like the commits tab only when you are viewing the subcommits of your currently checked out branch. I could see that to leading to increased confusion though, as users will probably forget if they are viewing their currently checked out subcommits, or a different branch's subcommits.

If someone else has an idea of how to implement this though, I'd love to hear it!

@stefanhaller
Copy link
Collaborator

I have also been in that situation once or twice. However, I don't think offering the commands of the local commits panel in that view is a solution. Not because it's hard to implement (I'm sure we would find a way to do that), but because it doesn't feel right; this is a different view with a different purpose, and we shouldn't blur the line between them.

If this is really too confusing, I think we should rather try to find ways to make the two views visually different somehow, so that there's less confusion about which view you're in. I'm not a skilled UI designer, so I have no concrete suggestions how this might be achieved.

@KiaraGrouwstra
Copy link
Author

for what it's worth, when switching branches lazygit seems to know how to deal with unstaged changes, offering to automatically stash and unstash them.

in the event of commit actions on a different branch, i would imagine something like that could help as well, to allow temp switching into a branch to perform the requested actions.

whether it's desirable is a question i'll defer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants