summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2020-08-22 21:19:57 +0200
committerThomas Wolf <thomas.wolf@paranor.ch>2020-08-22 22:57:14 +0200
commite9c7ba6fdccf64b16fdadd74106175f95454ec4f (patch)
treec42bdfc4716332b99cb97b1b70a044c11759bac3
parentb6ca1993b089fc35128009b39996ebd2ec9d79db (diff)
downloadjgit-e9c7ba6fdccf64b16fdadd74106175f95454ec4f.tar.gz
jgit-e9c7ba6fdccf64b16fdadd74106175f95454ec4f.zip
Do not prematurely create directory of jgit's XDG config file
LockFile.lock() will create it anyway when the config file is created. Bug: 565637 Change-Id: I078b89a695193fd76f130f6de7ac1cf26d2f8f0f Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
-rw-r--r--org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java3
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java22
3 files changed, 8 insertions, 20 deletions
diff --git a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
index 70883352ba..4eee09faff 100644
--- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
+++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
@@ -202,10 +202,8 @@ countingObjects=Counting objects
corruptPack=Pack file {0} is corrupt, removing it from pack list
createBranchFailedUnknownReason=Create branch failed for unknown reason
createBranchUnexpectedResult=Create branch returned unexpected result {0}
-createJGitConfigFailed=Creating JGit config directory {} failed
createNewFileFailed=Could not create new file {0}
createRequiresZeroOldId=Create requires old ID to be zero
-createXDGConfigHomeFailed=Creating XDG_CONFIG_HOME directory {} failed
credentialPassword=Password
credentialPassphrase=Passphrase
credentialUsername=Username
@@ -410,6 +408,7 @@ lockError=lock error: {0}
lockFailedRetry=locking {0} failed after {1} retries
lockOnNotClosed=Lock on {0} not closed.
lockOnNotHeld=Lock on {0} not held.
+logXDGConfigHomeInvalid=Environment variable XDG_CONFIG_HOME contains an invalid path {}
maxCountMustBeNonNegative=max count must be >= 0
mergeConflictOnNonNoteEntries=Merge conflict on non-note entries: base = {0}, ours = {1}, theirs = {2}
mergeConflictOnNotes=Merge conflict on note {0}. base = {1}, ours = {2}, theirs = {2}
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
index 0e35a9947b..583a386f14 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
@@ -230,10 +230,8 @@ public class JGitText extends TranslationBundle {
/***/ public String countingObjects;
/***/ public String createBranchFailedUnknownReason;
/***/ public String createBranchUnexpectedResult;
- /***/ public String createJGitConfigFailed;
/***/ public String createNewFileFailed;
/***/ public String createRequiresZeroOldId;
- /***/ public String createXDGConfigHomeFailed;
/***/ public String credentialPassword;
/***/ public String credentialPassphrase;
/***/ public String credentialUsername;
@@ -438,6 +436,7 @@ public class JGitText extends TranslationBundle {
/***/ public String lockFailedRetry;
/***/ public String lockOnNotClosed;
/***/ public String lockOnNotHeld;
+ /***/ public String logXDGConfigHomeInvalid;
/***/ public String maxCountMustBeNonNegative;
/***/ public String mergeConflictOnNonNoteEntries;
/***/ public String mergeConflictOnNotes;
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
index bcb8380625..447f417e7e 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java
@@ -17,7 +17,6 @@ import java.io.File;
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
-import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -116,11 +115,9 @@ public abstract class SystemReader {
.getAbsolutePath();
}
try {
- Path xdgHomePath = Paths.get(configHomePath);
- Files.createDirectories(xdgHomePath);
- return xdgHomePath;
- } catch (IOException | InvalidPathException e) {
- LOG.error(JGitText.get().createXDGConfigHomeFailed,
+ return Paths.get(configHomePath);
+ } catch (InvalidPathException e) {
+ LOG.error(JGitText.get().logXDGConfigHomeInvalid,
configHomePath, e);
}
return null;
@@ -130,16 +127,9 @@ public abstract class SystemReader {
public FileBasedConfig openJGitConfig(Config parent, FS fs) {
Path xdgPath = getXDGConfigHome(fs);
if (xdgPath != null) {
- Path configPath = null;
- try {
- configPath = xdgPath.resolve("jgit"); //$NON-NLS-1$
- Files.createDirectories(configPath);
- configPath = configPath.resolve(Constants.CONFIG);
- return new FileBasedConfig(parent, configPath.toFile(), fs);
- } catch (IOException e) {
- LOG.error(JGitText.get().createJGitConfigFailed, configPath,
- e);
- }
+ Path configPath = xdgPath.resolve("jgit") //$NON-NLS-1$
+ .resolve(Constants.CONFIG);
+ return new FileBasedConfig(parent, configPath.toFile(), fs);
}
return new FileBasedConfig(parent,
new File(fs.userHome(), ".jgitconfig"), fs); //$NON-NLS-1$