@@ -383,10 +383,11 @@ static int collect_ambiguous(const struct object_id *oid, void *data)
383
383
return 0 ;
384
384
}
385
385
386
+ static struct repository * sort_ambiguous_repo ;
386
387
static int sort_ambiguous (const void * a , const void * b )
387
388
{
388
- int a_type = oid_object_info (the_repository , a , NULL );
389
- int b_type = oid_object_info (the_repository , b , NULL );
389
+ int a_type = oid_object_info (sort_ambiguous_repo , a , NULL );
390
+ int b_type = oid_object_info (sort_ambiguous_repo , b , NULL );
390
391
int a_type_sort ;
391
392
int b_type_sort ;
392
393
@@ -411,6 +412,14 @@ static int sort_ambiguous(const void *a, const void *b)
411
412
return a_type_sort > b_type_sort ? 1 : -1 ;
412
413
}
413
414
415
+ static void sort_ambiguous_oid_array (struct repository * r , struct oid_array * a )
416
+ {
417
+ /* mutex will be needed if this code is to be made thread safe */
418
+ sort_ambiguous_repo = r ;
419
+ QSORT (a -> oid , a -> nr , sort_ambiguous );
420
+ sort_ambiguous_repo = NULL ;
421
+ }
422
+
414
423
static enum get_oid_result get_short_oid (const char * name , int len ,
415
424
struct object_id * oid ,
416
425
unsigned flags )
@@ -458,7 +467,7 @@ static enum get_oid_result get_short_oid(const char *name, int len,
458
467
459
468
advise (_ ("The candidates are:" ));
460
469
for_each_abbrev (ds .hex_pfx , collect_ambiguous , & collect );
461
- QSORT ( collect . oid , collect . nr , sort_ambiguous );
470
+ sort_ambiguous_oid_array ( the_repository , & collect );
462
471
463
472
if (oid_array_for_each (& collect , show_ambiguous_object , & ds ))
464
473
BUG ("show_ambiguous_object shouldn't return non-zero" );
0 commit comments