Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
sha1-name: make sort_ambiguous_oid_array() thread-safe
author
René Scharfe
<l.s.r@web.de>
Tue, 20 Aug 2019 18:49:12 +0000
(20:49 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Tue, 20 Aug 2019 20:59:59 +0000
(13:59 -0700)
Use QSORT_S instead of QSORT, which allows passing the repository
pointer to the comparison function without using a static variable.
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1-name.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
75b2f01
)
diff --git
a/sha1-name.c
b/sha1-name.c
index 728e6f1f61ea4641272e59e6287b6b47bfe0c74e..c99fbb2f8ec07c06d43fce919b234f3ce0aa0af9 100644
(file)
--- 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);
}
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;
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)
{
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,
}
static enum get_oid_result get_short_oid(struct repository *r,