Skip to content

Commit 8d4d86b

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f6ca67d commit 8d4d86b

File tree

4 files changed

+3
-10
lines changed

4 files changed

+3
-10
lines changed

builtin/clone.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,7 @@ static int checkout(int submodule_progress)
785785
if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK))
786786
die(_("unable to write new index file"));
787787

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),
789789
oid_to_hex(&oid), "1", NULL);
790790

791791
if (!err && (option_recurse_submodules.nr > 0)) {

builtin/submodule--helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ static int module_list(int argc, const char **argv, const char *prefix)
424424
const struct cache_entry *ce = list.entries[i];
425425

426426
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));
428428
else
429429
printf("%06o %s %d\t", ce->ce_mode,
430430
oid_to_hex(&ce->oid), ce_stage(ce));

cache.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,7 +1029,6 @@ const char *repo_find_unique_abbrev(struct repository *r, const struct object_id
10291029
int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
10301030
#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len)
10311031

1032-
extern const unsigned char null_sha1[GIT_MAX_RAWSZ];
10331032
extern const struct object_id null_oid;
10341033

10351034
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
10641063
return hasheq(oid1->hash, oid2->hash);
10651064
}
10661065

1067-
static inline int is_null_sha1(const unsigned char *sha1)
1068-
{
1069-
return hasheq(sha1, null_sha1);
1070-
}
1071-
10721066
static inline int is_null_oid(const struct object_id *oid)
10731067
{
1074-
return hasheq(oid->hash, null_sha1);
1068+
return oideq(oid, &null_oid);
10751069
}
10761070

10771071
static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)

sha1-file.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@
5555
"\x6f\xe1\x41\xf7\x74\x91\x20\xa3\x03\x72" \
5656
"\x18\x13"
5757

58-
const unsigned char null_sha1[GIT_MAX_RAWSZ];
5958
const struct object_id null_oid;
6059
static const struct object_id empty_tree_oid = {
6160
EMPTY_TREE_SHA1_BIN_LITERAL

0 commit comments

Comments
 (0)