[PATCH] ls-tree matching multiple paths
[git/kirr.git] / t / t1000-read-tree-m-3way.sh
blobbd7406fd5ccaf70009710c615a0864e78f7335e3
1 #!/bin/sh
3 # Copyright (c) 2005 Junio C Hamano
6 test_description='Three way merge with read-tree -m
8 This test tries three-way merge with read-tree -m
10 There is one ancestor (called O for Original) and two branches A
11 and B derived from it. We want to do a 3-way merge between A and
12 B, using O as the common ancestor.
14 merge A O B
16 Decisions are made by comparing contents of O, A and B pathname
17 by pathname. The result is determined by the following guiding
18 principle:
20 - If only A does something to it and B does not touch it, take
21 whatever A does.
23 - If only B does something to it and A does not touch it, take
24 whatever B does.
26 - If both A and B does something but in the same way, take
27 whatever they do.
29 - If A and B does something but different things, we need a
30 3-way merge:
32 - We cannot do anything about the following cases:
34 * O does not have it. A and B both must be adding to the
35 same path independently.
37 * A deletes it. B must be modifying.
39 - Otherwise, A and B are modifying. Run 3-way merge.
41 First, the case matrix.
43 - Vertical axis is for A'\''s actions.
44 - Horizontal axis is for B'\''s actions.
46 .----------------------------------------------------------------.
47 | A B | No Action | Delete | Modify | Add |
48 |------------+------------+------------+------------+------------|
49 | No Action | | | | |
50 | | select O | delete | select B | select B |
51 | | | | | |
52 |------------+------------+------------+------------+------------|
53 | Delete | | | ********** | can |
54 | | delete | delete | merge | not |
55 | | | | | happen |
56 |------------+------------+------------+------------+------------|
57 | Modify | | ********** | ?????????? | can |
58 | | select A | merge | select A=B | not |
59 | | | | merge | happen |
60 |------------+------------+------------+------------+------------|
61 | Add | | can | can | ?????????? |
62 | | select A | not | not | select A=B |
63 | | | happen | happen | merge |
64 .----------------------------------------------------------------.
66 In addition:
68 SS: a special case of MM, where A and B makes the same modification.
69 LL: a special case of AA, where A and B creates the same file.
70 TT: a special case of MM, where A and B makes mergeable changes.
71 DF: a special case, where A makes a directory and B makes a file.
74 . ./test-lib.sh
75 . ../lib-read-tree-m-3way.sh
77 ################################################################
78 # Try merging and showing the various diffs
80 test_expect_success \
81 '3-way merge with git-read-tree -m' \
82 "git-read-tree -m $tree_O $tree_A $tree_B"
84 strip_object_id='s/^\([0-7]*\) [0-9a-f]* \([0-3].*\)$/\1 \2/'
86 test_expect_success \
87 'git-ls-files --stage of the merge result' \
88 'git-ls-files --stage >current- &&
89 sed -e "$strip_object_id" <current- >current'
91 cat >expected <<\EOF
92 100644 2 AA
93 100644 3 AA
94 100644 2 AN
95 100644 1 DD
96 100644 3 DF
97 100644 2 DF/DF
98 100644 1 DM
99 100644 3 DM
100 100644 1 DN
101 100644 3 DN
102 100644 2 LL
103 100644 3 LL
104 100644 1 MD
105 100644 2 MD
106 100644 1 MM
107 100644 2 MM
108 100644 3 MM
109 100644 0 MN
110 100644 3 NA
111 100644 1 ND
112 100644 2 ND
113 100644 0 NM
114 100644 0 NN
115 100644 0 SS
116 100644 1 TT
117 100644 2 TT
118 100644 3 TT
119 100644 2 Z/AA
120 100644 3 Z/AA
121 100644 2 Z/AN
122 100644 1 Z/DD
123 100644 1 Z/DM
124 100644 3 Z/DM
125 100644 1 Z/DN
126 100644 3 Z/DN
127 100644 1 Z/MD
128 100644 2 Z/MD
129 100644 1 Z/MM
130 100644 2 Z/MM
131 100644 3 Z/MM
132 100644 0 Z/MN
133 100644 3 Z/NA
134 100644 1 Z/ND
135 100644 2 Z/ND
136 100644 0 Z/NM
137 100644 0 Z/NN
140 test_expect_success \
141 'validate merge result' \
142 'diff current expected'
144 test_done