@@ -96,12 +96,36 @@ public virtual IEnumerable<DirectReference> ListReferences(Remote remote, Creden
96
96
/// <param name="url">The url to list from.</param>
97
97
/// <returns>The references in the remote repository.</returns>
98
98
public virtual IEnumerable < DirectReference > ListReferences ( string url )
99
+ {
100
+ return ListReferences ( url , null ) ;
101
+ }
102
+
103
+ /// <summary>
104
+ /// List references in a remote repository.
105
+ /// <para>
106
+ /// When the remote tips are ahead of the local ones, the retrieved
107
+ /// <see cref="DirectReference"/>s may point to non existing
108
+ /// <see cref="GitObject"/>s in the local repository. In that
109
+ /// case, <see cref="DirectReference.Target"/> will return <c>null</c>.
110
+ /// </para>
111
+ /// </summary>
112
+ /// <param name="url">The url to list from.</param>
113
+ /// <param name="credentialsProvider">The <see cref="Func{Credentials}"/> used to connect to remote repository.</param>
114
+ /// <returns>The references in the remote repository.</returns>
115
+ public virtual IEnumerable < DirectReference > ListReferences ( string url , CredentialsHandler credentialsProvider )
99
116
{
100
117
Ensure . ArgumentNotNull ( url , "url" ) ;
101
118
102
119
using ( RemoteSafeHandle remoteHandle = Proxy . git_remote_create_anonymous ( repository . Handle , url ) )
103
120
{
104
121
GitRemoteCallbacks gitCallbacks = new GitRemoteCallbacks { version = 1 } ;
122
+
123
+ if ( credentialsProvider != null )
124
+ {
125
+ var callbacks = new RemoteCallbacks ( credentialsProvider ) ;
126
+ gitCallbacks = callbacks . GenerateCallbacks ( ) ;
127
+ }
128
+
105
129
Proxy . git_remote_connect ( remoteHandle , GitDirection . Fetch , ref gitCallbacks ) ;
106
130
return Proxy . git_remote_ls ( repository , remoteHandle ) ;
107
131
}
0 commit comments