]> git.ipfire.org Git - thirdparty/git.git/commitdiff
hash-lookup: rename from sha1-lookup
authorMartin Ågren <martin.agren@gmail.com>
Thu, 31 Dec 2020 11:56:23 +0000 (12:56 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 4 Jan 2021 21:01:55 +0000 (13:01 -0800)
Change all remnants of "sha1" in hash-lookup.c and .h and rename them to
reflect that we're not just able to handle SHA-1 these days.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
14 files changed:
Makefile
bisect.c
builtin/name-rev.c
commit-graph.c
commit.c
hash-lookup.c [moved from sha1-lookup.c with 90% similarity]
hash-lookup.h [moved from sha1-lookup.h with 78% similarity]
midx.c
object-file.c
oid-array.c
pack-bitmap-write.c
packfile.c
patch-ids.c
rerere.c

index 224a1c6940697ff2a0c76c5c2d81d7a09337d7bf..7a141facc7cd12b58b81bae75db4d7d1d85cf1d6 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -901,6 +901,7 @@ LIB_OBJS += gettext.o
 LIB_OBJS += gpg-interface.o
 LIB_OBJS += graph.o
 LIB_OBJS += grep.o
+LIB_OBJS += hash-lookup.o
 LIB_OBJS += hashmap.o
 LIB_OBJS += help.o
 LIB_OBJS += hex.o
@@ -995,7 +996,6 @@ LIB_OBJS += sequencer.o
 LIB_OBJS += serve.o
 LIB_OBJS += server-info.o
 LIB_OBJS += setup.o
-LIB_OBJS += sha1-lookup.o
 LIB_OBJS += shallow.o
 LIB_OBJS += sideband.o
 LIB_OBJS += sigchain.o
index d8c2c8f7a78bf99e5f6d202ee7996ab9952b417f..75ea0eb57ff18979702b0abd5da345f27948e530 100644 (file)
--- a/bisect.c
+++ b/bisect.c
@@ -6,7 +6,7 @@
 #include "refs.h"
 #include "list-objects.h"
 #include "quote.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "run-command.h"
 #include "log-tree.h"
 #include "bisect.h"
index 4939ceb2e54f7648dc25c76a38878301d4eb7045..3fe71a8c01012fd7ce7e97a65e4cb9cbd697c86d 100644 (file)
@@ -7,7 +7,7 @@
 #include "refs.h"
 #include "parse-options.h"
 #include "prio-queue.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "commit-slab.h"
 
 /*
index c672feee9160b55421c7f6e3cb5a2282a544dae6..e9124d4a4123b96a644a57816999afe76f24a804 100644 (file)
@@ -7,7 +7,7 @@
 #include "object.h"
 #include "refs.h"
 #include "revision.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "commit-graph.h"
 #include "object-store.h"
 #include "alloc.h"
index 0b7bace0224bedacf3feb064671103db1a2919ed..cb119ebdf2205606b14d0a3db938c1db5fba5e9d 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -14,7 +14,7 @@
 #include "mergesort.h"
 #include "commit-slab.h"
 #include "prio-queue.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "wt-status.h"
 #include "advice.h"
 #include "refs.h"
similarity index 90%
rename from sha1-lookup.c
rename to hash-lookup.c
index 45489edfe8ef2e93e514badf2057bbaa27d695ef..1191856a32e6f5dba93b444cae269fac50cbf15f 100644 (file)
@@ -1,9 +1,9 @@
 #include "cache.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 
-static uint32_t take2(const unsigned char *sha1)
+static uint32_t take2(const unsigned char *hash)
 {
-       return ((sha1[0] << 8) | sha1[1]);
+       return ((hash[0] << 8) | hash[1]);
 }
 
 /*
@@ -100,17 +100,17 @@ int hash_pos(const unsigned char *hash, void *table, size_t nr,
        return index_pos_to_insert_pos(lo);
 }
 
-int bsearch_hash(const unsigned char *sha1, const uint32_t *fanout_nbo,
+int bsearch_hash(const unsigned char *hash, const uint32_t *fanout_nbo,
                 const unsigned char *table, size_t stride, uint32_t *result)
 {
        uint32_t hi, lo;
 
-       hi = ntohl(fanout_nbo[*sha1]);
-       lo = ((*sha1 == 0x0) ? 0 : ntohl(fanout_nbo[*sha1 - 1]));
+       hi = ntohl(fanout_nbo[*hash]);
+       lo = ((*hash == 0x0) ? 0 : ntohl(fanout_nbo[*hash - 1]));
 
        while (lo < hi) {
                unsigned mi = lo + (hi - lo) / 2;
-               int cmp = hashcmp(table + mi * stride, sha1);
+               int cmp = hashcmp(table + mi * stride, hash);
 
                if (!cmp) {
                        if (result)
similarity index 78%
rename from sha1-lookup.h
rename to hash-lookup.h
index 79973d47853eea67df9ecbf31de358d4cbf4b676..5d476dec72c7b20357a6cb448bf1147472a1c152 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef SHA1_LOOKUP_H
-#define SHA1_LOOKUP_H
+#ifndef HASH_LOOKUP_H
+#define HASH_LOOKUP_H
 
 typedef const unsigned char *hash_access_fn(size_t index, void *table);
 
@@ -9,12 +9,12 @@ int hash_pos(const unsigned char *hash,
             hash_access_fn fn);
 
 /*
- * Searches for sha1 in table, using the given fanout table to determine the
+ * Searches for hash in table, using the given fanout table to determine the
  * interval to search, then using binary search. Returns 1 if found, 0 if not.
  *
  * Takes the following parameters:
  *
- *  - sha1: the hash to search for
+ *  - hash: the hash to search for
  *  - fanout_nbo: a 256-element array of NETWORK-order 32-bit integers; the
  *    integer at position i represents the number of elements in table whose
  *    first byte is less than or equal to i
@@ -23,10 +23,10 @@ int hash_pos(const unsigned char *hash,
  *    GIT_MAX_RAWSZ or greater)
  *  - result: if not NULL, this function stores the element index of the
  *    position found (if the search is successful) or the index of the least
- *    element that is greater than sha1 (if the search is not successful)
+ *    element that is greater than hash (if the search is not successful)
  *
  * This function does not verify the validity of the fanout table.
  */
-int bsearch_hash(const unsigned char *sha1, const uint32_t *fanout_nbo,
+int bsearch_hash(const unsigned char *hash, const uint32_t *fanout_nbo,
                 const unsigned char *table, size_t stride, uint32_t *result);
 #endif
diff --git a/midx.c b/midx.c
index 79c282b070d26d5ffac866feaaee244fea986d43..f9d9b832bbb26927bdac4d6a89f01dabbf766400 100644 (file)
--- a/midx.c
+++ b/midx.c
@@ -5,7 +5,7 @@
 #include "lockfile.h"
 #include "packfile.h"
 #include "object-store.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "midx.h"
 #include "progress.h"
 #include "trace2.h"
index 3508598d972fab886d9d3c1a1c3f313332aca3a8..5bcfde84718868ac6ae35cddfc102d4a13f0c502 100644 (file)
@@ -20,7 +20,7 @@
 #include "tree-walk.h"
 #include "refs.h"
 #include "pack-revindex.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "bulk-checkin.h"
 #include "repository.h"
 #include "replace-object.h"
index fb4c3dd79599a1aad13f70f63b00888023ce2008..889b311f22777deefb87d552c791b0538b6bcf0a 100644 (file)
@@ -1,6 +1,6 @@
 #include "cache.h"
 #include "oid-array.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 
 void oid_array_append(struct oid_array *array, const struct object_id *oid)
 {
index 27ece05ec7c9aa43a321ed1f17e04178a6d0e7c1..ae6d1475f9ee8f06575b2517f3eb2c39117e84f1 100644 (file)
@@ -9,7 +9,7 @@
 #include "pack-revindex.h"
 #include "pack.h"
 #include "pack-bitmap.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "pack-objects.h"
 #include "commit-reach.h"
 
index 86f5c8dbf6677195ffca0e03f3cf810e84c5f0df..62d92e0c7c9a5ec47b08066f5154870024b10db3 100644 (file)
@@ -7,7 +7,7 @@
 #include "packfile.h"
 #include "delta.h"
 #include "streaming.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "commit.h"
 #include "object.h"
 #include "tag.h"
index 21973e49332c36532438bb067c8821a0e377baf9..cf5e8045b71073873a5a36f844d1c1ceb283384b 100644 (file)
@@ -1,7 +1,7 @@
 #include "cache.h"
 #include "diff.h"
 #include "commit.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 #include "patch-ids.h"
 
 static int patch_id_defined(struct commit *commit)
index 9fc76eb756d873e3a0661e2aba1e67d27f9fbbd5..d6928c1b5c1a84980e403c805d2e5fcd072e40aa 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -10,7 +10,7 @@
 #include "attr.h"
 #include "pathspec.h"
 #include "object-store.h"
-#include "sha1-lookup.h"
+#include "hash-lookup.h"
 
 #define RESOLVED 0
 #define PUNTED 1