summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2012-06-25 03:08:03 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2012-06-25 03:08:03 -0400
commit1bf5b9c7a8d2d6c254cdb022100e9172bae6cf56 (patch)
treee82f99a5aaf136a872418a7e2da00ffe4198893d /org.eclipse.jgit
parent3d98c3f0f30633b4952617a657e8fda590ed2af4 (diff)
parente623db0f876d95c9faae7ca089cb11c0bc2e6a7c (diff)
downloadjgit-1bf5b9c7a8d2d6c254cdb022100e9172bae6cf56.tar.gz
jgit-1bf5b9c7a8d2d6c254cdb022100e9172bae6cf56.zip
Merge changes I6b2ce96b,I499f518f
* changes: Fix order of deletion for files/dirs in ResolveMerger Don't return success on failing paths in ResolveMerger
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java27
1 files changed, 17 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 7b1b36c946..2410d6fe04 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java
@@ -126,6 +126,8 @@ public class ResolveMerger extends ThreeWayMerger {
private Map<String, DirCacheEntry> toBeCheckedOut = new HashMap<String, DirCacheEntry>();
+ private List<String> toBeDeleted = new ArrayList<String>();
+
private Map<String, MergeResult<? extends Sequence>> mergeResults = new HashMap<String, MergeResult<? extends Sequence>>();
private Map<String, MergeFailureReason> failingPaths = new HashMap<String, MergeFailureReason>();
@@ -221,7 +223,7 @@ public class ResolveMerger extends ThreeWayMerger {
builder = null;
}
- if (getUnmergedPaths().isEmpty()) {
+ if (getUnmergedPaths().isEmpty() && !failed()) {
resultTree = dircache.writeTree(getObjectInserter());
return true;
} else {
@@ -240,16 +242,21 @@ public class ResolveMerger extends ThreeWayMerger {
for (Map.Entry<String, DirCacheEntry> entry : toBeCheckedOut
.entrySet()) {
File f = new File(db.getWorkTree(), entry.getKey());
- if (entry.getValue() != null) {
- createDir(f.getParentFile());
- DirCacheCheckout.checkoutEntry(db, f, entry.getValue(), r);
- } else {
- if (!f.delete())
- failingPaths.put(entry.getKey(),
- MergeFailureReason.COULD_NOT_DELETE);
- }
+ createDir(f.getParentFile());
+ DirCacheCheckout.checkoutEntry(db, f, entry.getValue(), r);
modifiedFiles.add(entry.getKey());
}
+ // Iterate in reverse so that "folder/file" is deleted before
+ // "folder". Otherwise this could result in a failing path because
+ // of a non-empty directory, for which delete() would fail.
+ for (int i = toBeDeleted.size() - 1; i >= 0; i--) {
+ String fileName = toBeDeleted.get(i);
+ File f = new File(db.getWorkTree(), fileName);
+ if (!f.delete())
+ failingPaths.put(fileName,
+ MergeFailureReason.COULD_NOT_DELETE);
+ modifiedFiles.add(fileName);
+ }
} finally {
r.release();
}
@@ -441,7 +448,7 @@ public class ResolveMerger extends ThreeWayMerger {
} else if (modeT == 0 && modeB != 0) {
// we want THEIRS ... but THEIRS contains the deletion of the
// file
- toBeCheckedOut.put(tw.getPathString(), null);
+ toBeDeleted.add(tw.getPathString());
return true;
}
}