7
7
#include "refs.h"
8
8
#include "refspec.h"
9
9
#include "object-store.h"
10
+ #include "oidset.h"
10
11
#include "commit.h"
11
12
#include "builtin.h"
12
13
#include "string-list.h"
@@ -245,15 +246,13 @@ static void add_merge_config(struct ref **head,
245
246
}
246
247
}
247
248
248
- static int will_fetch (struct ref * * head , const unsigned char * sha1 )
249
+ static void create_fetch_oidset (struct ref * * head , struct oidset * out )
249
250
{
250
251
struct ref * rm = * head ;
251
252
while (rm ) {
252
- if (hasheq (rm -> old_oid .hash , sha1 ))
253
- return 1 ;
253
+ oidset_insert (out , & rm -> old_oid );
254
254
rm = rm -> next ;
255
255
}
256
- return 0 ;
257
256
}
258
257
259
258
struct refname_hash_entry {
@@ -319,13 +318,15 @@ static void find_non_local_tags(const struct ref *refs,
319
318
{
320
319
struct hashmap existing_refs ;
321
320
struct hashmap remote_refs ;
321
+ struct oidset fetch_oids = OIDSET_INIT ;
322
322
struct string_list remote_refs_list = STRING_LIST_INIT_NODUP ;
323
323
struct string_list_item * remote_ref_item ;
324
324
const struct ref * ref ;
325
325
struct refname_hash_entry * item = NULL ;
326
326
327
327
refname_hash_init (& existing_refs );
328
328
refname_hash_init (& remote_refs );
329
+ create_fetch_oidset (head , & fetch_oids );
329
330
330
331
for_each_ref (add_one_refname , & existing_refs );
331
332
for (ref = refs ; ref ; ref = ref -> next ) {
@@ -342,9 +343,9 @@ static void find_non_local_tags(const struct ref *refs,
342
343
if (item &&
343
344
!has_object_file_with_flags (& ref -> old_oid ,
344
345
OBJECT_INFO_QUICK ) &&
345
- !will_fetch ( head , ref -> old_oid . hash ) &&
346
+ !oidset_contains ( & fetch_oids , & ref -> old_oid ) &&
346
347
!has_object_file_with_flags (& item -> oid , OBJECT_INFO_QUICK ) &&
347
- !will_fetch ( head , item -> oid . hash ))
348
+ !oidset_contains ( & fetch_oids , & item -> oid ))
348
349
clear_item (item );
349
350
item = NULL ;
350
351
continue ;
@@ -358,7 +359,7 @@ static void find_non_local_tags(const struct ref *refs,
358
359
*/
359
360
if (item &&
360
361
!has_object_file_with_flags (& item -> oid , OBJECT_INFO_QUICK ) &&
361
- !will_fetch ( head , item -> oid . hash ))
362
+ !oidset_contains ( & fetch_oids , & item -> oid ))
362
363
clear_item (item );
363
364
364
365
item = NULL ;
@@ -379,7 +380,7 @@ static void find_non_local_tags(const struct ref *refs,
379
380
*/
380
381
if (item &&
381
382
!has_object_file_with_flags (& item -> oid , OBJECT_INFO_QUICK ) &&
382
- !will_fetch ( head , item -> oid . hash ))
383
+ !oidset_contains ( & fetch_oids , & item -> oid ))
383
384
clear_item (item );
384
385
385
386
/*
@@ -406,6 +407,7 @@ static void find_non_local_tags(const struct ref *refs,
406
407
}
407
408
hashmap_free (& remote_refs , 1 );
408
409
string_list_clear (& remote_refs_list , 0 );
410
+ oidset_clear (& fetch_oids );
409
411
}
410
412
411
413
static struct ref * get_ref_map (struct remote * remote ,
0 commit comments