1#!/bin/sh
2
3test_description='git rebase + directory rename tests'
4
5. ./test-lib.sh
6. "$TEST_DIRECTORY"/lib-rebase.sh
7
8test_expect_success 'setup testcase' '
9 test_create_repo dir-rename &&
10 (
11 cd dir-rename &&
12
13 mkdir x &&
14 test_seq 1 10 >x/a &&
15 test_seq 11 20 >x/b &&
16 test_seq 21 30 >x/c &&
17 test_write_lines a b c d e f g h i >l &&
18 git add x l &&
19 git commit -m "Initial" &&
20
21 git branch O &&
22 git branch A &&
23 git branch B &&
24
25 git checkout A &&
26 git mv x y &&
27 git mv l letters &&
28 git commit -m "Rename x to y, l to letters" &&
29
30 git checkout B &&
31 echo j >>l &&
32 test_seq 31 40 >x/d &&
33 git add l x/d &&
34 git commit -m "Modify l, add x/d"
35 )
36'
37
38test_expect_success 'rebase --interactive: directory rename detected' '
39 (
40 cd dir-rename &&
41
42 git checkout B^0 &&
43
44 set_fake_editor &&
45 FAKE_LINES="1" git rebase --interactive A &&
46
47 git ls-files -s >out &&
48 test_line_count = 5 out &&
49
50 test_path_is_file y/d &&
51 test_path_is_missing x/d
52 )
53'
54
55test_expect_failure 'rebase (am): directory rename detected' '
56 (
57 cd dir-rename &&
58
59 git checkout B^0 &&
60
61 git rebase A &&
62
63 git ls-files -s >out &&
64 test_line_count = 5 out &&
65
66 test_path_is_file y/d &&
67 test_path_is_missing x/d
68 )
69'
70
71test_expect_success 'rebase --merge: directory rename detected' '
72 (
73 cd dir-rename &&
74
75 git checkout B^0 &&
76
77 git rebase --merge A &&
78
79 git ls-files -s >out &&
80 test_line_count = 5 out &&
81
82 test_path_is_file y/d &&
83 test_path_is_missing x/d
84 )
85'
86
87test_expect_failure 'am: directory rename detected' '
88 (
89 cd dir-rename &&
90
91 git checkout A^0 &&
92
93 git format-patch -1 B &&
94
95 git am --3way 0001*.patch &&
96
97 git ls-files -s >out &&
98 test_line_count = 5 out &&
99
100 test_path_is_file y/d &&
101 test_path_is_missing x/d
102 )
103'
104
105test_done