Skip to content

Commit 87bfbd5

Browse files
committed
Merge branch 'en/merge-ort-restart-optim-fix'
The merge-ort misbehaved when merge.renameLimit configuration is set too low and failed to find all renames. * en/merge-ort-restart-optim-fix: merge-ort: avoid assuming all renames detected
2 parents e1c192d + 9ae39fe commit 87bfbd5

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

merge-ort.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,6 +3060,10 @@ static int detect_and_process_renames(struct merge_options *opt,
30603060
trace2_region_enter("merge", "regular renames", opt->repo);
30613061
detection_run |= detect_regular_renames(opt, MERGE_SIDE1);
30623062
detection_run |= detect_regular_renames(opt, MERGE_SIDE2);
3063+
if (renames->needed_limit) {
3064+
renames->cached_pairs_valid_side = 0;
3065+
renames->redo_after_renames = 0;
3066+
}
30633067
if (renames->redo_after_renames && detection_run) {
30643068
int i, side;
30653069
struct diff_filepair *p;

t/t6429-merge-sequence-rename-caching.sh

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,4 +697,71 @@ test_expect_success 'caching renames only on upstream side, part 2' '
697697
)
698698
'
699699

700+
#
701+
# The following testcase just creates two simple renames (slightly modified
702+
# on both sides but without conflicting changes), and a directory full of
703+
# files that are otherwise uninteresting. The setup is as follows:
704+
#
705+
# base: unrelated/<BUNCH OF FILES>
706+
# numbers
707+
# values
708+
# upstream: modify: numbers
709+
# modify: values
710+
# topic: add: unrelated/foo
711+
# modify: numbers
712+
# modify: values
713+
# rename: numbers -> sequence
714+
# rename: values -> progression
715+
#
716+
# This is a trivial rename case, but we're curious what happens with a very
717+
# low renameLimit interacting with the restart optimization trying to notice
718+
# that unrelated/ looks like a trivial merge candidate.
719+
#
720+
test_expect_success 'avoid assuming we detected renames' '
721+
git init redo-weirdness &&
722+
(
723+
cd redo-weirdness &&
724+
725+
mkdir unrelated &&
726+
for i in $(test_seq 1 10)
727+
do
728+
>unrelated/$i
729+
done &&
730+
test_seq 2 10 >numbers &&
731+
test_seq 12 20 >values &&
732+
git add numbers values unrelated/ &&
733+
git commit -m orig &&
734+
735+
git branch upstream &&
736+
git branch topic &&
737+
738+
git switch upstream &&
739+
test_seq 1 10 >numbers &&
740+
test_seq 11 20 >values &&
741+
git add numbers &&
742+
git commit -m "Some tweaks" &&
743+
744+
git switch topic &&
745+
746+
>unrelated/foo &&
747+
test_seq 2 12 >numbers &&
748+
test_seq 12 22 >values &&
749+
git add numbers values unrelated/ &&
750+
git mv numbers sequence &&
751+
git mv values progression &&
752+
git commit -m A &&
753+
754+
#
755+
# Actual testing
756+
#
757+
758+
git switch --detach topic^0 &&
759+
760+
test_must_fail git -c merge.renameLimit=1 rebase upstream &&
761+
762+
git ls-files -u >actual &&
763+
! test_file_is_empty actual
764+
)
765+
'
766+
700767
test_done

0 commit comments

Comments
 (0)