summaryrefslogtreecommitdiff
path: root/sha1_name.c
diff options
context:
space:
mode:
Diffstat (limited to 'sha1_name.c')
-rw-r--r--sha1_name.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/sha1_name.c b/sha1_name.c
index 16e0003..24894b3 100644
--- a/sha1_name.c
+++ b/sha1_name.c
@@ -512,32 +512,16 @@ static void find_abbrev_len_for_pack(struct packed_git *p,
struct min_abbrev_data *mad)
{
int match = 0;
- uint32_t num, last, first = 0;
+ uint32_t num, first = 0;
struct object_id oid;
+ const struct object_id *mad_oid;
if (open_pack_index(p) || !p->num_objects)
return;
num = p->num_objects;
- last = num;
- while (first < last) {
- uint32_t mid = first + (last - first) / 2;
- const unsigned char *current;
- int cmp;
-
- current = nth_packed_object_sha1(p, mid);
- cmp = hashcmp(mad->oid->hash, current);
- if (!cmp) {
- match = 1;
- first = mid;
- break;
- }
- if (cmp > 0) {
- first = mid + 1;
- continue;
- }
- last = mid;
- }
+ mad_oid = mad->oid;
+ match = bsearch_pack(mad_oid, p, &first);
/*
* first is now the position in the packfile where we would insert