Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn2014-04-14 16:07:35 -0400
committerMatthias Sohn2014-04-16 09:34:48 -0400
commit3818190082ee2e17e9ea5b1ff6823494dac0352c (patch)
tree324abad151b6fa60a702dada0d1ea642b960e296
parentabd3f86e0f5fb7039d5f90eb6296ac6865f1e242 (diff)
downloadegit-3818190082ee2e17e9ea5b1ff6823494dac0352c.tar.gz
egit-3818190082ee2e17e9ea5b1ff6823494dac0352c.tar.xz
egit-3818190082ee2e17e9ea5b1ff6823494dac0352c.zip
Use correct syntax for auto ignoring directories
Ignore patterns for ignoring directories should end with a trailing slash. Bug: 410872 Change-Id: Ie9cef9d0ee875540af15130f2ca72e5b5163bd2c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/IgnoreOperationTest.java23
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java6
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/IgnoreOperation.java15
3 files changed, 31 insertions, 13 deletions
diff --git a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/IgnoreOperationTest.java b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/IgnoreOperationTest.java
index e037a0cfd1..cc74ee7509 100644
--- a/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/IgnoreOperationTest.java
+++ b/org.eclipse.egit.core.test/src/org/eclipse/egit/core/test/op/IgnoreOperationTest.java
@@ -72,7 +72,16 @@ public class IgnoreOperationTest extends GitTestCase {
IgnoreOperation operation = executeIgnore(binFolder.getLocation());
String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
- assertEquals("/bin\n", content);
+ assertEquals("/bin/\n", content);
+ assertFalse(operation.isGitignoreOutsideWSChanged());
+ }
+
+ @Test
+ public void testIgnoreFile() throws Exception {
+ IFile aFile = project.createFile("aFile.txt", new byte[0]);
+ IgnoreOperation operation = executeIgnore(aFile.getLocation());
+ String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
+ assertEquals("/aFile.txt\n", content);
assertFalse(operation.isGitignoreOutsideWSChanged());
}
@@ -97,19 +106,19 @@ public class IgnoreOperationTest extends GitTestCase {
}
@Test
- public void testIgnoreMultiFile() throws Exception {
+ public void testIgnoreMultiFolders() throws Exception {
project.createSourceFolder();
IFolder binFolder = project.getProject().getFolder("bin");
IFolder srcFolder = project.getProject().getFolder("src");
executeIgnore(binFolder.getLocation());
String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
- assertEquals("/bin\n", content);
+ assertEquals("/bin/\n", content);
executeIgnore(srcFolder.getLocation());
content = project.getFileContent(Constants.GITIGNORE_FILENAME);
- assertEquals("/bin\n/src\n", content);
+ assertEquals("/bin/\n/src/\n", content);
}
@Test
@@ -122,7 +131,7 @@ public class IgnoreOperationTest extends GitTestCase {
File ignoreFile = new File(rootFile, Constants.GITIGNORE_FILENAME);
String content = testUtils.slurpAndClose(ignoreFile.toURI().toURL()
.openStream());
- assertEquals("/" + project.getProject().getName() + "\n", content);
+ assertEquals("/" + project.getProject().getName() + "/\n", content);
assertTrue(operation.isGitignoreOutsideWSChanged());
}
@@ -139,7 +148,7 @@ public class IgnoreOperationTest extends GitTestCase {
IgnoreOperation operation = executeIgnore(binFolder.getLocation());
String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
- assertEquals(existing + "\n/bin\n", content);
+ assertEquals(existing + "\n/bin/\n", content);
assertFalse(operation.isGitignoreOutsideWSChanged());
}
@@ -151,7 +160,7 @@ public class IgnoreOperationTest extends GitTestCase {
operation.execute(new NullProgressMonitor());
String content = project.getFileContent(Constants.GITIGNORE_FILENAME);
- assertEquals("/bin\n", content);
+ assertEquals("/bin/\n", content);
}
@Test
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
index 4c55f51320..410412a61e 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/Activator.java
@@ -10,13 +10,13 @@ package org.eclipse.egit.core;
import java.io.File;
import java.io.IOException;
import java.text.MessageFormat;
-import java.util.ArrayList;
import java.util.Collection;
import java.util.Dictionary;
import java.util.HashMap;
import java.util.Hashtable;
-import java.util.List;
+import java.util.LinkedHashSet;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -382,7 +382,7 @@ public class Activator extends Plugin implements DebugOptionsListener {
if (d == null || !autoIgnoreDerived())
return;
- final List<IPath> toBeIgnored = new ArrayList<IPath>();
+ final Set<IPath> toBeIgnored = new LinkedHashSet<IPath>();
d.accept(new IResourceDeltaVisitor() {
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/IgnoreOperation.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/IgnoreOperation.java
index 2f52fefbc5..d928970a39 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/IgnoreOperation.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/IgnoreOperation.java
@@ -123,10 +123,19 @@ public class IgnoreOperation implements IEGitOperation {
IPath parent = path.removeLastSegments(1);
IResource resource = ResourceUtil.getResourceForLocation(path);
IContainer container = null;
- if (resource != null)
+ boolean isDirectory = false;
+ if (resource != null) {
+ isDirectory = resource instanceof IContainer;
container = resource.getParent();
-
- String entry = "/" + path.lastSegment() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$
+ } else
+ isDirectory = path.toFile().isDirectory();
+
+ StringBuilder b = new StringBuilder("/"); //$NON-NLS-1$
+ b.append(path.lastSegment());
+ if (isDirectory)
+ b.append('/');
+ b.append('\n');
+ String entry = b.toString();
if (container == null || container instanceof IWorkspaceRoot) {
Repository repository = RepositoryMapping.getMapping(

Back to the top