diff options
author | Junio C Hamano <gitster@pobox.com> | 2019-09-09 21:26:39 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-09-09 21:26:39 +0200 |
commit | 2743b61bc65156d337c0740da5122b58a044b1a5 (patch) | |
tree | 2921d81d6e15b6139813433716286f11104f74e4 /sha1-name.c | |
parent | Merge branch 'nd/diff-parseopt' (diff) | |
parent | sha1-name: make sort_ambiguous_oid_array() thread-safe (diff) | |
download | git-2743b61bc65156d337c0740da5122b58a044b1a5.tar.xz git-2743b61bc65156d337c0740da5122b58a044b1a5.zip |
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
Diffstat (limited to 'sha1-name.c')
-rw-r--r-- | sha1-name.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/sha1-name.c b/sha1-name.c index 2989e27b71..c665e3f96d 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -403,9 +403,9 @@ static int repo_collect_ambiguous(struct repository *r, return collect_ambiguous(oid, data); } -static struct repository *sort_ambiguous_repo; -static int sort_ambiguous(const void *a, const void *b) +static int sort_ambiguous(const void *a, const void *b, void *ctx) { + struct repository *sort_ambiguous_repo = ctx; int a_type = oid_object_info(sort_ambiguous_repo, a, NULL); int b_type = oid_object_info(sort_ambiguous_repo, b, NULL); int a_type_sort; @@ -434,10 +434,7 @@ static int sort_ambiguous(const void *a, const void *b) static void sort_ambiguous_oid_array(struct repository *r, struct oid_array *a) { - /* mutex will be needed if this code is to be made thread safe */ - sort_ambiguous_repo = r; - QSORT(a->oid, a->nr, sort_ambiguous); - sort_ambiguous_repo = NULL; + QSORT_S(a->oid, a->nr, sort_ambiguous, r); } static enum get_oid_result get_short_oid(struct repository *r, |