]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sha1-lookup: rename `sha1_pos()` as `hash_pos()`
authorMartin Ågren <martin.agren@gmail.com>
Thu, 31 Dec 2020 11:56:22 +0000 (12:56 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 4 Jan 2021 21:01:55 +0000 (13:01 -0800)
Rename this function to reflect that we're not just able to handle SHA-1
these days. There are a few instances of "sha1" left in sha1-lookup.[ch]
after this, but those will be addressed in the next commit.

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>
builtin/name-rev.c
commit-graph.c
commit.c
oid-array.c
pack-bitmap-write.c
rerere.c
sha1-lookup.c
sha1-lookup.h

index 725dd04519133595dc212ce6c68e511b07c6b92a..4939ceb2e54f7648dc25c76a38878301d4eb7045 100644 (file)
@@ -408,7 +408,7 @@ static const char *get_exact_ref_match(const struct object *o)
                tip_table.sorted = 1;
        }
 
-       found = sha1_pos(o->oid.hash, tip_table.table, tip_table.nr,
+       found = hash_pos(o->oid.hash, tip_table.table, tip_table.nr,
                         nth_tip_table_ent);
        if (0 <= found)
                return tip_table.table[found].refname;
index 06f8dc1d8966f1ec59f58460a41df67b63180b24..c672feee9160b55421c7f6e3cb5a2282a544dae6 100644 (file)
@@ -1043,7 +1043,7 @@ static int write_graph_chunk_data(struct hashfile *f,
                if (!parent)
                        edge_value = GRAPH_PARENT_NONE;
                else {
-                       edge_value = sha1_pos(parent->item->object.oid.hash,
+                       edge_value = hash_pos(parent->item->object.oid.hash,
                                              ctx->commits.list,
                                              ctx->commits.nr,
                                              commit_to_sha1);
@@ -1074,7 +1074,7 @@ static int write_graph_chunk_data(struct hashfile *f,
                else if (parent->next)
                        edge_value = GRAPH_EXTRA_EDGES_NEEDED | num_extra_edges;
                else {
-                       edge_value = sha1_pos(parent->item->object.oid.hash,
+                       edge_value = hash_pos(parent->item->object.oid.hash,
                                              ctx->commits.list,
                                              ctx->commits.nr,
                                              commit_to_sha1);
@@ -1143,7 +1143,7 @@ static int write_graph_chunk_extra_edges(struct hashfile *f,
 
                /* Since num_parents > 2, this initializer is safe. */
                for (parent = (*list)->parents->next; parent; parent = parent->next) {
-                       int edge_value = sha1_pos(parent->item->object.oid.hash,
+                       int edge_value = hash_pos(parent->item->object.oid.hash,
                                                  ctx->commits.list,
                                                  ctx->commits.nr,
                                                  commit_to_sha1);
index fe1fa3dc41fe787883752671e5954b75616fe9ac..0b7bace0224bedacf3feb064671103db1a2919ed 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -113,7 +113,7 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)
 
 int commit_graft_pos(struct repository *r, const unsigned char *sha1)
 {
-       return sha1_pos(sha1, r->parsed_objects->grafts,
+       return hash_pos(sha1, r->parsed_objects->grafts,
                        r->parsed_objects->grafts_nr,
                        commit_graft_sha1_access);
 }
index 8e1bcedc0cb56a11a4cb6d27d33b33ed39b02bfe..fb4c3dd79599a1aad13f70f63b00888023ce2008 100644 (file)
@@ -31,7 +31,7 @@ static const unsigned char *sha1_access(size_t index, void *table)
 int oid_array_lookup(struct oid_array *array, const struct object_id *oid)
 {
        oid_array_sort(array);
-       return sha1_pos(oid->hash, array->oid, array->nr, sha1_access);
+       return hash_pos(oid->hash, array->oid, array->nr, sha1_access);
 }
 
 void oid_array_clear(struct oid_array *array)
index 5e998bdaa7998817a4dc73e5d6da711e0615b992..27ece05ec7c9aa43a321ed1f17e04178a6d0e7c1 100644 (file)
@@ -482,7 +482,7 @@ static void write_selected_commits_v1(struct hashfile *f,
                struct bitmapped_commit *stored = &writer.selected[i];
 
                int commit_pos =
-                       sha1_pos(stored->commit->object.oid.hash, index, index_nr, sha1_access);
+                       hash_pos(stored->commit->object.oid.hash, index, index_nr, sha1_access);
 
                if (commit_pos < 0)
                        BUG("trying to write commit not in index");
index 9281131a9f10cdf1f83c54b42e4fd7034ded16db..9fc76eb756d873e3a0661e2aba1e67d27f9fbbd5 100644 (file)
--- a/rerere.c
+++ b/rerere.c
@@ -147,7 +147,7 @@ static struct rerere_dir *find_rerere_dir(const char *hex)
 
        if (get_sha1_hex(hex, hash))
                return NULL; /* BUG */
-       pos = sha1_pos(hash, rerere_dir, rerere_dir_nr, rerere_dir_hash);
+       pos = hash_pos(hash, rerere_dir, rerere_dir_nr, rerere_dir_hash);
        if (pos < 0) {
                rr_dir = xmalloc(sizeof(*rr_dir));
                hashcpy(rr_dir->hash, hash);
index 29185844ecd48d3d4ac7f838e97f3c02d42125f9..45489edfe8ef2e93e514badf2057bbaa27d695ef 100644 (file)
@@ -47,11 +47,11 @@ static uint32_t take2(const unsigned char *sha1)
  */
 /*
  * The table should contain "nr" elements.
- * The sha1 of element i (between 0 and nr - 1) should be returned
+ * The hash 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,
-            sha1_access_fn fn)
+int hash_pos(const unsigned char *hash, void *table, size_t nr,
+            hash_access_fn fn)
 {
        size_t hi = nr;
        size_t lo = 0;
@@ -74,7 +74,7 @@ int sha1_pos(const unsigned char *hash, void *table, size_t nr,
                        if (lov != hiv) {
                                /*
                                 * At this point miv could be equal
-                                * to hiv (but sha1 could still be higher);
+                                * to hiv (but hash could still be higher);
                                 * the invariant of (mi < hi) should be
                                 * kept.
                                 */
index 5afcd011c6be3c7b9add226b098860b88c77c2fd..79973d47853eea67df9ecbf31de358d4cbf4b676 100644 (file)
@@ -1,12 +1,12 @@
 #ifndef SHA1_LOOKUP_H
 #define SHA1_LOOKUP_H
 
-typedef const unsigned char *sha1_access_fn(size_t index, void *table);
+typedef const unsigned char *hash_access_fn(size_t index, void *table);
 
-int sha1_pos(const unsigned char *sha1,
+int hash_pos(const unsigned char *hash,
             void *table,
             size_t nr,
-            sha1_access_fn fn);
+            hash_access_fn fn);
 
 /*
  * Searches for sha1 in table, using the given fanout table to determine the