@@ -75,7 +75,6 @@ func Init(ctx context.Context, path string, opts ...InitOptions) error {
7575 }
7676
7777 args := []string {"init" }
78- args = append (args , opt .Args ... )
7978 if opt .Bare {
8079 args = append (args , "--bare" )
8180 }
@@ -133,7 +132,6 @@ func Clone(ctx context.Context, url, dst string, opts ...CloneOptions) error {
133132 }
134133
135134 args := []string {"clone" }
136- args = append (args , opt .Args ... )
137135 if opt .Mirror {
138136 args = append (args , "--mirror" )
139137 }
@@ -173,10 +171,10 @@ func (r *Repository) Fetch(ctx context.Context, opts ...FetchOptions) error {
173171 }
174172
175173 args := []string {"fetch" }
176- args = append (args , opt .Args ... )
177174 if opt .Prune {
178175 args = append (args , "--prune" )
179176 }
177+ args = append (args , "--end-of-options" )
180178
181179 _ , err := exec (ctx , r .path , args , opt .Envs )
182180 return err
@@ -206,13 +204,13 @@ func (r *Repository) Pull(ctx context.Context, opts ...PullOptions) error {
206204 }
207205
208206 args := []string {"pull" }
209- args = append (args , opt .Args ... )
210207 if opt .Rebase {
211208 args = append (args , "--rebase" )
212209 }
213210 if opt .All {
214211 args = append (args , "--all" )
215212 }
213+ args = append (args , "--end-of-options" )
216214 if ! opt .All && opt .Remote != "" {
217215 args = append (args , opt .Remote )
218216 if opt .Branch != "" {
@@ -239,9 +237,7 @@ func (r *Repository) Push(ctx context.Context, remote, branch string, opts ...Pu
239237 opt = opts [0 ]
240238 }
241239
242- args := []string {"push" }
243- args = append (args , opt .Args ... )
244- args = append (args , "--end-of-options" , remote , branch )
240+ args := []string {"push" , "--end-of-options" , remote , branch }
245241 _ , err := exec (ctx , r .path , args , opt .Envs )
246242 return err
247243}
@@ -264,13 +260,10 @@ func (r *Repository) Checkout(ctx context.Context, branch string, opts ...Checko
264260 }
265261
266262 args := []string {"checkout" }
267- args = append (args , opt .Args ... )
268- if opt .BaseBranch != "" {
269- args = append (args , "-b" )
270- }
271- args = append (args , branch )
272263 if opt .BaseBranch != "" {
273- args = append (args , opt .BaseBranch )
264+ args = append (args , "-b" , branch , "--end-of-options" , opt .BaseBranch )
265+ } else {
266+ args = append (args , "--end-of-options" , branch )
274267 }
275268
276269 _ , err := exec (ctx , r .path , args , opt .Envs )
@@ -298,7 +291,6 @@ func (r *Repository) Reset(ctx context.Context, rev string, opts ...ResetOptions
298291 if opt .Hard {
299292 args = append (args , "--hard" )
300293 }
301- args = append (args , opt .Args ... )
302294 args = append (args , "--end-of-options" , rev )
303295
304296 _ , err := exec (ctx , r .path , args , opt .Envs )
@@ -322,9 +314,7 @@ func (r *Repository) Move(ctx context.Context, src, dst string, opts ...MoveOpti
322314 opt = opts [0 ]
323315 }
324316
325- args := []string {"mv" }
326- args = append (args , opt .Args ... )
327- args = append (args , "--end-of-options" , src , dst )
317+ args := []string {"mv" , "--end-of-options" , src , dst }
328318 _ , err := exec (ctx , r .path , args , opt .Envs )
329319 return err
330320}
@@ -349,7 +339,6 @@ func (r *Repository) Add(ctx context.Context, opts ...AddOptions) error {
349339 }
350340
351341 args := []string {"add" }
352- args = append (args , opt .Args ... )
353342 if opt .All {
354343 args = append (args , "--all" )
355344 }
@@ -389,7 +378,7 @@ func (r *Repository) Commit(ctx context.Context, committer *Signature, message s
389378 args := []string {"commit" }
390379 args = append (args , fmt .Sprintf ("--author=%s <%s>" , opt .Author .Name , opt .Author .Email ))
391380 args = append (args , "-m" , message )
392- args = append (args , opt . Args ... )
381+ args = append (args , "--end-of-options" )
393382
394383 _ , err := exec (ctx , r .path , args , envs )
395384 // No stderr but exit status 1 means nothing to commit.
@@ -444,9 +433,7 @@ func (r *Repository) ShowNameStatus(ctx context.Context, rev string, opts ...Sho
444433 done <- struct {}{}
445434 }()
446435
447- args := []string {"show" , "--name-status" , "--pretty=format:''" }
448- args = append (args , opt .Args ... )
449- args = append (args , "--end-of-options" , rev )
436+ args := []string {"show" , "--name-status" , "--pretty=format:''" , "--end-of-options" , rev }
450437
451438 err := pipe (ctx , r .path , args , opt .Envs , w )
452439 _ = w .Close () // Close writer to exit parsing goroutine
@@ -474,9 +461,7 @@ func (r *Repository) RevParse(ctx context.Context, rev string, opts ...RevParseO
474461 opt = opts [0 ]
475462 }
476463
477- args := []string {"rev-parse" }
478- args = append (args , opt .Args ... )
479- args = append (args , rev )
464+ args := []string {"rev-parse" , rev }
480465
481466 commitID , err := exec (ctx , r .path , args , opt .Envs )
482467 if err != nil {
@@ -515,8 +500,7 @@ func (r *Repository) CountObjects(ctx context.Context, opts ...CountObjectsOptio
515500 opt = opts [0 ]
516501 }
517502
518- args := []string {"count-objects" , "-v" }
519- args = append (args , opt .Args ... )
503+ args := []string {"count-objects" , "-v" , "--end-of-options" }
520504
521505 stdout , err := exec (ctx , r .path , args , opt .Envs )
522506 if err != nil {
@@ -569,8 +553,7 @@ func (r *Repository) Fsck(ctx context.Context, opts ...FsckOptions) error {
569553 opt = opts [0 ]
570554 }
571555
572- args := []string {"fsck" }
573- args = append (args , opt .Args ... )
556+ args := []string {"fsck" , "--end-of-options" }
574557 _ , err := exec (ctx , r .path , args , opt .Envs )
575558 return err
576559}
0 commit comments