]> source.dussan.org Git - jgit.git/commitdiff
Do not prematurely create directory of jgit's XDG config file 96/168096/2
authorMatthias Sohn <matthias.sohn@sap.com>
Sat, 22 Aug 2020 19:19:57 +0000 (21:19 +0200)
committerThomas Wolf <thomas.wolf@paranor.ch>
Sat, 22 Aug 2020 20:57:14 +0000 (22:57 +0200)
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>
org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties
org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java
org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java

index 70883352ba65d37ab50cc4a4bad786a0c05b5722..4eee09faff956e793ee35d9b8bf7d8d897fd7646 100644 (file)
@@ -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}
index 0e35a9947b9a09ba135a019695d88fa46f13b364..583a386f148be36042605b632656ccea953969ae 100644 (file)
@@ -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;
index bcb8380625280ec9901c2d9414f079bf203d1359..447f417e7e611a8200ad1d76927b4c6bd8db3cd1 100644 (file)
@@ -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$