read-tree: narrow scope of index expansion for '--prefix'
[alt-git.git] / t / t4130-apply-criss-cross-rename.sh
blobf3ea63274258c664fd612dc314e205b9804cc13c
1 #!/bin/sh
3 test_description='git apply handling criss-cross rename patch.'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 create_file() {
9 cnt=0
10 while test $cnt -le 100
12 cnt=$(($cnt + 1))
13 echo "$2" >> "$1"
14 done
17 test_expect_success 'setup' '
18 # Ensure that file sizes are different, because on Windows
19 # lstat() does not discover inode numbers, and we need
20 # other properties to discover swapped files
21 # (mtime is not always different, either).
22 create_file file1 "some content" &&
23 create_file file2 "some other content" &&
24 create_file file3 "again something else" &&
25 git add file1 file2 file3 &&
26 git commit -m 1
29 test_expect_success 'criss-cross rename' '
30 mv file1 tmp &&
31 mv file2 file1 &&
32 mv tmp file2 &&
33 cp file1 file1-swapped &&
34 cp file2 file2-swapped
37 test_expect_success 'diff -M -B' '
38 git diff -M -B > diff &&
39 git reset --hard
43 test_expect_success 'apply' '
44 git apply diff &&
45 test_cmp file1 file1-swapped &&
46 test_cmp file2 file2-swapped
49 test_expect_success 'criss-cross rename' '
50 git reset --hard &&
51 mv file1 tmp &&
52 mv file2 file1 &&
53 mv file3 file2 &&
54 mv tmp file3 &&
55 cp file1 file1-swapped &&
56 cp file2 file2-swapped &&
57 cp file3 file3-swapped
60 test_expect_success 'diff -M -B' '
61 git diff -M -B > diff &&
62 git reset --hard
65 test_expect_success 'apply' '
66 git apply diff &&
67 test_cmp file1 file1-swapped &&
68 test_cmp file2 file2-swapped &&
69 test_cmp file3 file3-swapped
72 test_done