diff options
author | Thomas Wolf <thomas.wolf@paranor.ch> | 2018-07-18 09:47:32 +0200 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2018-07-19 12:38:28 +0200 |
commit | a9b54b026d22be9a42aec4cdc0ea168da7a300dd (patch) | |
tree | 96fe1596f5b6365eb65a31a055b48ddb08e691ea /org.eclipse.jgit/src/org/eclipse/jgit/merge | |
parent | e4774f45c4190ee0c5ec4f5f575d9d4df1df4959 (diff) | |
download | jgit-a9b54b026d22be9a42aec4cdc0ea168da7a300dd.tar.gz jgit-a9b54b026d22be9a42aec4cdc0ea168da7a300dd.zip |
ResolveMerger: don't try needlessly to delete directories
Don't try to delete folders if the merger chooses THEIRS, but all of
BASE, OURS, and THEIRS contain the folder.
Add a test for rebase with auto-stash and subdirectories that
verifies this case. The needless directory deletion and reporting
such directories in getModifiedFiles() was the root cause of bug
536880.
Note even with this fix, bug 536880 will not be fixed in all cases
yet. There may still be cases where the set of modified files ends
up containing directories. This will be dealt with in EGit where
this set is used. (See https://git.eclipse.org/r/#/c/126242/ .)
Bug: 536880
Change-Id: I62b4571a1c1d4415934a6cb4270e0c8036deb2e9
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/merge')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java | 14 |
1 files changed, 9 insertions, 5 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 da6a3da67d..3042fdd3f4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java @@ -632,12 +632,16 @@ public class ResolveMerger extends ThreeWayMerger { return true; } else { // we want THEIRS ... but THEIRS contains a folder or the - // deletion of the path. Delete what's in the workingtree (the - // workingtree is clean) but do not complain if the file is - // already deleted locally. This complements the test in - // isWorktreeDirty() for the same case. - if (tw.getTreeCount() > T_FILE && tw.getRawMode(T_FILE) == 0) + // deletion of the path. Delete what's in the working tree, + // which we know to be clean. + if (tw.getTreeCount() > T_FILE && tw.getRawMode(T_FILE) == 0) { + // Not present in working tree, so nothing to delete return true; + } + if (modeT != 0 && modeT == modeB) { + // Base, ours, and theirs all contain a folder: don't delete + return true; + } toBeDeleted.add(tw.getPathString()); return true; } |