Skip to content
Merged
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
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ require (
github.com/jesseduffield/go-git/v5 v5.14.1-0.20250407170251-e1a013310ccd
github.com/jesseduffield/gocui v0.3.1-0.20251002151855-67e0e55ff42a
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
github.com/karimkhaleel/jsonschema v0.0.0-20231001195015-d933f0d94ea3
github.com/kyokomi/emoji/v2 v2.2.8
Expand Down Expand Up @@ -60,7 +59,6 @@ require (
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
github.com/go-git/go-billy/v5 v5.6.2 // indirect
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/gobwas/glob v0.2.3 // indirect
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect
github.com/hpcloud/tail v1.0.0 // indirect
github.com/invopop/jsonschema v0.10.0 // indirect
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4=
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
Expand Down Expand Up @@ -200,8 +198,6 @@ github.com/jesseduffield/gocui v0.3.1-0.20251002151855-67e0e55ff42a h1:z3NQvFXAW
github.com/jesseduffield/gocui v0.3.1-0.20251002151855-67e0e55ff42a/go.mod h1:sLIyZ2J42R6idGdtemZzsiR3xY5EF0KsvYEGh3dQv3s=
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5 h1:CDuQmfOjAtb1Gms6a1p5L2P8RhbLUq5t8aL7PiQd2uY=
github.com/jesseduffield/lazycore v0.0.0-20221012050358-03d2e40243c5/go.mod h1:qxN4mHOAyeIDLP7IK7defgPClM/z1Kze8VVQiaEjzsQ=
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e h1:uw/oo+kg7t/oeMs6sqlAwr85ND/9cpO3up3VxphxY0U=
github.com/jesseduffield/minimal/gitignore v0.3.3-0.20211018110810-9cde264e6b1e/go.mod h1:u60qdFGXRd36jyEXxetz0vQceQIxzI13lIo3EFUDf4I=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
Expand Down
16 changes: 16 additions & 0 deletions pkg/commands/git_commands/working_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,19 @@ func (self *WorkingTreeCommands) MergeFileForObjectIDs(strategy string, oursID s

return self.cmd.New(cmdArgs).RunWithOutput()
}

// Returns all tracked files in the repo (not in the working tree). The returned entries are
// relative paths to the repo root, using '/' as the path separator on all platforms.
// Does not really belong in WorkingTreeCommands, but it's close enough, and we don't seem to have a
// better place for it right now.
func (self *WorkingTreeCommands) AllRepoFiles() ([]string, error) {
cmdArgs := NewGitCmd("ls-files").Arg("-z").ToArgv()
output, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
if err != nil {
return nil, err
}
if output == "" {
return []string{}, nil
}
return strings.Split(strings.TrimRight(output, "\x00"), "\x00"), nil
}
29 changes: 29 additions & 0 deletions pkg/commands/git_commands/working_tree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,3 +563,32 @@ func TestWorkingTreeResetHard(t *testing.T) {
})
}
}

func TestWorkingTreeCommands_AllRepoFiles(t *testing.T) {
scenarios := []struct {
name string
runner *oscommands.FakeCmdObjRunner
expected []string
}{
{
name: "no files",
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"ls-files", "-z"}, "", nil),
expected: []string{},
},
{
name: "two files",
runner: oscommands.NewFakeRunner(t).
ExpectGitArgs([]string{"ls-files", "-z"}, "dir/file1.txt\x00dir2/file2.go\x00", nil),
expected: []string{"dir/file1.txt", "dir2/file2.go"},
},
}
for _, s := range scenarios {
t.Run(s.name, func(t *testing.T) {
instance := buildWorkingTreeCommands(commonDeps{runner: s.runner})
result, err := instance.AllRepoFiles()
assert.NoError(t, err)
assert.Equal(t, s.expected, result)
})
}
}
31 changes: 18 additions & 13 deletions pkg/gui/controllers/helpers/suggestions_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package helpers

import (
"fmt"
"os"
"strings"

"github.com/jesseduffield/generics/set"
"github.com/jesseduffield/gocui"
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/gui/presentation"
"github.com/jesseduffield/lazygit/pkg/gui/types"
"github.com/jesseduffield/lazygit/pkg/utils"
"github.com/jesseduffield/minimal/gitignore"
"github.com/samber/lo"
"golang.org/x/exp/slices"
"gopkg.in/ozeidan/fuzzy-patricia.v3/patricia"
Expand Down Expand Up @@ -92,22 +91,28 @@ func (self *SuggestionsHelper) GetBranchNameSuggestionsFunc() func(string) []*ty
func (self *SuggestionsHelper) GetFilePathSuggestionsFunc() func(string) []*types.Suggestion {
_ = self.c.WithWaitingStatus(self.c.Tr.LoadingFileSuggestions, func(gocui.Task) error {
trie := patricia.NewTrie()
// load every non-gitignored file in the repo
ignore, err := gitignore.FromGit()

// load every file in the repo
files, err := self.c.Git().WorkingTree.AllRepoFiles()
if err != nil {
return err
}

err = ignore.Walk(".",
func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
}
if path != "." {
trie.Insert(patricia.Prefix(path), path)
seen := set.New[string]()
for _, file := range files {
// For every file we also want to add its parent directories, but only once.
for i := range len(file) {
if file[i] == '/' {
dir := file[:i]
if !seen.Includes(dir) {
trie.Insert(patricia.Prefix(dir), dir)
seen.Add(dir)
}
}
return nil
})
}

trie.Insert(patricia.Prefix(file), file)
}

// cache the trie for future use
self.c.Model().FilesTrie = trie
Expand Down
8 changes: 0 additions & 8 deletions vendor/github.com/gobwas/glob/.gitignore

This file was deleted.

9 changes: 0 additions & 9 deletions vendor/github.com/gobwas/glob/.travis.yml

This file was deleted.

21 changes: 0 additions & 21 deletions vendor/github.com/gobwas/glob/LICENSE

This file was deleted.

26 changes: 0 additions & 26 deletions vendor/github.com/gobwas/glob/bench.sh

This file was deleted.

Loading