]> git.ipfire.org Git - thirdparty/git.git/blob - t/t4130-apply-criss-cross-rename.sh
The third batch
[thirdparty/git.git] / t / t4130-apply-criss-cross-rename.sh
1 #!/bin/sh
2
3 test_description='git apply handling criss-cross rename patch.'
4
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
7
8 create_file() {
9 cnt=0
10 while test $cnt -le 100
11 do
12 cnt=$(($cnt + 1))
13 echo "$2" >> "$1"
14 done
15 }
16
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
27 '
28
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
35 '
36
37 test_expect_success 'diff -M -B' '
38 git diff -M -B > diff &&
39 git reset --hard
40
41 '
42
43 test_expect_success 'apply' '
44 git apply diff &&
45 test_cmp file1 file1-swapped &&
46 test_cmp file2 file2-swapped
47 '
48
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
58 '
59
60 test_expect_success 'diff -M -B' '
61 git diff -M -B > diff &&
62 git reset --hard
63 '
64
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
70 '
71
72 test_done