diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-02-09 14:20:58 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-09 14:20:58 -0800 |
commit | 87bfbd52e21b6e9373cd70fc148f09dcdad39f09 (patch) | |
tree | 8c2c72ce24dafbb91c6140536851e2570a535698 | |
parent | Merge branch 'js/test-unset-trace2-parents' (diff) | |
parent | merge-ort: avoid assuming all renames detected (diff) | |
download | tgif-87bfbd52e21b6e9373cd70fc148f09dcdad39f09.tar.xz |
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
-rw-r--r-- | merge-ort.c | 4 | ||||
-rwxr-xr-x | t/t6429-merge-sequence-rename-caching.sh | 67 |
2 files changed, 71 insertions, 0 deletions
diff --git a/merge-ort.c b/merge-ort.c index c319797021..b0ff9a7287 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -3060,6 +3060,10 @@ static int detect_and_process_renames(struct merge_options *opt, trace2_region_enter("merge", "regular renames", opt->repo); detection_run |= detect_regular_renames(opt, MERGE_SIDE1); detection_run |= detect_regular_renames(opt, MERGE_SIDE2); + if (renames->needed_limit) { + renames->cached_pairs_valid_side = 0; + renames->redo_after_renames = 0; + } if (renames->redo_after_renames && detection_run) { int i, side; struct diff_filepair *p; diff --git a/t/t6429-merge-sequence-rename-caching.sh b/t/t6429-merge-sequence-rename-caching.sh index 035edc40b1..f2bc8a7d2a 100755 --- a/t/t6429-merge-sequence-rename-caching.sh +++ b/t/t6429-merge-sequence-rename-caching.sh @@ -697,4 +697,71 @@ test_expect_success 'caching renames only on upstream side, part 2' ' ) ' +# +# The following testcase just creates two simple renames (slightly modified +# on both sides but without conflicting changes), and a directory full of +# files that are otherwise uninteresting. The setup is as follows: +# +# base: unrelated/<BUNCH OF FILES> +# numbers +# values +# upstream: modify: numbers +# modify: values +# topic: add: unrelated/foo +# modify: numbers +# modify: values +# rename: numbers -> sequence +# rename: values -> progression +# +# This is a trivial rename case, but we're curious what happens with a very +# low renameLimit interacting with the restart optimization trying to notice +# that unrelated/ looks like a trivial merge candidate. +# +test_expect_success 'avoid assuming we detected renames' ' + git init redo-weirdness && + ( + cd redo-weirdness && + + mkdir unrelated && + for i in $(test_seq 1 10) + do + >unrelated/$i + done && + test_seq 2 10 >numbers && + test_seq 12 20 >values && + git add numbers values unrelated/ && + git commit -m orig && + + git branch upstream && + git branch topic && + + git switch upstream && + test_seq 1 10 >numbers && + test_seq 11 20 >values && + git add numbers && + git commit -m "Some tweaks" && + + git switch topic && + + >unrelated/foo && + test_seq 2 12 >numbers && + test_seq 12 22 >values && + git add numbers values unrelated/ && + git mv numbers sequence && + git mv values progression && + git commit -m A && + + # + # Actual testing + # + + git switch --detach topic^0 && + + test_must_fail git -c merge.renameLimit=1 rebase upstream && + + git ls-files -u >actual && + ! test_file_is_empty actual + ) +' + test_done |