@@ -61,7 +61,7 @@ static int mark_local(git_remote *remote)
6161
6262 git_vector_foreach (& remote -> refs , i , head ) {
6363 /* If we have the object, mark it so we don't ask for it.
64- However if we are unshallowing, we need to ask for it
64+ However if we are unshallowing, we need to ask for it
6565 even though the head exists locally. */
6666 if (remote -> nego .depth != INT_MAX && git_odb_exists (odb , & head -> oid ))
6767 head -> local = 1 ;
@@ -169,6 +169,7 @@ static int filter_wants(git_remote *remote, const git_fetch_options *opts)
169169int git_fetch_negotiate (git_remote * remote , const git_fetch_options * opts )
170170{
171171 git_transport * t = remote -> transport ;
172+ int error ;
172173
173174 remote -> need_pack = 0 ;
174175
@@ -191,33 +192,39 @@ int git_fetch_negotiate(git_remote *remote, const git_fetch_options *opts)
191192 * server what we want and what we have.
192193 */
193194 remote -> nego .refs = (const git_remote_head * const * )remote -> refs .contents ;
194- remote -> nego .count = remote -> refs .length ;
195- remote -> nego .shallow_roots = git__malloc (sizeof (* remote -> nego .shallow_roots ));
196-
197- git_array_init (remote -> nego .shallow_roots -> array );
195+ remote -> nego .refs_len = remote -> refs .length ;
198196
199- git_repository__shallow_roots (& remote -> nego .shallow_roots -> array , remote -> repo );
197+ if (git_repository__shallow_roots (& remote -> nego .shallow_roots ,
198+ & remote -> nego .shallow_roots_len ,
199+ remote -> repo ) < 0 )
200+ return -1 ;
200201
201- return t -> negotiate_fetch (t ,
202+ error = t -> negotiate_fetch (t ,
202203 remote -> repo ,
203204 & remote -> nego );
205+
206+ git__free (remote -> nego .shallow_roots );
207+
208+ return error ;
204209}
205210
206211int git_fetch_download_pack (git_remote * remote )
207212{
213+ git_oidarray shallow_roots = { NULL };
208214 git_transport * t = remote -> transport ;
209215 int error ;
210216
211217 if (!remote -> need_pack )
212218 return 0 ;
213219
214- if ((error = t -> download_pack (t , remote -> repo , & remote -> stats )) != 0 )
220+ if ((error = t -> download_pack (t , remote -> repo , & remote -> stats )) != 0 ||
221+ (error = t -> shallow_roots (& shallow_roots , t )) != 0 )
215222 return error ;
216223
217- if ((error = git_repository__shallow_roots_write (remote -> repo , remote -> nego .shallow_roots -> array )) != 0 )
218- return error ;
224+ error = git_repository__shallow_roots_write (remote -> repo , & shallow_roots );
219225
220- return 0 ;
226+ git_oidarray_dispose (& shallow_roots );
227+ return error ;
221228}
222229
223230int git_fetch_options_init (git_fetch_options * opts , unsigned int version )
0 commit comments