Skip to content

Commit 7a7d992

Browse files
Martin Ågrengitster
authored andcommitted
sha1-lookup: rename sha1_pos() as hash_pos()
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 <[email protected]> Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e5afd44 commit 7a7d992

File tree

8 files changed

+15
-15
lines changed

8 files changed

+15
-15
lines changed

builtin/name-rev.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static const char *get_exact_ref_match(const struct object *o)
408408
tip_table.sorted = 1;
409409
}
410410

411-
found = sha1_pos(o->oid.hash, tip_table.table, tip_table.nr,
411+
found = hash_pos(o->oid.hash, tip_table.table, tip_table.nr,
412412
nth_tip_table_ent);
413413
if (0 <= found)
414414
return tip_table.table[found].refname;

commit-graph.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1043,7 +1043,7 @@ static int write_graph_chunk_data(struct hashfile *f,
10431043
if (!parent)
10441044
edge_value = GRAPH_PARENT_NONE;
10451045
else {
1046-
edge_value = sha1_pos(parent->item->object.oid.hash,
1046+
edge_value = hash_pos(parent->item->object.oid.hash,
10471047
ctx->commits.list,
10481048
ctx->commits.nr,
10491049
commit_to_sha1);
@@ -1074,7 +1074,7 @@ static int write_graph_chunk_data(struct hashfile *f,
10741074
else if (parent->next)
10751075
edge_value = GRAPH_EXTRA_EDGES_NEEDED | num_extra_edges;
10761076
else {
1077-
edge_value = sha1_pos(parent->item->object.oid.hash,
1077+
edge_value = hash_pos(parent->item->object.oid.hash,
10781078
ctx->commits.list,
10791079
ctx->commits.nr,
10801080
commit_to_sha1);
@@ -1143,7 +1143,7 @@ static int write_graph_chunk_extra_edges(struct hashfile *f,
11431143

11441144
/* Since num_parents > 2, this initializer is safe. */
11451145
for (parent = (*list)->parents->next; parent; parent = parent->next) {
1146-
int edge_value = sha1_pos(parent->item->object.oid.hash,
1146+
int edge_value = hash_pos(parent->item->object.oid.hash,
11471147
ctx->commits.list,
11481148
ctx->commits.nr,
11491149
commit_to_sha1);

commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static const unsigned char *commit_graft_sha1_access(size_t index, void *table)
113113

114114
int commit_graft_pos(struct repository *r, const unsigned char *sha1)
115115
{
116-
return sha1_pos(sha1, r->parsed_objects->grafts,
116+
return hash_pos(sha1, r->parsed_objects->grafts,
117117
r->parsed_objects->grafts_nr,
118118
commit_graft_sha1_access);
119119
}

oid-array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static const unsigned char *sha1_access(size_t index, void *table)
3131
int oid_array_lookup(struct oid_array *array, const struct object_id *oid)
3232
{
3333
oid_array_sort(array);
34-
return sha1_pos(oid->hash, array->oid, array->nr, sha1_access);
34+
return hash_pos(oid->hash, array->oid, array->nr, sha1_access);
3535
}
3636

3737
void oid_array_clear(struct oid_array *array)

pack-bitmap-write.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ static void write_selected_commits_v1(struct hashfile *f,
482482
struct bitmapped_commit *stored = &writer.selected[i];
483483

484484
int commit_pos =
485-
sha1_pos(stored->commit->object.oid.hash, index, index_nr, sha1_access);
485+
hash_pos(stored->commit->object.oid.hash, index, index_nr, sha1_access);
486486

487487
if (commit_pos < 0)
488488
BUG("trying to write commit not in index");

rerere.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ static struct rerere_dir *find_rerere_dir(const char *hex)
147147

148148
if (get_sha1_hex(hex, hash))
149149
return NULL; /* BUG */
150-
pos = sha1_pos(hash, rerere_dir, rerere_dir_nr, rerere_dir_hash);
150+
pos = hash_pos(hash, rerere_dir, rerere_dir_nr, rerere_dir_hash);
151151
if (pos < 0) {
152152
rr_dir = xmalloc(sizeof(*rr_dir));
153153
hashcpy(rr_dir->hash, hash);

sha1-lookup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@ static uint32_t take2(const unsigned char *sha1)
4747
*/
4848
/*
4949
* The table should contain "nr" elements.
50-
* The sha1 of element i (between 0 and nr - 1) should be returned
50+
* The hash of element i (between 0 and nr - 1) should be returned
5151
* by "fn(i, table)".
5252
*/
53-
int sha1_pos(const unsigned char *hash, void *table, size_t nr,
54-
sha1_access_fn fn)
53+
int hash_pos(const unsigned char *hash, void *table, size_t nr,
54+
hash_access_fn fn)
5555
{
5656
size_t hi = nr;
5757
size_t lo = 0;
@@ -74,7 +74,7 @@ int sha1_pos(const unsigned char *hash, void *table, size_t nr,
7474
if (lov != hiv) {
7575
/*
7676
* At this point miv could be equal
77-
* to hiv (but sha1 could still be higher);
77+
* to hiv (but hash could still be higher);
7878
* the invariant of (mi < hi) should be
7979
* kept.
8080
*/

sha1-lookup.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef SHA1_LOOKUP_H
22
#define SHA1_LOOKUP_H
33

4-
typedef const unsigned char *sha1_access_fn(size_t index, void *table);
4+
typedef const unsigned char *hash_access_fn(size_t index, void *table);
55

6-
int sha1_pos(const unsigned char *sha1,
6+
int hash_pos(const unsigned char *hash,
77
void *table,
88
size_t nr,
9-
sha1_access_fn fn);
9+
hash_access_fn fn);
1010

1111
/*
1212
* Searches for sha1 in table, using the given fanout table to determine the

0 commit comments

Comments
 (0)