Skip to content

Commit f25f04e

Browse files
committed
Merge branch 'en/merge-recursive-oid-eq-simplify'
Code cleanup. * en/merge-recursive-oid-eq-simplify: merge-recursive: remove unnecessary oid_eq function
2 parents c20d4fd + 763a59e commit f25f04e

File tree

1 file changed

+11
-22
lines changed

1 file changed

+11
-22
lines changed

merge-recursive.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -224,17 +224,6 @@ static struct commit *make_virtual_commit(struct repository *repo,
224224
return commit;
225225
}
226226

227-
/*
228-
* Since we use get_tree_entry(), which does not put the read object into
229-
* the object pool, we cannot rely on a == b.
230-
*/
231-
static int oid_eq(const struct object_id *a, const struct object_id *b)
232-
{
233-
if (!a && !b)
234-
return 2;
235-
return a && b && oideq(a, b);
236-
}
237-
238227
enum rename_type {
239228
RENAME_NORMAL = 0,
240229
RENAME_VIA_DIR,
@@ -805,7 +794,7 @@ static int was_tracked_and_matches(struct merge_options *opt, const char *path,
805794

806795
/* See if the file we were tracking before matches */
807796
ce = opt->priv->orig_index.cache[pos];
808-
return (oid_eq(&ce->oid, &blob->oid) && ce->ce_mode == blob->mode);
797+
return (oideq(&ce->oid, &blob->oid) && ce->ce_mode == blob->mode);
809798
}
810799

811800
/*
@@ -1317,7 +1306,7 @@ static int merge_mode_and_contents(struct merge_options *opt,
13171306
oidcpy(&result->blob.oid, &b->oid);
13181307
}
13191308
} else {
1320-
if (!oid_eq(&a->oid, &o->oid) && !oid_eq(&b->oid, &o->oid))
1309+
if (!oideq(&a->oid, &o->oid) && !oideq(&b->oid, &o->oid))
13211310
result->merge = 1;
13221311

13231312
/*
@@ -1333,9 +1322,9 @@ static int merge_mode_and_contents(struct merge_options *opt,
13331322
}
13341323
}
13351324

1336-
if (oid_eq(&a->oid, &b->oid) || oid_eq(&a->oid, &o->oid))
1325+
if (oideq(&a->oid, &b->oid) || oideq(&a->oid, &o->oid))
13371326
oidcpy(&result->blob.oid, &b->oid);
1338-
else if (oid_eq(&b->oid, &o->oid))
1327+
else if (oideq(&b->oid, &o->oid))
13391328
oidcpy(&result->blob.oid, &a->oid);
13401329
else if (S_ISREG(a->mode)) {
13411330
mmbuffer_t result_buf;
@@ -1368,7 +1357,7 @@ static int merge_mode_and_contents(struct merge_options *opt,
13681357
switch (opt->recursive_variant) {
13691358
case MERGE_VARIANT_NORMAL:
13701359
oidcpy(&result->blob.oid, &a->oid);
1371-
if (!oid_eq(&a->oid, &b->oid))
1360+
if (!oideq(&a->oid, &b->oid))
13721361
result->clean = 0;
13731362
break;
13741363
case MERGE_VARIANT_OURS:
@@ -2836,15 +2825,15 @@ static int process_renames(struct merge_options *opt,
28362825
dst_other.mode = ren1->dst_entry->stages[other_stage].mode;
28372826
try_merge = 0;
28382827

2839-
if (oid_eq(&src_other.oid, &null_oid) &&
2828+
if (oideq(&src_other.oid, &null_oid) &&
28402829
ren1->dir_rename_original_type == 'A') {
28412830
setup_rename_conflict_info(RENAME_VIA_DIR,
28422831
opt, ren1, NULL);
2843-
} else if (oid_eq(&src_other.oid, &null_oid)) {
2832+
} else if (oideq(&src_other.oid, &null_oid)) {
28442833
setup_rename_conflict_info(RENAME_DELETE,
28452834
opt, ren1, NULL);
28462835
} else if ((dst_other.mode == ren1->pair->two->mode) &&
2847-
oid_eq(&dst_other.oid, &ren1->pair->two->oid)) {
2836+
oideq(&dst_other.oid, &ren1->pair->two->oid)) {
28482837
/*
28492838
* Added file on the other side identical to
28502839
* the file being renamed: clean merge.
@@ -2859,7 +2848,7 @@ static int process_renames(struct merge_options *opt,
28592848
1, /* update_cache */
28602849
0 /* update_wd */))
28612850
clean_merge = -1;
2862-
} else if (!oid_eq(&dst_other.oid, &null_oid)) {
2851+
} else if (!oideq(&dst_other.oid, &null_oid)) {
28632852
/*
28642853
* Probably not a clean merge, but it's
28652854
* premature to set clean_merge to 0 here,
@@ -3037,7 +3026,7 @@ static int blob_unchanged(struct merge_options *opt,
30373026

30383027
if (a->mode != o->mode)
30393028
return 0;
3040-
if (oid_eq(&o->oid, &a->oid))
3029+
if (oideq(&o->oid, &a->oid))
30413030
return 1;
30423031
if (!renormalize)
30433032
return 0;
@@ -3478,7 +3467,7 @@ static int merge_trees_internal(struct merge_options *opt,
34783467
opt->subtree_shift);
34793468
}
34803469

3481-
if (oid_eq(&merge_base->object.oid, &merge->object.oid)) {
3470+
if (oideq(&merge_base->object.oid, &merge->object.oid)) {
34823471
output(opt, 0, _("Already up to date!"));
34833472
*result = head;
34843473
return 1;

0 commit comments

Comments
 (0)