On 11/2/2020 3:43 PM, Elijah Newren wrote: > @@ -99,6 +99,15 @@ static int collect_merge_info_callback(int n, > unsigned mbase_null = !(mask & 1); > unsigned side1_null = !(mask & 2); > unsigned side2_null = !(mask & 4); > + unsigned side1_matches_mbase = (!side1_null && !mbase_null && > + names[0].mode == names[1].mode && > + oideq(&names[0].oid, &names[1].oid)); > + unsigned side2_matches_mbase = (!side2_null && !mbase_null && > + names[0].mode == names[2].mode && > + oideq(&names[0].oid, &names[2].oid)); > + unsigned sides_match = (!side1_null && !side2_null && > + names[1].mode == names[2].mode && > + oideq(&names[1].oid, &names[2].oid)); If the *_null values were in an array, instead, then all of these lines could be grouped as a macro: unsigned null_oid[3] = { !(mask & 1), !(mask & 2), !(mask & 4) }; #define trivial_merge(i,j) (!null_oid[i] && !null_oid[j] && \ names[i].mode == names[j].mode && \ oideq(&names[i].oid, &names[j].oid)) unsigned side1_matches_mbase = trivial_merge(0, 1); unsigned side2_matches_mbase = trivial_merge(0, 2); unsigned sides_match = trivial_merge(1, 2); I briefly considered making these last three an array, as well, except the loop below doesn't use 'i' in a symmetrical way: > + if (i == 1 && side1_matches_mbase) > + t[1] = t[0]; > + else if (i == 2 && side2_matches_mbase) > + t[2] = t[0]; > + else if (i == 2 && sides_match) > + t[2] = t[1]; Since the 'i == 2' case has two possible options, it wouldn't be possible to just have 'side_matches[i]' here. > + else { > + const struct object_id *oid = NULL; > + if (dirmask & 1) > + oid = &names[i].oid; > + buf[i] = fill_tree_descriptor(opt->repo, > + t + i, oid); > + } I do appreciate the reduced recursion here! Thanks, -Stolee