Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ _Legend: `<c-b>` means ctrl+b, `<a-b>` means alt+b, `B` means shift+b_
| `` t `` | Revert | Create a revert commit for the selected commit, which applies the selected commit's changes in reverse. |
| `` T `` | Tag commit | Create a new tag pointing at the selected commit. You'll be prompted to enter a tag name and optional description. |
| `` <c-l> `` | View log options | View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph. |
| `` z `` | Toggle first-parent only (flat view) | Show only first-parent commits, hiding all commits from merged branches. This gives a flat view of the main branch history. |
| `` <space> `` | Checkout | Checkout the selected commit as a detached HEAD. |
| `` y `` | Copy commit attribute to clipboard | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
| `` o `` | Open commit in browser | |
Expand Down
3 changes: 3 additions & 0 deletions pkg/commands/git_commands/commit_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ type GetCommitsOptions struct {
RefForPushedStatus models.Ref // the ref to use for determining pushed/unpushed status
// determines if we show the whole git graph i.e. pass the '--all' flag
All bool
// determines if we show only first-parent commits (flat view)
FirstParentOnly bool
// If non-empty, show divergence from this ref (left-right log)
RefToShowDivergenceFrom string
MainBranches *MainBranches
Expand Down Expand Up @@ -588,6 +590,7 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) *oscommands.CmdObj {
Arg(refSpec).
ArgIf(gitLogOrder != "default", "--"+gitLogOrder).
ArgIf(opts.All, "--all").
ArgIf(opts.FirstParentOnly, "--first-parent").
Arg("--oneline").
Arg(prettyFormat).
Arg("--abbrev=40").
Expand Down
11 changes: 11 additions & 0 deletions pkg/gui/context/local_commits_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ type LocalCommitsViewModel struct {

// If this is true we'll use git log --all when fetching the commits.
showWholeGitGraph bool

// If this is true we'll use git log --first-parent for a flat view.
showFirstParentOnly bool
}

func NewLocalCommitsViewModel(getModel func() []*models.Commit, c *ContextCommon) *LocalCommitsViewModel {
Expand Down Expand Up @@ -242,6 +245,14 @@ func (self *LocalCommitsViewModel) GetShowWholeGitGraph() bool {
return self.showWholeGitGraph
}

func (self *LocalCommitsViewModel) SetShowFirstParentOnly(value bool) {
self.showFirstParentOnly = value
}

func (self *LocalCommitsViewModel) GetShowFirstParentOnly() bool {
return self.showFirstParentOnly
}

func (self *LocalCommitsViewModel) GetCommits() []*models.Commit {
return self.getModel()
}
Expand Down
1 change: 1 addition & 0 deletions pkg/gui/controllers/helpers/refresh_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ func (self *RefreshHelper) refreshCommitsWithLimit() error {
RefName: self.refForLog(),
RefForPushedStatus: checkedOutRef,
All: self.c.Contexts().LocalCommits.GetShowWholeGitGraph(),
FirstParentOnly: self.c.Contexts().LocalCommits.GetShowFirstParentOnly(),
MainBranches: self.c.Model().MainBranches,
HashPool: self.c.Model().HashPool,
},
Expand Down
12 changes: 12 additions & 0 deletions pkg/gui/controllers/local_commits_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,12 @@ func (self *LocalCommitsController) GetKeybindings(opts types.KeybindingsOpts) [
Tooltip: self.c.Tr.OpenLogMenuTooltip,
OpensMenu: true,
},
{
Key: 'z',
Handler: self.toggleFirstParentOnly,
Description: self.c.Tr.ToggleFirstParentOnly,
Tooltip: self.c.Tr.ToggleFirstParentOnlyTooltip,
},
}

return bindings
Expand Down Expand Up @@ -1485,3 +1491,9 @@ func (self *LocalCommitsController) pickEnabled(selectedCommits []*models.Commit

return self.midRebaseCommandEnabled(selectedCommits, startIdx, endIdx)
}

func (self *LocalCommitsController) toggleFirstParentOnly() error {
self.context().SetShowFirstParentOnly(!self.context().GetShowFirstParentOnly())
self.c.Refresh(types.RefreshOptions{Scope: []types.RefreshableView{types.COMMITS}})
return nil
}
4 changes: 4 additions & 0 deletions pkg/i18n/english.go
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ type TranslationSet struct {
OpenLogMenu string
OpenLogMenuTooltip string
LogMenuTitle string
ToggleFirstParentOnly string
ToggleFirstParentOnlyTooltip string
ToggleShowGitGraphAll string
ShowGitGraph string
ShowGitGraphTooltip string
Expand Down Expand Up @@ -1876,6 +1878,8 @@ func EnglishTranslationSet() *TranslationSet {
OpenLogMenu: "View log options",
OpenLogMenuTooltip: "View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph.",
LogMenuTitle: "Commit Log Options",
ToggleFirstParentOnly: "Toggle first-parent only (flat view)",
ToggleFirstParentOnlyTooltip: "Show only first-parent commits, hiding all commits from merged branches. This gives a flat view of the main branch history.",
ToggleShowGitGraphAll: "Toggle show whole git graph (pass the `--all` flag to `git log`)",
ShowGitGraph: "Show git graph",
ShowGitGraphTooltip: "Show or hide the git graph in the commit log.\n\nThe default can be changed in the config file with the key 'git.log.showGraph'.",
Expand Down