This commit is contained in:
Jacob Bayer 2026-09-09 18:23:04 +09:00 committed by GitHub
commit fcc05ed972
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 53 additions and 5 deletions

View file

@ -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

View file

@ -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").

View file

@ -34,6 +34,7 @@ func TestGetCommits(t *testing.T) {
expectedCommitOpts []models.NewCommitOpts
expectedError error
logOrder string
allRefsArgs []string
opts GetCommitsOptions
mainBranches []string
}
@ -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",
@ -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{

View file

@ -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 {
@ -950,6 +952,7 @@ func GetDefaultConfigForPlatform(platform string) *UserConfig {
Order: "topo-order",
ShowGraph: "always",
ShowWholeGraph: false,
AllRefsArgs: []string{"--all"},
},
LocalBranchSortOrder: "date",
RemoteBranchSortOrder: "date",

View file

@ -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,