read-tree: narrow scope of index expansion for '--prefix'
[alt-git.git] / t / t6412-merge-large-rename.sh
blobca018d11f547978bf66a41804c16bf24a0b614f8
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-lib.sh
9 count() {
10 i=1
11 while test $i -le $1; do
12 echo $i
13 i=$(($i + 1))
14 done
17 test_expect_success 'setup (initial)' '
18 touch file &&
19 git add . &&
20 git commit -m initial &&
21 git tag initial
24 make_text() {
25 echo $1: $2
26 for i in $(count 20); do
27 echo $1: $i
28 done
29 echo $1: $3
32 test_rename() {
33 test_expect_success "rename ($1, $2)" '
34 n='$1' &&
35 expect='$2' &&
36 git checkout -f main &&
37 test_might_fail git branch -D test$n &&
38 git reset --hard initial &&
39 for i in $(count $n); do
40 make_text $i initial initial >$i || return 1
41 done &&
42 git add . &&
43 git commit -m add=$n &&
44 for i in $(count $n); do
45 make_text $i changed initial >$i || return 1
46 done &&
47 git commit -a -m change=$n &&
48 git checkout -b test$n HEAD^ &&
49 for i in $(count $n); do
50 git rm $i &&
51 make_text $i initial changed >$i.moved || return 1
52 done &&
53 git add . &&
54 git commit -m change+rename=$n &&
55 case "$expect" in
56 ok) git merge main ;;
57 *) test_must_fail git merge main ;;
58 esac
62 test_rename 5 ok
64 test_expect_success 'set diff.renamelimit to 4' '
65 git config diff.renamelimit 4
67 test_rename 4 ok
68 test_rename 5 fail
70 test_expect_success 'set merge.renamelimit to 5' '
71 git config merge.renamelimit 5
73 test_rename 5 ok
74 test_rename 6 fail
76 test_expect_success 'setup large simple rename' '
77 git config --unset merge.renamelimit &&
78 git config --unset diff.renamelimit &&
80 git reset --hard initial &&
81 for i in $(count 200); do
82 make_text foo bar baz >$i || return 1
83 done &&
84 git add . &&
85 git commit -m create-files &&
87 git branch simple-change &&
88 git checkout -b simple-rename &&
90 mkdir builtin &&
91 git mv [0-9]* builtin/ &&
92 git commit -m renamed &&
94 git checkout simple-change &&
95 >unrelated-change &&
96 git add unrelated-change &&
97 git commit -m unrelated-change
100 test_expect_success 'massive simple rename does not spam added files' '
101 sane_unset GIT_MERGE_VERBOSITY &&
102 git merge --no-stat simple-rename | grep -v Removing >output &&
103 test_line_count -lt 5 output
106 test_done