Skip to content
This repository was archived by the owner on Apr 12, 2019. It is now read-only.

Commit 389d3c8

Browse files
michaelkuhnlafriks
authored andcommitted
command: fix NewCommand (#135)
Make an explicit copy of GlobalCommandArgs, otherwise append might overwrite it.
1 parent 6b81917 commit 389d3c8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

command.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,12 @@ func (c *Command) String() string {
3737

3838
// NewCommand creates and returns a new Git Command based on given command and arguments.
3939
func NewCommand(args ...string) *Command {
40+
// Make an explicit copy of GlobalCommandArgs, otherwise append might overwrite it
41+
cargs := make([]string, len(GlobalCommandArgs))
42+
copy(cargs, GlobalCommandArgs)
4043
return &Command{
4144
name: "git",
42-
args: append(GlobalCommandArgs, args...),
45+
args: append(cargs, args...),
4346
}
4447
}
4548

0 commit comments

Comments
 (0)