cache: remove null_sha1
All of the existing uses of null_sha1 can be converted into uses of null_oid, so do so. Remove null_sha1 and is_null_sha1, and define is_null_oid in terms of null_oid. This also has the additional benefit of removing several uses of sha1_to_hex. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
brian m. carlson committed
Aug 18, 2019 at 20:04 UTC
8d4d86b0f0a875e7916d7de083a88d7f11251406
4 files changed
+3
-10
builtin/clone.c
+1
-1
@@ -785,7 +785,7 @@ static int checkout(int submodule_progress)
785
if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
786
die(_("unable to write new index file"));
787
788
- err |= run_hook_le(NULL, "post-checkout", sha1_to_hex(null_sha1),
788
+ err |= run_hook_le(NULL, "post-checkout", oid_to_hex(&null_oid),
789
oid_to_hex(&oid), "1", NULL);
790
791
if (!err && (option_recurse_submodules.nr > 0)) {
builtin/submodule--helper.c
+1
-1
@@ -424,7 +424,7 @@ static int module_list(int argc, const char **argv, const char *prefix)
424
const struct cache_entry *ce = list.entries[i];
425
426
if (ce_stage(ce))
427
- printf("%06o %s U\t", ce->ce_mode, sha1_to_hex(null_sha1));
427
+ printf("%06o %s U\t", ce->ce_mode, oid_to_hex(&null_oid));
428
else
429
printf("%06o %s %d\t", ce->ce_mode,
430
oid_to_hex(&ce->oid), ce_stage(ce));
cache.h
+1
-7
@@ -1029,7 +1029,6 @@ const char *repo_find_unique_abbrev(struct repository *r, const struct object_id
1029
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
1030
#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
1031
1032
-extern const unsigned char null_sha1[GIT_MAX_RAWSZ];
1032
extern const struct object_id null_oid;
1033
1034
static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
@@ -1064,14 +1063,9 @@ static inline int oideq(const struct object_id *oid1, const struct object_id *oi
1063
return hasheq(oid1->hash, oid2->hash);
1064
}
1065
1067
-static inline int is_null_sha1(const unsigned char *sha1)
1068
-{
1069
- return hasheq(sha1, null_sha1);
1070
-}
1071
-
1066
static inline int is_null_oid(const struct object_id *oid)
1067
{
1074
- return hasheq(oid->hash, null_sha1);
1068
+ return oideq(oid, &null_oid);
1069
}
1070
1071
static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
sha1-file.c
-1
@@ -55,7 +55,6 @@
55
"\x6f\xe1\x41\xf7\x74\x91\x20\xa3\x03\x72" \
56
"\x18\x13"
57
58
-const unsigned char null_sha1[GIT_MAX_RAWSZ];
58
const struct object_id null_oid;
59
static const struct object_id empty_tree_oid = {
60
EMPTY_TREE_SHA1_BIN_LITERAL