[PATCH v2 0/4] rename "sha1-foo" files
- From
- Martin Ågren <martin.agren@gmail.com>
- Date
- Dec 31, 2020, 11:56 UTC
- Message-ID
- <cover.1609415114.git.martin.agren@gmail.com>
- In-Reply-To
- <cover.1609282997.git.martin.agren@gmail.com>
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