summaryrefslogtreecommitdiff
path: root/sha1-name.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2019-04-16 09:33:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-04-16 09:56:52 (GMT)
commitfae2ae45df32192bb862f1d71704381d67ce81b3 (patch)
tree72601d9c799193a114b9b8d7e58e05e957172488 /sha1-name.c
parent301b8c7f405d3cd4f32b14bd336ac8c0400d9382 (diff)
downloadgit-fae2ae45df32192bb862f1d71704381d67ce81b3.zip
git-fae2ae45df32192bb862f1d71704381d67ce81b3.tar.gz
git-fae2ae45df32192bb862f1d71704381d67ce81b3.tar.bz2
sha1-name.c: remove the_repo from sort_ambiguous()
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1-name.c')
-rw-r--r--sha1-name.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/sha1-name.c b/sha1-name.c
index 15a1107..7558ce5 100644
--- a/sha1-name.c
+++ b/sha1-name.c
@@ -383,10 +383,11 @@ static int collect_ambiguous(const struct object_id *oid, void *data)
return 0;
}
+static struct repository *sort_ambiguous_repo;
static int sort_ambiguous(const void *a, const void *b)
{
- int a_type = oid_object_info(the_repository, a, NULL);
- int b_type = oid_object_info(the_repository, b, NULL);
+ 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 b_type_sort;
@@ -411,6 +412,14 @@ static int sort_ambiguous(const void *a, const void *b)
return a_type_sort > b_type_sort ? 1 : -1;
}
+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;
+}
+
static enum get_oid_result get_short_oid(const char *name, int len,
struct object_id *oid,
unsigned flags)
@@ -458,7 +467,7 @@ static enum get_oid_result get_short_oid(const char *name, int len,
advise(_("The candidates are:"));
for_each_abbrev(ds.hex_pfx, collect_ambiguous, &collect);
- QSORT(collect.oid, collect.nr, sort_ambiguous);
+ sort_ambiguous_oid_array(the_repository, &collect);
if (oid_array_for_each(&collect, show_ambiguous_object, &ds))
BUG("show_ambiguous_object shouldn't return non-zero");