commit: avoid allocation in clear_commit_marks_many()
[git.git] / t / t6044-merge-unrelated-index-changes.sh
blob01023486c5363da00c9e381fcf1e7d5479c348ae
1 #!/bin/sh
3 test_description="merges with unrelated index changes"
5 . ./test-lib.sh
7 # Testcase for some simple merges
8 # A
9 # o-----o B
10 # \
11 # \---o C
12 # \
13 # \-o D
14 # \
15 # o E
16 # Commit A: some file a
17 # Commit B: adds file b, modifies end of a
18 # Commit C: adds file c
19 # Commit D: adds file d, modifies beginning of a
20 # Commit E: renames a->subdir/a, adds subdir/e
22 test_expect_success 'setup trivial merges' '
23 test_seq 1 10 >a &&
24 git add a &&
25 test_tick && git commit -m A &&
27 git branch A &&
28 git branch B &&
29 git branch C &&
30 git branch D &&
31 git branch E &&
33 git checkout B &&
34 echo b >b &&
35 echo 11 >>a &&
36 git add a b &&
37 test_tick && git commit -m B &&
39 git checkout C &&
40 echo c >c &&
41 git add c &&
42 test_tick && git commit -m C &&
44 git checkout D &&
45 test_seq 2 10 >a &&
46 echo d >d &&
47 git add a d &&
48 test_tick && git commit -m D &&
50 git checkout E &&
51 mkdir subdir &&
52 git mv a subdir/a &&
53 echo e >subdir/e &&
54 git add subdir &&
55 test_tick && git commit -m E
58 test_expect_success 'ff update' '
59 git reset --hard &&
60 git checkout A^0 &&
62 touch random_file && git add random_file &&
64 git merge E^0 &&
66 test_must_fail git rev-parse HEAD:random_file &&
67 test "$(git diff --name-only --cached E)" = "random_file"
70 test_expect_success 'ff update, important file modified' '
71 git reset --hard &&
72 git checkout A^0 &&
74 mkdir subdir &&
75 touch subdir/e &&
76 git add subdir/e &&
78 test_must_fail git merge E^0
81 test_expect_success 'resolve, trivial' '
82 git reset --hard &&
83 git checkout B^0 &&
85 touch random_file && git add random_file &&
87 test_must_fail git merge -s resolve C^0
90 test_expect_success 'resolve, non-trivial' '
91 git reset --hard &&
92 git checkout B^0 &&
94 touch random_file && git add random_file &&
96 test_must_fail git merge -s resolve D^0
99 test_expect_success 'recursive' '
100 git reset --hard &&
101 git checkout B^0 &&
103 touch random_file && git add random_file &&
105 test_must_fail git merge -s recursive C^0
108 test_expect_success 'octopus, unrelated file touched' '
109 git reset --hard &&
110 git checkout B^0 &&
112 touch random_file && git add random_file &&
114 test_must_fail git merge C^0 D^0
117 test_expect_success 'octopus, related file removed' '
118 git reset --hard &&
119 git checkout B^0 &&
121 git rm b &&
123 test_must_fail git merge C^0 D^0
126 test_expect_success 'octopus, related file modified' '
127 git reset --hard &&
128 git checkout B^0 &&
130 echo 12 >>a && git add a &&
132 test_must_fail git merge C^0 D^0
135 test_expect_success 'ours' '
136 git reset --hard &&
137 git checkout B^0 &&
139 touch random_file && git add random_file &&
141 test_must_fail git merge -s ours C^0
144 test_expect_success 'subtree' '
145 git reset --hard &&
146 git checkout B^0 &&
148 touch random_file && git add random_file &&
150 test_must_fail git merge -s subtree E^0
153 test_done