]> git.ipfire.org Git - thirdparty/git.git/blame - t/t4130-apply-criss-cross-rename.sh
Merge branch 'gc/branch-recurse-submodules-fix'
[thirdparty/git.git] / t / t4130-apply-criss-cross-rename.sh
CommitLineData
1d49f0d1
MK
1#!/bin/sh
2
3test_description='git apply handling criss-cross rename patch.'
f54f48fc
ÆAB
4
5TEST_PASSES_SANITIZE_LEAK=true
1d49f0d1
MK
6. ./test-lib.sh
7
8create_file() {
9 cnt=0
10 while test $cnt -le 100
11 do
12 cnt=$(($cnt + 1))
13 echo "$2" >> "$1"
14 done
15}
16
17test_expect_success 'setup' '
54956df9
JS
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" &&
f0583867 25 git add file1 file2 file3 &&
1d49f0d1
MK
26 git commit -m 1
27'
28
29test_expect_success 'criss-cross rename' '
30 mv file1 tmp &&
31 mv file2 file1 &&
f0583867
MK
32 mv tmp file2 &&
33 cp file1 file1-swapped &&
34 cp file2 file2-swapped
1d49f0d1
MK
35'
36
37test_expect_success 'diff -M -B' '
38 git diff -M -B > diff &&
39 git reset --hard
40
41'
42
e8141fcf 43test_expect_success 'apply' '
f0583867
MK
44 git apply diff &&
45 test_cmp file1 file1-swapped &&
46 test_cmp file2 file2-swapped
47'
48
49test_expect_success 'criss-cross rename' '
50 git reset --hard &&
51 mv file1 tmp &&
52 mv file2 file1 &&
a48fcd83 53 mv file3 file2 &&
f0583867
MK
54 mv tmp file3 &&
55 cp file1 file1-swapped &&
56 cp file2 file2-swapped &&
57 cp file3 file3-swapped
58'
59
60test_expect_success 'diff -M -B' '
61 git diff -M -B > diff &&
62 git reset --hard
63'
64
65test_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
1d49f0d1
MK
70'
71
72test_done