diff options
author | Shawn Pearce <sop@google.com> | 2012-07-24 20:07:48 -0400 |
---|---|---|
committer | Gerrit Code Review @ Eclipse.org <gerrit@eclipse.org> | 2012-07-24 20:07:48 -0400 |
commit | 955b024995a423c32154b73f99cff606d882bbe4 (patch) | |
tree | 98d8c77094ba012226e9f079fe4a50e011db1012 /org.eclipse.jgit | |
parent | 3ea694c2523d909190b5350e13254a62e94ec5d5 (diff) | |
download | jgit-955b024995a423c32154b73f99cff606d882bbe4.tar.gz jgit-955b024995a423c32154b73f99cff606d882bbe4.zip |
Revert "Teach ResolveMerger to create more correct DirCacheEntry's"
This reverts commit 3ea694c2523d909190b5350e13254a62e94ec5d5
Merges with unmodified subtrees are broken with this commit present.
Back it out until a fixed version can be supplied.
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java | 100 |
1 files changed, 26 insertions, 74 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java index 3034bfb5d3..2410d6fe04 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java @@ -204,13 +204,6 @@ public class ResolveMerger extends ThreeWayMerger { } if (!inCore) { - // No problem found. The only thing left to be done is to - // checkout - // all files from "theirs" which have been selected to go into - // the - // new index. - checkout(); - // All content-merges are successfully done. If we can now write the // new index we are on quite safe ground. Even if the checkout of // files coming from "theirs" fails the user can work around such @@ -221,6 +214,10 @@ public class ResolveMerger extends ThreeWayMerger { } builder = null; + // No problem found. The only thing left to be done is to checkout + // all files from "theirs" which have been selected to go into the + // new index. + checkout(); } else { builder.finish(); builder = null; @@ -316,18 +313,13 @@ public class ResolveMerger extends ThreeWayMerger { * @param path * @param p * @param stage - * @param lastMod - * @param len * @return the entry which was added to the index */ - private DirCacheEntry add(byte[] path, CanonicalTreeParser p, int stage, - long lastMod, long len) { + private DirCacheEntry add(byte[] path, CanonicalTreeParser p, int stage) { if (p != null && !p.getEntryFileMode().equals(FileMode.TREE)) { DirCacheEntry e = new DirCacheEntry(path, stage); e.setFileMode(p.getEntryFileMode()); e.setObjectId(p.getEntryObjectId()); - e.setLastModified(lastMod); - e.setLength(len); builder.add(e); return e; } @@ -335,25 +327,6 @@ public class ResolveMerger extends ThreeWayMerger { } /** - * adds a entry to the index builder which is a copy of the specified - * DirCacheEntry - * - * @param e - * the entry which should be copied - * - * @return the entry which was added to the index - */ - private DirCacheEntry keep(DirCacheEntry e) { - DirCacheEntry newEntry = new DirCacheEntry(e.getPathString(), e.getStage()); - newEntry.setFileMode(e.getFileMode()); - newEntry.setObjectId(e.getObjectId()); - newEntry.setLastModified(e.getLastModified()); - newEntry.setLength(e.getLength()); - builder.add(newEntry); - return newEntry; - } - - /** * Processes one path and tries to merge. This method will do all do all * trivial (not content) merges and will also detect if a merge will fail. * The merge will fail when one of the following is true @@ -409,27 +382,12 @@ public class ResolveMerger extends ThreeWayMerger { if (isIndexDirty()) return false; - DirCacheEntry ourDce = null; - - if (index == null) { - // create a fake DCE, but only if ours is valid. ours is kept only - // in case it is valid, so a null ourDce is ok in all other cases. - if (modeO != 0) { - ourDce = new DirCacheEntry(tw.getRawPath()); - ourDce.setObjectId(tw.getObjectId(T_OURS)); - ourDce.setFileMode(tw.getFileMode(T_OURS)); - } - } else { - ourDce = index.getDirCacheEntry(); - } - if (nonTree(modeO) && nonTree(modeT) && tw.idEqual(T_OURS, T_THEIRS)) { // OURS and THEIRS have equal content. Check the file mode if (modeO == modeT) { // content and mode of OURS and THEIRS are equal: it doesn't - // matter which one we choose. OURS is chosen. Since the index - // is clean (the index matches already OURS) we can keep the existing one - keep(ourDce); + // matter which one we choose. OURS is chosen. + add(tw.getRawPath(), ours, DirCacheEntry.STAGE_0); // no checkout needed! return true; } else { @@ -440,25 +398,22 @@ public class ResolveMerger extends ThreeWayMerger { if (newMode != FileMode.MISSING.getBits()) { if (newMode == modeO) // ours version is preferred - keep(ourDce); + add(tw.getRawPath(), ours, DirCacheEntry.STAGE_0); else { // the preferred version THEIRS has a different mode // than ours. Check it out! if (isWorktreeDirty(work)) return false; - // we know about length and lastMod only after we have written the new content. - // This will happen later. Set these values to 0 for know. DirCacheEntry e = add(tw.getRawPath(), theirs, - DirCacheEntry.STAGE_0, 0, 0); + DirCacheEntry.STAGE_0); toBeCheckedOut.put(tw.getPathString(), e); } return true; } else { - // FileModes are not mergeable. We found a conflict on modes. - // For conflicting entries we don't know lastModified and length. - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, 0, 0); - add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, 0, 0); + // FileModes are not mergeable. We found a conflict on modes + add(tw.getRawPath(), base, DirCacheEntry.STAGE_1); + add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2); + add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3); unmergedPaths.add(tw.getPathString()); mergeResults.put( tw.getPathString(), @@ -471,8 +426,8 @@ public class ResolveMerger extends ThreeWayMerger { if (nonTree(modeO) && modeB == modeT && tw.idEqual(T_BASE, T_THEIRS)) { // THEIRS was not changed compared to BASE. All changes must be in - // OURS. OURS is chosen. We can keep the existing entry. - keep(ourDce); + // OURS. OURS is chosen. + add(tw.getRawPath(), ours, DirCacheEntry.STAGE_0); // no checkout needed! return true; } @@ -485,11 +440,8 @@ public class ResolveMerger extends ThreeWayMerger { if (isWorktreeDirty(work)) return false; if (nonTree(modeT)) { - // we know about length and lastMod only after we have written - // the new content. - // This will happen later. Set these values to 0 for know. DirCacheEntry e = add(tw.getRawPath(), theirs, - DirCacheEntry.STAGE_0, 0, 0); + DirCacheEntry.STAGE_0); if (e != null) toBeCheckedOut.put(tw.getPathString(), e); return true; @@ -508,16 +460,16 @@ public class ResolveMerger extends ThreeWayMerger { // detected later if (nonTree(modeO) && !nonTree(modeT)) { if (nonTree(modeB)) - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, 0, 0); + add(tw.getRawPath(), base, DirCacheEntry.STAGE_1); + add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2); unmergedPaths.add(tw.getPathString()); enterSubtree = false; return true; } if (nonTree(modeT) && !nonTree(modeO)) { if (nonTree(modeB)) - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0); - add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, 0, 0); + add(tw.getRawPath(), base, DirCacheEntry.STAGE_1); + add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3); unmergedPaths.add(tw.getPathString()); enterSubtree = false; return true; @@ -550,10 +502,10 @@ public class ResolveMerger extends ThreeWayMerger { if (((modeO != 0 && !tw.idEqual(T_BASE, T_OURS)) || (modeT != 0 && !tw .idEqual(T_BASE, T_THEIRS)))) { - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, 0, 0); + add(tw.getRawPath(), base, DirCacheEntry.STAGE_1); + add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2); DirCacheEntry e = add(tw.getRawPath(), theirs, - DirCacheEntry.STAGE_3, 0, 0); + DirCacheEntry.STAGE_3); // OURS was deleted checkout THEIRS if (modeO == 0) { @@ -657,9 +609,9 @@ public class ResolveMerger extends ThreeWayMerger { // a conflict occurred, the file will contain conflict markers // the index will be populated with the three stages and only the // workdir (if used) contains the halfways merged content - add(tw.getRawPath(), base, DirCacheEntry.STAGE_1, 0, 0); - add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2, 0, 0); - add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3, 0, 0); + add(tw.getRawPath(), base, DirCacheEntry.STAGE_1); + add(tw.getRawPath(), ours, DirCacheEntry.STAGE_2); + add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_3); mergeResults.put(tw.getPathString(), result); } else { // no conflict occurred, the file will contain fully merged content. |