Browse Source

Merge branch 'stable-5.2' into stable-5.3

* stable-5.2:
  Prepare 5.1.11-SNAPSHOT builds
  JGit v5.1.10.201908230655-r
  Use AtomicReferences to cache user and system level configs
  Fix copy-paste typo in CloneCommand#cleanup

Change-Id: I3ababc0f9b540cf1785925395d32a85d30aed40d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.3
Matthias Sohn 5 years ago
parent
commit
6dfdfe1f67
  1. 2
      org.eclipse.jgit.lfs.server/.settings/.api_filters
  2. 2
      org.eclipse.jgit.lfs/.settings/.api_filters
  3. 2
      org.eclipse.jgit/.settings/.api_filters
  4. 2
      org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java
  5. 47
      org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java

2
org.eclipse.jgit.lfs.server/.settings/.api_filters

@ -3,7 +3,7 @@
<resource path="META-INF/MANIFEST.MF"> <resource path="META-INF/MANIFEST.MF">
<filter id="924844039"> <filter id="924844039">
<message_arguments> <message_arguments>
<message_argument value="5.3.3"/> <message_argument value="5.3.4"/>
<message_argument value="5.3.0"/> <message_argument value="5.3.0"/>
</message_arguments> </message_arguments>
</filter> </filter>

2
org.eclipse.jgit.lfs/.settings/.api_filters

@ -3,7 +3,7 @@
<resource path="META-INF/MANIFEST.MF"> <resource path="META-INF/MANIFEST.MF">
<filter id="924844039"> <filter id="924844039">
<message_arguments> <message_arguments>
<message_argument value="5.3.3"/> <message_argument value="5.3.4"/>
<message_argument value="5.3.0"/> <message_argument value="5.3.0"/>
</message_arguments> </message_arguments>
</filter> </filter>

2
org.eclipse.jgit/.settings/.api_filters

@ -3,7 +3,7 @@
<resource path="META-INF/MANIFEST.MF"> <resource path="META-INF/MANIFEST.MF">
<filter id="924844039"> <filter id="924844039">
<message_arguments> <message_arguments>
<message_argument value="5.3.3"/> <message_argument value="5.3.4"/>
<message_argument value="5.3.0"/> <message_argument value="5.3.0"/>
</message_arguments> </message_arguments>
</filter> </filter>

2
org.eclipse.jgit/src/org/eclipse/jgit/api/CloneCommand.java

@ -713,7 +713,7 @@ public class CloneCommand extends TransportCommand<CloneCommand, Git> {
FileUtils.delete(gitDir, FileUtils.RECURSIVE FileUtils.delete(gitDir, FileUtils.RECURSIVE
| FileUtils.SKIP_MISSING | FileUtils.IGNORE_ERRORS); | FileUtils.SKIP_MISSING | FileUtils.IGNORE_ERRORS);
} else { } else {
deleteChildren(directory); deleteChildren(gitDir);
} }
} }
} catch (IOException e) { } catch (IOException e) {

47
org.eclipse.jgit/src/org/eclipse/jgit/util/SystemReader.java

@ -56,6 +56,7 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale; import java.util.Locale;
import java.util.TimeZone; import java.util.TimeZone;
import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jgit.errors.ConfigInvalidException; import org.eclipse.jgit.errors.ConfigInvalidException;
import org.eclipse.jgit.errors.CorruptObjectException; import org.eclipse.jgit.errors.CorruptObjectException;
@ -97,9 +98,9 @@ public abstract class SystemReader {
private static class Default extends SystemReader { private static class Default extends SystemReader {
private volatile String hostname; private volatile String hostname;
private volatile FileBasedConfig systemConfig; private AtomicReference<FileBasedConfig> systemConfig = new AtomicReference<>();
private volatile FileBasedConfig userConfig; private volatile AtomicReference<FileBasedConfig> userConfig = new AtomicReference<>();
@Override @Override
public String getenv(String variable) { public String getenv(String variable) {
@ -113,10 +114,13 @@ public abstract class SystemReader {
@Override @Override
public FileBasedConfig openSystemConfig(Config parent, FS fs) { public FileBasedConfig openSystemConfig(Config parent, FS fs) {
if (systemConfig == null) { FileBasedConfig c = systemConfig.get();
systemConfig = createSystemConfig(parent, fs); if (c == null) {
systemConfig.compareAndSet(null,
createSystemConfig(parent, fs));
c = systemConfig.get();
} }
return systemConfig; return c;
} }
protected FileBasedConfig createSystemConfig(Config parent, FS fs) { protected FileBasedConfig createSystemConfig(Config parent, FS fs) {
@ -142,40 +146,35 @@ public abstract class SystemReader {
@Override @Override
public FileBasedConfig openUserConfig(Config parent, FS fs) { public FileBasedConfig openUserConfig(Config parent, FS fs) {
if (userConfig == null) { FileBasedConfig c = userConfig.get();
File home = fs.userHome(); if (c == null) {
userConfig = new FileBasedConfig(parent, userConfig.compareAndSet(null, new FileBasedConfig(parent,
new File(home, ".gitconfig"), fs); //$NON-NLS-1$ new File(fs.userHome(), ".gitconfig"), fs)); //$NON-NLS-1$
c = userConfig.get();
} }
return userConfig; return c;
} }
@Override @Override
public StoredConfig getSystemConfig() public StoredConfig getSystemConfig()
throws IOException, ConfigInvalidException { throws IOException, ConfigInvalidException {
if (systemConfig == null) { FileBasedConfig c = openSystemConfig(null, FS.DETECTED);
systemConfig = createSystemConfig(null, FS.DETECTED); if (c.isOutdated()) {
}
if (systemConfig.isOutdated()) {
LOG.debug("loading system config {}", systemConfig); //$NON-NLS-1$ LOG.debug("loading system config {}", systemConfig); //$NON-NLS-1$
systemConfig.load(); c.load();
} }
return systemConfig; return c;
} }
@Override @Override
public StoredConfig getUserConfig() public StoredConfig getUserConfig()
throws IOException, ConfigInvalidException { throws IOException, ConfigInvalidException {
if (userConfig == null) { FileBasedConfig c = openUserConfig(getSystemConfig(), FS.DETECTED);
userConfig = openUserConfig(getSystemConfig(), FS.DETECTED); if (c.isOutdated()) {
} else {
getSystemConfig();
}
if (userConfig.isOutdated()) {
LOG.debug("loading user config {}", userConfig); //$NON-NLS-1$ LOG.debug("loading user config {}", userConfig); //$NON-NLS-1$
userConfig.load(); c.load();
} }
return userConfig; return c;
} }
@Override @Override

Loading…
Cancel
Save