diff options
author | Vincent Ambo <mail@tazj.in> | 2020-11-21T18·20+0100 |
---|---|---|
committer | Vincent Ambo <mail@tazj.in> | 2020-11-21T18·45+0100 |
commit | f4609b896fac842433bd495c166d5987852a6a73 (patch) | |
tree | 95511c465c54c4f5d27e5d39ce187e2a1dd82bd3 /third_party/git/sha1-lookup.c | |
parent | 082c006c04343a78d87b6c6ab3608c25d6213c3f (diff) |
merge(3p/git): Merge git subtree at v2.29.2 r/1890
This also bumps the stable nixpkgs to 20.09 as of 2020-11-21, because there is some breakage in the git build related to the netrc credentials helper which someone has taken care of in nixpkgs. The stable channel is not used for anything other than git, so this should be fine. Change-Id: I3575a19dab09e1e9556cf8231d717de9890484fb
Diffstat (limited to 'third_party/git/sha1-lookup.c')
-rw-r--r-- | third_party/git/sha1-lookup.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/third_party/git/sha1-lookup.c b/third_party/git/sha1-lookup.c index 796ab68da83c..29185844ecd4 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 *sha1, void *table, size_t nr, +int sha1_pos(const unsigned char *hash, void *table, size_t nr, sha1_access_fn fn) { size_t hi = nr; @@ -63,14 +63,14 @@ int sha1_pos(const unsigned char *sha1, void *table, size_t nr, if (nr != 1) { size_t lov, hiv, miv, ofs; - for (ofs = 0; ofs < 18; ofs += 2) { + for (ofs = 0; ofs < the_hash_algo->rawsz - 2; ofs += 2) { lov = take2(fn(0, table) + ofs); hiv = take2(fn(nr - 1, table) + ofs); - miv = take2(sha1 + ofs); + miv = take2(hash + ofs); if (miv < lov) return -1; if (hiv < miv) - return -1 - nr; + return index_pos_to_insert_pos(nr); if (lov != hiv) { /* * At this point miv could be equal @@ -88,7 +88,7 @@ int sha1_pos(const unsigned char *sha1, void *table, size_t nr, do { int cmp; - cmp = hashcmp(fn(mi, table), sha1); + cmp = hashcmp(fn(mi, table), hash); if (!cmp) return mi; if (cmp > 0) @@ -97,7 +97,7 @@ int sha1_pos(const unsigned char *sha1, void *table, size_t nr, lo = mi + 1; mi = lo + (hi - lo) / 2; } while (lo < hi); - return -lo-1; + return index_pos_to_insert_pos(lo); } int bsearch_hash(const unsigned char *sha1, const uint32_t *fanout_nbo, |