From: Matthias Sohn Date: Mon, 19 Aug 2019 22:10:01 +0000 (+0200) Subject: Merge branch 'stable-5.3' into stable-5.4 X-Git-Tag: v5.4.1.201908211225-r~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=35d99477b81043f24314c4c84da8f29e601bec19;p=jgit.git Merge branch 'stable-5.3' into stable-5.4 * stable-5.3: Fix NPE in RebaseTodoFile#parseComments Fix NPE in ObjectIdOwnerMap#get Fix NPE in CommitOnlyTest#getHead FileUtils#lastModifiedInstant should not log error if path doesn't exist Cache user global and system-wide git configurations Avoid setup and saving FileStoreAttributes compete for ~/.gitconfig lock Add missing dependencies for running FS_POSIXTest in Eclipse Fix javadoc for SystemReader#getInstance Improve retry handling when saving FileStoreAttributes fails Ensure FSTest uses MockSystemReader Make supportsAtomicCreateNewFile return true as default Update orbit to R20190602212107-2019-06 to enable backports from master Handle InvalidPathException in FS_POSIX#createNewFileAtomic Ensure root cause of lock creation failures is logged Implement toString in MockSystemReader and MockConfig LocalDiskRefTreeDatabaseTest shall use MockSystemReader Ensure LocalDiskRepositoryTestCase#setup fully uses MockSystemReader Ensure we use MockSystemReader in tests Override FileBasedConfig's save method in MockConfig Remove FileBasedConfig.load(boolean) introduced in d45219ba Disable debug log for FS in org.eclipse.jgit.test Bazel: enable logging for tests in org.eclipse.jgit.test LockFile: log exception if creation of lock file failed Stop using deprecated Constants.CHARACTER_ENCODING Change-Id: I43c2ab8b44c3e87d48e4072907ad169c81e3ffe0 Signed-off-by: Matthias Sohn --- 35d99477b81043f24314c4c84da8f29e601bec19 diff --cc org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java index 54c1c03b50,017e2c7aa3..8b85bef305 --- a/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java +++ b/org.eclipse.jgit.http.test/tst/org/eclipse/jgit/http/test/SmartClientSmartServerTest.java @@@ -124,7 -123,9 +123,6 @@@ import org.eclipse.jgit.transport.Usern import org.eclipse.jgit.transport.http.HttpConnectionFactory; import org.eclipse.jgit.transport.http.JDKHttpConnectionFactory; import org.eclipse.jgit.transport.http.apache.HttpClientConnectionFactory; - import org.eclipse.jgit.util.FS; -import org.eclipse.jgit.transport.resolver.ServiceNotAuthorizedException; -import org.eclipse.jgit.transport.resolver.ServiceNotEnabledException; -import org.eclipse.jgit.transport.resolver.UploadPackFactory; import org.eclipse.jgit.util.HttpSupport; import org.eclipse.jgit.util.SystemReader; import org.hamcrest.Matchers; diff --cc org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target index 1915747206,86653bef02..36660ff3e6 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target @@@ -1,7 -1,7 +1,7 @@@ - - ++ diff --cc org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.target index e5ea33101f,0000000000..afa4b3da2c mode 100644,000000..100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.target @@@ -1,92 -1,0 +1,92 @@@ + + + - ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - ++ ++ ++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --cc org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12-staging.target index 5daa8e8ad5,0000000000..92c9a88366 mode 100644,000000..100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12-staging.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12-staging.target @@@ -1,92 -1,0 +1,92 @@@ + + + - ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - ++ ++ ++ ++ ++ ++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --cc org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target index 0638b46a34,05488b9c3d..9724939f8a --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target @@@ -1,7 -1,7 +1,7 @@@ - - ++ diff --cc org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target index 1044299df5,e82222a0c5..6bd70e0160 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target @@@ -1,7 -1,7 +1,7 @@@ - - ++ diff --cc org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target index a5f948fdee,0b353db260..e33ece710a --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target @@@ -1,7 -1,7 +1,7 @@@ - - ++ diff --cc org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target index e0afda3a6e,94a752c74c..9b3fe1b930 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target @@@ -1,7 -1,7 +1,7 @@@ - - ++ diff --cc org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20190602212107-2019-06.tpd index df9a810e07,65d5c9f1f5..db674493b5 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20190602212107-2019-06.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20190602212107-2019-06.tpd @@@ -57,8 -57,8 +57,9 @@@ location "https://download.eclipse.org/ com.jcraft.jzlib.source [1.1.1.v201205102305,1.1.1.v201205102305] net.i2p.crypto.eddsa [0.3.0.v20181102-1323,0.3.0.v20181102-1323] net.i2p.crypto.eddsa.source [0.3.0.v20181102-1323,0.3.0.v20181102-1323] - org.apache.sshd.core [2.0.0.v20181102-1323,2.0.0.v20181102-1323] - org.apache.sshd.core.source [2.0.0.v20181102-1323,2.0.0.v20181102-1323] - org.apache.sshd.sftp [2.0.0.v20181102-1323,2.0.0.v20181102-1323] - org.apache.sshd.sftp.source [2.0.0.v20181102-1323,2.0.0.v20181102-1323] + org.apache.sshd.osgi [2.2.0.v20190425-2127,2.2.0.v20190425-2127] + org.apache.sshd.osgi.source [2.2.0.v20190425-2127,2.2.0.v20190425-2127] + org.apache.sshd.sftp [2.2.0.v20190425-2127,2.2.0.v20190425-2127] + org.apache.sshd.sftp.source [2.2.0.v20190425-2127,2.2.0.v20190425-2127] } ++ diff --cc org.eclipse.jgit/.settings/.api_filters index 2f6d2fa1d0,bb37dd8c8a..5ca7c0f664 --- a/org.eclipse.jgit/.settings/.api_filters +++ b/org.eclipse.jgit/.settings/.api_filters @@@ -48,14 -62,62 +48,6 @@@ - - - - - - - - - - - - - - -- -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -- -- -- diff --cc org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties index 34faf31042,91136620c4..a10d1d7ed9 --- a/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties +++ b/org.eclipse.jgit/resources/org/eclipse/jgit/internal/JGitText.properties @@@ -635,7 -632,7 +639,8 @@@ rewinding=Rewinding to commit {0 s3ActionDeletion=Deletion s3ActionReading=Reading s3ActionWriting=Writing +searchForReachableBranches=Finding reachable branches + saveFileStoreAttributesFailed=Saving measured FileStore attributes to user config failed searchForReuse=Finding sources searchForSizes=Getting sizes secondsAgo={0} seconds ago diff --cc org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java index 37918500a7,039a6b2b43..cd50e347ab --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/JGitText.java @@@ -696,7 -693,7 +700,8 @@@ public class JGitText extends Translati /***/ public String s3ActionDeletion; /***/ public String s3ActionReading; /***/ public String s3ActionWriting; + /***/ public String saveFileStoreAttributesFailed; + /***/ public String searchForReachableBranches; /***/ public String searchForReuse; /***/ public String searchForSizes; /***/ public String secondsAgo; diff --cc org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/FileRepository.java index 90772970ae,356d64b563..4f5f8a613e --- 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 @@@ -199,12 -190,14 +188,9 @@@ public class FileRepository extends Rep repoConfig = new FileBasedConfig(userConfig, getFS().resolve( getDirectory(), Constants.CONFIG), getFS()); - - loadSystemConfig(); - loadUserConfig(); loadRepoConfig(); - repoConfig.addChangeListener(new ConfigChangedListener() { - @Override - public void onConfigChanged(ConfigChangedEvent event) { - fireEvent(event); - } - }); + repoConfig.addChangeListener(this::fireEvent); final long repositoryFormatVersion = getConfig().getLong( ConfigConstants.CONFIG_CORE_SECTION, null, diff --cc org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java index 10b00b77a0,bdbd7c9072..5bb8153a58 --- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/FileBasedConfig.java @@@ -148,28 -148,7 +148,8 @@@ public class FileBasedConfig extends St */ @Override public void load() throws IOException, ConfigInvalidException { - load(true); - } - - /** - * Load the configuration as a Git text style configuration file. - *

- * If the file does not exist, this configuration is cleared, and thus - * behaves the same as though the file exists, but is empty. - * - * @param useFileSnapshotWithConfig - * if {@code true} use the FileSnapshot with config, otherwise - * use it without config - * @throws IOException - * if IO failed - * @throws ConfigInvalidException - * if config is invalid - * @since 5.1.9 - */ - public void load(boolean useFileSnapshotWithConfig) - throws IOException, ConfigInvalidException { - final int maxStaleRetries = 5; + final int maxRetries = 5; + int retryDelayMillis = 20; int retries = 0; while (true) { final FileSnapshot oldSnapshot = snapshot; diff --cc org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java index 6ec50c24e0,eda0fae247..a485389a9a --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java @@@ -48,9 -51,10 +51,11 @@@ import java.io.IOException import java.io.InputStreamReader; import java.io.PrintStream; import java.nio.charset.Charset; -import java.nio.file.AccessDeniedException; + import java.nio.file.FileAlreadyExistsException; +import java.nio.file.FileStore; +import java.nio.file.FileSystemException; import java.nio.file.Files; + import java.nio.file.InvalidPathException; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.PosixFilePermission; @@@ -87,9 -88,9 +91,9 @@@ public class FS_POSIX extends FS private static final int DEFAULT_UMASK = 0022; private volatile int umask = -1; - private volatile boolean supportsUnixNLink = true; + private static final Map CAN_HARD_LINK = new ConcurrentHashMap<>(); - private volatile AtomicFileCreation supportsAtomicCreateNewFile = AtomicFileCreation.UNDEFINED; + private volatile AtomicFileCreation supportsAtomicFileCreation = AtomicFileCreation.UNDEFINED; private enum AtomicFileCreation { SUPPORTED, NOT_SUPPORTED, UNDEFINED @@@ -459,26 -432,18 +446,29 @@@ */ @Override public LockToken createNewFileAtomic(File file) throws IOException { - if (!file.createNewFile()) { + Path path; + try { + path = file.toPath(); + Files.createFile(path); + } catch (FileAlreadyExistsException | InvalidPathException e) { return token(false, null); } - if (supportsAtomicCreateNewFile() || !supportsUnixNLink) { + if (supportsAtomicCreateNewFile()) { return token(true, null); } Path link = null; - Path path = file.toPath(); + FileStore store = null; try { + store = Files.getFileStore(path); + } catch (SecurityException e) { + return token(true, null); + } + try { + Boolean canLink = CAN_HARD_LINK.computeIfAbsent(store, + s -> Boolean.TRUE); + if (Boolean.FALSE.equals(canLink)) { + return token(true, null); + } link = Files.createLink(Paths.get(uniqueLinkPath(file)), path); Integer nlink = (Integer) (Files.getAttribute(path, "unix:nlink")); //$NON-NLS-1$