git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 1/4] object-name.c: rename from sha1-name.c

From
MÅMartin Ågren <martin.agren@gmail.com>
Date
Dec 31, 2020, 11:56 UTC
Message-ID
<4d69d448a3057dfc1a1dcbbd0e4468060e4fde0d.1609415114.git.martin.agren@gmail.com>
In-Reply-To
<cover.1609415114.git.martin.agren@gmail.com>

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
Previous: Martin ÅgrenNext: Martin Ågren
Message 14 of 19 in “rename "sha1-foo" files”
  1. 0/4 rename "sha1-foo" filesMartin Ågren, Dec 29, 2020
  2. 1/4 object-name.c: rename from sha1-name.cMartin Ågren, Dec 29, 2020
  3. Derrick StoleeDec 30, 2020
  4. 2/4 object-file.c: rename from sha1-file.cMartin Ågren, Dec 29, 2020
  5. 3/4 sha1-lookup: rename `sha1_pos()` as `hash_pos()`Martin Ågren, Dec 29, 2020
  6. Derrick StoleeDec 30, 2020
  7. 4/4 hash-lookup: rename from sha1-lookupMartin Ågren, Dec 29, 2020
  8. Derrick StoleeDec 30, 2020
  9. Martin ÅgrenDec 30, 2020
  10. Derrick StoleeDec 30, 2020
  11. brian m. carlsonDec 30, 2020
  12. Martin ÅgrenDec 30, 2020
  13. 0/4 rename "sha1-foo" filesMartin Ågren, Dec 31, 2020
  14. 1/4 object-name.c: rename from sha1-name.cMartin Ågren, Dec 31, 2020
  15. 2/4 object-file.c: rename from sha1-file.cMartin Ågren, Dec 31, 2020
  16. 3/4 sha1-lookup: rename `sha1_pos()` as `hash_pos()`Martin Ågren, Dec 31, 2020
  17. 4/4 hash-lookup: rename from sha1-lookupMartin Ågren, Dec 31, 2020
  18. Derrick StoleeDec 31, 2020
  19. Martin ÅgrenDec 31, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.