Skip to content

Commit 8b327f1

Browse files
committed
Merge branch 'ma/sha1-is-a-hash'
Retire more names with "sha1" in it. * ma/sha1-is-a-hash: hash-lookup: rename from sha1-lookup sha1-lookup: rename `sha1_pos()` as `hash_pos()` object-file.c: rename from sha1-file.c object-name.c: rename from sha1-name.c
2 parents 16a8055 + bc62692 commit 8b327f1

19 files changed

+58
-58
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ LIB_OBJS += gettext.o
901901
LIB_OBJS += gpg-interface.o
902902
LIB_OBJS += graph.o
903903
LIB_OBJS += grep.o
904+
LIB_OBJS += hash-lookup.o
904905
LIB_OBJS += hashmap.o
905906
LIB_OBJS += help.o
906907
LIB_OBJS += hex.o
@@ -937,6 +938,8 @@ LIB_OBJS += notes-cache.o
937938
LIB_OBJS += notes-merge.o
938939
LIB_OBJS += notes-utils.o
939940
LIB_OBJS += notes.o
941+
LIB_OBJS += object-file.o
942+
LIB_OBJS += object-name.o
940943
LIB_OBJS += object.o
941944
LIB_OBJS += oid-array.o
942945
LIB_OBJS += oidmap.o
@@ -993,9 +996,6 @@ LIB_OBJS += sequencer.o
993996
LIB_OBJS += serve.o
994997
LIB_OBJS += server-info.o
995998
LIB_OBJS += setup.o
996-
LIB_OBJS += sha1-file.o
997-
LIB_OBJS += sha1-lookup.o
998-
LIB_OBJS += sha1-name.o
999999
LIB_OBJS += shallow.o
10001000
LIB_OBJS += sideband.o
10011001
LIB_OBJS += sigchain.o

bisect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "refs.h"
77
#include "list-objects.h"
88
#include "quote.h"
9-
#include "sha1-lookup.h"
9+
#include "hash-lookup.h"
1010
#include "run-command.h"
1111
#include "log-tree.h"
1212
#include "bisect.h"

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1641,7 +1641,7 @@ static void read_idx_option(struct pack_idx_option *opts, const char *pack_name)
16411641
/*
16421642
* Get rid of the idx file as we do not need it anymore.
16431643
* NEEDSWORK: extract this bit from free_pack_by_name() in
1644-
* sha1-file.c, perhaps? It shouldn't matter very much as we
1644+
* object-file.c, perhaps? It shouldn't matter very much as we
16451645
* know we haven't installed this pack (hence we never have
16461646
* read anything from it).
16471647
*/

builtin/name-rev.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "refs.h"
88
#include "parse-options.h"
99
#include "prio-queue.h"
10-
#include "sha1-lookup.h"
10+
#include "hash-lookup.h"
1111
#include "commit-slab.h"
1212

1313
/*
@@ -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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include "object.h"
88
#include "refs.h"
99
#include "revision.h"
10-
#include "sha1-lookup.h"
10+
#include "hash-lookup.h"
1111
#include "commit-graph.h"
1212
#include "object-store.h"
1313
#include "alloc.h"
@@ -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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include "mergesort.h"
1515
#include "commit-slab.h"
1616
#include "prio-queue.h"
17-
#include "sha1-lookup.h"
17+
#include "hash-lookup.h"
1818
#include "wt-status.h"
1919
#include "advice.h"
2020
#include "refs.h"
@@ -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
}

sha1-lookup.c renamed to hash-lookup.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "cache.h"
2-
#include "sha1-lookup.h"
2+
#include "hash-lookup.h"
33

4-
static uint32_t take2(const unsigned char *sha1)
4+
static uint32_t take2(const unsigned char *hash)
55
{
6-
return ((sha1[0] << 8) | sha1[1]);
6+
return ((hash[0] << 8) | hash[1]);
77
}
88

99
/*
@@ -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
*/
@@ -100,17 +100,17 @@ int sha1_pos(const unsigned char *hash, void *table, size_t nr,
100100
return index_pos_to_insert_pos(lo);
101101
}
102102

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,
104104
const unsigned char *table, size_t stride, uint32_t *result)
105105
{
106106
uint32_t hi, lo;
107107

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]));
110110

111111
while (lo < hi) {
112112
unsigned mi = lo + (hi - lo) / 2;
113-
int cmp = hashcmp(table + mi * stride, sha1);
113+
int cmp = hashcmp(table + mi * stride, hash);
114114

115115
if (!cmp) {
116116
if (result)
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
#ifndef SHA1_LOOKUP_H
2-
#define SHA1_LOOKUP_H
1+
#ifndef HASH_LOOKUP_H
2+
#define HASH_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
/*
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
1313
* interval to search, then using binary search. Returns 1 if found, 0 if not.
1414
*
1515
* Takes the following parameters:
1616
*
17-
* - sha1: the hash to search for
17+
* - hash: the hash to search for
1818
* - fanout_nbo: a 256-element array of NETWORK-order 32-bit integers; the
1919
* integer at position i represents the number of elements in table whose
2020
* first byte is less than or equal to i
@@ -23,10 +23,10 @@ int sha1_pos(const unsigned char *sha1,
2323
* GIT_MAX_RAWSZ or greater)
2424
* - result: if not NULL, this function stores the element index of the
2525
* 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)
2727
*
2828
* This function does not verify the validity of the fanout table.
2929
*/
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,
3131
const unsigned char *table, size_t stride, uint32_t *result);
3232
#endif

list-objects-filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* in the traversal (until we mark it SEEN). This is a way to
2222
* let us silently de-dup calls to show() in the caller. This
2323
* is subtly different from the "revision.h:SHOWN" and the
24-
* "sha1-name.c:ONELINE_SEEN" bits. And also different from
24+
* "object-name.c:ONELINE_SEEN" bits. And also different from
2525
* the non-de-dup usage in pack-bitmap.c
2626
*/
2727
#define FILTER_SHOWN_BUT_REVISIT (1<<21)

midx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "lockfile.h"
66
#include "packfile.h"
77
#include "object-store.h"
8-
#include "sha1-lookup.h"
8+
#include "hash-lookup.h"
99
#include "midx.h"
1010
#include "progress.h"
1111
#include "trace2.h"

0 commit comments

Comments
 (0)