From cf491d1b5b3814d8cd6e65a340883eee67f407cc Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 6 Apr 2026 11:20:51 +0200 Subject: [PATCH] Turn the ForceShowUntracked field of GetStatusFileOptions into an enum --- pkg/commands/git_commands/file_loader.go | 29 +++++++++++++++---- pkg/gui/controllers/helpers/refresh_helper.go | 6 +++- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/pkg/commands/git_commands/file_loader.go b/pkg/commands/git_commands/file_loader.go index 36ab8ef67..9329aa0d5 100644 --- a/pkg/commands/git_commands/file_loader.go +++ b/pkg/commands/git_commands/file_loader.go @@ -30,20 +30,37 @@ func NewFileLoader(gitCommon *GitCommon, cmd oscommands.ICmdObjBuilder, config F } } +type ShowUntrackedMode int + +const ( + // Use the value from git config (show all if not set) + ShowUntrackedModeAuto ShowUntrackedMode = iota + // Show untracked files regardless of git config. Useful for users with bare + // repos for dotfiles who default to hiding untracked files, but want to + // occasionally see them to `git add` a new file. + ShowUntrackedModeOn + // Hide untracked files regardless of git config. + ShowUntrackedModeOff +) + type GetStatusFileOptions struct { - NoRenames bool - // If true, we'll show untracked files even if the user has set the config to hide them. - // This is useful for users with bare repos for dotfiles who default to hiding untracked files, - // but want to occasionally see them to `git add` a new file. - ForceShowUntracked bool + NoRenames bool + ShowUntracked ShowUntrackedMode } func (self *FileLoader) GetStatusFiles(opts GetStatusFileOptions) []*models.File { // check if config wants us ignoring untracked files untrackedFilesSetting := self.config.GetShowUntrackedFiles() - if opts.ForceShowUntracked || untrackedFilesSetting == "" { + switch opts.ShowUntracked { + case ShowUntrackedModeOn: untrackedFilesSetting = "all" + case ShowUntrackedModeOff: + untrackedFilesSetting = "no" + default: // ShowUntrackedModeAuto + if untrackedFilesSetting == "" { + untrackedFilesSetting = "all" + } } untrackedFilesArg := fmt.Sprintf("--untracked-files=%s", untrackedFilesSetting) diff --git a/pkg/gui/controllers/helpers/refresh_helper.go b/pkg/gui/controllers/helpers/refresh_helper.go index 126018da6..84c5a1991 100644 --- a/pkg/gui/controllers/helpers/refresh_helper.go +++ b/pkg/gui/controllers/helpers/refresh_helper.go @@ -599,9 +599,13 @@ func (self *RefreshHelper) refreshStateFiles() error { } } + showUntracked := git_commands.ShowUntrackedModeAuto + if self.c.Contexts().Files.ForceShowUntracked() { + showUntracked = git_commands.ShowUntrackedModeOn + } files := self.c.Git().Loaders.FileLoader. GetStatusFiles(git_commands.GetStatusFileOptions{ - ForceShowUntracked: self.c.Contexts().Files.ForceShowUntracked(), + ShowUntracked: showUntracked, }) conflictFileCount := 0