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
12 changes: 10 additions & 2 deletions docs-master/Config.md
Original file line number Diff line number Diff line change
Expand Up @@ -513,10 +513,18 @@ git:
# (`<ctrl+l>` in the commits window by default).
showGraph: always

# displays the whole git graph by default in the commits view (equivalent to
# passing the `--all` argument to `git log`)
# displays the whole git graph by default in the commits view (see `allRefsArgs`
# for which refs that includes)
showWholeGraph: false

# The `git log` args used to select which refs are shown in the commits view
# when showing the whole graph. Defaults to `["--all"]`, which includes every
# ref; set it to something narrower such as `["--branches", "--remotes"]` to
# leave out refs that aren't branches, e.g. stashes or refs written by external
# tooling.
allRefsArgs:
- --all

# How branches are sorted in the local branches view.
# One of: 'date' (default) | 'recency' | 'alphabetical'
# Can be changed from within Lazygit with the Sort Order menu (`s`) in the
Expand Down
2 changes: 1 addition & 1 deletion pkg/commands/git_commands/commit_loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ func (self *CommitLoader) getLogCmd(opts GetCommitsOptions) *oscommands.CmdObj {
cmdArgs := NewGitCmd("log").
Arg(refSpec).
ArgIf(gitLogOrder != "default", "--"+gitLogOrder).
ArgIf(opts.All, "--all").
ArgIf(opts.All, self.UserConfig().Git.Log.AllRefsArgs...).
Arg("--oneline").
Arg(prettyFormat).
Arg("--abbrev=40").
Expand Down
27 changes: 27 additions & 0 deletions pkg/commands/git_commands/commit_loader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TestGetCommits(t *testing.T) {
expectedCommitOpts []models.NewCommitOpts
expectedError error
logOrder string
allRefsArgs []string
opts GetCommitsOptions
mainBranches []string
}
Expand Down Expand Up @@ -61,6 +62,29 @@ func TestGetCommits(t *testing.T) {
expectedCommitOpts: []models.NewCommitOpts{},
expectedError: nil,
},
{
testName: "should pass the default all-refs args when showing the whole graph",
logOrder: "topo-order",
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: &models.Branch{Name: "mybranch"}, IncludeRebaseCommits: false, All: true},
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"rev-list", "refs/heads/mybranch", "^mybranch@{u}"}, "", nil).
ExpectGitArgs([]string{"log", "HEAD", "--topo-order", "--all", "--oneline", "--pretty=format:+%H%x00%at%x00%aN%x00%ae%x00%P%x00%m%x00%D%x00%s", "--abbrev=40", "--no-show-signature", "--"}, "", nil),

expectedCommitOpts: []models.NewCommitOpts{},
expectedError: nil,
},
{
testName: "should pass the configured all-refs args when showing the whole graph",
logOrder: "topo-order",
allRefsArgs: []string{"--branches", "--remotes"},
opts: GetCommitsOptions{RefName: "HEAD", RefForPushedStatus: &models.Branch{Name: "mybranch"}, IncludeRebaseCommits: false, All: true},
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"rev-list", "refs/heads/mybranch", "^mybranch@{u}"}, "", nil).
ExpectGitArgs([]string{"log", "HEAD", "--topo-order", "--branches", "--remotes", "--oneline", "--pretty=format:+%H%x00%at%x00%aN%x00%ae%x00%P%x00%m%x00%D%x00%s", "--abbrev=40", "--no-show-signature", "--"}, "", nil),

expectedCommitOpts: []models.NewCommitOpts{},
expectedError: nil,
},
{
testName: "should return commits if they are present",
logOrder: "topo-order",
Expand Down Expand Up @@ -300,6 +324,9 @@ func TestGetCommits(t *testing.T) {
t.Run(scenario.testName, func(t *testing.T) {
common := common.NewDummyCommon()
common.UserConfig().Git.Log.Order = scenario.logOrder
if scenario.allRefsArgs != nil {
common.UserConfig().Git.Log.AllRefsArgs = scenario.allRefsArgs
}
cmd := oscommands.NewDummyCmdObjBuilder(scenario.runner)

builder := &CommitLoader{
Expand Down
5 changes: 4 additions & 1 deletion pkg/config/user_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,10 @@ type LogConfig struct {
//
// Can be toggled from within lazygit with `Log menu -> Show git graph` (`<ctrl+l>` in the commits window by default).
ShowGraph string `yaml:"showGraph" jsonschema:"enum=always,enum=never,enum=when-maximised"`
// displays the whole git graph by default in the commits view (equivalent to passing the `--all` argument to `git log`)
// displays the whole git graph by default in the commits view (see `allRefsArgs` for which refs that includes)
ShowWholeGraph bool `yaml:"showWholeGraph"`
// The `git log` args used to select which refs are shown in the commits view when showing the whole graph. Defaults to `["--all"]`, which includes every ref; set it to something narrower such as `["--branches", "--remotes"]` to leave out refs that aren't branches, e.g. stashes or refs written by external tooling.
AllRefsArgs []string `yaml:"allRefsArgs"`
}

type CommitPrefixConfig struct {
Expand Down Expand Up @@ -950,6 +952,7 @@ func GetDefaultConfigForPlatform(platform string) *UserConfig {
Order: "topo-order",
ShowGraph: "always",
ShowWholeGraph: false,
AllRefsArgs: []string{"--all"},
},
LocalBranchSortOrder: "date",
RemoteBranchSortOrder: "date",
Expand Down
12 changes: 11 additions & 1 deletion schema-master/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3492,8 +3492,18 @@
},
"showWholeGraph": {
"type": "boolean",
"description": "displays the whole git graph by default in the commits view (equivalent to passing the `--all` argument to `git log`)",
"description": "displays the whole git graph by default in the commits view (see `allRefsArgs` for which refs that includes)",
"default": false
},
"allRefsArgs": {
"items": {
"type": "string"
},
"type": "array",
"description": "The `git log` args used to select which refs are shown in the commits view when showing the whole graph. Defaults to `[\"--all\"]`, which includes every ref; set it to something narrower such as `[\"--branches\", \"--remotes\"]` to leave out refs that aren't branches, e.g. stashes or refs written by external tooling.",
"default": [
"--all"
]
}
},
"additionalProperties": false,
Expand Down