From 14228447c9ce664a4e9c31ba10344ec5e4ea4ba5 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Mon, 26 Apr 2021 01:02:56 +0000 Subject: 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 Signed-off-by: Junio C Hamano --- merge-recursive.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'merge-recursive.c') diff --git a/merge-recursive.c b/merge-recursive.c index ed31f9496c..03f5c0769e 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -486,7 +486,7 @@ static int get_tree_entry_if_blob(struct repository *r, ret = get_tree_entry(r, tree, path, &dfs->oid, &dfs->mode); if (S_ISDIR(dfs->mode)) { - oidcpy(&dfs->oid, &null_oid); + oidcpy(&dfs->oid, null_oid()); dfs->mode = 0; } return ret; @@ -1604,7 +1604,7 @@ static int handle_file_collision(struct merge_options *opt, /* Store things in diff_filespecs for functions that need it */ null.path = (char *)collide_path; - oidcpy(&null.oid, &null_oid); + oidcpy(&null.oid, null_oid()); null.mode = 0; if (merge_mode_and_contents(opt, &null, a, b, collide_path, @@ -2789,11 +2789,11 @@ static int process_renames(struct merge_options *opt, dst_other.mode = ren1->dst_entry->stages[other_stage].mode; try_merge = 0; - if (oideq(&src_other.oid, &null_oid) && + if (oideq(&src_other.oid, null_oid()) && ren1->dir_rename_original_type == 'A') { setup_rename_conflict_info(RENAME_VIA_DIR, opt, ren1, NULL); - } else if (oideq(&src_other.oid, &null_oid)) { + } else if (oideq(&src_other.oid, null_oid())) { setup_rename_conflict_info(RENAME_DELETE, opt, ren1, NULL); } else if ((dst_other.mode == ren1->pair->two->mode) && @@ -2812,7 +2812,7 @@ static int process_renames(struct merge_options *opt, 1, /* update_cache */ 0 /* update_wd */)) clean_merge = -1; - } else if (!oideq(&dst_other.oid, &null_oid)) { + } else if (!oideq(&dst_other.oid, null_oid())) { /* * Probably not a clean merge, but it's * premature to set clean_merge to 0 here, -- cgit v1.2.3