mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-12 04:45:47 +02:00
Support older versions of git when fetching worktrees
Older versions of git don't support the -z flag in `git worktree list`. So we're using newlines. Also, we're not raising an error upon error because that triggers another refresh, which gets us into an infinite loop
This commit is contained in:
parent
ca6f9c4155
commit
81a9133261
2 changed files with 6 additions and 3 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
"github.com/jesseduffield/lazygit/pkg/commands/models"
|
||||||
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
|
||||||
"github.com/jesseduffield/lazygit/pkg/common"
|
"github.com/jesseduffield/lazygit/pkg/common"
|
||||||
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/samber/lo"
|
"github.com/samber/lo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,13 +28,13 @@ func NewWorktreeLoader(
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *WorktreeLoader) GetWorktrees() ([]*models.Worktree, error) {
|
func (self *WorktreeLoader) GetWorktrees() ([]*models.Worktree, error) {
|
||||||
cmdArgs := NewGitCmd("worktree").Arg("list", "--porcelain", "-z").ToArgv()
|
cmdArgs := NewGitCmd("worktree").Arg("list", "--porcelain").ToArgv()
|
||||||
worktreesOutput, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
worktreesOutput, err := self.cmd.New(cmdArgs).DontLog().RunWithOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
splitLines := strings.Split(worktreesOutput, "\x00")
|
splitLines := utils.SplitLines(worktreesOutput)
|
||||||
|
|
||||||
var worktrees []*models.Worktree
|
var worktrees []*models.Worktree
|
||||||
var current *models.Worktree
|
var current *models.Worktree
|
||||||
|
|
|
@ -605,7 +605,9 @@ func (self *RefreshHelper) refreshWorktrees() error {
|
||||||
|
|
||||||
worktrees, err := self.c.Git().Loaders.Worktrees.GetWorktrees()
|
worktrees, err := self.c.Git().Loaders.Worktrees.GetWorktrees()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return self.c.Error(err)
|
self.c.Log.Error(err)
|
||||||
|
self.c.Model().Worktrees = []*models.Worktree{}
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
self.c.Model().Worktrees = worktrees
|
self.c.Model().Worktrees = worktrees
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue