Skip to content

Commit 2743b61

Browse files
committed
Merge branch 'rs/sort-oid-array-thread-safe'
Prepare get_short_oid() codepath to be thread-safe. * rs/sort-oid-array-thread-safe: sha1-name: make sort_ambiguous_oid_array() thread-safe
2 parents 4c49dd0 + 7cfcb16 commit 2743b61

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

sha1-name.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,9 @@ static int repo_collect_ambiguous(struct repository *r,
403403
return collect_ambiguous(oid, data);
404404
}
405405

406-
static struct repository *sort_ambiguous_repo;
407-
static int sort_ambiguous(const void *a, const void *b)
406+
static int sort_ambiguous(const void *a, const void *b, void *ctx)
408407
{
408+
struct repository *sort_ambiguous_repo = ctx;
409409
int a_type = oid_object_info(sort_ambiguous_repo, a, NULL);
410410
int b_type = oid_object_info(sort_ambiguous_repo, b, NULL);
411411
int a_type_sort;
@@ -434,10 +434,7 @@ static int sort_ambiguous(const void *a, const void *b)
434434

435435
static void sort_ambiguous_oid_array(struct repository *r, struct oid_array *a)
436436
{
437-
/* mutex will be needed if this code is to be made thread safe */
438-
sort_ambiguous_repo = r;
439-
QSORT(a->oid, a->nr, sort_ambiguous);
440-
sort_ambiguous_repo = NULL;
437+
QSORT_S(a->oid, a->nr, sort_ambiguous, r);
441438
}
442439

443440
static enum get_oid_result get_short_oid(struct repository *r,

0 commit comments

Comments
 (0)