about summary refs log tree commit diff
path: root/third_party/git/sha1-lookup.c
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-25T23·06+0100
committerVincent Ambo <tazjin@google.com>2020-05-25T23·06+0100
commit93ba78d6f4632ef1c5228965e3edc8c0faf88c1e (patch)
tree85730c182a9f5f492ade8e8ccdb1c2356f9900bd /third_party/git/sha1-lookup.c
parent6f8fbf4aa4b1654ab27d4829e114538761817de0 (diff)
revert(3p/git): Revert merge of git upstream at v2.26.2 r/852
This causes cgit to serve error pages, which is undesirable.

This reverts commit 5229c9b232de5bfa959ad6ebbb4c8192ac513352, reversing
changes made to f2b211131f2347342dde63975b09cf603149f1a3.
Diffstat (limited to 'third_party/git/sha1-lookup.c')
-rw-r--r--third_party/git/sha1-lookup.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/third_party/git/sha1-lookup.c b/third_party/git/sha1-lookup.c
index 29185844ec..796ab68da8 100644
--- a/third_party/git/sha1-lookup.c
+++ b/third_party/git/sha1-lookup.c
@@ -50,7 +50,7 @@ static uint32_t take2(const unsigned char *sha1)
  * The sha1 of element i (between 0 and nr - 1) should be returned
  * by "fn(i, table)".
  */
-int sha1_pos(const unsigned char *hash, void *table, size_t nr,
+int sha1_pos(const unsigned char *sha1, void *table, size_t nr,
 	     sha1_access_fn fn)
 {
 	size_t hi = nr;
@@ -63,14 +63,14 @@ int sha1_pos(const unsigned char *hash, void *table, size_t nr,
 	if (nr != 1) {
 		size_t lov, hiv, miv, ofs;
 
-		for (ofs = 0; ofs < the_hash_algo->rawsz - 2; ofs += 2) {
+		for (ofs = 0; ofs < 18; ofs += 2) {
 			lov = take2(fn(0, table) + ofs);
 			hiv = take2(fn(nr - 1, table) + ofs);
-			miv = take2(hash + ofs);
+			miv = take2(sha1 + ofs);
 			if (miv < lov)
 				return -1;
 			if (hiv < miv)
-				return index_pos_to_insert_pos(nr);
+				return -1 - nr;
 			if (lov != hiv) {
 				/*
 				 * At this point miv could be equal
@@ -88,7 +88,7 @@ int sha1_pos(const unsigned char *hash, void *table, size_t nr,
 
 	do {
 		int cmp;
-		cmp = hashcmp(fn(mi, table), hash);
+		cmp = hashcmp(fn(mi, table), sha1);
 		if (!cmp)
 			return mi;
 		if (cmp > 0)
@@ -97,7 +97,7 @@ int sha1_pos(const unsigned char *hash, void *table, size_t nr,
 			lo = mi + 1;
 		mi = lo + (hi - lo) / 2;
 	} while (lo < hi);
-	return index_pos_to_insert_pos(lo);
+	return -lo-1;
 }
 
 int bsearch_hash(const unsigned char *sha1, const uint32_t *fanout_nbo,