aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Rosenberg <robin.rosenberg@dewire.com>2014-01-06 18:42:15 +0100
committerRobin Rosenberg <robin.rosenberg@dewire.com>2014-01-06 18:49:37 +0100
commited7e1eff07787e847e460f75cd82ba546b6d0655 (patch)
treed77e5d0bbed4e092f1e8d2e8551ead41350b5323
parentb0d9c57f35f46910975a5a461f773175fba968c5 (diff)
downloadjgit-ed7e1eff07787e847e460f75cd82ba546b6d0655.tar.gz
jgit-ed7e1eff07787e847e460f75cd82ba546b6d0655.zip
Suppport the GIT_CONFIG_NOSYSTEM environment variable
Change-Id: If3cc05931683d396b5ae2ea8952adceeb9a82ab9
-rw-r--r--org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java6
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java18
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java3
3 files changed, 25 insertions, 2 deletions
diff --git a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
index 0ec5c1e148..8569e9278e 100644
--- a/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
+++ b/org.eclipse.jgit.pgm/src/org/eclipse/jgit/pgm/Config.java
@@ -47,6 +47,7 @@ import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.util.FS;
+import org.eclipse.jgit.util.StringUtils;
import org.eclipse.jgit.util.SystemReader;
import org.kohsuke.args4j.Option;
@@ -82,7 +83,10 @@ class Config extends TextBuiltin {
list(new FileBasedConfig(configFile, fs));
return;
}
- if (system || isListAll())
+ if (system
+ || (isListAll() && StringUtils.isEmptyOrNull(SystemReader
+ .getInstance()
+ .getenv(Constants.GIT_CONFIG_NOSYSTEM_KEY))))
list(SystemReader.getInstance().openSystemConfig(null, fs));
if (global || isListAll())
list(SystemReader.getInstance().openUserConfig(null, fs));
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
index d0c470988a..33026aad72 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java
@@ -72,7 +72,9 @@ import org.eclipse.jgit.lib.ReflogReader;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.storage.file.FileBasedConfig;
import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.util.FS;
import org.eclipse.jgit.util.FileUtils;
+import org.eclipse.jgit.util.StringUtils;
import org.eclipse.jgit.util.SystemReader;
/**
@@ -162,7 +164,21 @@ public class FileRepository extends Repository {
public FileRepository(final BaseRepositoryBuilder options) throws IOException {
super(options);
- systemConfig = SystemReader.getInstance().openSystemConfig(null, getFS());
+ if (StringUtils.isEmptyOrNull(SystemReader.getInstance().getenv(
+ Constants.GIT_CONFIG_NOSYSTEM_KEY)))
+ systemConfig = SystemReader.getInstance().openSystemConfig(null,
+ getFS());
+ else
+ systemConfig = new FileBasedConfig(null, FS.DETECTED) {
+ public void load() {
+ // empty, do not load
+ }
+
+ public boolean isOutdated() {
+ // regular class would bomb here
+ return false;
+ }
+ };
userConfig = SystemReader.getInstance().openUserConfig(systemConfig,
getFS());
repoConfig = new FileBasedConfig(userConfig, getFS().resolve(
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
index 058addf8ac..d9d04bd082 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/Constants.java
@@ -287,6 +287,9 @@ public final class Constants {
/** The environment variable that contains the commiter's email */
public static final String GIT_COMMITTER_EMAIL_KEY = "GIT_COMMITTER_EMAIL";
+ /** The environment variable that blocks use of the system config file */
+ public static final String GIT_CONFIG_NOSYSTEM_KEY = "GIT_CONFIG_NOSYSTEM";
+
/**
* The environment variable that limits how close to the root of the file
* systems JGit will traverse when looking for a repository root.