Browse Source

Make sure checkout is not deleting folders outside the workingtree

There was a chance that jgit deletes symbolic links which point to the
folder on top of the working tree. Make sure not to touch these
resources.

Thanks to Cedric Darloy who reported this bug on
http://www.eclipse.org/forums/index.php/m/776910/#msg_776910 and to
Ondrej Vrabec who reported bug 412489.

Bug: 412489
Change-Id: I81735ba0394ef6794e9b2b8bdd8bd7e8b9c6460f
Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
Signed-off-by: Robin Stocker <robin@nibor.org>
stable-3.0
Christian Halstrick 13 years ago committed by Matthias Sohn
parent
commit
bd57789735
  1. 4
      org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java

4
org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheCheckout.java vendored

@ -417,7 +417,7 @@ public class DirCacheCheckout {
builder.finish(); builder.finish();
File file = null; File file = null;
String last = ""; //$NON-NLS-1$ String last = null;
// when deleting files process them in the opposite order as they have // when deleting files process them in the opposite order as they have
// been reported. This ensures the files are deleted before we delete // been reported. This ensures the files are deleted before we delete
// their parent folders // their parent folders
@ -433,7 +433,7 @@ public class DirCacheCheckout {
if (!file.isDirectory()) if (!file.isDirectory())
toBeDeleted.add(r); toBeDeleted.add(r);
} else { } else {
if (!isSamePrefix(r, last)) if (last != null && !isSamePrefix(r, last))
removeEmptyParents(new File(repo.getWorkTree(), last)); removeEmptyParents(new File(repo.getWorkTree(), last));
last = r; last = r;
} }

Loading…
Cancel
Save