git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/4] rename "sha1-foo" files
@ 2020-12-29 23:52 Martin Ågren
  2020-12-29 23:52 ` [PATCH 1/4] object-name.c: rename from sha1-name.c Martin Ågren
                   ` (6 more replies)
  0 siblings, 7 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-29 23:52 UTC (permalink / raw)
  To: git; +Cc: brian m. carlson

We have some source files with filenames such as sha1-lookup.c and
sha1-name.c containing a few variable names, comments and the like
referencing "sha1". But they are able to handle SHA-256 as well. Here's
my attempt at removing "sha1" from the contents and names of these
files.

Martin Ågren (4):
  object-name.c: rename from sha1-name.c
  object-file.c: rename from sha1-file.c
  sha1-lookup: rename `sha1_pos()` as `hash_pos()`
  hash-lookup: rename from sha1-lookup

 t/oid-info/README              |  2 +-
 sha1-lookup.h => hash-lookup.h | 14 +++++++-------
 bisect.c                       |  2 +-
 builtin/index-pack.c           |  2 +-
 builtin/name-rev.c             |  4 ++--
 commit-graph.c                 |  8 ++++----
 commit.c                       |  4 ++--
 sha1-lookup.c => hash-lookup.c | 22 +++++++++++-----------
 list-objects-filter.c          |  2 +-
 midx.c                         |  2 +-
 sha1-file.c => object-file.c   |  4 ++--
 sha1-name.c => object-name.c   | 14 +++++++-------
 oid-array.c                    |  4 ++--
 pack-bitmap-write.c            |  4 ++--
 packfile.c                     |  2 +-
 patch-ids.c                    |  2 +-
 rerere.c                       |  4 ++--
 Makefile                       |  6 +++---
 18 files changed, 51 insertions(+), 51 deletions(-)
 rename sha1-lookup.h => hash-lookup.h (72%)
 rename sha1-lookup.c => hash-lookup.c (84%)
 rename sha1-file.c => object-file.c (99%)
 rename sha1-name.c => object-name.c (99%)

-- 
2.30.0


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH 1/4] object-name.c: rename from sha1-name.c
  2020-12-29 23:52 [PATCH 0/4] rename "sha1-foo" files Martin Ågren
@ 2020-12-29 23:52 ` Martin Ågren
  2020-12-30  1:19   ` Derrick Stolee
  2020-12-29 23:52 ` [PATCH 2/4] object-file.c: rename from sha1-file.c Martin Ågren
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Martin Ågren @ 2020-12-29 23:52 UTC (permalink / raw)
  To: git; +Cc: brian m. carlson

Generalize the last remnants of "sha" and "sha1" in this file and rename
it to reflect that we're not just able to handle SHA-1 these days.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 list-objects-filter.c        |  2 +-
 sha1-name.c => object-name.c | 14 +++++++-------
 Makefile                     |  2 +-
 3 files changed, 9 insertions(+), 9 deletions(-)
 rename sha1-name.c => object-name.c (99%)

diff --git a/list-objects-filter.c b/list-objects-filter.c
index 0a3ef3cab3..4ec0041cfb 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -21,7 +21,7 @@
  * in the traversal (until we mark it SEEN).  This is a way to
  * let us silently de-dup calls to show() in the caller.  This
  * is subtly different from the "revision.h:SHOWN" and the
- * "sha1-name.c:ONELINE_SEEN" bits.  And also different from
+ * "object-name.c:ONELINE_SEEN" bits.  And also different from
  * the non-de-dup usage in pack-bitmap.c
  */
 #define FILTER_SHOWN_BUT_REVISIT (1<<21)
diff --git a/sha1-name.c b/object-name.c
similarity index 99%
rename from sha1-name.c
rename to object-name.c
index 0b23b86ceb..7e58a58777 100644
--- a/sha1-name.c
+++ b/object-name.c
@@ -85,7 +85,7 @@ static void update_candidates(struct disambiguate_state *ds, const struct object
 	/* otherwise, current can be discarded and candidate is still good */
 }
 
-static int match_sha(unsigned, const unsigned char *, const unsigned char *);
+static int match_hash(unsigned, const unsigned char *, const unsigned char *);
 
 static void find_short_object_filename(struct disambiguate_state *ds)
 {
@@ -102,7 +102,7 @@ static void find_short_object_filename(struct disambiguate_state *ds)
 		while (!ds->ambiguous && pos < loose_objects->nr) {
 			const struct object_id *oid;
 			oid = loose_objects->oid + pos;
-			if (!match_sha(ds->len, ds->bin_pfx.hash, oid->hash))
+			if (!match_hash(ds->len, ds->bin_pfx.hash, oid->hash))
 				break;
 			update_candidates(ds, oid);
 			pos++;
@@ -110,7 +110,7 @@ static void find_short_object_filename(struct disambiguate_state *ds)
 	}
 }
 
-static int match_sha(unsigned len, const unsigned char *a, const unsigned char *b)
+static int match_hash(unsigned len, const unsigned char *a, const unsigned char *b)
 {
 	do {
 		if (*a != *b)
@@ -145,7 +145,7 @@ static void unique_in_midx(struct multi_pack_index *m,
 	for (i = first; i < num && !ds->ambiguous; i++) {
 		struct object_id oid;
 		current = nth_midxed_object_oid(&oid, m, i);
-		if (!match_sha(ds->len, ds->bin_pfx.hash, current->hash))
+		if (!match_hash(ds->len, ds->bin_pfx.hash, current->hash))
 			break;
 		update_candidates(ds, current);
 	}
@@ -173,7 +173,7 @@ static void unique_in_pack(struct packed_git *p,
 	for (i = first; i < num && !ds->ambiguous; i++) {
 		struct object_id oid;
 		nth_packed_object_id(&oid, p, i);
-		if (!match_sha(ds->len, ds->bin_pfx.hash, oid.hash))
+		if (!match_hash(ds->len, ds->bin_pfx.hash, oid.hash))
 			break;
 		update_candidates(ds, &oid);
 	}
@@ -1811,7 +1811,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
 	if (!ret)
 		return ret;
 	/*
-	 * sha1:path --> object name of path in ent sha1
+	 * tree:path --> object name of path in tree
 	 * :path -> object name of absolute path in index
 	 * :./path -> object name of path relative to cwd in index
 	 * :[0-3]:path -> object name of path in index at stage
@@ -1949,6 +1949,6 @@ enum get_oid_result get_oid_with_context(struct repository *repo,
 					 struct object_context *oc)
 {
 	if (flags & GET_OID_FOLLOW_SYMLINKS && flags & GET_OID_ONLY_TO_DIE)
-		BUG("incompatible flags for get_sha1_with_context");
+		BUG("incompatible flags for get_oid_with_context");
 	return get_oid_with_context_1(repo, str, flags, NULL, oid, oc);
 }
diff --git a/Makefile b/Makefile
index 7b64106930..8bb1163f70 100644
--- a/Makefile
+++ b/Makefile
@@ -937,6 +937,7 @@ LIB_OBJS += notes-cache.o
 LIB_OBJS += notes-merge.o
 LIB_OBJS += notes-utils.o
 LIB_OBJS += notes.o
+LIB_OBJS += object-name.o
 LIB_OBJS += object.o
 LIB_OBJS += oid-array.o
 LIB_OBJS += oidmap.o
@@ -995,7 +996,6 @@ LIB_OBJS += server-info.o
 LIB_OBJS += setup.o
 LIB_OBJS += sha1-file.o
 LIB_OBJS += sha1-lookup.o
-LIB_OBJS += sha1-name.o
 LIB_OBJS += shallow.o
 LIB_OBJS += sideband.o
 LIB_OBJS += sigchain.o
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 2/4] object-file.c: rename from sha1-file.c
  2020-12-29 23:52 [PATCH 0/4] rename "sha1-foo" files Martin Ågren
  2020-12-29 23:52 ` [PATCH 1/4] object-name.c: rename from sha1-name.c Martin Ågren
@ 2020-12-29 23:52 ` Martin Ågren
  2020-12-29 23:52 ` [PATCH 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()` Martin Ågren
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-29 23:52 UTC (permalink / raw)
  To: git; +Cc: brian m. carlson

Drop the last remnant of "sha1" in this file and rename it to reflect
that we're not just able to handle SHA-1 these days.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 t/oid-info/README            | 2 +-
 builtin/index-pack.c         | 2 +-
 sha1-file.c => object-file.c | 2 +-
 Makefile                     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
 rename sha1-file.c => object-file.c (99%)

diff --git a/t/oid-info/README b/t/oid-info/README
index 27f843fc00..ca56a74b1e 100644
--- a/t/oid-info/README
+++ b/t/oid-info/README
@@ -5,7 +5,7 @@ starting with `#` are ignored.  The key and value are separated by whitespace
 (specifically, those whitespace in the default `$IFS`).  The key consists only
 of shell identifier characters, and the value consists of a hash algorithm,
 colon, and value.  The hash algorithm also consists only of shell identifier
-characters; it should match the value in sha1-file.c.
+characters; it should match the value in object-file.c.
 
 For example, the following lines map the key "rawsz" to "20" if SHA-1 is in use
 and to "32" if SHA-256 is in use:
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 4b8d86e0ad..557bd2f348 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1641,7 +1641,7 @@ static void read_idx_option(struct pack_idx_option *opts, const char *pack_name)
 	/*
 	 * Get rid of the idx file as we do not need it anymore.
 	 * NEEDSWORK: extract this bit from free_pack_by_name() in
-	 * sha1-file.c, perhaps?  It shouldn't matter very much as we
+	 * object-file.c, perhaps?  It shouldn't matter very much as we
 	 * know we haven't installed this pack (hence we never have
 	 * read anything from it).
 	 */
diff --git a/sha1-file.c b/object-file.c
similarity index 99%
rename from sha1-file.c
rename to object-file.c
index c3c49d2fa5..b0c47b02bd 100644
--- a/sha1-file.c
+++ b/object-file.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  *
- * This handles basic git sha1 object files - packing, unpacking,
+ * This handles basic git object files - packing, unpacking,
  * creation etc.
  */
 #include "cache.h"
diff --git a/Makefile b/Makefile
index 8bb1163f70..224a1c6940 100644
--- a/Makefile
+++ b/Makefile
@@ -937,6 +937,7 @@ LIB_OBJS += notes-cache.o
 LIB_OBJS += notes-merge.o
 LIB_OBJS += notes-utils.o
 LIB_OBJS += notes.o
+LIB_OBJS += object-file.o
 LIB_OBJS += object-name.o
 LIB_OBJS += object.o
 LIB_OBJS += oid-array.o
@@ -994,7 +995,6 @@ LIB_OBJS += sequencer.o
 LIB_OBJS += serve.o
 LIB_OBJS += server-info.o
 LIB_OBJS += setup.o
-LIB_OBJS += sha1-file.o
 LIB_OBJS += sha1-lookup.o
 LIB_OBJS += shallow.o
 LIB_OBJS += sideband.o
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()`
  2020-12-29 23:52 [PATCH 0/4] rename "sha1-foo" files Martin Ågren
  2020-12-29 23:52 ` [PATCH 1/4] object-name.c: rename from sha1-name.c Martin Ågren
  2020-12-29 23:52 ` [PATCH 2/4] object-file.c: rename from sha1-file.c Martin Ågren
@ 2020-12-29 23:52 ` Martin Ågren
  2020-12-30  1:21   ` Derrick Stolee
  2020-12-29 23:53 ` [PATCH 4/4] hash-lookup: rename from sha1-lookup Martin Ågren
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 19+ messages in thread
From: Martin Ågren @ 2020-12-29 23:52 UTC (permalink / raw)
  To: git; +Cc: brian m. carlson

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>
---
 sha1-lookup.h       | 6 +++---
 builtin/name-rev.c  | 2 +-
 commit-graph.c      | 6 +++---
 commit.c            | 2 +-
 oid-array.c         | 2 +-
 pack-bitmap-write.c | 2 +-
 rerere.c            | 2 +-
 sha1-lookup.c       | 8 ++++----
 8 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/sha1-lookup.h b/sha1-lookup.h
index 5afcd011c6..79973d4785 100644
--- a/sha1-lookup.h
+++ b/sha1-lookup.h
@@ -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
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 725dd04519..4939ceb2e5 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -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;
diff --git a/commit-graph.c b/commit-graph.c
index 06f8dc1d89..c672feee91 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -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);
diff --git a/commit.c b/commit.c
index fe1fa3dc41..0b7bace022 100644
--- 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);
 }
diff --git a/oid-array.c b/oid-array.c
index 8e1bcedc0c..fb4c3dd795 100644
--- a/oid-array.c
+++ b/oid-array.c
@@ -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)
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 5e998bdaa7..27ece05ec7 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -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");
diff --git a/rerere.c b/rerere.c
index 9281131a9f..9fc76eb756 100644
--- 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);
diff --git a/sha1-lookup.c b/sha1-lookup.c
index 29185844ec..45489edfe8 100644
--- a/sha1-lookup.c
+++ b/sha1-lookup.c
@@ -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.
 				 */
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH 4/4] hash-lookup: rename from sha1-lookup
  2020-12-29 23:52 [PATCH 0/4] rename "sha1-foo" files Martin Ågren
                   ` (2 preceding siblings ...)
  2020-12-29 23:52 ` [PATCH 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()` Martin Ågren
@ 2020-12-29 23:53 ` Martin Ågren
  2020-12-30  1:29 ` [PATCH 0/4] rename "sha1-foo" files Derrick Stolee
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-29 23:53 UTC (permalink / raw)
  To: git; +Cc: brian m. carlson

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>
---
 sha1-lookup.h => hash-lookup.h |  8 ++++----
 bisect.c                       |  2 +-
 builtin/name-rev.c             |  2 +-
 commit-graph.c                 |  2 +-
 commit.c                       |  2 +-
 sha1-lookup.c => hash-lookup.c | 14 +++++++-------
 midx.c                         |  2 +-
 object-file.c                  |  2 +-
 oid-array.c                    |  2 +-
 pack-bitmap-write.c            |  2 +-
 packfile.c                     |  2 +-
 patch-ids.c                    |  2 +-
 rerere.c                       |  2 +-
 Makefile                       |  2 +-
 14 files changed, 23 insertions(+), 23 deletions(-)
 rename sha1-lookup.h => hash-lookup.h (82%)
 rename sha1-lookup.c => hash-lookup.c (90%)

diff --git a/sha1-lookup.h b/hash-lookup.h
similarity index 82%
rename from sha1-lookup.h
rename to hash-lookup.h
index 79973d4785..005795f4a3 100644
--- a/sha1-lookup.h
+++ b/hash-lookup.h
@@ -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/bisect.c b/bisect.c
index d8c2c8f7a7..75ea0eb57f 100644
--- 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"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 4939ceb2e5..3fe71a8c01 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -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"
 
 /*
diff --git a/commit-graph.c b/commit-graph.c
index c672feee91..e9124d4a41 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -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"
diff --git a/commit.c b/commit.c
index 0b7bace022..cb119ebdf2 100644
--- 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"
diff --git a/sha1-lookup.c b/hash-lookup.c
similarity index 90%
rename from sha1-lookup.c
rename to hash-lookup.c
index 45489edfe8..1191856a32 100644
--- a/sha1-lookup.c
+++ b/hash-lookup.c
@@ -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)
diff --git a/midx.c b/midx.c
index 79c282b070..f9d9b832bb 100644
--- 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"
diff --git a/object-file.c b/object-file.c
index b0c47b02bd..0f9b81c91a 100644
--- a/object-file.c
+++ b/object-file.c
@@ -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"
diff --git a/oid-array.c b/oid-array.c
index fb4c3dd795..889b311f22 100644
--- a/oid-array.c
+++ b/oid-array.c
@@ -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)
 {
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 27ece05ec7..ae6d1475f9 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -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"
 
diff --git a/packfile.c b/packfile.c
index 86f5c8dbf6..62d92e0c7c 100644
--- a/packfile.c
+++ b/packfile.c
@@ -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"
diff --git a/patch-ids.c b/patch-ids.c
index 21973e4933..cf5e8045b7 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -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)
diff --git a/rerere.c b/rerere.c
index 9fc76eb756..d6928c1b5c 100644
--- 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
diff --git a/Makefile b/Makefile
index 224a1c6940..7a141facc7 100644
--- 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
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH 1/4] object-name.c: rename from sha1-name.c
  2020-12-29 23:52 ` [PATCH 1/4] object-name.c: rename from sha1-name.c Martin Ågren
@ 2020-12-30  1:19   ` Derrick Stolee
  0 siblings, 0 replies; 19+ messages in thread
From: Derrick Stolee @ 2020-12-30  1:19 UTC (permalink / raw)
  To: Martin Ågren, git; +Cc: brian m. carlson

On 12/29/2020 6:52 PM, Martin Ågren wrote:
> Generalize the last remnants of "sha" and "sha1" in this file and rename
> it to reflect that we're not just able to handle SHA-1 these days.
> 
> Signed-off-by: Martin Ågren <martin.agren@gmail.com>
> ---
>  list-objects-filter.c        |  2 +-
>  sha1-name.c => object-name.c | 14 +++++++-------
>  Makefile                     |  2 +-
>  3 files changed, 9 insertions(+), 9 deletions(-)
>  rename sha1-name.c => object-name.c (99%)

I was tempted to recommend making the content changes to
sha1-name.c in a preperatory patch then doing a patch that
preforms an exact rename (along with edits to Makefile and
list-objects-filter.c).

However, I talked myself out of it while writing this
response. Having an exact rename won't materially change
how "git log --follow" or "git blame" behave.
 
Thanks,
-Stolee


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()`
  2020-12-29 23:52 ` [PATCH 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()` Martin Ågren
@ 2020-12-30  1:21   ` Derrick Stolee
  0 siblings, 0 replies; 19+ messages in thread
From: Derrick Stolee @ 2020-12-30  1:21 UTC (permalink / raw)
  To: Martin Ågren, git; +Cc: brian m. carlson

On 12/29/2020 6:52 PM, Martin Ågren wrote:
> 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.
...
> @@ -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);

Thanks for catching this comment, too!

-Stolee


^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] rename "sha1-foo" files
  2020-12-29 23:52 [PATCH 0/4] rename "sha1-foo" files Martin Ågren
                   ` (3 preceding siblings ...)
  2020-12-29 23:53 ` [PATCH 4/4] hash-lookup: rename from sha1-lookup Martin Ågren
@ 2020-12-30  1:29 ` Derrick Stolee
  2020-12-30  8:01   ` Martin Ågren
  2020-12-30  4:22 ` brian m. carlson
  2020-12-31 11:56 ` [PATCH v2 " Martin Ågren
  6 siblings, 1 reply; 19+ messages in thread
From: Derrick Stolee @ 2020-12-30  1:29 UTC (permalink / raw)
  To: Martin Ågren, git; +Cc: brian m. carlson

On 12/29/2020 6:52 PM, Martin Ågren wrote:
> We have some source files with filenames such as sha1-lookup.c and
> sha1-name.c containing a few variable names, comments and the like
> referencing "sha1". But they are able to handle SHA-256 as well. Here's
> my attempt at removing "sha1" from the contents and names of these
> files.

I think this is a good effort. Timing is good after the v2.30.0
release. As long as this doesn't conflict drastically with things in
flight, I think this change should "jump the line" and merge with
priority to avoid future conflicts.

It _has_ been bothering me that it was still sha1-file.c.

Oh, and I remembered the one semi-legitimate case to try for exact
renames whenever possible: "git log --follow" will download fewer
blobs in a blobless partial clone (--filter=blob:none). Of course,
this only works if the rule is always followed and is not really a
justification for doubling the number of your patches.

It does make me think that it is worth checking if "git log --follow"
short-circuits the full rename detection if the path it cares about
was found to be an exact rename (so doing a full content-rename check
on the other adds and deletes is worthless). Making a note [1] to
investigate.

[1] https://github.com/gitgitgadget/git/issues/827

Thanks,
-Stolee

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] rename "sha1-foo" files
  2020-12-29 23:52 [PATCH 0/4] rename "sha1-foo" files Martin Ågren
                   ` (4 preceding siblings ...)
  2020-12-30  1:29 ` [PATCH 0/4] rename "sha1-foo" files Derrick Stolee
@ 2020-12-30  4:22 ` brian m. carlson
  2020-12-30  8:04   ` Martin Ågren
  2020-12-31 11:56 ` [PATCH v2 " Martin Ågren
  6 siblings, 1 reply; 19+ messages in thread
From: brian m. carlson @ 2020-12-30  4:22 UTC (permalink / raw)
  To: Martin Ågren; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 675 bytes --]

On 2020-12-29 at 23:52:56, Martin Ågren wrote:
> We have some source files with filenames such as sha1-lookup.c and
> sha1-name.c containing a few variable names, comments and the like
> referencing "sha1". But they are able to handle SHA-256 as well. Here's
> my attempt at removing "sha1" from the contents and names of these
> files.

I agree that this series looks pretty good, and thanks for sending it.
This series ended up being a lot smaller than I expected given the work
on the transition, which is a nice surprise and also means it's less
likely to conflict with other topics in flight.
-- 
brian m. carlson (he/him or they/them)
Houston, Texas, US

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 263 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] rename "sha1-foo" files
  2020-12-30  1:29 ` [PATCH 0/4] rename "sha1-foo" files Derrick Stolee
@ 2020-12-30  8:01   ` Martin Ågren
  2020-12-30 13:35     ` Derrick Stolee
  0 siblings, 1 reply; 19+ messages in thread
From: Martin Ågren @ 2020-12-30  8:01 UTC (permalink / raw)
  To: Derrick Stolee; +Cc: Git Mailing List, brian m. carlson

On Wed, 30 Dec 2020 at 02:29, Derrick Stolee <stolee@gmail.com> wrote:
>
> On 12/29/2020 6:52 PM, Martin Ågren wrote:
> > We have some source files with filenames such as sha1-lookup.c and
> > sha1-name.c containing a few variable names, comments and the like
> > referencing "sha1". But they are able to handle SHA-256 as well. Here's
> > my attempt at removing "sha1" from the contents and names of these
> > files.
>
> I think this is a good effort. Timing is good after the v2.30.0
> release. As long as this doesn't conflict drastically with things in
> flight, I think this change should "jump the line" and merge with
> priority to avoid future conflicts.

I built this on v2.30.0 and FWIW, it merges cleanly to seen. It could of
course be that there are topics on the mailing list that Junio didn't
pick up during the rc period so that there are conflicts just waiting to
happen.

> Oh, and I remembered the one semi-legitimate case to try for exact
> renames whenever possible: "git log --follow" will download fewer
> blobs in a blobless partial clone (--filter=blob:none). Of course,
> this only works if the rule is always followed and is not really a
> justification for doubling the number of your patches.

Ok, I see. Well, if you and/or others feel we should aim for a 100%
rename, I don't mind splitting the patches. My gut reaction is along
your "only works if the rule is always followed", plus I wonder if there
are actually Git developers using a blobless partial clone of git.git
[other than for testing blobless partial clones].


Martin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] rename "sha1-foo" files
  2020-12-30  4:22 ` brian m. carlson
@ 2020-12-30  8:04   ` Martin Ågren
  0 siblings, 0 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-30  8:04 UTC (permalink / raw)
  To: brian m. carlson, Martin Ågren, Git Mailing List

On Wed, 30 Dec 2020 at 05:22, brian m. carlson
<sandals@crustytoothpaste.net> wrote:
>
> On 2020-12-29 at 23:52:56, Martin Ågren wrote:
> > We have some source files with filenames such as sha1-lookup.c and
> > sha1-name.c containing a few variable names, comments and the like
> > referencing "sha1". But they are able to handle SHA-256 as well. Here's
> > my attempt at removing "sha1" from the contents and names of these
> > files.
>
> I agree that this series looks pretty good, and thanks for sending it.
> This series ended up being a lot smaller than I expected given the work
> on the transition, which is a nice surprise and also means it's less
> likely to conflict with other topics in flight.

It's a lot smaller than I expected, too -- I looked into one file and
figured it would be littered with "sha" instances, but was pleasantly
surprised so I continued. Certainly, the only reason this series is
smaller than expected is because of all the work that has already been
put into the transition. Thank you!


Martin

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH 0/4] rename "sha1-foo" files
  2020-12-30  8:01   ` Martin Ågren
@ 2020-12-30 13:35     ` Derrick Stolee
  0 siblings, 0 replies; 19+ messages in thread
From: Derrick Stolee @ 2020-12-30 13:35 UTC (permalink / raw)
  To: Martin Ågren; +Cc: Git Mailing List, brian m. carlson

On 12/30/2020 3:01 AM, Martin Ågren wrote:
> On Wed, 30 Dec 2020 at 02:29, Derrick Stolee <stolee@gmail.com> wrote:
>> Oh, and I remembered the one semi-legitimate case to try for exact
>> renames whenever possible: "git log --follow" will download fewer
>> blobs in a blobless partial clone (--filter=blob:none). Of course,
>> this only works if the rule is always followed and is not really a
>> justification for doubling the number of your patches.
> 
> Ok, I see. Well, if you and/or others feel we should aim for a 100%
> rename, I don't mind splitting the patches. My gut reaction is along
> your "only works if the rule is always followed", plus I wonder if there
> are actually Git developers using a blobless partial clone of git.git
> [other than for testing blobless partial clones].

The upside is so small, it is not worth re-rolling your series. I was
just thinking out loud to justify my first gut reaction. Even in
blobless clones, this is not a huge cost (as long as we didn't also
add or remove enormous blobs). This behavior of "filling in the gaps"
is expected we use the repository.

Thanks,
-Stolee

^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 0/4] rename "sha1-foo" files
  2020-12-29 23:52 [PATCH 0/4] rename "sha1-foo" files Martin Ågren
                   ` (5 preceding siblings ...)
  2020-12-30  4:22 ` brian m. carlson
@ 2020-12-31 11:56 ` Martin Ågren
  2020-12-31 11:56   ` [PATCH v2 1/4] object-name.c: rename from sha1-name.c Martin Ågren
                     ` (4 more replies)
  6 siblings, 5 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-31 11:56 UTC (permalink / raw)
  To: git; +Cc: brian m . carlson, Derrick Stolee

Thanks to Derrick and brian for commenting on v1 [1] of my series for
renaming sha1-foo files and generalizing "sha", "sha1" and so on in
them. I realized I hadn't renamed the header guard in hash-lookup.h as I
renamed the file. That made me realize that I had failed to look for
"SHA-1" (capital letters). So this v2 is a bit bigger than v1, but not
by too much, I think. The range-diff is below.

[1] https://lore.kernel.org/git/cover.1609282997.git.martin.agren@gmail.com/

Martin Ågren (4):
  object-name.c: rename from sha1-name.c
  object-file.c: rename from sha1-file.c
  sha1-lookup: rename `sha1_pos()` as `hash_pos()`
  hash-lookup: rename from sha1-lookup

 t/oid-info/README                   |  2 +-
 t/t1512-rev-parse-disambiguation.sh |  2 +-
 sha1-lookup.h => hash-lookup.h      | 18 +++++++++---------
 bisect.c                            |  2 +-
 builtin/index-pack.c                |  2 +-
 builtin/name-rev.c                  |  4 ++--
 commit-graph.c                      |  8 ++++----
 commit.c                            |  4 ++--
 sha1-lookup.c => hash-lookup.c      | 22 +++++++++++-----------
 list-objects-filter.c               |  2 +-
 midx.c                              |  2 +-
 sha1-file.c => object-file.c        | 10 +++++-----
 sha1-name.c => object-name.c        | 16 ++++++++--------
 oid-array.c                         |  4 ++--
 pack-bitmap-write.c                 |  4 ++--
 packfile.c                          |  2 +-
 patch-ids.c                         |  2 +-
 rerere.c                            |  4 ++--
 Makefile                            |  6 +++---
 19 files changed, 58 insertions(+), 58 deletions(-)
 rename sha1-lookup.h => hash-lookup.h (68%)
 rename sha1-lookup.c => hash-lookup.c (84%)
 rename sha1-file.c => object-file.c (99%)
 rename sha1-name.c => object-name.c (98%)

Range-diff against v1:
1:  aac3a3c3e2 ! 1:  4d69d448a3 object-name.c: rename from sha1-name.c
    @@ Commit message
         Generalize the last remnants of "sha" and "sha1" in this file and rename
         it to reflect that we're not just able to handle SHA-1 these days.
     
    +    We need to update one test to check for an updated error string.
    +
         Signed-off-by: Martin Ågren <martin.agren@gmail.com>
     
    + ## t/t1512-rev-parse-disambiguation.sh ##
    +@@ t/t1512-rev-parse-disambiguation.sh: test_expect_success 'blob and tree' '
    + 
    + test_expect_success 'warn ambiguity when no candidate matches type hint' '
    + 	test_must_fail git rev-parse --verify 000000000^{commit} 2>actual &&
    +-	test_i18ngrep "short SHA1 000000000 is ambiguous" actual
    ++	test_i18ngrep "short object ID 000000000 is ambiguous" actual
    + '
    + 
    + test_expect_success 'disambiguate tree-ish' '
    +
      ## list-objects-filter.c ##
     @@
       * in the traversal (until we mark it SEEN).  This is a way to
    @@ object-name.c: static void unique_in_pack(struct packed_git *p,
      			break;
      		update_candidates(ds, &oid);
      	}
    +@@ object-name.c: static enum get_oid_result get_short_oid(struct repository *r,
    + 	if (!quietly && (status == SHORT_NAME_AMBIGUOUS)) {
    + 		struct oid_array collect = OID_ARRAY_INIT;
    + 
    +-		error(_("short SHA1 %s is ambiguous"), ds.hex_pfx);
    ++		error(_("short object ID %s is ambiguous"), ds.hex_pfx);
    + 
    + 		/*
    + 		 * We may still have ambiguity if we simply saw a series of
     @@ object-name.c: static enum get_oid_result get_oid_with_context_1(struct repository *repo,
      	if (!ret)
      		return ret;
2:  4243886d8a ! 2:  7ab29b868f object-file.c: rename from sha1-file.c
    @@ sha1-file.c => object-file.c
       * creation etc.
       */
      #include "cache.h"
    +@@ object-file.c: static int alt_odb_usable(struct raw_object_store *o,
    +  * LF separated.  Its base points at a statically allocated buffer that
    +  * contains "/the/directory/corresponding/to/.git/objects/...", while
    +  * its name points just after the slash at the end of ".git/objects/"
    +- * in the example above, and has enough space to hold 40-byte hex
    +- * SHA1, an extra slash for the first level indirection, and the
    +- * terminating NUL.
    ++ * in the example above, and has enough space to hold all hex characters
    ++ * of the object ID, an extra slash for the first level indirection, and
    ++ * the terminating NUL.
    +  */
    + static void read_info_alternates(struct repository *r,
    + 				 const char *relative_base,
     
      ## Makefile ##
     @@ Makefile: LIB_OBJS += notes-cache.o
3:  8d3b123633 = 3:  91617de0ac sha1-lookup: rename `sha1_pos()` as `hash_pos()`
4:  afee010474 ! 4:  9df53353dc hash-lookup: rename from sha1-lookup
    @@ Commit message
         Signed-off-by: Martin Ågren <martin.agren@gmail.com>
     
      ## sha1-lookup.h => hash-lookup.h ##
    +@@
    +-#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);
    + 
     @@ hash-lookup.h: int hash_pos(const unsigned char *hash,
      	     hash_access_fn fn);
      
-- 
2.30.0


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v2 1/4] object-name.c: rename from sha1-name.c
  2020-12-31 11:56 ` [PATCH v2 " Martin Ågren
@ 2020-12-31 11:56   ` Martin Ågren
  2020-12-31 11:56   ` [PATCH v2 2/4] object-file.c: rename from sha1-file.c Martin Ågren
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-31 11:56 UTC (permalink / raw)
  To: git; +Cc: brian m . carlson, Derrick Stolee

Generalize the last remnants of "sha" and "sha1" in this file and rename
it to reflect that we're not just able to handle SHA-1 these days.

We need to update one test to check for an updated error string.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 t/t1512-rev-parse-disambiguation.sh |  2 +-
 list-objects-filter.c               |  2 +-
 sha1-name.c => object-name.c        | 16 ++++++++--------
 Makefile                            |  2 +-
 4 files changed, 11 insertions(+), 11 deletions(-)
 rename sha1-name.c => object-name.c (98%)

diff --git a/t/t1512-rev-parse-disambiguation.sh b/t/t1512-rev-parse-disambiguation.sh
index 18fa6cf40d..cc889d7a84 100755
--- a/t/t1512-rev-parse-disambiguation.sh
+++ b/t/t1512-rev-parse-disambiguation.sh
@@ -48,7 +48,7 @@ test_expect_success 'blob and tree' '
 
 test_expect_success 'warn ambiguity when no candidate matches type hint' '
 	test_must_fail git rev-parse --verify 000000000^{commit} 2>actual &&
-	test_i18ngrep "short SHA1 000000000 is ambiguous" actual
+	test_i18ngrep "short object ID 000000000 is ambiguous" actual
 '
 
 test_expect_success 'disambiguate tree-ish' '
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 0a3ef3cab3..4ec0041cfb 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -21,7 +21,7 @@
  * in the traversal (until we mark it SEEN).  This is a way to
  * let us silently de-dup calls to show() in the caller.  This
  * is subtly different from the "revision.h:SHOWN" and the
- * "sha1-name.c:ONELINE_SEEN" bits.  And also different from
+ * "object-name.c:ONELINE_SEEN" bits.  And also different from
  * the non-de-dup usage in pack-bitmap.c
  */
 #define FILTER_SHOWN_BUT_REVISIT (1<<21)
diff --git a/sha1-name.c b/object-name.c
similarity index 98%
rename from sha1-name.c
rename to object-name.c
index 0b23b86ceb..64202de60b 100644
--- a/sha1-name.c
+++ b/object-name.c
@@ -85,7 +85,7 @@ static void update_candidates(struct disambiguate_state *ds, const struct object
 	/* otherwise, current can be discarded and candidate is still good */
 }
 
-static int match_sha(unsigned, const unsigned char *, const unsigned char *);
+static int match_hash(unsigned, const unsigned char *, const unsigned char *);
 
 static void find_short_object_filename(struct disambiguate_state *ds)
 {
@@ -102,7 +102,7 @@ static void find_short_object_filename(struct disambiguate_state *ds)
 		while (!ds->ambiguous && pos < loose_objects->nr) {
 			const struct object_id *oid;
 			oid = loose_objects->oid + pos;
-			if (!match_sha(ds->len, ds->bin_pfx.hash, oid->hash))
+			if (!match_hash(ds->len, ds->bin_pfx.hash, oid->hash))
 				break;
 			update_candidates(ds, oid);
 			pos++;
@@ -110,7 +110,7 @@ static void find_short_object_filename(struct disambiguate_state *ds)
 	}
 }
 
-static int match_sha(unsigned len, const unsigned char *a, const unsigned char *b)
+static int match_hash(unsigned len, const unsigned char *a, const unsigned char *b)
 {
 	do {
 		if (*a != *b)
@@ -145,7 +145,7 @@ static void unique_in_midx(struct multi_pack_index *m,
 	for (i = first; i < num && !ds->ambiguous; i++) {
 		struct object_id oid;
 		current = nth_midxed_object_oid(&oid, m, i);
-		if (!match_sha(ds->len, ds->bin_pfx.hash, current->hash))
+		if (!match_hash(ds->len, ds->bin_pfx.hash, current->hash))
 			break;
 		update_candidates(ds, current);
 	}
@@ -173,7 +173,7 @@ static void unique_in_pack(struct packed_git *p,
 	for (i = first; i < num && !ds->ambiguous; i++) {
 		struct object_id oid;
 		nth_packed_object_id(&oid, p, i);
-		if (!match_sha(ds->len, ds->bin_pfx.hash, oid.hash))
+		if (!match_hash(ds->len, ds->bin_pfx.hash, oid.hash))
 			break;
 		update_candidates(ds, &oid);
 	}
@@ -483,7 +483,7 @@ static enum get_oid_result get_short_oid(struct repository *r,
 	if (!quietly && (status == SHORT_NAME_AMBIGUOUS)) {
 		struct oid_array collect = OID_ARRAY_INIT;
 
-		error(_("short SHA1 %s is ambiguous"), ds.hex_pfx);
+		error(_("short object ID %s is ambiguous"), ds.hex_pfx);
 
 		/*
 		 * We may still have ambiguity if we simply saw a series of
@@ -1811,7 +1811,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo,
 	if (!ret)
 		return ret;
 	/*
-	 * sha1:path --> object name of path in ent sha1
+	 * tree:path --> object name of path in tree
 	 * :path -> object name of absolute path in index
 	 * :./path -> object name of path relative to cwd in index
 	 * :[0-3]:path -> object name of path in index at stage
@@ -1949,6 +1949,6 @@ enum get_oid_result get_oid_with_context(struct repository *repo,
 					 struct object_context *oc)
 {
 	if (flags & GET_OID_FOLLOW_SYMLINKS && flags & GET_OID_ONLY_TO_DIE)
-		BUG("incompatible flags for get_sha1_with_context");
+		BUG("incompatible flags for get_oid_with_context");
 	return get_oid_with_context_1(repo, str, flags, NULL, oid, oc);
 }
diff --git a/Makefile b/Makefile
index 7b64106930..8bb1163f70 100644
--- a/Makefile
+++ b/Makefile
@@ -937,6 +937,7 @@ LIB_OBJS += notes-cache.o
 LIB_OBJS += notes-merge.o
 LIB_OBJS += notes-utils.o
 LIB_OBJS += notes.o
+LIB_OBJS += object-name.o
 LIB_OBJS += object.o
 LIB_OBJS += oid-array.o
 LIB_OBJS += oidmap.o
@@ -995,7 +996,6 @@ LIB_OBJS += server-info.o
 LIB_OBJS += setup.o
 LIB_OBJS += sha1-file.o
 LIB_OBJS += sha1-lookup.o
-LIB_OBJS += sha1-name.o
 LIB_OBJS += shallow.o
 LIB_OBJS += sideband.o
 LIB_OBJS += sigchain.o
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 2/4] object-file.c: rename from sha1-file.c
  2020-12-31 11:56 ` [PATCH v2 " Martin Ågren
  2020-12-31 11:56   ` [PATCH v2 1/4] object-name.c: rename from sha1-name.c Martin Ågren
@ 2020-12-31 11:56   ` Martin Ågren
  2020-12-31 11:56   ` [PATCH v2 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()` Martin Ågren
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-31 11:56 UTC (permalink / raw)
  To: git; +Cc: brian m . carlson, Derrick Stolee

Drop the last remnant of "sha1" in this file and rename it to reflect
that we're not just able to handle SHA-1 these days.

Signed-off-by: Martin Ågren <martin.agren@gmail.com>
---
 t/oid-info/README            | 2 +-
 builtin/index-pack.c         | 2 +-
 sha1-file.c => object-file.c | 8 ++++----
 Makefile                     | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)
 rename sha1-file.c => object-file.c (99%)

diff --git a/t/oid-info/README b/t/oid-info/README
index 27f843fc00..ca56a74b1e 100644
--- a/t/oid-info/README
+++ b/t/oid-info/README
@@ -5,7 +5,7 @@ starting with `#` are ignored.  The key and value are separated by whitespace
 (specifically, those whitespace in the default `$IFS`).  The key consists only
 of shell identifier characters, and the value consists of a hash algorithm,
 colon, and value.  The hash algorithm also consists only of shell identifier
-characters; it should match the value in sha1-file.c.
+characters; it should match the value in object-file.c.
 
 For example, the following lines map the key "rawsz" to "20" if SHA-1 is in use
 and to "32" if SHA-256 is in use:
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 4b8d86e0ad..557bd2f348 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1641,7 +1641,7 @@ static void read_idx_option(struct pack_idx_option *opts, const char *pack_name)
 	/*
 	 * Get rid of the idx file as we do not need it anymore.
 	 * NEEDSWORK: extract this bit from free_pack_by_name() in
-	 * sha1-file.c, perhaps?  It shouldn't matter very much as we
+	 * object-file.c, perhaps?  It shouldn't matter very much as we
 	 * know we haven't installed this pack (hence we never have
 	 * read anything from it).
 	 */
diff --git a/sha1-file.c b/object-file.c
similarity index 99%
rename from sha1-file.c
rename to object-file.c
index c3c49d2fa5..3508598d97 100644
--- a/sha1-file.c
+++ b/object-file.c
@@ -3,7 +3,7 @@
  *
  * Copyright (C) Linus Torvalds, 2005
  *
- * This handles basic git sha1 object files - packing, unpacking,
+ * This handles basic git object files - packing, unpacking,
  * creation etc.
  */
 #include "cache.h"
@@ -508,9 +508,9 @@ static int alt_odb_usable(struct raw_object_store *o,
  * LF separated.  Its base points at a statically allocated buffer that
  * contains "/the/directory/corresponding/to/.git/objects/...", while
  * its name points just after the slash at the end of ".git/objects/"
- * in the example above, and has enough space to hold 40-byte hex
- * SHA1, an extra slash for the first level indirection, and the
- * terminating NUL.
+ * in the example above, and has enough space to hold all hex characters
+ * of the object ID, an extra slash for the first level indirection, and
+ * the terminating NUL.
  */
 static void read_info_alternates(struct repository *r,
 				 const char *relative_base,
diff --git a/Makefile b/Makefile
index 8bb1163f70..224a1c6940 100644
--- a/Makefile
+++ b/Makefile
@@ -937,6 +937,7 @@ LIB_OBJS += notes-cache.o
 LIB_OBJS += notes-merge.o
 LIB_OBJS += notes-utils.o
 LIB_OBJS += notes.o
+LIB_OBJS += object-file.o
 LIB_OBJS += object-name.o
 LIB_OBJS += object.o
 LIB_OBJS += oid-array.o
@@ -994,7 +995,6 @@ LIB_OBJS += sequencer.o
 LIB_OBJS += serve.o
 LIB_OBJS += server-info.o
 LIB_OBJS += setup.o
-LIB_OBJS += sha1-file.o
 LIB_OBJS += sha1-lookup.o
 LIB_OBJS += shallow.o
 LIB_OBJS += sideband.o
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()`
  2020-12-31 11:56 ` [PATCH v2 " Martin Ågren
  2020-12-31 11:56   ` [PATCH v2 1/4] object-name.c: rename from sha1-name.c Martin Ågren
  2020-12-31 11:56   ` [PATCH v2 2/4] object-file.c: rename from sha1-file.c Martin Ågren
@ 2020-12-31 11:56   ` Martin Ågren
  2020-12-31 11:56   ` [PATCH v2 4/4] hash-lookup: rename from sha1-lookup Martin Ågren
  2020-12-31 12:47   ` [PATCH v2 0/4] rename "sha1-foo" files Derrick Stolee
  4 siblings, 0 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-31 11:56 UTC (permalink / raw)
  To: git; +Cc: brian m . carlson, Derrick Stolee

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>
---
 sha1-lookup.h       | 6 +++---
 builtin/name-rev.c  | 2 +-
 commit-graph.c      | 6 +++---
 commit.c            | 2 +-
 oid-array.c         | 2 +-
 pack-bitmap-write.c | 2 +-
 rerere.c            | 2 +-
 sha1-lookup.c       | 8 ++++----
 8 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/sha1-lookup.h b/sha1-lookup.h
index 5afcd011c6..79973d4785 100644
--- a/sha1-lookup.h
+++ b/sha1-lookup.h
@@ -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
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 725dd04519..4939ceb2e5 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -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;
diff --git a/commit-graph.c b/commit-graph.c
index 06f8dc1d89..c672feee91 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -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);
diff --git a/commit.c b/commit.c
index fe1fa3dc41..0b7bace022 100644
--- 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);
 }
diff --git a/oid-array.c b/oid-array.c
index 8e1bcedc0c..fb4c3dd795 100644
--- a/oid-array.c
+++ b/oid-array.c
@@ -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)
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 5e998bdaa7..27ece05ec7 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -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");
diff --git a/rerere.c b/rerere.c
index 9281131a9f..9fc76eb756 100644
--- 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);
diff --git a/sha1-lookup.c b/sha1-lookup.c
index 29185844ec..45489edfe8 100644
--- a/sha1-lookup.c
+++ b/sha1-lookup.c
@@ -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.
 				 */
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v2 4/4] hash-lookup: rename from sha1-lookup
  2020-12-31 11:56 ` [PATCH v2 " Martin Ågren
                     ` (2 preceding siblings ...)
  2020-12-31 11:56   ` [PATCH v2 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()` Martin Ågren
@ 2020-12-31 11:56   ` Martin Ågren
  2020-12-31 12:47   ` [PATCH v2 0/4] rename "sha1-foo" files Derrick Stolee
  4 siblings, 0 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-31 11:56 UTC (permalink / raw)
  To: git; +Cc: brian m . carlson, Derrick Stolee

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>
---
 sha1-lookup.h => hash-lookup.h | 12 ++++++------
 bisect.c                       |  2 +-
 builtin/name-rev.c             |  2 +-
 commit-graph.c                 |  2 +-
 commit.c                       |  2 +-
 sha1-lookup.c => hash-lookup.c | 14 +++++++-------
 midx.c                         |  2 +-
 object-file.c                  |  2 +-
 oid-array.c                    |  2 +-
 pack-bitmap-write.c            |  2 +-
 packfile.c                     |  2 +-
 patch-ids.c                    |  2 +-
 rerere.c                       |  2 +-
 Makefile                       |  2 +-
 14 files changed, 25 insertions(+), 25 deletions(-)
 rename sha1-lookup.h => hash-lookup.h (78%)
 rename sha1-lookup.c => hash-lookup.c (90%)

diff --git a/sha1-lookup.h b/hash-lookup.h
similarity index 78%
rename from sha1-lookup.h
rename to hash-lookup.h
index 79973d4785..5d476dec72 100644
--- a/sha1-lookup.h
+++ b/hash-lookup.h
@@ -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/bisect.c b/bisect.c
index d8c2c8f7a7..75ea0eb57f 100644
--- 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"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 4939ceb2e5..3fe71a8c01 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -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"
 
 /*
diff --git a/commit-graph.c b/commit-graph.c
index c672feee91..e9124d4a41 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -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"
diff --git a/commit.c b/commit.c
index 0b7bace022..cb119ebdf2 100644
--- 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"
diff --git a/sha1-lookup.c b/hash-lookup.c
similarity index 90%
rename from sha1-lookup.c
rename to hash-lookup.c
index 45489edfe8..1191856a32 100644
--- a/sha1-lookup.c
+++ b/hash-lookup.c
@@ -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)
diff --git a/midx.c b/midx.c
index 79c282b070..f9d9b832bb 100644
--- 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"
diff --git a/object-file.c b/object-file.c
index 3508598d97..5bcfde8471 100644
--- a/object-file.c
+++ b/object-file.c
@@ -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"
diff --git a/oid-array.c b/oid-array.c
index fb4c3dd795..889b311f22 100644
--- a/oid-array.c
+++ b/oid-array.c
@@ -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)
 {
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 27ece05ec7..ae6d1475f9 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -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"
 
diff --git a/packfile.c b/packfile.c
index 86f5c8dbf6..62d92e0c7c 100644
--- a/packfile.c
+++ b/packfile.c
@@ -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"
diff --git a/patch-ids.c b/patch-ids.c
index 21973e4933..cf5e8045b7 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -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)
diff --git a/rerere.c b/rerere.c
index 9fc76eb756..d6928c1b5c 100644
--- 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
diff --git a/Makefile b/Makefile
index 224a1c6940..7a141facc7 100644
--- 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
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 0/4] rename "sha1-foo" files
  2020-12-31 11:56 ` [PATCH v2 " Martin Ågren
                     ` (3 preceding siblings ...)
  2020-12-31 11:56   ` [PATCH v2 4/4] hash-lookup: rename from sha1-lookup Martin Ågren
@ 2020-12-31 12:47   ` Derrick Stolee
  2020-12-31 13:36     ` Martin Ågren
  4 siblings, 1 reply; 19+ messages in thread
From: Derrick Stolee @ 2020-12-31 12:47 UTC (permalink / raw)
  To: Martin Ågren, git; +Cc: brian m . carlson, Derrick Stolee

On 12/31/2020 6:56 AM, Martin Ågren wrote:
> Thanks to Derrick and brian for commenting on v1 [1] of my series for
> renaming sha1-foo files and generalizing "sha", "sha1" and so on in
> them. I realized I hadn't renamed the header guard in hash-lookup.h as I
> renamed the file. That made me realize that I had failed to look for
> "SHA-1" (capital letters). So this v2 is a bit bigger than v1, but not
> by too much, I think. The range-diff is below.

Makes sense. Thanks for being diligent!

> Range-diff against v1:
> 1:  aac3a3c3e2 ! 1:  4d69d448a3 object-name.c: rename from sha1-name.c
>     @@ Commit message
>          Generalize the last remnants of "sha" and "sha1" in this file and rename
>          it to reflect that we're not just able to handle SHA-1 these days.
>      
>     +    We need to update one test to check for an updated error string.
>     +
>          Signed-off-by: Martin Ågren <martin.agren@gmail.com>
>      
>     + ## t/t1512-rev-parse-disambiguation.sh ##
>     +@@ t/t1512-rev-parse-disambiguation.sh: test_expect_success 'blob and tree' '
>     + 
>     + test_expect_success 'warn ambiguity when no candidate matches type hint' '
>     + 	test_must_fail git rev-parse --verify 000000000^{commit} 2>actual &&
>     +-	test_i18ngrep "short SHA1 000000000 is ambiguous" actual
>     ++	test_i18ngrep "short object ID 000000000 is ambiguous" actual
>     + '
>     + 
>     + test_expect_success 'disambiguate tree-ish' '
>     +
>       ## list-objects-filter.c ##
>      @@
>        * in the traversal (until we mark it SEEN).  This is a way to
>     @@ object-name.c: static void unique_in_pack(struct packed_git *p,
>       			break;
>       		update_candidates(ds, &oid);
>       	}
>     +@@ object-name.c: static enum get_oid_result get_short_oid(struct repository *r,
>     + 	if (!quietly && (status == SHORT_NAME_AMBIGUOUS)) {
>     + 		struct oid_array collect = OID_ARRAY_INIT;
>     + 
>     +-		error(_("short SHA1 %s is ambiguous"), ds.hex_pfx);
>     ++		error(_("short object ID %s is ambiguous"), ds.hex_pfx);
>     + 
>     + 		/*
>     + 		 * We may still have ambiguity if we simply saw a series of
>      @@ object-name.c: static enum get_oid_result get_oid_with_context_1(struct repository *repo,
>       	if (!ret)
>       		return ret;
> 2:  4243886d8a ! 2:  7ab29b868f object-file.c: rename from sha1-file.c
>     @@ sha1-file.c => object-file.c
>        * creation etc.
>        */
>       #include "cache.h"
>     +@@ object-file.c: static int alt_odb_usable(struct raw_object_store *o,
>     +  * LF separated.  Its base points at a statically allocated buffer that
>     +  * contains "/the/directory/corresponding/to/.git/objects/...", while
>     +  * its name points just after the slash at the end of ".git/objects/"
>     +- * in the example above, and has enough space to hold 40-byte hex
>     +- * SHA1, an extra slash for the first level indirection, and the
>     +- * terminating NUL.
>     ++ * in the example above, and has enough space to hold all hex characters
>     ++ * of the object ID, an extra slash for the first level indirection, and
>     ++ * the terminating NUL.
>     +  */
>     + static void read_info_alternates(struct repository *r,
>     + 				 const char *relative_base,
>      
>       ## Makefile ##
>      @@ Makefile: LIB_OBJS += notes-cache.o
> 3:  8d3b123633 = 3:  91617de0ac sha1-lookup: rename `sha1_pos()` as `hash_pos()`
> 4:  afee010474 ! 4:  9df53353dc hash-lookup: rename from sha1-lookup
>     @@ Commit message
>          Signed-off-by: Martin Ågren <martin.agren@gmail.com>
>      
>       ## sha1-lookup.h => hash-lookup.h ##
>     +@@
>     +-#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);
>     + 
>      @@ hash-lookup.h: int hash_pos(const unsigned char *hash,
>       	     hash_access_fn fn);

This range-diff looks sensible. I approve v2.

Reviewed-by: Derrick Stolee <dstolee@microsoft.com>

Thanks,
-Stolee

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v2 0/4] rename "sha1-foo" files
  2020-12-31 12:47   ` [PATCH v2 0/4] rename "sha1-foo" files Derrick Stolee
@ 2020-12-31 13:36     ` Martin Ågren
  0 siblings, 0 replies; 19+ messages in thread
From: Martin Ågren @ 2020-12-31 13:36 UTC (permalink / raw)
  To: Derrick Stolee; +Cc: Git Mailing List, brian m . carlson, Derrick Stolee

On Thu, 31 Dec 2020 at 13:48, Derrick Stolee <stolee@gmail.com> wrote:
>
> On 12/31/2020 6:56 AM, Martin Ågren wrote:
> > "SHA-1" (capital letters). So this v2 is a bit bigger than v1, but not
> > by too much, I think. The range-diff is below.
>
> Makes sense. Thanks for being diligent!

> This range-diff looks sensible. I approve v2.
>
> Reviewed-by: Derrick Stolee <dstolee@microsoft.com>

Thanks, Stolee!

Martin

^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2020-12-31 13:37 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29 23:52 [PATCH 0/4] rename "sha1-foo" files Martin Ågren
2020-12-29 23:52 ` [PATCH 1/4] object-name.c: rename from sha1-name.c Martin Ågren
2020-12-30  1:19   ` Derrick Stolee
2020-12-29 23:52 ` [PATCH 2/4] object-file.c: rename from sha1-file.c Martin Ågren
2020-12-29 23:52 ` [PATCH 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()` Martin Ågren
2020-12-30  1:21   ` Derrick Stolee
2020-12-29 23:53 ` [PATCH 4/4] hash-lookup: rename from sha1-lookup Martin Ågren
2020-12-30  1:29 ` [PATCH 0/4] rename "sha1-foo" files Derrick Stolee
2020-12-30  8:01   ` Martin Ågren
2020-12-30 13:35     ` Derrick Stolee
2020-12-30  4:22 ` brian m. carlson
2020-12-30  8:04   ` Martin Ågren
2020-12-31 11:56 ` [PATCH v2 " Martin Ågren
2020-12-31 11:56   ` [PATCH v2 1/4] object-name.c: rename from sha1-name.c Martin Ågren
2020-12-31 11:56   ` [PATCH v2 2/4] object-file.c: rename from sha1-file.c Martin Ågren
2020-12-31 11:56   ` [PATCH v2 3/4] sha1-lookup: rename `sha1_pos()` as `hash_pos()` Martin Ågren
2020-12-31 11:56   ` [PATCH v2 4/4] hash-lookup: rename from sha1-lookup Martin Ågren
2020-12-31 12:47   ` [PATCH v2 0/4] rename "sha1-foo" files Derrick Stolee
2020-12-31 13:36     ` Martin Ågren

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).