]> git.ipfire.org Git - thirdparty/git.git/commitdiff
cache: remove null_sha1
authorbrian m. carlson <sandals@crustytoothpaste.net>
Sun, 18 Aug 2019 20:04:20 +0000 (20:04 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 19 Aug 2019 22:04:59 +0000 (15:04 -0700)
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>
builtin/clone.c
builtin/submodule--helper.c
cache.h
sha1-file.c

index f665b28ccccfacaf5dfe84b7f94081e1afacdd49..eabd02846a6cd893fee12b3e091169a05c7eb87c 100644 (file)
@@ -785,7 +785,7 @@ static int checkout(int submodule_progress)
        if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
                die(_("unable to write new index file"));
 
-       err |= run_hook_le(NULL, "post-checkout", sha1_to_hex(null_sha1),
+       err |= run_hook_le(NULL, "post-checkout", oid_to_hex(&null_oid),
                           oid_to_hex(&oid), "1", NULL);
 
        if (!err && (option_recurse_submodules.nr > 0)) {
index 909e77e802d3302c2486aeb1646fe953d81a0a92..8a6f2abce4af6f3cef080e765f70bd0deb25738c 100644 (file)
@@ -424,7 +424,7 @@ static int module_list(int argc, const char **argv, const char *prefix)
                const struct cache_entry *ce = list.entries[i];
 
                if (ce_stage(ce))
-                       printf("%06o %s U\t", ce->ce_mode, sha1_to_hex(null_sha1));
+                       printf("%06o %s U\t", ce->ce_mode, oid_to_hex(&null_oid));
                else
                        printf("%06o %s %d\t", ce->ce_mode,
                               oid_to_hex(&ce->oid), ce_stage(ce));
diff --git a/cache.h b/cache.h
index b1da1ab08faad3da19657a9a5dcf5f2592c2127c..79efd2168fbeaa978c8de4b24715856257ca7734 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1029,7 +1029,6 @@ const char *repo_find_unique_abbrev(struct repository *r, const struct object_id
 int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
 #define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
 
-extern const unsigned char null_sha1[GIT_MAX_RAWSZ];
 extern const struct object_id null_oid;
 
 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
        return hasheq(oid1->hash, oid2->hash);
 }
 
-static inline int is_null_sha1(const unsigned char *sha1)
-{
-       return hasheq(sha1, null_sha1);
-}
-
 static inline int is_null_oid(const struct object_id *oid)
 {
-       return hasheq(oid->hash, null_sha1);
+       return oideq(oid, &null_oid);
 }
 
 static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
index 487ea35d2d398434d2a907188d8f7ede17721fe3..0ea28f7da3fdd438a437dc900b90960789aac3ce 100644 (file)
@@ -55,7 +55,6 @@
        "\x6f\xe1\x41\xf7\x74\x91\x20\xa3\x03\x72" \
        "\x18\x13"
 
-const unsigned char null_sha1[GIT_MAX_RAWSZ];
 const struct object_id null_oid;
 static const struct object_id empty_tree_oid = {
        EMPTY_TREE_SHA1_BIN_LITERAL