Skip to content

Commit 3639dfb

Browse files
newrengitster
authored andcommitted
merge-ort: support subtree shifting
merge-recursive has some simple code to support subtree shifting; copy it over to merge-ort. This fixes t6409.12 under GIT_TEST_MERGE_ALGORITHM=ort. Signed-off-by: Elijah Newren <[email protected]> Reviewed-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3860220 commit 3639dfb

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

merge-ort.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3551,6 +3551,23 @@ void merge_finalize(struct merge_options *opt,
35513551

35523552
/*** Function Grouping: helper functions for merge_incore_*() ***/
35533553

3554+
static struct tree *shift_tree_object(struct repository *repo,
3555+
struct tree *one, struct tree *two,
3556+
const char *subtree_shift)
3557+
{
3558+
struct object_id shifted;
3559+
3560+
if (!*subtree_shift) {
3561+
shift_tree(repo, &one->object.oid, &two->object.oid, &shifted, 0);
3562+
} else {
3563+
shift_tree_by(repo, &one->object.oid, &two->object.oid, &shifted,
3564+
subtree_shift);
3565+
}
3566+
if (oideq(&two->object.oid, &shifted))
3567+
return two;
3568+
return lookup_tree(repo, &shifted);
3569+
}
3570+
35543571
static inline void set_commit_tree(struct commit *c, struct tree *t)
35553572
{
35563573
c->maybe_tree = t;
@@ -3680,6 +3697,13 @@ static void merge_ort_nonrecursive_internal(struct merge_options *opt,
36803697
{
36813698
struct object_id working_tree_oid;
36823699

3700+
if (opt->subtree_shift) {
3701+
side2 = shift_tree_object(opt->repo, side1, side2,
3702+
opt->subtree_shift);
3703+
merge_base = shift_tree_object(opt->repo, side1, merge_base,
3704+
opt->subtree_shift);
3705+
}
3706+
36833707
trace2_region_enter("merge", "collect_merge_info", opt->repo);
36843708
if (collect_merge_info(opt, merge_base, side1, side2) != 0) {
36853709
/*

0 commit comments

Comments
 (0)