@@ -74,43 +74,41 @@ public virtual void Init(string name, bool overwrite)
74
74
/// Update specified submodule.
75
75
/// <para>
76
76
/// This will:
77
- /// 1) Optionally initialize the if it not already initialzed ,
77
+ /// 1) Optionally initialize the if it not already initialized ,
78
78
/// 2) clone the sub repository if it has not already been cloned, and
79
79
/// 3) checkout the commit ID for the submodule in the sub repository.
80
80
/// </para>
81
81
/// </summary>
82
82
/// <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>
84
84
public virtual void Update ( string name , SubmoduleUpdateOptions options )
85
85
{
86
- options = options ?? new SubmoduleUpdateOptions ( ) ;
86
+ options ??= new SubmoduleUpdateOptions ( ) ;
87
87
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 ( ) ;
95
91
96
- using ( GitCheckoutOptsWrapper checkoutOptionsWrapper = new GitCheckoutOptsWrapper ( options ) )
97
- {
98
- var gitCheckoutOptions = checkoutOptionsWrapper . Options ;
92
+ var gitCheckoutOptions = checkoutOptionsWrapper . Options ;
99
93
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 ( ) ;
102
97
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 ) ;
113
102
}
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 ) ;
114
112
}
115
113
116
114
/// <summary>
0 commit comments