summaryrefslogtreecommitdiff
path: root/src/pack.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pack.c')
-rw-r--r--src/pack.c22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/pack.c b/src/pack.c
index 7c6fc2cdb..fcf64f57d 100644
--- a/src/pack.c
+++ b/src/pack.c
@@ -12,7 +12,6 @@
#include "mwindow.h"
#include "odb.h"
#include "oid.h"
-#include "sha1_lookup.h"
/* Option to bypass checking existence of '.keep' files */
bool git_disable_pack_keep_file_checks = false;
@@ -1239,6 +1238,27 @@ int git_pack_foreach_entry(
return error;
}
+static int sha1_position(const void *table, size_t stride, unsigned lo,
+ unsigned hi, const unsigned char *key)
+{
+ const unsigned char *base = table;
+
+ while (lo < hi) {
+ unsigned mi = (lo + hi) / 2;
+ int cmp = git_oid__hashcmp(base + mi * stride, key);
+
+ if (!cmp)
+ return mi;
+
+ if (cmp > 0)
+ hi = mi;
+ else
+ lo = mi+1;
+ }
+
+ return -((int)lo)-1;
+}
+
static int pack_entry_find_offset(
off64_t *offset_out,
git_oid *found_oid,