Re: [JGIT PATCH 8/8] Define a basic merge API, and a two-way tree merge strategy

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



testTrivialTwoWay_disjointhistories() failed because merge strategy
didn't handle missing base
version. Am'i right?

  Tomi.

>From 1ed694b55d307c640d29eeebfcd108e08681297b Mon Sep 17 00:00:00 2001
From: Tomi Pakarinen <tomi.pakarinen@xxxxxx>
Date: Sat, 17 Jan 2009 20:56:04 +0200
Subject: [PATCH] If base version missing, we can merge version from
one of other trees.

Signed-off-by: Tomi Pakarinen <tomi.pakarinen@xxxxxx>
---
 .../jgit/merge/StrategySimpleTwoWayInCore.java     |   28 +++++++++++++++-----
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
b/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
index 893add9..eb718ab 100644
--- a/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
+++ b/org.spearce.jgit/src/org/spearce/jgit/merge/StrategySimpleTwoWayInCore.java
@@ -43,6 +43,7 @@
 import org.spearce.jgit.dircache.DirCacheBuilder;
 import org.spearce.jgit.dircache.DirCacheEntry;
 import org.spearce.jgit.errors.UnmergedPathException;
+import org.spearce.jgit.lib.FileMode;
 import org.spearce.jgit.lib.ObjectId;
 import org.spearce.jgit.lib.Repository;
 import org.spearce.jgit.treewalk.AbstractTreeIterator;
@@ -119,13 +120,26 @@ protected boolean mergeImpl() throws IOException {
 				}

 				final int modeB = tw.getRawMode(T_BASE);
-				if (modeB == modeO && tw.idEqual(T_BASE, T_OURS))
-					add(T_THEIRS, DirCacheEntry.STAGE_0);
-				else if (modeB == modeT && tw.idEqual(T_BASE, T_THEIRS))
-					add(T_OURS, DirCacheEntry.STAGE_0);
-				else {
-					conflict();
-					hasConflict = true;
+				if (!FileMode.MISSING.equals(modeB)) {
+					if (modeB == modeO && tw.idEqual(T_BASE, T_OURS))
+						add(T_THEIRS, DirCacheEntry.STAGE_0);
+					else if (modeB == modeT && tw.idEqual(T_BASE, T_THEIRS))
+						add(T_OURS, DirCacheEntry.STAGE_0);
+					else {
+						conflict();
+						hasConflict = true;
+					}
+				} else {
+					if (!FileMode.MISSING.equals(modeO)
+							&& FileMode.MISSING.equals(modeT))
+						add(T_OURS, DirCacheEntry.STAGE_0);
+					else if (FileMode.MISSING.equals(modeO)
+							&& !FileMode.MISSING.equals(modeT))
+						add(T_THEIRS, DirCacheEntry.STAGE_0);
+					else {
+						conflict();
+						hasConflict = true;
+					}
 				}
 			}
 			builder.finish();
-- 
1.6.0.4
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux