summaryrefslogtreecommitdiffstats
path: root/pkg/commands
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2023-07-17 19:23:35 +1000
committerJesse Duffield <jessedduffield@gmail.com>2023-07-30 18:35:23 +1000
commit81a91332613e9aff0e4dbae419f9127e5debeec6 (patch)
tree6029525ea17b8696ad64e2cfe6faa95227e41011 /pkg/commands
parentca6f9c4155c826ac2feb7a2a37d6953dcb94bb10 (diff)
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
Diffstat (limited to 'pkg/commands')
-rw-r--r--pkg/commands/git_commands/worktree_loader.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/commands/git_commands/worktree_loader.go b/pkg/commands/git_commands/worktree_loader.go
index a6561a78a..0c863d546 100644
--- a/pkg/commands/git_commands/worktree_loader.go
+++ b/pkg/commands/git_commands/worktree_loader.go
@@ -8,6 +8,7 @@ import (
"github.com/jesseduffield/lazygit/pkg/commands/models"
"github.com/jesseduffield/lazygit/pkg/commands/oscommands"
"github.com/jesseduffield/lazygit/pkg/common"
+ "github.com/jesseduffield/lazygit/pkg/utils"
"github.com/samber/lo"
)
@@ -27,13 +28,13 @@ func NewWorktreeLoader(
}
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()
if err != nil {
return nil, err
}
- splitLines := strings.Split(worktreesOutput, "\x00")
+ splitLines := utils.SplitLines(worktreesOutput)
var worktrees []*models.Worktree
var current *models.Worktree