Skip to content

Commit

Permalink
Break git.merging.args config into separate arguments on whitespace
Browse files Browse the repository at this point in the history
This makes it possible again to pass multiple arguments, for example
"--ff-only --autostash". This won't work correctly if you want to use
an argument that contains a space, but it's very unlikely that people
will want to do that, so I think this is good enough.
  • Loading branch information
stefanhaller committed Mar 2, 2024
1 parent aa81c45 commit 253a009
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/commands/git_commands/branch.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ type MergeOpts struct {
func (self *BranchCommands) Merge(branchName string, opts MergeOpts) error {
cmdArgs := NewGitCmd("merge").
Arg("--no-edit").
ArgIf(self.UserConfig.Git.Merging.Args != "", self.UserConfig.Git.Merging.Args).
Arg(strings.Fields(self.UserConfig.Git.Merging.Args)...).
ArgIf(opts.FastForwardOnly, "--ff-only").
Arg(branchName).
ToArgv()
Expand Down
3 changes: 1 addition & 2 deletions pkg/commands/git_commands/branch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@ func TestBranchMerge(t *testing.T) {
},
opts: MergeOpts{},
branchName: "mybranch",
expected: []string{"merge", "--no-edit", "--arg1 --arg2", "mybranch"},
// This is wrong, we want separate arguments for "--arg1" and "--arg2"
expected: []string{"merge", "--no-edit", "--arg1", "--arg2", "mybranch"},
},
{
testName: "fast forward only",
Expand Down

0 comments on commit 253a009

Please sign in to comment.