Skip to content

Commit fba1a2b

Browse files
stefanhallerjesseduffield
authored andcommitted
Add config gui.experimentalShowBranchHeads
People find the new (*) display for branch heads in the commits list confusing, so make it opt-in for now.
1 parent c6c4346 commit fba1a2b

File tree

6 files changed

+111
-45
lines changed

6 files changed

+111
-45
lines changed

docs/Config.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ gui:
5757
showFileTree: true # for rendering changes files in a tree format
5858
showListFooter: true # for seeing the '5 of 20' message in list panels
5959
showRandomTip: true
60+
experimentalShowBranchHeads: false # visualize branch heads with (*) in commits list
6061
showBottomLine: true # for hiding the bottom information line (unless it has important information to tell you)
6162
showCommandLog: true
6263
showIcons: false

pkg/config/user_config.go

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -27,32 +27,33 @@ type RefresherConfig struct {
2727
}
2828

2929
type GuiConfig struct {
30-
AuthorColors map[string]string `yaml:"authorColors"`
31-
BranchColors map[string]string `yaml:"branchColors"`
32-
ScrollHeight int `yaml:"scrollHeight"`
33-
ScrollPastBottom bool `yaml:"scrollPastBottom"`
34-
MouseEvents bool `yaml:"mouseEvents"`
35-
SkipUnstageLineWarning bool `yaml:"skipUnstageLineWarning"`
36-
SkipStashWarning bool `yaml:"skipStashWarning"`
37-
SidePanelWidth float64 `yaml:"sidePanelWidth"`
38-
ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"`
39-
MainPanelSplitMode string `yaml:"mainPanelSplitMode"`
40-
Language string `yaml:"language"`
41-
TimeFormat string `yaml:"timeFormat"`
42-
Theme ThemeConfig `yaml:"theme"`
43-
CommitLength CommitLengthConfig `yaml:"commitLength"`
44-
SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
45-
ShowListFooter bool `yaml:"showListFooter"`
46-
ShowFileTree bool `yaml:"showFileTree"`
47-
ShowRandomTip bool `yaml:"showRandomTip"`
48-
ShowCommandLog bool `yaml:"showCommandLog"`
49-
ShowBottomLine bool `yaml:"showBottomLine"`
50-
ShowIcons bool `yaml:"showIcons"`
51-
CommandLogSize int `yaml:"commandLogSize"`
52-
SplitDiff string `yaml:"splitDiff"`
53-
SkipRewordInEditorWarning bool `yaml:"skipRewordInEditorWarning"`
54-
WindowSize string `yaml:"windowSize"`
55-
Border string `yaml:"border"`
30+
AuthorColors map[string]string `yaml:"authorColors"`
31+
BranchColors map[string]string `yaml:"branchColors"`
32+
ScrollHeight int `yaml:"scrollHeight"`
33+
ScrollPastBottom bool `yaml:"scrollPastBottom"`
34+
MouseEvents bool `yaml:"mouseEvents"`
35+
SkipUnstageLineWarning bool `yaml:"skipUnstageLineWarning"`
36+
SkipStashWarning bool `yaml:"skipStashWarning"`
37+
SidePanelWidth float64 `yaml:"sidePanelWidth"`
38+
ExpandFocusedSidePanel bool `yaml:"expandFocusedSidePanel"`
39+
MainPanelSplitMode string `yaml:"mainPanelSplitMode"`
40+
Language string `yaml:"language"`
41+
TimeFormat string `yaml:"timeFormat"`
42+
Theme ThemeConfig `yaml:"theme"`
43+
CommitLength CommitLengthConfig `yaml:"commitLength"`
44+
SkipNoStagedFilesWarning bool `yaml:"skipNoStagedFilesWarning"`
45+
ShowListFooter bool `yaml:"showListFooter"`
46+
ShowFileTree bool `yaml:"showFileTree"`
47+
ShowRandomTip bool `yaml:"showRandomTip"`
48+
ShowCommandLog bool `yaml:"showCommandLog"`
49+
ShowBottomLine bool `yaml:"showBottomLine"`
50+
ShowIcons bool `yaml:"showIcons"`
51+
ExperimentalShowBranchHeads bool `yaml:"experimentalShowBranchHeads"`
52+
CommandLogSize int `yaml:"commandLogSize"`
53+
SplitDiff string `yaml:"splitDiff"`
54+
SkipRewordInEditorWarning bool `yaml:"skipRewordInEditorWarning"`
55+
WindowSize string `yaml:"windowSize"`
56+
Border string `yaml:"border"`
5657
}
5758

5859
type ThemeConfig struct {
@@ -408,18 +409,19 @@ func GetDefaultConfig() *UserConfig {
408409
UnstagedChangesColor: []string{"red"},
409410
DefaultFgColor: []string{"default"},
410411
},
411-
CommitLength: CommitLengthConfig{Show: true},
412-
SkipNoStagedFilesWarning: false,
413-
ShowListFooter: true,
414-
ShowCommandLog: true,
415-
ShowBottomLine: true,
416-
ShowFileTree: true,
417-
ShowRandomTip: true,
418-
ShowIcons: false,
419-
CommandLogSize: 8,
420-
SplitDiff: "auto",
421-
SkipRewordInEditorWarning: false,
422-
Border: "single",
412+
CommitLength: CommitLengthConfig{Show: true},
413+
SkipNoStagedFilesWarning: false,
414+
ShowListFooter: true,
415+
ShowCommandLog: true,
416+
ShowBottomLine: true,
417+
ShowFileTree: true,
418+
ShowRandomTip: true,
419+
ShowIcons: false,
420+
ExperimentalShowBranchHeads: false,
421+
CommandLogSize: 8,
422+
SplitDiff: "auto",
423+
SkipRewordInEditorWarning: false,
424+
Border: "single",
423425
},
424426
Git: GitConfig{
425427
Paging: PagingConfig{

pkg/gui/presentation/commits.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ func displayCommit(
277277
} else {
278278
if len(commit.Tags) > 0 {
279279
tagString = theme.DiffTerminalColor.SetBold().Sprint(strings.Join(commit.Tags, " ")) + " "
280-
} else if commit.ExtraInfo != "" {
280+
} else if common.UserConfig.Gui.ExperimentalShowBranchHeads && commit.ExtraInfo != "" {
281281
tagString = style.FgMagenta.SetBold().Sprint("(*)") + " "
282282
}
283283
}

pkg/integration/tests/interactive_rebase/drop_todo_commit_with_update_ref.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ var DropTodoCommitWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{
2323
t.Views().Commits().
2424
Focus().
2525
Lines(
26-
Contains("(*) commit 06").IsSelected(),
26+
Contains("commit 06").IsSelected(),
2727
Contains("commit 05"),
2828
Contains("commit 04"),
29-
Contains("(*) commit 03"),
29+
Contains("commit 03"),
3030
Contains("commit 02"),
3131
Contains("commit 01"),
3232
).
3333
NavigateToLine(Contains("commit 01")).
3434
Press(keys.Universal.Edit).
3535
Focus().
3636
Lines(
37-
Contains("pick").Contains("(*) commit 06"),
37+
Contains("pick").Contains("commit 06"),
3838
Contains("pick").Contains("commit 05"),
3939
Contains("pick").Contains("commit 04"),
4040
Contains("update-ref").Contains("master"),
41-
Contains("pick").Contains("(*) commit 03"),
41+
Contains("pick").Contains("commit 03"),
4242
Contains("pick").Contains("commit 02"),
4343
Contains("<-- YOU ARE HERE --- commit 01"),
4444
).
@@ -50,9 +50,9 @@ var DropTodoCommitWithUpdateRef = NewIntegrationTest(NewIntegrationTestArgs{
5050
t.Views().Commits().
5151
IsFocused().
5252
Lines(
53-
Contains("(*) commit 06"),
53+
Contains("commit 06"),
5454
Contains("commit 04"),
55-
Contains("(*) commit 03"),
55+
Contains("commit 03"),
5656
Contains("commit 02"),
5757
Contains("commit 01"),
5858
)
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package interactive_rebase
2+
3+
import (
4+
"github.com/jesseduffield/lazygit/pkg/config"
5+
. "github.com/jesseduffield/lazygit/pkg/integration/components"
6+
)
7+
8+
var DropTodoCommitWithUpdateRefShowBranchHeads = NewIntegrationTest(NewIntegrationTestArgs{
9+
Description: "Drops a commit during interactive rebase when there is an update-ref in the git-rebase-todo file (with experimentalShowBranchHeads on)",
10+
ExtraCmdArgs: "",
11+
Skip: false,
12+
GitVersion: From("2.38.0"),
13+
SetupConfig: func(config *config.AppConfig) {
14+
config.UserConfig.Gui.ExperimentalShowBranchHeads = true
15+
},
16+
SetupRepo: func(shell *Shell) {
17+
shell.
18+
CreateNCommits(3).
19+
NewBranch("mybranch").
20+
CreateNCommitsStartingAt(3, 4)
21+
22+
shell.SetConfig("rebase.updateRefs", "true")
23+
},
24+
Run: func(t *TestDriver, keys config.KeybindingConfig) {
25+
t.Views().Commits().
26+
Focus().
27+
Lines(
28+
Contains("(*) commit 06").IsSelected(),
29+
Contains("commit 05"),
30+
Contains("commit 04"),
31+
Contains("(*) commit 03"),
32+
Contains("commit 02"),
33+
Contains("commit 01"),
34+
).
35+
NavigateToLine(Contains("commit 01")).
36+
Press(keys.Universal.Edit).
37+
Focus().
38+
Lines(
39+
Contains("pick").Contains("(*) commit 06"),
40+
Contains("pick").Contains("commit 05"),
41+
Contains("pick").Contains("commit 04"),
42+
Contains("update-ref").Contains("master"),
43+
Contains("pick").Contains("(*) commit 03"),
44+
Contains("pick").Contains("commit 02"),
45+
Contains("<-- YOU ARE HERE --- commit 01"),
46+
).
47+
NavigateToLine(Contains("commit 05")).
48+
Press(keys.Universal.Remove)
49+
50+
t.Common().ContinueRebase()
51+
52+
t.Views().Commits().
53+
IsFocused().
54+
Lines(
55+
Contains("(*) commit 06"),
56+
Contains("commit 04"),
57+
Contains("(*) commit 03"),
58+
Contains("commit 02"),
59+
Contains("commit 01"),
60+
)
61+
},
62+
})

pkg/integration/tests/test_list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ var tests = []*components.IntegrationTest{
9393
interactive_rebase.AmendMerge,
9494
interactive_rebase.AmendNonHeadCommitDuringRebase,
9595
interactive_rebase.DropTodoCommitWithUpdateRef,
96+
interactive_rebase.DropTodoCommitWithUpdateRefShowBranchHeads,
9697
interactive_rebase.EditFirstCommit,
9798
interactive_rebase.EditNonTodoCommitDuringRebase,
9899
interactive_rebase.FixupFirstCommit,

0 commit comments

Comments
 (0)