Sync with 'maint'
[alt-git.git] / t / t6412-merge-large-rename.sh
blobd0863a8fb5101615df4f8ff27db46a882c0a470e
1 #!/bin/sh
3 test_description='merging with large rename matrix'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK=true
8 . ./test-lib.sh
10 count() {
11 i=1
12 while test $i -le $1; do
13 echo $i
14 i=$(($i + 1))
15 done
18 test_expect_success 'setup (initial)' '
19 touch file &&
20 git add . &&
21 git commit -m initial &&
22 git tag initial
25 make_text() {
26 echo $1: $2
27 for i in $(count 20); do
28 echo $1: $i
29 done
30 echo $1: $3
33 test_rename() {
34 test_expect_success "rename ($1, $2)" '
35 n='$1' &&
36 expect='$2' &&
37 git checkout -f main &&
38 test_might_fail git branch -D test$n &&
39 git reset --hard initial &&
40 for i in $(count $n); do
41 make_text $i initial initial >$i || return 1
42 done &&
43 git add . &&
44 git commit -m add=$n &&
45 for i in $(count $n); do
46 make_text $i changed initial >$i || return 1
47 done &&
48 git commit -a -m change=$n &&
49 git checkout -b test$n HEAD^ &&
50 for i in $(count $n); do
51 git rm $i &&
52 make_text $i initial changed >$i.moved || return 1
53 done &&
54 git add . &&
55 git commit -m change+rename=$n &&
56 case "$expect" in
57 ok) git merge main ;;
58 *) test_must_fail git merge main ;;
59 esac
63 test_rename 5 ok
65 test_expect_success 'set diff.renamelimit to 4' '
66 git config diff.renamelimit 4
68 test_rename 4 ok
69 test_rename 5 fail
71 test_expect_success 'set merge.renamelimit to 5' '
72 git config merge.renamelimit 5
74 test_rename 5 ok
75 test_rename 6 fail
77 test_expect_success 'setup large simple rename' '
78 git config --unset merge.renamelimit &&
79 git config --unset diff.renamelimit &&
81 git reset --hard initial &&
82 for i in $(count 200); do
83 make_text foo bar baz >$i || return 1
84 done &&
85 git add . &&
86 git commit -m create-files &&
88 git branch simple-change &&
89 git checkout -b simple-rename &&
91 mkdir builtin &&
92 git mv [0-9]* builtin/ &&
93 git commit -m renamed &&
95 git checkout simple-change &&
96 >unrelated-change &&
97 git add unrelated-change &&
98 git commit -m unrelated-change
101 test_expect_success 'massive simple rename does not spam added files' '
102 sane_unset GIT_MERGE_VERBOSITY &&
103 git merge --no-stat simple-rename | grep -v Removing >output &&
104 test_line_count -lt 5 output
107 test_done