aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2010-11-03 14:13:56 +0100
committerChristian Halstrick <christian.halstrick@sap.com>2010-11-07 14:59:01 +0100
commit0e815fe8c5bd7fb4de9d82b9d25d8ad9a9ec32c4 (patch)
treefe2d8fa809bdf7e2425ece956f05077e3db1648a /org.eclipse.jgit
parentd1e8e97316f8a1349e69a773b1fb0837d9892bbd (diff)
downloadjgit-0e815fe8c5bd7fb4de9d82b9d25d8ad9a9ec32c4.tar.gz
jgit-0e815fe8c5bd7fb4de9d82b9d25d8ad9a9ec32c4.zip
Fixed ResolveMerger regarding handling of deletions
There was a bug in ResolveMerger which is one reason for bug 328841. If a merge was failing because of conflicts deletions where not handled correctly. Files which have to be deleted (because there was a non-conflicting deletion coming in from THEIRS) are not deleted. In the non-conflicting case we also forgot to delete the file but in this case we explicitly checkout in the end these files get deleted during that checkout. This is fixed by handling incoming deletions explicitly. Bug: 328841 Change-Id: I7f4c94ab54138e1b2f3fcdf34fb803d68e209ad0 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java36
1 files changed, 26 insertions, 10 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 a8ab433fb5..1b6ec23bae 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
@@ -93,7 +93,9 @@ public class ResolveMerger extends ThreeWayMerger {
/** the merge failed because of a dirty index */
DIRTY_INDEX,
/** the merge failed because of a dirty workingtree */
- DIRTY_WORKTREE
+ DIRTY_WORKTREE,
+ /** the merge failed because of a file could not be deleted */
+ COULD_NOT_DELETE
}
private NameConflictTreeWalk tw;
@@ -229,10 +231,16 @@ public class ResolveMerger extends ThreeWayMerger {
private void checkout() throws NoWorkTreeException, IOException {
for (Map.Entry<String, DirCacheEntry> entry : toBeCheckedOut.entrySet()) {
File f = new File(db.getWorkTree(), entry.getKey());
- createDir(f.getParentFile());
- DirCacheCheckout.checkoutEntry(db,
- f,
- entry.getValue(), true);
+ if (entry.getValue() != null) {
+ createDir(f.getParentFile());
+ DirCacheCheckout.checkoutEntry(db,
+ f,
+ entry.getValue(), true);
+ } else {
+ if (!f.delete())
+ failingPathes.put(entry.getKey(),
+ MergeFailureReason.COULD_NOT_DELETE);
+ }
modifiedFiles.add(entry.getKey());
}
}
@@ -373,13 +381,21 @@ public class ResolveMerger extends ThreeWayMerger {
return true;
}
- if (nonTree(modeT) && modeB == modeO && tw.idEqual(T_BASE, T_OURS)) {
+ if (modeB == modeO && tw.idEqual(T_BASE, T_OURS)) {
// OURS was not changed compared to base. All changes must be in
// THEIRS. Choose THEIRS.
- DirCacheEntry e=add(tw.getRawPath(), theirs, DirCacheEntry.STAGE_0);
- if (e!=null)
- toBeCheckedOut.put(tw.getPathString(), e);
- return true;
+ if (nonTree(modeT)) {
+ DirCacheEntry e = add(tw.getRawPath(), theirs,
+ DirCacheEntry.STAGE_0);
+ if (e != null)
+ toBeCheckedOut.put(tw.getPathString(), e);
+ return true;
+ } else if (modeT == 0) {
+ // we want THEIRS ... but THEIRS contains the deletion of the
+ // file
+ toBeCheckedOut.put(tw.getPathString(), null);
+ return true;
+ }
}
if (tw.isSubtree()) {