Commit | Line | Data |
---|---|---|
1d49f0d1 MK |
1 | #!/bin/sh |
2 | ||
3 | test_description='git apply handling criss-cross rename patch.' | |
4 | . ./test-lib.sh | |
5 | ||
6 | create_file() { | |
7 | cnt=0 | |
8 | while test $cnt -le 100 | |
9 | do | |
10 | cnt=$(($cnt + 1)) | |
11 | echo "$2" >> "$1" | |
12 | done | |
13 | } | |
14 | ||
15 | test_expect_success 'setup' ' | |
16 | create_file file1 "File1 contents" && | |
17 | create_file file2 "File2 contents" && | |
f0583867 MK |
18 | create_file file3 "File3 contents" && |
19 | git add file1 file2 file3 && | |
1d49f0d1 MK |
20 | git commit -m 1 |
21 | ' | |
22 | ||
23 | test_expect_success 'criss-cross rename' ' | |
24 | mv file1 tmp && | |
25 | mv file2 file1 && | |
f0583867 MK |
26 | mv tmp file2 && |
27 | cp file1 file1-swapped && | |
28 | cp file2 file2-swapped | |
1d49f0d1 MK |
29 | ' |
30 | ||
31 | test_expect_success 'diff -M -B' ' | |
32 | git diff -M -B > diff && | |
33 | git reset --hard | |
34 | ||
35 | ' | |
36 | ||
e8141fcf | 37 | test_expect_success 'apply' ' |
f0583867 MK |
38 | git apply diff && |
39 | test_cmp file1 file1-swapped && | |
40 | test_cmp file2 file2-swapped | |
41 | ' | |
42 | ||
43 | test_expect_success 'criss-cross rename' ' | |
44 | git reset --hard && | |
45 | mv file1 tmp && | |
46 | mv file2 file1 && | |
a48fcd83 | 47 | mv file3 file2 && |
f0583867 MK |
48 | mv tmp file3 && |
49 | cp file1 file1-swapped && | |
50 | cp file2 file2-swapped && | |
51 | cp file3 file3-swapped | |
52 | ' | |
53 | ||
54 | test_expect_success 'diff -M -B' ' | |
55 | git diff -M -B > diff && | |
56 | git reset --hard | |
57 | ' | |
58 | ||
59 | test_expect_success 'apply' ' | |
60 | git apply diff && | |
61 | test_cmp file1 file1-swapped && | |
62 | test_cmp file2 file2-swapped && | |
63 | test_cmp file3 file3-swapped | |
1d49f0d1 MK |
64 | ' |
65 | ||
66 | test_done |