Git fork

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>

authored by

Martin Ågren and committed by
Junio C Hamano
1e6771e5 71ca53e8

+11 -11
+1 -1
Makefile
··· 937 937 LIB_OBJS += notes-merge.o 938 938 LIB_OBJS += notes-utils.o 939 939 LIB_OBJS += notes.o 940 + LIB_OBJS += object-name.o 940 941 LIB_OBJS += object.o 941 942 LIB_OBJS += oid-array.o 942 943 LIB_OBJS += oidmap.o ··· 995 996 LIB_OBJS += setup.o 996 997 LIB_OBJS += sha1-file.o 997 998 LIB_OBJS += sha1-lookup.o 998 - LIB_OBJS += sha1-name.o 999 999 LIB_OBJS += shallow.o 1000 1000 LIB_OBJS += sideband.o 1001 1001 LIB_OBJS += sigchain.o
+1 -1
list-objects-filter.c
··· 21 21 * in the traversal (until we mark it SEEN). This is a way to 22 22 * let us silently de-dup calls to show() in the caller. This 23 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 25 * the non-de-dup usage in pack-bitmap.c 26 26 */ 27 27 #define FILTER_SHOWN_BUT_REVISIT (1<<21)
+8 -8
sha1-name.c object-name.c
··· 85 85 /* otherwise, current can be discarded and candidate is still good */ 86 86 } 87 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 89 90 90 static void find_short_object_filename(struct disambiguate_state *ds) 91 91 { ··· 102 102 while (!ds->ambiguous && pos < loose_objects->nr) { 103 103 const struct object_id *oid; 104 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 106 break; 107 107 update_candidates(ds, oid); 108 108 pos++; ··· 110 110 } 111 111 } 112 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 114 { 115 115 do { 116 116 if (*a != *b) ··· 145 145 for (i = first; i < num && !ds->ambiguous; i++) { 146 146 struct object_id oid; 147 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 149 break; 150 150 update_candidates(ds, current); 151 151 } ··· 173 173 for (i = first; i < num && !ds->ambiguous; i++) { 174 174 struct object_id oid; 175 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 177 break; 178 178 update_candidates(ds, &oid); 179 179 } ··· 483 483 if (!quietly && (status == SHORT_NAME_AMBIGUOUS)) { 484 484 struct oid_array collect = OID_ARRAY_INIT; 485 485 486 - error(_("short SHA1 %s is ambiguous"), ds.hex_pfx); 486 + error(_("short object ID %s is ambiguous"), ds.hex_pfx); 487 487 488 488 /* 489 489 * We may still have ambiguity if we simply saw a series of ··· 1811 1811 if (!ret) 1812 1812 return ret; 1813 1813 /* 1814 - * sha1:path --> object name of path in ent sha1 1814 + * tree:path --> object name of path in tree 1815 1815 * :path -> object name of absolute path in index 1816 1816 * :./path -> object name of path relative to cwd in index 1817 1817 * :[0-3]:path -> object name of path in index at stage ··· 1949 1949 struct object_context *oc) 1950 1950 { 1951 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 1953 return get_oid_with_context_1(repo, str, flags, NULL, oid, oc); 1954 1954 }
+1 -1
t/t1512-rev-parse-disambiguation.sh
··· 48 48 49 49 test_expect_success 'warn ambiguity when no candidate matches type hint' ' 50 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 52 ' 53 53 54 54 test_expect_success 'disambiguate tree-ish' '