@@ -284,17 +284,21 @@ pub fn make_refmapping_ignore_predicate(fetch_tags: Tags, ref_map: &RefMap) -> i
284284/// * `ref_map` is the state of refs as known on the remote.
285285/// * `shallow` defines if the history should be shallow.
286286/// * `mapping_is_ignored` is typically initialized with [`make_refmapping_ignore_predicate`].
287+ ///
288+ /// Returns `true` if at least one [want](crate::fetch::Arguments::want()) was added, or `false` otherwise.
289+ /// Note that not adding a single want can make the remote hang, so it's avoided on the client side by ending the fetch operation.
287290pub fn add_wants (
288291 objects : & impl gix_object:: FindHeader ,
289292 arguments : & mut crate :: fetch:: Arguments ,
290293 ref_map : & RefMap ,
291294 remote_ref_target_known : & [ bool ] ,
292295 shallow : & Shallow ,
293296 mapping_is_ignored : impl Fn ( & refmap:: Mapping ) -> bool ,
294- ) {
297+ ) -> bool {
295298 // When using shallow, we can't exclude `wants` as the remote won't send anything then. Thus, we have to resend everything
296299 // we have as want instead to get exactly the same graph, but possibly deepened.
297300 let is_shallow = !matches ! ( shallow, Shallow :: NoChange ) ;
301+ let mut has_want = false ;
298302 let wants = ref_map
299303 . mappings
300304 . iter ( )
@@ -306,13 +310,15 @@ pub fn add_wants(
306310 if !arguments. can_use_ref_in_want ( ) || matches ! ( want. remote, refmap:: Source :: ObjectId ( _) ) {
307311 if let Some ( id) = id_on_remote {
308312 arguments. want ( id) ;
313+ has_want = true ;
309314 }
310315 } else {
311316 arguments. want_ref (
312317 want. remote
313318 . as_name ( )
314319 . expect ( "name available if this isn't an object id" ) ,
315320 ) ;
321+ has_want = true ;
316322 }
317323 let id_is_annotated_tag_we_have = id_on_remote
318324 . and_then ( |id| objects. try_header ( id) . ok ( ) . flatten ( ) . map ( |h| ( id, h) ) )
@@ -324,6 +330,7 @@ pub fn add_wants(
324330 arguments. have ( tag_on_remote) ;
325331 }
326332 }
333+ has_want
327334}
328335
329336/// Remove all commits that are more recent than the cut-off, which is the commit time of the oldest common commit we have with the server.
0 commit comments