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
@ -870,7 +870,7 @@ static void handle_tag(const char *name, struct tag *tag)
|
||||
p = rewrite_commit((struct commit *)tagged);
|
||||
if (!p) {
|
||||
printf("reset %s\nfrom %s\n\n",
|
||||
name, oid_to_hex(&null_oid));
|
||||
name, oid_to_hex(null_oid()));
|
||||
free(buf);
|
||||
return;
|
||||
}
|
||||
@ -884,7 +884,7 @@ static void handle_tag(const char *name, struct tag *tag)
|
||||
|
||||
if (tagged->type == OBJ_TAG) {
|
||||
printf("reset %s\nfrom %s\n\n",
|
||||
name, oid_to_hex(&null_oid));
|
||||
name, oid_to_hex(null_oid()));
|
||||
}
|
||||
skip_prefix(name, "refs/tags/", &name);
|
||||
printf("tag %s\n", name);
|
||||
@ -1016,7 +1016,7 @@ static void handle_tags_and_duplicates(struct string_list *extras)
|
||||
* it.
|
||||
*/
|
||||
printf("reset %s\nfrom %s\n\n",
|
||||
name, oid_to_hex(&null_oid));
|
||||
name, oid_to_hex(null_oid()));
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1035,7 +1035,7 @@ static void handle_tags_and_duplicates(struct string_list *extras)
|
||||
if (!reference_excluded_commits) {
|
||||
/* delete the ref */
|
||||
printf("reset %s\nfrom %s\n\n",
|
||||
name, oid_to_hex(&null_oid));
|
||||
name, oid_to_hex(null_oid()));
|
||||
continue;
|
||||
}
|
||||
/* set ref to commit using oid, not mark */
|
||||
@ -1146,7 +1146,7 @@ static void handle_deletes(void)
|
||||
continue;
|
||||
|
||||
printf("reset %s\nfrom %s\n\n",
|
||||
refspec->dst, oid_to_hex(&null_oid));
|
||||
refspec->dst, oid_to_hex(null_oid()));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user