mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-11 20:36:03 +02:00
Construct arg vector manually rather than parse string
By constructing an arg vector manually, we no longer need to quote arguments Mandate that args must be passed when building a command Now you need to provide an args array when building a command. There are a handful of places where we need to deal with a string, such as with user-defined custom commands, and for those we now require that at the callsite they use str.ToArgv to do that. I don't want to provide a method out of the box for it because I want to discourage its use. For some reason we were invoking a command through a shell when amending a commit, and I don't believe we needed to do that as there was nothing user- supplied about the command. So I've switched to using a regular command out- side the shell there
This commit is contained in:
parent
70e473b25d
commit
63dc07fded
221 changed files with 1050 additions and 885 deletions
|
@ -97,15 +97,15 @@ func (self *BisectCommands) GetInfo() *BisectInfo {
|
|||
}
|
||||
|
||||
func (self *BisectCommands) Reset() error {
|
||||
cmdStr := NewGitCmd("bisect").Arg("reset").ToString()
|
||||
cmdArgs := NewGitCmd("bisect").Arg("reset").ToArgv()
|
||||
|
||||
return self.cmd.New(cmdStr).StreamOutput().Run()
|
||||
return self.cmd.New(cmdArgs).StreamOutput().Run()
|
||||
}
|
||||
|
||||
func (self *BisectCommands) Mark(ref string, term string) error {
|
||||
cmdStr := NewGitCmd("bisect").Arg(term, ref).ToString()
|
||||
cmdArgs := NewGitCmd("bisect").Arg(term, ref).ToArgv()
|
||||
|
||||
return self.cmd.New(cmdStr).
|
||||
return self.cmd.New(cmdArgs).
|
||||
IgnoreEmptyError().
|
||||
StreamOutput().
|
||||
Run()
|
||||
|
@ -116,9 +116,9 @@ func (self *BisectCommands) Skip(ref string) error {
|
|||
}
|
||||
|
||||
func (self *BisectCommands) Start() error {
|
||||
cmdStr := NewGitCmd("bisect").Arg("start").ToString()
|
||||
cmdArgs := NewGitCmd("bisect").Arg("start").ToArgv()
|
||||
|
||||
return self.cmd.New(cmdStr).StreamOutput().Run()
|
||||
return self.cmd.New(cmdArgs).StreamOutput().Run()
|
||||
}
|
||||
|
||||
// tells us whether we've found our problem commit(s). We return a string slice of
|
||||
|
@ -140,8 +140,8 @@ func (self *BisectCommands) IsDone() (bool, []string, error) {
|
|||
done := false
|
||||
candidates := []string{}
|
||||
|
||||
cmdStr := NewGitCmd("rev-list").Arg(newSha).ToString()
|
||||
err := self.cmd.New(cmdStr).RunAndProcessLines(func(line string) (bool, error) {
|
||||
cmdArgs := NewGitCmd("rev-list").Arg(newSha).ToArgv()
|
||||
err := self.cmd.New(cmdArgs).RunAndProcessLines(func(line string) (bool, error) {
|
||||
sha := strings.TrimSpace(line)
|
||||
|
||||
if status, ok := info.statusMap[sha]; ok {
|
||||
|
@ -171,11 +171,11 @@ func (self *BisectCommands) IsDone() (bool, []string, error) {
|
|||
// bisecting is actually a descendant of our current bisect commit. If it's not, we need to
|
||||
// render the commits from the bad commit.
|
||||
func (self *BisectCommands) ReachableFromStart(bisectInfo *BisectInfo) bool {
|
||||
cmdStr := NewGitCmd("merge-base").
|
||||
cmdArgs := NewGitCmd("merge-base").
|
||||
Arg("--is-ancestor", bisectInfo.GetNewSha(), bisectInfo.GetStartSha()).
|
||||
ToString()
|
||||
ToArgv()
|
||||
|
||||
err := self.cmd.New(cmdStr).DontLog().Run()
|
||||
err := self.cmd.New(cmdArgs).DontLog().Run()
|
||||
|
||||
return err == nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue