command: fix NewCommand (#135)

Make an explicit copy of GlobalCommandArgs, otherwise append might
overwrite it.
This commit is contained in:
Michael Kuhn
2018-11-27 23:50:05 +01:00
committed by Lauris BH
parent 6b819173ed
commit 389d3c803e
+4 -1
View File
@@ -37,9 +37,12 @@ func (c *Command) String() string {
// NewCommand creates and returns a new Git Command based on given command and arguments.
func NewCommand(args ...string) *Command {
// Make an explicit copy of GlobalCommandArgs, otherwise append might overwrite it
cargs := make([]string, len(GlobalCommandArgs))
copy(cargs, GlobalCommandArgs)
return &Command{
name: "git",
args: append(GlobalCommandArgs, args...),
args: append(cargs, args...),
}
}