aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorShawn Pearce <spearce@spearce.org>2011-02-23 18:08:50 -0500
committerCode Review <codereview-daemon@eclipse.org>2011-02-23 18:08:50 -0500
commit2902c7679bde83075370ff3c05e3dbbc6d637e42 (patch)
tree6b1c635b90546fc34144ce08a69c6284f9bc9725 /org.eclipse.jgit
parent7505b93546376d3d46976e3a81ea791ba6a265ce (diff)
parente703b6c640f7b8b4aee84ce2661fce1da281d926 (diff)
downloadjgit-2902c7679bde83075370ff3c05e3dbbc6d637e42.tar.gz
jgit-2902c7679bde83075370ff3c05e3dbbc6d637e42.zip
Merge "Respect core.excludesfile to enable global ignore rules "
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java11
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java27
3 files changed, 38 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
index ccadf6bfe0..7e4cb3bee2 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
@@ -72,6 +72,9 @@ public class ConfigConstants {
/** The "bare" key */
public static final String CONFIG_KEY_BARE = "bare";
+ /** The "excludesfile" key */
+ public static final String CONFIG_KEY_EXCLUDESFILE = "excludesfile";
+
/** The "filemode" key */
public static final String CONFIG_KEY_FILEMODE = "filemode";
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java
index a6da60ffdd..2d9f44aad8 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/CoreConfig.java
@@ -80,10 +80,14 @@ public class CoreConfig {
private final boolean logAllRefUpdates;
+ private final String excludesfile;
+
private CoreConfig(final Config rc) {
compression = rc.getInt("core", "compression", DEFAULT_COMPRESSION);
packIndexVersion = rc.getInt("pack", "indexversion", 2);
logAllRefUpdates = rc.getBoolean("core", "logallrefupdates", true);
+ excludesfile = rc.getString(ConfigConstants.CONFIG_CORE_SECTION, null,
+ ConfigConstants.CONFIG_KEY_EXCLUDESFILE);
}
/**
@@ -106,4 +110,11 @@ public class CoreConfig {
public boolean isLogAllRefUpdates() {
return logAllRefUpdates;
}
+
+ /**
+ * @return path of excludesfile
+ */
+ public String getExcludesFile() {
+ return excludesfile;
+ }
}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
index e2dd0c7735..d067e9099f 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/treewalk/WorkingTreeIterator.java
@@ -48,6 +48,7 @@ package org.eclipse.jgit.treewalk;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
@@ -69,8 +70,10 @@ import org.eclipse.jgit.errors.CorruptObjectException;
import org.eclipse.jgit.ignore.IgnoreNode;
import org.eclipse.jgit.ignore.IgnoreRule;
import org.eclipse.jgit.lib.Constants;
+import org.eclipse.jgit.lib.CoreConfig;
import org.eclipse.jgit.lib.FileMode;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.IO;
import org.eclipse.jgit.util.io.EolCanonicalizingInputStream;
@@ -897,7 +900,27 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
r = new IgnoreNode();
}
- File exclude = new File(repository.getDirectory(), "info/exclude");
+ FS fs = repository.getFS();
+ String path = repository.getConfig().get(CoreConfig.KEY)
+ .getExcludesFile();
+ if (path != null) {
+ File excludesfile;
+ if (path.startsWith("~/"))
+ excludesfile = fs.resolve(fs.userHome(), path.substring(2));
+ else
+ excludesfile = fs.resolve(null, path);
+ loadRulesFromFile(r, excludesfile);
+ }
+
+ File exclude = fs
+ .resolve(repository.getDirectory(), "info/exclude");
+ loadRulesFromFile(r, exclude);
+
+ return r.getRules().isEmpty() ? null : r;
+ }
+
+ private void loadRulesFromFile(IgnoreNode r, File exclude)
+ throws FileNotFoundException, IOException {
if (exclude.exists()) {
FileInputStream in = new FileInputStream(exclude);
try {
@@ -906,8 +929,6 @@ public abstract class WorkingTreeIterator extends AbstractTreeIterator {
in.close();
}
}
-
- return r.getRules().isEmpty() ? null : r;
}
}