hash: provide per-algorithm null OIDs
Up until recently, object IDs did not have an algorithm member, only a hash. Consequently, it was possible to share one null (all-zeros) object ID among all hash algorithms. Now that we're going to be handling objects from multiple hash algorithms, it's important to make sure that all object IDs have a correct algorithm field. Introduce a per-algorithm null OID, and add it to struct hash_algo. Introduce a wrapper function as well, and use it everywhere we used to use the null_oid constant. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
5a6dce70d7
commit
14228447c9
@ -106,8 +106,8 @@ static int post_checkout_hook(struct commit *old_commit, struct commit *new_comm
|
||||
int changed)
|
||||
{
|
||||
return run_hook_le(NULL, "post-checkout",
|
||||
oid_to_hex(old_commit ? &old_commit->object.oid : &null_oid),
|
||||
oid_to_hex(new_commit ? &new_commit->object.oid : &null_oid),
|
||||
oid_to_hex(old_commit ? &old_commit->object.oid : null_oid()),
|
||||
oid_to_hex(new_commit ? &new_commit->object.oid : null_oid()),
|
||||
changed ? "1" : "0", NULL);
|
||||
/* "new_commit" can be NULL when checking out from the index before
|
||||
a commit exists. */
|
||||
@ -638,7 +638,7 @@ static int reset_tree(struct tree *tree, const struct checkout_opts *o,
|
||||
opts.src_index = &the_index;
|
||||
opts.dst_index = &the_index;
|
||||
init_checkout_metadata(&opts.meta, info->refname,
|
||||
info->commit ? &info->commit->object.oid : &null_oid,
|
||||
info->commit ? &info->commit->object.oid : null_oid(),
|
||||
NULL);
|
||||
parse_tree(tree);
|
||||
init_tree_desc(&tree_desc, tree->buffer, tree->size);
|
||||
|
||||
Reference in New Issue
Block a user