@@ -74,43 +74,41 @@ public virtual void Init(string name, bool overwrite)
7474 /// Update specified submodule.
7575 /// <para>
7676 /// This will:
77- /// 1) Optionally initialize the if it not already initialzed ,
77+ /// 1) Optionally initialize the if it not already initialized ,
7878 /// 2) clone the sub repository if it has not already been cloned, and
7979 /// 3) checkout the commit ID for the submodule in the sub repository.
8080 /// </para>
8181 /// </summary>
8282 /// <param name="name">The name of the submodule to update.</param>
83- /// <param name="options">Options controlling submodule udpate behavior and callbacks.</param>
83+ /// <param name="options">Options controlling submodule update behavior and callbacks.</param>
8484 public virtual void Update ( string name , SubmoduleUpdateOptions options )
8585 {
86- options = options ?? new SubmoduleUpdateOptions ( ) ;
86+ options ??= new SubmoduleUpdateOptions ( ) ;
8787
88- using ( var handle = Proxy . git_submodule_lookup ( repo . Handle , name ) )
89- {
90- if ( handle == null )
91- {
92- throw new NotFoundException ( "Submodule lookup failed for '{0}'." ,
93- name ) ;
94- }
88+ using var handle = Proxy . git_submodule_lookup ( repo . Handle , name ) ?? throw new NotFoundException ( "Submodule lookup failed for '{0}'." , name ) ;
89+ using var checkoutOptionsWrapper = new GitCheckoutOptsWrapper ( options ) ;
90+ using var fetchOptionsWrapper = new GitFetchOptionsWrapper ( ) ;
9591
96- using ( GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper ( options ) )
97- {
98- var gitCheckoutOptions = checkoutOptionsWrapper . Options ;
92+ var gitCheckoutOptions = checkoutOptionsWrapper . Options ;
9993
100- var remoteCallbacks = new RemoteCallbacks ( options ) ;
101- var gitRemoteCallbacks = remoteCallbacks . GenerateCallbacks ( ) ;
94+ var gitFetchOptions = fetchOptionsWrapper . Options ;
95+ gitFetchOptions . ProxyOptions = options . FetchOptions . ProxyOptions . CreateGitProxyOptions ( ) ;
96+ gitFetchOptions . RemoteCallbacks = new RemoteCallbacks ( options . FetchOptions ) . GenerateCallbacks ( ) ;
10297
103- var gitSubmoduleUpdateOpts = new GitSubmoduleUpdateOptions
104- {
105- Version = 1 ,
106- CheckoutOptions = gitCheckoutOptions ,
107- FetchOptions = new GitFetchOptions { ProxyOptions = options . ProxyOptions . CreateGitProxyOptions ( ) , RemoteCallbacks = gitRemoteCallbacks } ,
108- CloneCheckoutStrategy = CheckoutStrategy . GIT_CHECKOUT_SAFE
109- } ;
110-
111- Proxy . git_submodule_update ( handle , options . Init , ref gitSubmoduleUpdateOpts ) ;
112- }
98+ if ( options . FetchOptions != null && options . FetchOptions . CustomHeaders != null )
99+ {
100+ gitFetchOptions . CustomHeaders =
101+ GitStrArrayManaged . BuildFrom ( options . FetchOptions . CustomHeaders ) ;
113102 }
103+
104+ var gitSubmoduleUpdateOpts = new GitSubmoduleUpdateOptions
105+ {
106+ Version = 1 ,
107+ CheckoutOptions = gitCheckoutOptions ,
108+ FetchOptions = gitFetchOptions
109+ } ;
110+
111+ Proxy . git_submodule_update ( handle , options . Init , ref gitSubmoduleUpdateOpts ) ;
114112 }
115113
116114 /// <summary>
0 commit comments