@matheusbsbs / matheus-bagliano / commits / bb6d7b893e
Fork 0

Documentaiton (read-tree): update description of 3-way

The merge-one-file used to leave the working tree intact, but it has long been changed to leave the merge result there since 2a68a8659f7dc55fd285d235ae2d19e7a8116c30 commit. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Dec 5, 2005 at 23:26 UTC bb6d7b893e7f9f22e58a63d871b5b4c87b887513
1 file changed +31 -12
Documentation/git-read-tree.txt
+31 -12
@@ -167,20 +167,26 @@ $ git-read-tree -m <tree1> <tree2> <tree3>
167
168 and you will end up with an index with all of the <tree1> entries in
169 "stage1", all of the <tree2> entries in "stage2" and all of the
170 -<tree3> entries in "stage3".
170 +<tree3> entries in "stage3". When performing a merge of another
171 +branch into the current branch, we use the common ancestor tree
172 +as <tree1>, the current branch head as <tree2>, and the other
173 +branch head as <tree3>.
174
175 Furthermore, `git-read-tree` has special-case logic that says: if you see
176 a file that matches in all respects in the following states, it
177 "collapses" back to "stage0":
178
179 - stage 2 and 3 are the same; take one or the other (it makes no
177 - difference - the same work has been done on stage 2 and 3)
180 + difference - the same work has been done on our branch in
181 + stage 2 and their branch in stage 3)
182
183 - stage 1 and stage 2 are the same and stage 3 is different; take
180 - stage 3 (some work has been done on stage 3)
184 + stage 3 (our branch in stage 2 did not do anything since the
185 + ancestor in stage 1 while their branch in stage 3 worked on
186 + it)
187
188 - stage 1 and stage 3 are the same and stage 2 is different take
183 - stage 2 (some work has been done on stage 2)
189 + stage 2 (we did something while they did nothing)
190
191 The `git-write-tree` command refuses to write a nonsensical tree, and it
192 will complain about unmerged entries if it sees a single entry that is not
@@ -223,11 +229,9 @@ populated. Here is an outline of how the algorithm works:
229 trivial rules ..
230
231 You would normally use `git-merge-index` with supplied
226 -`git-merge-one-file` to do this last step. The script
227 -does not touch the files in the work tree, and the entire merge
228 -happens in the index file. In other words, there is no need to
229 -worry about what is in the working directory, since it is never
230 -shown and never used.
232 +`git-merge-one-file` to do this last step. The script updates
233 +the files in the working tree as it merges each path and at the
234 +end of a successful merge.
235
236 When you start a 3-way merge with an index file that is already
237 populated, it is assumed that it represents the state of the
@@ -238,7 +242,8 @@ merge refuses to run if it finds an entry in the original index
242 file that does not match stage 2.
243
244 This is done to prevent you from losing your work-in-progress
241 -changes. To illustrate, suppose you start from what has been
245 +changes, and mixing your random changes in an unrelated merge
246 +commit. To illustrate, suppose you start from what has been
247 commited last to your repository:
248
249 ----------------
@@ -251,8 +256,8 @@ you notice that the tip of your "upstream" tree has advanced
256 since you pulled from him:
257
258 ----------------
254 -$ git-fetch rsync://.... linus
255 -$ LT=`cat .git/MERGE_HEAD`
259 +$ git-fetch git://.... linus
260 +$ LT=`cat .git/FETCH_HEAD`
261 ----------------
262
263 Your work tree is still based on your HEAD ($JC), but you have
@@ -271,6 +276,20 @@ what you would commit is a pure merge between $JC and $LT without
276 your work-in-progress changes, and your work tree would be
277 updated to the result of the merge.
278
279 +However, if you have local changes in the working tree that
280 +would be overwritten by this merge,`git-read-tree` will refuse
281 +to run to prevent your changes from being lost.
282 +
283 +In other words, there is no need to worry about what exists only
284 +in the working tree. When you have local changes in a part of
285 +the project that is not involved in the merge, your changes do
286 +not interfere with the merge, and are kept intact. When they
287 +*do* interfere, the merge does not even start (`git-read-tree`
288 +complains loudly and fails without modifying anything). In such
289 +a case, you can simply continue doing what you were in the
290 +middle of doing, and when your working tree is ready (i.e. you
291 +have finished your work-in-progress), attempt the merge again.
292 +
293
294 See Also
295 --------