From 389d3c803e12a30dffcbb54a15c2242521bc4333 Mon Sep 17 00:00:00 2001 From: Michael Kuhn Date: Tue, 27 Nov 2018 23:50:05 +0100 Subject: [PATCH] command: fix NewCommand (#135) Make an explicit copy of GlobalCommandArgs, otherwise append might overwrite it. --- command.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/command.go b/command.go index 8ca99fd..fc48d28 100644 --- a/command.go +++ b/command.go @@ -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...), } }