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);
}
/**
public boolean isLogAllRefUpdates() {
return logAllRefUpdates;
}
+
+ /**
+ * @return path of excludesfile
+ */
+ public String getExcludesFile() {
+ return excludesfile;
+ }
}
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;
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;
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 {
in.close();
}
}
-
- return r.getRules().isEmpty() ? null : r;
}
}