]> source.dussan.org Git - jgit.git/commit
Fix order of deletion for files/dirs in ResolveMerger 27/6327/2
authorRobin Stocker <robin@nibor.org>
Tue, 12 Jun 2012 17:03:52 +0000 (19:03 +0200)
committerRobin Stocker <robin@nibor.org>
Sat, 23 Jun 2012 14:32:34 +0000 (16:32 +0200)
commite623db0f876d95c9faae7ca089cb11c0bc2e6a7c
tree7407be15793ce6ff8e7846159ae46d1761fc123a
parent028434e4f58bfc154da2f56a68e7aefc220bb359
Fix order of deletion for files/dirs in ResolveMerger

Before, the paths to delete were stored in a HashMap, which doesn't have
a particular order. So when e.g. both the file "a/b" and the directory
"a" were to be deleted, it would sometimes try to delete "a" first. This
resulted in a failed path because File#delete() fails when a directory
isn't empty.

With this change, an ArrayList is used for storing the paths to delete.
The list contains the paths in a top-down order, as defined by the order
of processEntry. When the files are deleted, the list is iterated in
reverse, ensuring that all files of a directory are deleted before the
directory itself.

Bug: 354099
Change-Id: I6b2ce96b3932ca84ecdfbeab457ce823c95433fb
Signed-off-by: Robin Stocker <robin@nibor.org>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/MergeCommandTest.java
org.eclipse.jgit/src/org/eclipse/jgit/merge/ResolveMerger.java