summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Haller <stefan@haller-berlin.de>2023-07-25 11:33:39 +0200
committerStefan Haller <stefan@haller-berlin.de>2023-07-31 08:34:01 +0200
commitf5c9764dd265d700ef5b829cbcbe045cc0d62965 (patch)
tree2b753c6c88359388b4fb65f06c306142c073aaac
parent6dc25d796b0315764c4c50a590dde91c802ea5dc (diff)
Don't show branch heads in reflog subcommits
It's tricky to get this right for reflog commits wrt what's the current branch for each one; so just disable it entirely here, it's probably not something anybody needs here.
-rw-r--r--pkg/gui/context/branches_context.go4
-rw-r--r--pkg/gui/context/reflog_commits_context.go4
-rw-r--r--pkg/gui/context/remote_branches_context.go4
-rw-r--r--pkg/gui/context/sub_commits_context.go17
-rw-r--r--pkg/gui/context/tags_context.go4
-rw-r--r--pkg/gui/controllers/switch_to_sub_commits_controller.go2
-rw-r--r--pkg/integration/tests/reflog/do_not_show_branch_markers_in_reflog_subcommits.go71
-rw-r--r--pkg/integration/tests/test_list.go1
8 files changed, 105 insertions, 2 deletions
diff --git a/pkg/gui/context/branches_context.go b/pkg/gui/context/branches_context.go
index 85c45c64a..e4806165f 100644
--- a/pkg/gui/context/branches_context.go
+++ b/pkg/gui/context/branches_context.go
@@ -83,3 +83,7 @@ func (self *BranchesContext) GetDiffTerminals() []string {
}
return nil
}
+
+func (self *BranchesContext) ShowBranchHeadsInSubCommits() bool {
+ return true
+}
diff --git a/pkg/gui/context/reflog_commits_context.go b/pkg/gui/context/reflog_commits_context.go
index 421a7c8d5..5038b1870 100644
--- a/pkg/gui/context/reflog_commits_context.go
+++ b/pkg/gui/context/reflog_commits_context.go
@@ -86,3 +86,7 @@ func (self *ReflogCommitsContext) GetDiffTerminals() []string {
return []string{itemId}
}
+
+func (self *ReflogCommitsContext) ShowBranchHeadsInSubCommits() bool {
+ return false
+}
diff --git a/pkg/gui/context/remote_branches_context.go b/pkg/gui/context/remote_branches_context.go
index 602a19a65..fbc91f352 100644
--- a/pkg/gui/context/remote_branches_context.go
+++ b/pkg/gui/context/remote_branches_context.go
@@ -72,3 +72,7 @@ func (self *RemoteBranchesContext) GetDiffTerminals() []string {
return []string{itemId}
}
+
+func (self *RemoteBranchesContext) ShowBranchHeadsInSubCommits() bool {
+ return true
+}
diff --git a/pkg/gui/context/sub_commits_context.go b/pkg/gui/context/sub_commits_context.go
index 1a606ac91..2af3fc4cc 100644
--- a/pkg/gui/context/sub_commits_context.go
+++ b/pkg/gui/context/sub_commits_context.go
@@ -51,10 +51,14 @@ func NewSubCommitsContext(
selectedCommitSha = selectedCommit.Sha
}
}
+ branches := []*models.Branch{}
+ if viewModel.GetShowBranchHeads() {
+ branches = c.Model().Branches
+ }
return presentation.GetCommitListDisplayStrings(
c.Common,
c.Model().SubCommits,
- c.Model().Branches,
+ branches,
viewModel.GetRef().RefName(),
c.State().GetRepoState().GetScreenMode() != types.SCREEN_NORMAL,
c.Modes().CherryPicking.SelectedShaSet(),
@@ -106,7 +110,8 @@ type SubCommitsViewModel struct {
ref types.Ref
*ListViewModel[*models.Commit]
- limitCommits bool
+ limitCommits bool
+ showBranchHeads bool
}
func (self *SubCommitsViewModel) SetRef(ref types.Ref) {
@@ -117,6 +122,14 @@ func (self *SubCommitsViewModel) GetRef() types.Ref {
return self.ref
}
+func (self *SubCommitsViewModel) SetShowBranchHeads(value bool) {
+ self.showBranchHeads = value
+}
+
+func (self *SubCommitsViewModel) GetShowBranchHeads() bool {
+ return self.showBranchHeads
+}
+
func (self *SubCommitsContext) GetSelectedItemId() string {
item := self.GetSelected()
if item == nil {
diff --git a/pkg/gui/context/tags_context.go b/pkg/gui/context/tags_context.go
index 71ea36981..95b845a28 100644
--- a/pkg/gui/context/tags_context.go
+++ b/pkg/gui/context/tags_context.go
@@ -69,3 +69,7 @@ func (self *TagsContext) GetDiffTerminals() []string {
return []string{itemId}
}
+
+func (self *TagsContext) ShowBranchHeadsInSubCommits() bool {
+ return true
+}
diff --git a/pkg/gui/controllers/switch_to_sub_commits_controller.go b/pkg/gui/controllers/switch_to_sub_commits_controller.go
index 8aa92f14b..68fc7d0a0 100644
--- a/pkg/gui/controllers/switch_to_sub_commits_controller.go
+++ b/pkg/gui/controllers/switch_to_sub_commits_controller.go
@@ -11,6 +11,7 @@ var _ types.IController = &SwitchToSubCommitsController{}
type CanSwitchToSubCommits interface {
types.Context
GetSelectedRef() types.Ref
+ ShowBranchHeadsInSubCommits() bool
}
type SwitchToSubCommitsController struct {
@@ -79,6 +80,7 @@ func (self *SwitchToSubCommitsController) viewCommits() error {
subCommitsContext.SetTitleRef(ref.Description())
subCommitsContext.SetRef(ref)
subCommitsContext.SetLimitCommits(true)
+ subCommitsContext.SetShowBranchHeads(self.context.ShowBranchHeadsInSubCommits())
subCommitsContext.ClearSearchString()
subCommitsContext.GetView().ClearSearch()
diff --git a/pkg/integration/tests/reflog/do_not_show_branch_markers_in_reflog_subcommits.go b/pkg/integration/tests/reflog/do_not_show_branch_markers_in_reflog_subcommits.go
new file mode 100644
index 000000000..8e888c95a
--- /dev/null
+++ b/pkg/integration/tests/reflog/do_not_show_branch_markers_in_reflog_subcommits.go
@@ -0,0 +1,71 @@
+package reflog
+
+import (
+ "github.com/jesseduffield/lazygit/pkg/config"
+ . "github.com/jesseduffield/lazygit/pkg/integration/components"
+)
+
+var DoNotShowBranchMarkersInReflogSubcommits = NewIntegrationTest(NewIntegrationTestArgs{
+ Description: "Verify that no branch heads are shown in the subcommits view of a reflog entry",
+ ExtraCmdArgs: []string{},
+ Skip: false,
+ SetupConfig: func(config *config.AppConfig) {},
+ SetupRepo: func(shell *Shell) {
+ shell.NewBranch("branch1")
+ shell.EmptyCommit("one")
+ shell.EmptyCommit("two")
+ shell.NewBranch("branch2")
+ shell.EmptyCommit("three")
+ },
+ Run: func(t *TestDriver, keys config.KeybindingConfig) {
+ // Check that the local commits view does show a branch marker for branch1
+ t.Views().Commits().
+ Lines(
+ Contains("CI three"),
+ Contains("CI * two"),
+ Contains("CI one"),
+ )
+
+ t.Views().Branches().
+ Focus().
+ // Check out branch1
+ NavigateToLine(Contains("branch1")).
+ PressPrimaryAction().
+ // Look at the subcommits of branch2
+ NavigateToLine(Contains("branch2")).
+ PressEnter().
+ // Check that we see a marker for branch1 here (but not for
+ // branch2), even though branch1 is checked out
+ Tap(func() {
+ t.Views().SubCommits().
+ IsFocused().
+ Lines(
+ Contains("CI three"),
+ Contains("CI * two"),
+ Contains("CI one"),
+ ).
+ PressEscape()
+ }).
+ // Check out branch2 again
+ NavigateToLine(Contains("branch2")).
+ PressPrimaryAction()
+
+ t.Views().ReflogCommits().
+ Focus().
+ TopLines(
+ Contains("checkout: moving from branch1 to branch2").IsSelected(),
+ ).
+ PressEnter().
+ // Check that the subcommits view for a reflog entry doesn't show
+ // any branch markers
+ Tap(func() {
+ t.Views().SubCommits().
+ IsFocused().
+ Lines(
+ Contains("CI three"),
+ Contains("CI two"),
+ Contains("CI one"),
+ )
+ })
+ },
+})
diff --git a/pkg/integration/tests/test_list.go b/pkg/integration/tests/test_list.go
index fa58676f2..9dcb57dee 100644
--- a/pkg/integration/tests/test_list.go
+++ b/pkg/integration/tests/test_list.go
@@ -163,6 +163,7 @@ var tests = []*components.IntegrationTest{
patch_building.StartNewPatch,
reflog.Checkout,
reflog.CherryPick,
+ reflog.DoNotShowBranchMarkersInReflogSubcommits,
reflog.Patch,
reflog.Reset,
staging.DiffContextChange,