Merge branch 'bc/clone-with-git-default-hash-fix'
[git] / t / t6414-merge-rename-nocruft.sh
1 #!/bin/sh
2
3 test_description='Merge-recursive merging renames'
4 . ./test-lib.sh
5
6 test_expect_success 'setup' '
7         cat >A <<-\EOF &&
8         a aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
9         b bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
10         c cccccccccccccccccccccccccccccccccccccccccccccccc
11         d dddddddddddddddddddddddddddddddddddddddddddddddd
12         e eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
13         f ffffffffffffffffffffffffffffffffffffffffffffffff
14         g gggggggggggggggggggggggggggggggggggggggggggggggg
15         h hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
16         i iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiii
17         j jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj
18         k kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
19         l llllllllllllllllllllllllllllllllllllllllllllllll
20         m mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm
21         n nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
22         o oooooooooooooooooooooooooooooooooooooooooooooooo
23         EOF
24
25         cat >M <<-\EOF &&
26         A AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
27         B BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
28         C CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
29         D DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
30         E EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
31         F FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
32         G GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
33         H HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
34         I IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII
35         J JJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJJ
36         K KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK
37         L LLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLL
38         M MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
39         N NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
40         O OOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO
41         EOF
42
43         git add A M &&
44         git commit -m "initial has A and M" &&
45         git branch white &&
46         git branch red &&
47         git branch blue &&
48
49         git checkout white &&
50         sed -e "/^g /s/.*/g : white changes a line/" <A >B &&
51         sed -e "/^G /s/.*/G : colored branch changes a line/" <M >N &&
52         rm -f A M &&
53         git update-index --add --remove A B M N &&
54         git commit -m "white renames A->B, M->N" &&
55
56         git checkout red &&
57         echo created by red >R &&
58         git update-index --add R &&
59         git commit -m "red creates R" &&
60
61         git checkout blue &&
62         sed -e "/^o /s/.*/g : blue changes a line/" <A >B &&
63         rm -f A &&
64         mv B A &&
65         git update-index A &&
66         git commit -m "blue modify A" &&
67
68         git checkout master
69 '
70
71 # This test broke in 65ac6e9c3f47807cb603af07a6a9e1a43bc119ae
72 test_expect_success 'merge white into red (A->B,M->N)' '
73         git checkout -b red-white red &&
74         git merge white &&
75         git write-tree &&
76         test_path_is_file B &&
77         test_path_is_file N &&
78         test_path_is_file R &&
79         test_path_is_missing A &&
80         test_path_is_missing M
81 '
82
83 # This test broke in 8371234ecaaf6e14fe3f2082a855eff1bbd79ae9
84 test_expect_success 'merge blue into white (A->B, mod A, A untracked)' '
85         git checkout -b white-blue white &&
86         echo dirty >A &&
87         git merge blue &&
88         git write-tree &&
89         test_path_is_file A &&
90         echo dirty >expect &&
91         test_cmp expect A &&
92         test_path_is_file B &&
93         test_path_is_file N &&
94         test_path_is_missing M
95 '
96
97 test_done