@@ -57,7 +57,7 @@ internal static Remote BuildFromPtr(RemoteSafeHandle handle, Repository repo)
57
57
/// <param name="onCompletion">Completion callback. Corresponds to libgit2 completion callback.</param>
58
58
/// <param name="onUpdateTips">UpdateTips callback. Corresponds to libgit2 update_tips callback.</param>
59
59
public virtual void Fetch ( FetchProgress progress = null ,
60
- TagFetchMode ? tagFetchMode = null ,
60
+ TagFetchMode tagFetchMode = TagFetchMode . Auto ,
61
61
ProgressHandler onProgress = null ,
62
62
CompletionHandler onCompletion = null ,
63
63
UpdateTipsHandler onUpdateTips = null )
@@ -67,28 +67,23 @@ public virtual void Fetch(FetchProgress progress = null,
67
67
68
68
using ( RemoteSafeHandle remoteHandle = Proxy . git_remote_load ( repository . Handle , this . Name , true ) )
69
69
{
70
- RemoteCallbacks callbacks = new RemoteCallbacks ( onProgress , onCompletion , onUpdateTips ) ;
70
+ var callbacks = new RemoteCallbacks ( onProgress , onCompletion , onUpdateTips ) ;
71
71
GitRemoteCallbacks gitCallbacks = callbacks . GenerateCallbacks ( ) ;
72
72
73
+ Proxy . git_remote_set_autotag ( remoteHandle , tagFetchMode ) ;
74
+
75
+ // It is OK to pass the reference to the GitCallbacks directly here because libgit2 makes a copy of
76
+ // the data in the git_remote_callbacks structure. If, in the future, libgit2 changes its implementation
77
+ // to store a reference to the git_remote_callbacks structure this would introduce a subtle bug
78
+ // where the managed layer could move the git_remote_callbacks to a different location in memory,
79
+ // but libgit2 would still reference the old address.
80
+ //
81
+ // Also, if GitRemoteCallbacks were a class instead of a struct, we would need to guard against
82
+ // GC occuring in between setting the remote callbacks and actual usage in one of the functions afterwords.
83
+ Proxy . git_remote_set_callbacks ( remoteHandle , ref gitCallbacks ) ;
84
+
73
85
try
74
86
{
75
- // If a TagFetchMode value has been specified, pass it on to
76
- // to the libgit2 layer
77
- if ( tagFetchMode . HasValue )
78
- {
79
- Proxy . git_remote_set_autotag ( remoteHandle , tagFetchMode . Value ) ;
80
- }
81
-
82
- // It is OK to pass the reference to the GitCallbacks directly here because libgit2 makes a copy of
83
- // the data in the git_remote_callbacks structure. If, in the future, libgit2 changes its implementation
84
- // to store a reference to the git_remote_callbacks structure this would introduce a subtle bug
85
- // where the managed layer could move the git_remote_callbacks to a different location in memory,
86
- // but libgit2 would still reference the old address.
87
- //
88
- // Also, if GitRemoteCallbacks were a class instead of a struct, we would need to guard against
89
- // GC occuring in between setting the remote callbacks and actual usage in one of the functions afterwords.
90
- Proxy . git_remote_set_callbacks ( remoteHandle , ref gitCallbacks ) ;
91
-
92
87
Proxy . git_remote_connect ( remoteHandle , GitDirection . Fetch ) ;
93
88
94
89
Proxy . git_remote_download ( remoteHandle , ref progress . bytes , ref progress . IndexerStats . gitIndexerStats ) ;
0 commit comments