hash-lookup: rename from sha1-lookup

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>

Martin Ågren committed Dec 31, 2020 at 12:56 UTC bc626927575cea80b8bc5fd0dbb6c6439e34e606
14 files changed +25 -25
Makefile
+1 -1
@@ -901,6 +901,7 @@ LIB_OBJS += gettext.o
901 LIB_OBJS += gpg-interface.o
902 LIB_OBJS += graph.o
903 LIB_OBJS += grep.o
904 +LIB_OBJS += hash-lookup.o
905 LIB_OBJS += hashmap.o
906 LIB_OBJS += help.o
907 LIB_OBJS += hex.o
@@ -995,7 +996,6 @@ LIB_OBJS += sequencer.o
996 LIB_OBJS += serve.o
997 LIB_OBJS += server-info.o
998 LIB_OBJS += setup.o
998 -LIB_OBJS += sha1-lookup.o
999 LIB_OBJS += shallow.o
1000 LIB_OBJS += sideband.o
1001 LIB_OBJS += sigchain.o
bisect.c
+1 -1
@@ -6,7 +6,7 @@
6 #include "refs.h"
7 #include "list-objects.h"
8 #include "quote.h"
9 -#include "sha1-lookup.h"
9 +#include "hash-lookup.h"
10 #include "run-command.h"
11 #include "log-tree.h"
12 #include "bisect.h"
builtin/name-rev.c
+1 -1
@@ -7,7 +7,7 @@
7 #include "refs.h"
8 #include "parse-options.h"
9 #include "prio-queue.h"
10 -#include "sha1-lookup.h"
10 +#include "hash-lookup.h"
11 #include "commit-slab.h"
12
13 /*
commit-graph.c
+1 -1
@@ -7,7 +7,7 @@
7 #include "object.h"
8 #include "refs.h"
9 #include "revision.h"
10 -#include "sha1-lookup.h"
10 +#include "hash-lookup.h"
11 #include "commit-graph.h"
12 #include "object-store.h"
13 #include "alloc.h"
commit.c
+1 -1
@@ -14,7 +14,7 @@
14 #include "mergesort.h"
15 #include "commit-slab.h"
16 #include "prio-queue.h"
17 -#include "sha1-lookup.h"
17 +#include "hash-lookup.h"
18 #include "wt-status.h"
19 #include "advice.h"
20 #include "refs.h"
hash-lookup.c renamed
+7 -7
@@ -1,9 +1,9 @@
1 #include "cache.h"
2 -#include "sha1-lookup.h"
2 +#include "hash-lookup.h"
3
4 -static uint32_t take2(const unsigned char *sha1)
4 +static uint32_t take2(const unsigned char *hash)
5 {
6 - return ((sha1[0] << 8) | sha1[1]);
6 + return ((hash[0] << 8) | hash[1]);
7 }
8
9 /*
@@ -100,17 +100,17 @@ int hash_pos(const unsigned char *hash, void *table, size_t nr,
100 return index_pos_to_insert_pos(lo);
101 }
102
103 -int bsearch_hash(const unsigned char *sha1, const uint32_t *fanout_nbo,
103 +int bsearch_hash(const unsigned char *hash, const uint32_t *fanout_nbo,
104 const unsigned char *table, size_t stride, uint32_t *result)
105 {
106 uint32_t hi, lo;
107
108 - hi = ntohl(fanout_nbo[*sha1]);
109 - lo = ((*sha1 == 0x0) ? 0 : ntohl(fanout_nbo[*sha1 - 1]));
108 + hi = ntohl(fanout_nbo[*hash]);
109 + lo = ((*hash == 0x0) ? 0 : ntohl(fanout_nbo[*hash - 1]));
110
111 while (lo < hi) {
112 unsigned mi = lo + (hi - lo) / 2;
113 - int cmp = hashcmp(table + mi * stride, sha1);
113 + int cmp = hashcmp(table + mi * stride, hash);
114
115 if (!cmp) {
116 if (result)
hash-lookup.h renamed
+6 -6
@@ -1,5 +1,5 @@
1 -#ifndef SHA1_LOOKUP_H
2 -#define SHA1_LOOKUP_H
1 +#ifndef HASH_LOOKUP_H
2 +#define HASH_LOOKUP_H
3
4 typedef const unsigned char *hash_access_fn(size_t index, void *table);
5
@@ -9,12 +9,12 @@ int hash_pos(const unsigned char *hash,
9 hash_access_fn fn);
10
11 /*
12 - * Searches for sha1 in table, using the given fanout table to determine the
12 + * Searches for hash in table, using the given fanout table to determine the
13 * interval to search, then using binary search. Returns 1 if found, 0 if not.
14 *
15 * Takes the following parameters:
16 *
17 - * - sha1: the hash to search for
17 + * - hash: the hash to search for
18 * - fanout_nbo: a 256-element array of NETWORK-order 32-bit integers; the
19 * integer at position i represents the number of elements in table whose
20 * first byte is less than or equal to i
@@ -23,10 +23,10 @@ int hash_pos(const unsigned char *hash,
23 * GIT_MAX_RAWSZ or greater)
24 * - result: if not NULL, this function stores the element index of the
25 * position found (if the search is successful) or the index of the least
26 - * element that is greater than sha1 (if the search is not successful)
26 + * element that is greater than hash (if the search is not successful)
27 *
28 * This function does not verify the validity of the fanout table.
29 */
30 -int bsearch_hash(const unsigned char *sha1, const uint32_t *fanout_nbo,
30 +int bsearch_hash(const unsigned char *hash, const uint32_t *fanout_nbo,
31 const unsigned char *table, size_t stride, uint32_t *result);
32 #endif
midx.c
+1 -1
@@ -5,7 +5,7 @@
5 #include "lockfile.h"
6 #include "packfile.h"
7 #include "object-store.h"
8 -#include "sha1-lookup.h"
8 +#include "hash-lookup.h"
9 #include "midx.h"
10 #include "progress.h"
11 #include "trace2.h"
object-file.c
+1 -1
@@ -20,7 +20,7 @@
20 #include "tree-walk.h"
21 #include "refs.h"
22 #include "pack-revindex.h"
23 -#include "sha1-lookup.h"
23 +#include "hash-lookup.h"
24 #include "bulk-checkin.h"
25 #include "repository.h"
26 #include "replace-object.h"
oid-array.c
+1 -1
@@ -1,6 +1,6 @@
1 #include "cache.h"
2 #include "oid-array.h"
3 -#include "sha1-lookup.h"
3 +#include "hash-lookup.h"
4
5 void oid_array_append(struct oid_array *array, const struct object_id *oid)
6 {
pack-bitmap-write.c
+1 -1
@@ -9,7 +9,7 @@
9 #include "pack-revindex.h"
10 #include "pack.h"
11 #include "pack-bitmap.h"
12 -#include "sha1-lookup.h"
12 +#include "hash-lookup.h"
13 #include "pack-objects.h"
14 #include "commit-reach.h"
15
packfile.c
+1 -1
@@ -7,7 +7,7 @@
7 #include "packfile.h"
8 #include "delta.h"
9 #include "streaming.h"
10 -#include "sha1-lookup.h"
10 +#include "hash-lookup.h"
11 #include "commit.h"
12 #include "object.h"
13 #include "tag.h"
patch-ids.c
+1 -1
@@ -1,7 +1,7 @@
1 #include "cache.h"
2 #include "diff.h"
3 #include "commit.h"
4 -#include "sha1-lookup.h"
4 +#include "hash-lookup.h"
5 #include "patch-ids.h"
6
7 static int patch_id_defined(struct commit *commit)
rerere.c
+1 -1
@@ -10,7 +10,7 @@
10 #include "attr.h"
11 #include "pathspec.h"
12 #include "object-store.h"
13 -#include "sha1-lookup.h"
13 +#include "hash-lookup.h"
14
15 #define RESOLVED 0
16 #define PUNTED 1