diff --git a/repository.go b/repository.go index 00ffaf748..7f5b7930c 100644 --- a/repository.go +++ b/repository.go @@ -436,7 +436,10 @@ func (r *Repository) clone(ctx context.Context, o *CloneOptions) error { } if o.RecurseSubmodules != NoRecurseSubmodules { - if err := w.updateSubmodules(o.RecurseSubmodules); err != nil { + if err := w.updateSubmodules(&SubmoduleUpdateOptions{ + RecurseSubmodules: o.RecurseSubmodules, + Auth: o.Auth, + }); err != nil { return err } } diff --git a/worktree.go b/worktree.go index 4e4d54488..60c8adbb2 100644 --- a/worktree.go +++ b/worktree.go @@ -112,22 +112,22 @@ func (w *Worktree) PullContext(ctx context.Context, o *PullOptions) error { } if o.RecurseSubmodules != NoRecurseSubmodules { - return w.updateSubmodules(o.RecurseSubmodules) + return w.updateSubmodules(&SubmoduleUpdateOptions{ + RecurseSubmodules: o.RecurseSubmodules, + Auth: o.Auth, + }) } return nil } -func (w *Worktree) updateSubmodules(recursion SubmoduleRescursivity) error { +func (w *Worktree) updateSubmodules(o *SubmoduleUpdateOptions) error { s, err := w.Submodules() if err != nil { return err } - - return s.Update(&SubmoduleUpdateOptions{ - Init: true, - RecurseSubmodules: recursion, - }) + o.Init = true + return s.Update(o) } // Checkout switch branches or restore working tree files.