File tree 1 file changed +18
-0
lines changed
1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -254,6 +254,24 @@ func (s *Submodule) fetchAndCheckout(
254
254
return err
255
255
}
256
256
257
+ // Handle a case when submodule refers to an orphaned commit that's still reachable
258
+ // through Git server using a special protocol capability[1].
259
+ //
260
+ // [1]: https://git-scm.com/docs/protocol-capabilities#_allow_reachable_sha1_in_want
261
+ if ! o .NoFetch {
262
+ if _ , err := w .r .Object (plumbing .AnyObject , hash ); err != nil {
263
+ refSpec := config .RefSpec ("+" + hash .String () + ":" + hash .String ())
264
+
265
+ err := r .FetchContext (ctx , & FetchOptions {
266
+ Auth : o .Auth ,
267
+ RefSpecs : []config.RefSpec {refSpec },
268
+ })
269
+ if err != nil && err != NoErrAlreadyUpToDate && err != ErrExactSHA1NotSupported {
270
+ return err
271
+ }
272
+ }
273
+ }
274
+
257
275
if err := w .Checkout (& CheckoutOptions {Hash : hash }); err != nil {
258
276
return err
259
277
}
You can’t perform that action at this time.
0 commit comments