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/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ keybinding:
resetCherryPick: <ctrl+r>
copyCommitAttributeToClipboard: "y"
openLogMenu: <ctrl+l>
toggleOverviewMode: "~"
openInBrowser: o
openPullRequestInBrowser: G
viewBisectOptions: b
Expand Down
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 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` 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. |
| `` <ctrl+l> `` | View log options | View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph. |
| `` ~ `` | Toggle overview mode | Only show merge commits, and commits that a local or remote branch, a tag, or HEAD points to; hide all other commits. Useful for getting a high-level view of the history. |
| `` G `` | Open pull request in browser | |
| `` <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). |
Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` t `` | リバート | 選択したコミットの変更を逆に適用する、リバートコミットを作成します。 |
| `` T `` | コミットにタグを付ける | 選択したコミットを指すタグを新規作成します。タグ名とオプションの説明を入力するよう促されます。 |
| `` <ctrl+l> `` | ログオプションを表示 | コミットログのオプションを表示します(例:並び順の変更、Gitグラフの非表示、Gitグラフ全体の表示)。 |
| `` ~ `` | Toggle overview mode | Only show merge commits, and commits that a local or remote branch, a tag, or HEAD points to; hide all other commits. Useful for getting a high-level view of the history. |
| `` G `` | Open pull request in browser | |
| `` <space> `` | チェックアウト(ブランチの切り替え) | 選択したコミットをデタッチドヘッド(特定のブランチに属さない状態)としてチェックアウトします。 |
| `` y `` | コミット属性をクリップボードにコピー | コミット属性をクリップボードにコピーします(例:ハッシュ、URL、差分、メッセージ、作者)。 |
Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_ko.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` 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. |
| `` <ctrl+l> `` | 로그 메뉴 열기 | View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph. |
| `` ~ `` | Toggle overview mode | Only show merge commits, and commits that a local or remote branch, a tag, or HEAD points to; hide all other commits. Useful for getting a high-level view of the history. |
| `` G `` | Open pull request in browser | |
| `` <space> `` | 체크아웃 | Checkout the selected commit as a detached HEAD. |
| `` y `` | 커밋 attribute 복사 | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_nl.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` 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. |
| `` <ctrl+l> `` | View log options | View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph. |
| `` ~ `` | Toggle overview mode | Only show merge commits, and commits that a local or remote branch, a tag, or HEAD points to; hide all other commits. Useful for getting a high-level view of the history. |
| `` G `` | Open pull request in browser | |
| `` <space> `` | Uitchecken | 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). |
Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` t `` | Cofnij | Utwórz commit cofający dla wybranego commita, który stosuje zmiany wybranego commita w odwrotnej kolejności. |
| `` T `` | Otaguj commit | Utwórz nowy tag wskazujący na wybrany commit. Zostaniesz poproszony o wprowadzenie nazwy tagu i opcjonalnego opisu. |
| `` <ctrl+l> `` | Zobacz opcje logów | Zobacz opcje dla logów commitów, np. zmiana kolejności sortowania, ukrywanie grafu gita, pokazywanie całego grafu gita. |
| `` ~ `` | Toggle overview mode | Only show merge commits, and commits that a local or remote branch, a tag, or HEAD points to; hide all other commits. Useful for getting a high-level view of the history. |
| `` G `` | Otwórz żądanie ściągnięcia w przeglądarce | |
| `` <space> `` | Przełącz | Przełącz wybrany commit jako odłączoną HEAD. |
| `` y `` | Kopiuj atrybut commita do schowka | Kopiuj atrybut commita do schowka (np. hash, URL, różnice, wiadomość, autor). |
Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_pt.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` t `` | Reverter | Crie um commit reverter para o commit selecionado, que aplica as alterações do commit selecionado em reverso. |
| `` T `` | Etiquetar commit | Create a new tag pointing at the selected commit. You'll be prompted to enter a tag name and optional description. |
| `` <ctrl+l> `` | View log options | View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph. |
| `` ~ `` | Toggle overview mode | Only show merge commits, and commits that a local or remote branch, a tag, or HEAD points to; hide all other commits. Useful for getting a high-level view of the history. |
| `` G `` | Open pull request in browser | |
| `` <space> `` | Verificar | 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). |
Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` t `` | Revert | Create a revert commit for the selected commit, which applies the selected commit's changes in reverse. |
| `` T `` | Пометить коммит тегом | Create a new tag pointing at the selected commit. You'll be prompted to enter a tag name and optional description. |
| `` <ctrl+l> `` | Открыть меню журнала | View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph. |
| `` ~ `` | Toggle overview mode | Only show merge commits, and commits that a local or remote branch, a tag, or HEAD points to; hide all other commits. Useful for getting a high-level view of the history. |
| `` G `` | Open pull request in browser | |
| `` <space> `` | Переключить | Checkout the selected commit as a detached HEAD. |
| `` y `` | Скопировать атрибут коммита | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` t `` | 撤销(Revert) | 为所选提交创建还原提交,这会反向应用所选提交的更改。 |
| `` T `` | 标签提交 | 创建一个新标签指向所选提交。您可以在弹窗中输入标签名称和描述(可选)。 |
| `` <ctrl+l> `` | 打开日志菜单 | 查看提交日志的选项,例如更改排序顺序、隐藏 git graph、显示整个 git graph。 |
| `` ~ `` | Toggle overview mode | Only show merge commits, and commits that a local or remote branch, a tag, or HEAD points to; hide all other commits. Useful for getting a high-level view of the history. |
| `` G `` | 在浏览器中打开拉取请求 | |
| `` <space> `` | 检出 | 检出所选择的提交作为分离HEAD。 |
| `` y `` | 复制提交属性到剪贴板 | 复制提交属性到剪贴板(如hash、URL、diff、消息、作者)。 |
Expand Down
1 change: 1 addition & 0 deletions docs-master/keybindings/Keybindings_zh-TW.md
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
| `` t `` | 還原 | Create a revert commit for the selected commit, which applies the selected commit's changes in reverse. |
| `` T `` | 打標籤到提交 | Create a new tag pointing at the selected commit. You'll be prompted to enter a tag name and optional description. |
| `` <ctrl+l> `` | 開啟記錄選單 | View options for commit log e.g. changing sort order, hiding the git graph, showing the whole git graph. |
| `` ~ `` | Toggle overview mode | Only show merge commits, and commits that a local or remote branch, a tag, or HEAD points to; hide all other commits. Useful for getting a high-level view of the history. |
| `` G `` | Open pull request in browser | |
| `` <space> `` | 檢出 | Checkout the selected commit as a detached HEAD. |
| `` y `` | 複製提交屬性 | Copy commit attribute to clipboard (e.g. hash, URL, diff, message, author). |
Expand Down
2 changes: 2 additions & 0 deletions pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,7 @@ type KeybindingCommitsConfig struct {
ResetCherryPick Keybinding `yaml:"resetCherryPick"`
CopyCommitAttributeToClipboard Keybinding `yaml:"copyCommitAttributeToClipboard"`
OpenLogMenu Keybinding `yaml:"openLogMenu"`
ToggleOverviewMode Keybinding `yaml:"toggleOverviewMode"`
OpenInBrowser Keybinding `yaml:"openInBrowser"`
OpenPullRequestInBrowser Keybinding `yaml:"openPullRequestInBrowser"`
ViewBisectOptions Keybinding `yaml:"viewBisectOptions"`
Expand Down Expand Up @@ -1144,6 +1145,7 @@ func GetDefaultConfigForPlatform(platform string) *UserConfig {
ResetCherryPick: Keybinding{"<ctrl+r>"},
CopyCommitAttributeToClipboard: Keybinding{"y"},
OpenLogMenu: Keybinding{"<ctrl+l>"},
ToggleOverviewMode: Keybinding{"~"},
OpenInBrowser: Keybinding{"o"},
OpenPullRequestInBrowser: Keybinding{"G"},
ViewBisectOptions: Keybinding{"b"},
Expand Down
73 changes: 72 additions & 1 deletion pkg/gui/context/local_commits_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,18 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {

hasRebaseUpdateRefsConfig := c.Git().Config.GetRebaseUpdateRefs()

// In overview mode the model only holds the displayed subset of the
// commits; the graph is rendered from the full list so that hiding
// rows doesn't change its shape.
commits := c.Model().Commits
displayIndices := overviewDisplayIndices(c, startIdx, endIdx)
if displayIndices != nil {
commits = c.Model().OverviewCommitsSource
}

return presentation.GetCommitListDisplayStrings(
c.Common,
c.Model().Commits,
commits,
c.Model().Branches,
c.Model().CheckedOutBranch,
hasRebaseUpdateRefsConfig,
Expand All @@ -61,6 +70,7 @@ func NewLocalCommitsContext(c *ContextCommon) *LocalCommitsContext {
selectedCommitHashPtr,
startIdx,
endIdx,
displayIndices,
shouldShowGraph(c),
c.Model().BisectInfo,
)
Expand Down Expand Up @@ -149,6 +159,17 @@ type LocalCommitsViewModel struct {

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

// If this is true we only show merge commits and commits that a local or
// remote branch, a tag, or HEAD points to.
overviewMode bool

// When enabling overview mode hides the selected commit, we remember it
// here, along with the commit the selection was moved to, so that
// disabling the mode can jump back to it if the selection hasn't moved
// in the meantime.
overviewReturnHash string
overviewAutoSelectedHash string
}

func NewLocalCommitsViewModel(getModel func() []*models.Commit, c *ContextCommon) *LocalCommitsViewModel {
Expand Down Expand Up @@ -243,10 +264,60 @@ func (self *LocalCommitsViewModel) GetShowWholeGitGraph() bool {
return self.showWholeGitGraph
}

func (self *LocalCommitsViewModel) SetOverviewMode(value bool) {
self.overviewMode = value
}

func (self *LocalCommitsViewModel) GetOverviewMode() bool {
return self.overviewMode
}

func (self *LocalCommitsViewModel) SetOverviewReturnHashes(returnHash string, autoSelectedHash string) {
self.overviewReturnHash = returnHash
self.overviewAutoSelectedHash = autoSelectedHash
}

func (self *LocalCommitsViewModel) GetOverviewReturnHashes() (string, string) {
return self.overviewReturnHash, self.overviewAutoSelectedHash
}

func (self *LocalCommitsViewModel) GetCommits() []*models.Commit {
return self.getModel()
}

// overviewDisplayIndices returns, for the given window of displayed rows, the
// indices of those rows in Model().OverviewCommitsSource, or nil when overview
// mode is off. It validates that the mapping matches the displayed commits and
// returns nil on a mismatch (which can happen transiently when something other
// than a commits refresh replaces Model().Commits, e.g. the mid-rebase todo
// refresh), so the caller falls back to rendering from the displayed list.
func overviewDisplayIndices(c *ContextCommon, startIdx int, endIdx int) []int {
indices := c.Model().OverviewCommitIndices
if indices == nil {
return nil
}

displayed := c.Model().Commits
source := c.Model().OverviewCommitsSource
if len(indices) != len(displayed) {
return nil
}

endIdx = min(endIdx, len(displayed))
if startIdx >= endIdx {
return []int{}
}

window := indices[startIdx:endIdx]
for i, modelIdx := range window {
if modelIdx >= len(source) || source[modelIdx] != displayed[startIdx+i] {
return nil
}
}

return window
}

func shouldShowGraph(c *ContextCommon) bool {
if c.Modes().Filtering.Active() {
return false
Expand Down
1 change: 1 addition & 0 deletions pkg/gui/context/sub_commits_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ func NewSubCommitsContext(
selectedCommitHashPtr,
startIdx,
endIdx,
nil,
shouldShowGraph(c),
git_commands.NewNullBisectInfo(),
)
Expand Down
99 changes: 99 additions & 0 deletions pkg/gui/controllers/helpers/mode_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"strings"

"github.com/jesseduffield/lazygit/pkg/gocui"
"github.com/jesseduffield/lazygit/pkg/gui/style"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/samber/lo"
Expand Down Expand Up @@ -92,6 +93,16 @@ func (self *ModeHelper) Statuses() []ModeStatus {
},
Reset: self.ExitFilterMode,
},
{
IsActive: self.c.Contexts().LocalCommits.GetOverviewMode,
InfoLabel: func() string {
return self.withResetButton(self.c.Tr.OverviewModeStatus, style.FgBlue)
},
CancelLabel: func() string {
return self.c.Tr.ExitOverviewMode
},
Reset: self.ExitOverviewMode,
},
{
IsActive: self.c.Modes().MarkedBaseCommit.Active,
InfoLabel: func() string {
Expand Down Expand Up @@ -182,6 +193,94 @@ func (self *ModeHelper) ExitFilterMode() error {
return self.ClearFiltering()
}

// updateCommitsViewTitle gives the commits view's title and tab label an
// "(overview)" suffix while overview mode is on. The tab strip is shared by
// all views of the panel, so updating the commits view's own tab entry is
// enough for the label to show whichever tab is selected.
func (self *ModeHelper) updateCommitsViewTitle() {
view := self.c.Views().Commits
title := lo.Ternary(self.c.Contexts().LocalCommits.GetOverviewMode(),
self.c.Tr.CommitsOverviewTitle, self.c.Tr.CommitsTitle)
view.Title = title
if len(view.Tabs) > 0 {
view.Tabs[view.TabIndex] = title
}
}

func (self *ModeHelper) EnterOverviewMode() error {
commitsContext := self.c.Contexts().LocalCommits

// If the selected commit is about to be hidden, remember it and move the
// selection to the nearest commit above it that stays visible (or the top
// one); exiting the mode jumps back to it if the selection hasn't moved
// in the meantime.
hiddenSelectionHash := ""
autoSelectHash := ""
if selected := commitsContext.GetSelected(); selected != nil && !commitShownInOverview(selected) {
hiddenSelectionHash = selected.Hash()
commits := self.c.Model().Commits
for i := commitsContext.GetSelectedLineIdx() - 1; i >= 0; i-- {
if commitShownInOverview(commits[i]) {
autoSelectHash = commits[i].Hash()
break
}
}
}

commitsContext.SetOverviewMode(true)
self.updateCommitsViewTitle()
// The condensed list can have far fewer rows than the threshold of the
// "load more commits when the selection approaches the end of the list"
// heuristic, which would then never kick in; load the whole history
// instead.
commitsContext.SetLimitCommits(false)

return self.c.WithWaitingStatus(self.c.Tr.LoadingCommits, func(gocui.Task) error {
self.c.RefreshFromWorker(types.RefreshOptions{
Mode: types.SYNC,
Scope: []types.RefreshableView{types.COMMITS},
Then: func() error {
if hiddenSelectionHash == "" {
return nil
}
if autoSelectHash == "" || !commitsContext.SelectCommitByHash(autoSelectHash) {
commitsContext.SetSelection(0)
}
commitsContext.SetOverviewReturnHashes(
hiddenSelectionHash, commitsContext.GetSelectedCommitHash())
self.c.PostRefreshUpdate(commitsContext)
commitsContext.FocusLine(true)
return nil
},
})
return nil
})
}

func (self *ModeHelper) ExitOverviewMode() error {
commitsContext := self.c.Contexts().LocalCommits

returnHash, autoSelectedHash := commitsContext.GetOverviewReturnHashes()
jumpBack := returnHash != "" && commitsContext.GetSelectedCommitHash() == autoSelectedHash

commitsContext.SetOverviewMode(false)
commitsContext.SetOverviewReturnHashes("", "")
self.updateCommitsViewTitle()

self.c.Refresh(types.RefreshOptions{
Scope: []types.RefreshableView{types.COMMITS},
Then: func() error {
if jumpBack {
commitsContext.SelectCommitByHash(returnHash)
self.c.PostRefreshUpdate(commitsContext)
commitsContext.FocusLine(true)
}
return nil
},
})
return nil
}

func (self *ModeHelper) ClearFiltering() error {
selectedCommitHash := self.c.Contexts().LocalCommits.GetSelectedCommitHash()
self.c.Modes().Filtering.Reset()
Expand Down
Loading