object-name.c: rename from sha1-name.c

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> Reviewed-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Martin Ågren committed Dec 31, 2020 at 12:56 UTC 1e6771e5046232e448e2dde4f0fee1752c9e1d04
4 files changed +11 -11
Makefile
+1 -1
@@ -937,6 +937,7 @@ LIB_OBJS += notes-cache.o
937 LIB_OBJS += notes-merge.o
938 LIB_OBJS += notes-utils.o
939 LIB_OBJS += notes.o
940 +LIB_OBJS += object-name.o
941 LIB_OBJS += object.o
942 LIB_OBJS += oid-array.o
943 LIB_OBJS += oidmap.o
@@ -995,7 +996,6 @@ LIB_OBJS += server-info.o
996 LIB_OBJS += setup.o
997 LIB_OBJS += sha1-file.o
998 LIB_OBJS += sha1-lookup.o
998 -LIB_OBJS += sha1-name.o
999 LIB_OBJS += shallow.o
1000 LIB_OBJS += sideband.o
1001 LIB_OBJS += sigchain.o
list-objects-filter.c
+1 -1
@@ -21,7 +21,7 @@
21 * in the traversal (until we mark it SEEN). This is a way to
22 * let us silently de-dup calls to show() in the caller. This
23 * 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
25 * the non-de-dup usage in pack-bitmap.c
26 */
27 #define FILTER_SHOWN_BUT_REVISIT (1<<21)
object-name.c renamed
+8 -8
@@ -85,7 +85,7 @@ static void update_candidates(struct disambiguate_state *ds, const struct object
85 /* otherwise, current can be discarded and candidate is still good */
86 }
87
88 -static int match_sha(unsigned, const unsigned char *, const unsigned char *);
88 +static int match_hash(unsigned, const unsigned char *, const unsigned char *);
89
90 static void find_short_object_filename(struct disambiguate_state *ds)
91 {
@@ -102,7 +102,7 @@ static void find_short_object_filename(struct disambiguate_state *ds)
102 while (!ds->ambiguous && pos < loose_objects->nr) {
103 const struct object_id *oid;
104 oid = loose_objects->oid + pos;
105 - if (!match_sha(ds->len, ds->bin_pfx.hash, oid->hash))
105 + if (!match_hash(ds->len, ds->bin_pfx.hash, oid->hash))
106 break;
107 update_candidates(ds, oid);
108 pos++;
@@ -110,7 +110,7 @@ static void find_short_object_filename(struct disambiguate_state *ds)
110 }
111 }
112
113 -static int match_sha(unsigned len, const unsigned char *a, const unsigned char *b)
113 +static int match_hash(unsigned len, const unsigned char *a, const unsigned char *b)
114 {
115 do {
116 if (*a != *b)
@@ -145,7 +145,7 @@ static void unique_in_midx(struct multi_pack_index *m,
145 for (i = first; i < num && !ds->ambiguous; i++) {
146 struct object_id oid;
147 current = nth_midxed_object_oid(&oid, m, i);
148 - if (!match_sha(ds->len, ds->bin_pfx.hash, current->hash))
148 + if (!match_hash(ds->len, ds->bin_pfx.hash, current->hash))
149 break;
150 update_candidates(ds, current);
151 }
@@ -173,7 +173,7 @@ static void unique_in_pack(struct packed_git *p,
173 for (i = first; i < num && !ds->ambiguous; i++) {
174 struct object_id oid;
175 nth_packed_object_id(&oid, p, i);
176 - if (!match_sha(ds->len, ds->bin_pfx.hash, oid.hash))
176 + if (!match_hash(ds->len, ds->bin_pfx.hash, oid.hash))
177 break;
178 update_candidates(ds, &oid);
179 }
@@ -483,7 +483,7 @@ static enum get_oid_result get_short_oid(struct repository *r,
483 if (!quietly && (status == SHORT_NAME_AMBIGUOUS)) {
484 struct oid_array collect = OID_ARRAY_INIT;
485
486 - error(_("short SHA1 %s is ambiguous"), ds.hex_pfx);
486 + error(_("short object ID %s is ambiguous"), ds.hex_pfx);
487
488 /*
489 * 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,
1811 if (!ret)
1812 return ret;
1813 /*
1814 - * sha1:path --> object name of path in ent sha1
1814 + * tree:path --> object name of path in tree
1815 * :path -> object name of absolute path in index
1816 * :./path -> object name of path relative to cwd in index
1817 * :[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,
1949 struct object_context *oc)
1950 {
1951 if (flags & GET_OID_FOLLOW_SYMLINKS && flags & GET_OID_ONLY_TO_DIE)
1952 - BUG("incompatible flags for get_sha1_with_context");
1952 + BUG("incompatible flags for get_oid_with_context");
1953 return get_oid_with_context_1(repo, str, flags, NULL, oid, oc);
1954 }
t/t1512-rev-parse-disambiguation.sh
+1 -1
@@ -48,7 +48,7 @@ test_expect_success 'blob and tree' '
48
49 test_expect_success 'warn ambiguity when no candidate matches type hint' '
50 test_must_fail git rev-parse --verify 000000000^{commit} 2>actual &&
51 - test_i18ngrep "short SHA1 000000000 is ambiguous" actual
51 + test_i18ngrep "short object ID 000000000 is ambiguous" actual
52 '
53
54 test_expect_success 'disambiguate tree-ish' '