aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
Commit message (Collapse)AuthorAgeFilesLines
* FS, FS_Posix: remove deprecated #createNewFile(File) methodMatthias Sohn2024-09-031-67/+0
| | | | Change-Id: Id34a0be998eee360e69f74b469c4990afa153c1b
* Check an execution bit by reading it from the file systemYury Molchan2024-05-131-2/+11
| | | | | | | | Files.isExecutable() checks possibility to execute a file from the JVM, not POSIX attributes. So it fails when Java Security Manager does not allow to execute a file, but file has X-bit. Change-Id: I85b96fb6cedbaff1b3c063728c25b6ce4d04e9b9
* FS_POSIX.runInShell(): on MacOS use a login shellThomas Wolf2024-03-091-1/+5
| | | | | | | | | | | | | | On Mac, $PATH for UI programs is not the same as in a shell (terminal). It is typically much shorter. This may lead to surprises when hooks that work fine via the command-line git do not work when run via JGit in a UI application, such as EGit in Eclipse. Therefore use a login shell to run hooks and other commands spawned by git if we're on MacOS. This will give the hooks the same environment as in a terminal. Bug: egit-16 Change-Id: Id2e5485c6d3080d3ef8baa61ad7f6f198f77c590 Signed-off-by: Thomas Wolf <twolf@apache.org>
* [errorprone] Remove unnecessary parenthesesMatthias Sohn2023-09-221-4/+3
| | | | | | see https://errorprone.info/bugpattern/UnnecessaryParentheses Change-Id: Id08cf0e05b3d35f139fc34e0aa83882555a8a81a
* Fix all Javadoc warnings and fail on themAntoine Musso2023-06-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes all the javadoc warnings, stops ignoring doclint 'missing' category and fails the build on javadoc warnings for public and protected classes and class members. Since javadoc doesn't allow access specifiers when specifying doclint configuration we cannot set `-Xdoclint:all,-missing/private` hence there is no simple way to skip private elements from doclint. Therefore we check javadoc using the Eclipse Java compiler (which is used by default) and javadoc configuration in `.settings/org.eclipse.jdt.core.prefs` files. This allows more fine grained configuration. We can reconsider this when javadoc starts supporting access specifiers in the doclint configuration. Below are detailled explanations for most modifications. @inheritDoc =========== doclint complains about explicits `{@inheritDoc}` when the parent does not have any documentation. As far as I can tell, javadoc defaults to inherit comments and should only be used when one wants to append extra documentation from the parent. Given the parent has no documentation, remove those usages which doclint complains about. In some case I have moved up the documentation from the concrete class up to the abstract class. Remove `{@inheritDoc}` on overriden methods which don't add additional documentation since javadoc defaults to inherit javadoc of overridden methods. @value to @link =============== In PackConfig, DEFAULT_SEARCH_FOR_REUSE_TIMEOUT and similar are forged from Integer.MAX_VALUE and are thus not considered constants (I guess cause the value would depends on the platform). Replace it with a link to `Integer.MAX_VALUE`. In `StringUtils.toBoolean`, @value was used to refer to the `stringValue` parameter. I have replaced it with `{@code stringValue}`. {@link <url>} to <a> ==================== @link does not support being given an external URL. Replaces them with HTML `<a>`. @since: being invalid ===================== org.eclipse.jgit/src/org/eclipse/jgit/util/Equality.java has an invalid tag `@since: ` due to the extra `:`. Javadoc does not complain about it with version 11.0.18+10 but does with 11.0.19.7. It is invalid regardless. invalid HTML syntax =================== - javadoc doesn't allow <br/>, <p/> and </p> anymore, use <br> and <p> instead - replace <tt>code</tt> by {@code code} - <table> tags don't allow summary attribute, specify caption as <caption>caption</caption> to fix this doclint visibility issue ======================== In the private abstract classes `BaseDirCacheEditor` and `BasePackConnection` links to other methods in the abstract class are inherited in the public subclasses but doclint gets confused and considers them unreachable. The HTML documentation for the sub classes shows the relative links in the sub classes, so it is all correct. It must be a bug somewhere in javadoc. Mute those warnings with: @SuppressWarnings("doclint:missing") Misc ==== Replace `<` and `>` with HTML encoded entities (`&lt; and `&gt;`). In `SshConstants` I went enclosing a serie of -> arrows in @literal. Additional tags =============== Configure maven-javad0c-plugin to allow the following additional tags defined in https://openjdk.org/jeps/8068562: - apiNote - implSpec - implNote Missing javadoc =============== Add missing @params and descriptions Change-Id: I840056389aa59135cfb360da0d5e40463ce35bd0 Also-By: Matthias Sohn <matthias.sohn@sap.com>
* Don't rely on an implicit default character setThomas Wolf2021-10-261-5/+6
| | | | | | | | | | | | | JEP 400 (Java 18) will change the default character set to UTF-8 unconditionally.[1] Introduce SystemReader.getDefaultCharset() that provides the locale-dependent charset the way JEP 400 recommends. Change all code locations using Charset.defaultCharset() to use the new SystemReader method instead. [1] https://openjdk.java.net/jeps/400 Change-Id: I986f97a410d2fc70748b6f93228a2d45ff100b2c Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* GitHook: use generic OutputStream instead of PrintStreamMatthias Sohn2021-02-151-2/+2
| | | | Change-Id: I15e64dc963c9d27dc9c8de4976dd63f74b918b15 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* FS_POSIX: avoid prompt to install the XCode tools on OS XThomas Wolf2020-07-261-7/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | OS X ships with a default /usr/bin/git that is just a wrapper that at run-time delegates to the selected XCode toolchain, and that prompts the user to install the XCode command line tools if not already installed. This is annoying for people who don't want to do so, since they'll be prompted on each Eclipse start. Also, since on OS X the $PATH for applications started via the GUI is not the same as the $PATH as set via the shell profile, just using /usr/bin/git (which will normally be found when JGit runs inside Eclipse) may give slightly surprising results if the user has installed a non-Apple git and changed his $PATH in the shell such that the non-Apple git is used in the shell. (For instance by placing /usr/local/bin earlier on the path.) Eclipse and the shell will use different git executables, and thus different git system configs. Therefore, try to find git via bash --login -c 'which git' not only if we couldn't find it on $PATH but also if we found the default git /usr/bin/git. If that finds some other git, use that. If the bash approach also finds /usr/bin/git, double check via xcode-select -p that an XCode git is present. If not, assume there is no git installed, and work without any system config. Bug: 564372 Change-Id: Ie9d010ebd9437a491ba5d92b4ffd1860c203f8ca Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Merge branch 'stable-5.6' into stable-5.7Thomas Wolf2020-04-031-1/+6
|\ | | | | | | | | | | | | | | * stable-5.6: FS.runInShell(): handle quoted filters and hooksPath containing blanks Handle non-normalized index also for executable files Change-Id: I240377e87c073ee7a621a88e39fc319c59fa037a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
| * FS.runInShell(): handle quoted filters and hooksPath containing blanksThomas Wolf2020-04-031-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Revert commit 2323d7a. Using $0 in the shell command call results in the command string being taken literally. That was introduced to fix a problem with backslashes, but is actually not correct. First, the problem with backslashes occurred only on Win32/Cygwin, and has been properly fixed in commit 6f268f8. Second, this is used only for hooks (which don't have backslashes in their names) and filter commands from the git config, where the user is responsible for properly quoting or escaping such that the commands work. Third, using $0 actually breaks correctly quoted filter commands like in the bug report. The shell really takes the command literally, and then doesn't find the command because of quotes. So revert this change. At the same time there's a related problem with hooks. If the path to the hook contains blanks, runInShell() would also fail to find the hook. In this case, the command doesn't come from user input but is just a Java File object with an absolute path containing blanks. (Can occur if core.hooksPath points to such a path with blanks, or if the repository has such a path.) The path to the hook as obtained from the file system must be quoted. Add a test for a hook path with a blank. This reverts commit 2323d7a1ef909f9deb3f21329cf30bd1173ee9cf. Bug: 561666 Change-Id: I4d7df13e6c9b245fe1706e191e4316685a8a9d59 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | Merge branch 'stable-5.6'Matthias Sohn2020-02-221-1/+1
|\| | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.6: Revert "Prepend hostname to subsection used to store file timestamp resolution" SimilarityRenameDetector: Fix inconsistent indentation Use indexOf(char) and lastIndexOf(char) rather than String versions Reorder modifiers to follow Java Language Specification GitmoduleEntry: Remove redundant import of class from same package Remove redundant "static" qualifier from enum declarations Change-Id: Ibb66bef7e8373f81e3e653c9843d986243446d68 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Reorder modifiers to follow Java Language SpecificationDavid Pursehouse2020-02-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Java Language Specification recommends listing modifiers in the following order: 1. Annotations 2. public 3. protected 4. private 5. abstract 6. static 7. final 8. transient 9. volatile 10. synchronized 11. native 12. strictfp Not following this convention has no technical impact, but will reduce the code's readability because most developers are used to the standard order. This was detected using SonarLint. Change-Id: I9cddecb4f4234dae1021b677e915be23d349a380 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Update EDL 1.0 license headers to new short SPDX compliant formatMatthias Sohn2020-01-041-38/+5
|/ | | | | | | | | | This is the format given by the Eclipse legal doc generator [1]. [1] https://www.eclipse.org/projects/tools/documentation.php?id=technology.jgit Bug: 548298 Change-Id: I8d8cabc998ba1b083e3f0906a8d558d391ffb6c4 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Hooks: avoid problems with backslashes in pathsThomas Wolf2019-12-241-1/+1
| | | | | | | | | | | | | | | | | | | | | Calling sh -c with a script path containing backslashes may fail since the shell may try to process them as escape characters. Instead of calling sh.exe -c 'C:\path\script "$@"' 'C:\path\script' other args call sh.exe -c '$0 "$@"' 'C:\path\script' other args which avoids this escape processing. Note that this is not specific to Windows. If the path or the script name contain backslashes, this also occurs on Unix. Bug: 558577 Change-Id: I47d63db6f8644f956c55c42b07dbcad7d7f305aa Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Support for core.hooksPathThomas Wolf2019-10-211-15/+0
| | | | | | | | | Support the core.hooksPath git config. This can be an absolute or relative path of a directory where to find git hooks; a relative path is resolved relative to the directory the hook will run in. Bug: 500266 Change-Id: I671999a6386a837e897c31718583c91d8035f3ba Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Fix error occurring when SecurityManager is enabledNail Samatov2019-08-231-6/+0
| | | | | | | | | | | | | | | | It's expected that jgit should work without native git installation. In such case Security Manager can be configured to deny access to the files outside of git repository. JGit tries to find cygwin installation. If Security manager restricts access to some folders in PATH, it should be considered that those folders are absent for jgit. Also JGit tries to detect if symbolic links are supported by OS. If security manager forbids creation of symlinks, it should be assumed that symlinks aren't supported. Bug: 550115 Change-Id: Ic4b243cada604bc1090db6cc1cfd74f0fa324b98 Signed-off-by: Nail Samatov <sanail@yandex.ru>
* Merge branch 'stable-5.3' into stable-5.4Matthias Sohn2019-08-201-40/+30
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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 <matthias.sohn@sap.com>
| * Merge branch 'stable-5.2' into stable-5.3Matthias Sohn2019-08-191-40/+30
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-5.2: 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: If0c5010a2cf151ebebb2f2088fac3ee02c5007b9 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Cache user global and system-wide git configurationsMatthias Sohn2019-08-181-42/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | So far the git configuration and the system wide git configuration were always reloaded when jgit accessed these global configuration files to access global configuration options which are not in the context of a single git repository. Cache these configurations in SystemReader and only reload them if their file metadata observed using FileSnapshot indicates a modification. Change-Id: I092fe11a5d95f1c5799273cacfc7a415d0b7786c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
| | * Make supportsAtomicCreateNewFile return true as defaultVishal Devgire2019-08-121-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The method org.eclipse.jgit.util.FS.supportsAtomicCreateNewFile() should default to true as mentioned in docs [1] org.eclipse.jgit.util.FS_POSIX.supportsAtomicCreateNewFile() method will set the value to false if the git config core.supportsatomiccreatenewfile is not set. It should default to true if the configuration is undefined. [1] https://github.com/eclipse/jgit/blob/4169a95a65683e39e7a6a8f2b11b543e2bc754db/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java#L372 Bug: 544164 Change-Id: I16ccf989a89da2cf4975c200b3228b25ba4c0d55 Signed-off-by: Vishal Devgire <vishaldevgire@gmail.com> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Handle InvalidPathException in FS_POSIX#createNewFileAtomicMatthias Sohn2019-08-121-1/+2
| | | | | | | | | | | | | | | Bug: 547400 Change-Id: Ic3541e360a2968ba3532a3d3fa4828b0d0463c02 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Ensure root cause of lock creation failures is loggedMatthias Sohn2019-08-121-3/+7
| | | | | | | | | | | | Change-Id: I91cdf1e085a29c0aabd6d22c6ebe848b2d75f42c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | FS_POSIX: handle Files.getFileStore() failuresThomas Wolf2019-08-081-2/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Android unconditionally throws a SecurityException;[1] getFileStore() is not supported. Catch the exception and don't attempt the hard- linking atomic file mechanism. [1] https://android.googlesource.com/platform/libcore/+/21e6175e25 Bug: 548947 Change-Id: Idfba2d9dbcbc80ea15ab2ae7889e5142444c1581 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | FS_POSIX: Fix reference comparison of Boolean.FALSEDavid Pursehouse2019-06-111-2/+2
| | | | | | | | | | | | | | | Change-Id: Ic205d017b365ea85983d0b0d9d033fcf7e6bf6ab Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | Determine hard-linking and nlink support per FileStoreThomas Wolf2019-06-061-9/+24
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | It's quite possible that JGit can use the hard-linking mechanism for atomic file creation on some volumes but not on others. Ultimately it depends on the file systems on the mounted volumes. Cache the information per FileStore instead of using a single global flag. Also catch FileSystemException, it may be thrown if the operating system reports a failure. The previously caught AccessDeniedException is a sub-class of FileSystemException. Bug: 547332 Change-Id: I1ef672b3468b0be79e71674344f16f28f9d11ba1 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | Remove duplicate externalized messageThomas Wolf2019-02-261-1/+1
| | | | | | | | | | | | | | | | Instead of a new "unexpectedNlinkValue" message use the already existing "failedAtomicFileCreation". Remove a stray double quote from the latter. Change-Id: I1ba5e9ea48d3f7615354b2ace2575883070b3206 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | FS_POSIX: Externalize log messageDavid Pursehouse2019-02-251-2/+3
| | | | | | | | | | Change-Id: Ida538e05c4595fdce99f1fa87469a3be60160adb Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | Atomic file creation: hard-linking may not be allowedThomas Wolf2019-02-021-1/+3
|/ | | | | | | | | | | | | | | Android for instance forbids hard linking via a SELinux policy. If we can't hard link, the NFS work-around for atomic file creation cannot work at all. In this case, fall back to not using the hard-linking mechanism. Android throws an AccessDeniedException, so we catch that. The javadoc on Files.createLink() indicates that another possibility might be a SecurityException, so catch that, too. Bug: 543956 Change-Id: I551b7a45f7b2fbbd8cf94f0b7233dbd8a200520e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Merge branch 'stable-4.11' into stable-5.0Matthias Sohn2018-09-081-5/+85
|\ | | | | | | | | | | | | | | | | | | | | * stable-4.11: Fix atomic lock file creation on NFS Use constant for ".lock" Fix handling of option core.supportsAtomicCreateNewFile GC: Avoid logging errors when deleting non-empty folders Change-Id: Ifcc8bfab4fd05c18a08dd82588860dffd0e6d726 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| * Merge branch 'stable-4.9' into stable-4.10Matthias Sohn2018-09-081-5/+85
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.9: Fix atomic lock file creation on NFS Use constant for ".lock" Fix handling of option core.supportsAtomicCreateNewFile GC: Avoid logging errors when deleting non-empty folders Change-Id: I32dc651870b7ba7c88de448c7984134b7c99e7e3 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Merge branch 'stable-4.8' into stable-4.9Matthias Sohn2018-09-081-5/+85
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.8: Fix atomic lock file creation on NFS Use constant for ".lock" Fix handling of option core.supportsAtomicCreateNewFile GC: Avoid logging errors when deleting non-empty folders Change-Id: Id7f68f4e8fb07a21737e3b7090f600507a13bbbe Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | * Fix atomic lock file creation on NFSMatthias Sohn2018-09-071-1/+75
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | FS_POSIX.createNewFile(File) failed to properly implement atomic file creation on NFS using the algorithm [1]: - name of the hard link must be unique to prevent that two processes using different NFS clients try to create the same link. This would render nlink useless to detect if there was a race. - the hard link must be retained for the lifetime of the file since we don't know when the state of the involved NFS clients will be synchronized. This depends on NFS configuration options. To fix these issues we need to change the signature of createNewFile which would break API. Hence deprecate the old method FS.createNewFile(File) and add a new method createNewFileAtomic(File). The new method returns a LockToken which needs to be retained by the caller (LockFile) until all involved NFS clients synchronized their state. Since we don't know when the NFS caches are synchronized we need to retain the token until the corresponding file is no longer needed. The LockToken must be closed after the LockFile using it has been committed or unlocked. On Posix, if core.supportsAtomicCreateNewFile = false this will delete the hard link which guarded the atomic creation of the file. When acquiring the lock fails ensure that the hard link is removed. [1] https://www.time-travellers.org/shane/papers/NFS_considered_harmful.html also see file creation flag O_EXCL in http://man7.org/linux/man-pages/man2/open.2.html Change-Id: I84fcb16143a5f877e9b08c6ee0ff8fa4ea68a90d Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | * Fix handling of option core.supportsAtomicCreateNewFileChristian Halstrick2018-09-071-4/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When core.supportsAtomicCreateNewFile was set to false and the repository was located on a filesystem which doesn't support the file attribute "unix:nlink" then FS_POSIX#createNewFile may report an error even if everything was ok. Modify FS_POSIX#createNewFile to silently ignore this situation. An example of such a filesystem is sshfs where reading "unix:nlink" always returns 1 (instead of throwing a exception). Bug: 537969 Change-Id: I6deda7672fa7945efa8706ea1cd652272604ff19 Also-by: Thomas Wolf <thomas.wolf@paranor.ch>
* | | | Fix wrong warning message in case of lock failuresChristian Halstrick2018-08-161-1/+1
|/ / / | | | | | | | | | | | | Bug: 537969 Change-Id: I0854bbbe7393abaca36640d429886c30d95d5bf1
* | | Fix javadoc in org.eclipse.jgit util packagesMatthias Sohn2017-12-201-17/+22
| | | | | | | | | | | | Change-Id: Ia655f45153bcf1d422ffffce6dcf914847e14c4c Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* | | FS_POSIX: Fix boxing/unboxing of BooleanDavid Pursehouse2017-12-071-12/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Boolean is being abused to represent three possible states of atomic file creation support (true/enabled, false/disabled, null/undefined). Replace this with an enum of the three explicit states. Change-Id: I2cd7fa6422311dc427823304b082ce8da50d2fbe Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* | | Merge branch 'stable-4.9'Matthias Sohn2017-11-241-0/+88
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.9: Ignore warning for minor version change without API change Silence boxing warning Prepare 4.5.5-SNAPSHOT builds JGit v4.5.4.201711221230-r Fix LockFile semantics when running on NFS Honor trustFolderStats also when reading packed-refs Prepare 4.5.4-SNAPSHOT builds JGit v4.5.3.201708160445-r Change-Id: Icc33d2e36f140e8714fce088379673a8834ae9de
| * | Merge branch 'stable-4.8' into stable-4.9Matthias Sohn2017-11-241-0/+88
| |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.8: Silence boxing warning Prepare 4.5.5-SNAPSHOT builds JGit v4.5.4.201711221230-r Fix LockFile semantics when running on NFS Honor trustFolderStats also when reading packed-refs Prepare 4.5.4-SNAPSHOT builds JGit v4.5.3.201708160445-r Change-Id: I7cf2e48934195430b3945b6d74b092f93a3ccd36 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | * Merge branch 'stable-4.6' into stable-4.7Matthias Sohn2017-11-221-0/+88
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * stable-4.6: Silence boxing warning Prepare 4.5.5-SNAPSHOT builds JGit v4.5.4.201711221230-r Fix LockFile semantics when running on NFS Honor trustFolderStats also when reading packed-refs Prepare 4.5.4-SNAPSHOT builds JGit v4.5.3.201708160445-r Change-Id: I8f6bc09540727c6273d22775a9f9ca382a729c9b Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | * Silence boxing warningMatthias Sohn2017-11-221-0/+1
| | | | | | | | | | | | | | | | Change-Id: I36c40eb91ce0c51f89b47911fa14beffcbc0a7cd Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
| | | * Fix LockFile semantics when running on NFSChristian Halstrick2017-11-221-0/+86
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running on NFS there was a chance that JGits LockFile semantic is broken because File#createNewFile() may allow multiple clients to create the same file in parallel. This change provides a fix which is only used when the new config option core.supportsAtomicCreateNewFile is set to false. The default for this option is true. This option can only be set in the global or the system config file. The repository config file is not taken into account in this case. If the config option core.supportsAtomicCreateNewFile is true then File#createNewFile() is trusted and the behaviour doesn't change. But if core.supportsAtomicCreateNewFile is set to false then after successful creation of the lock file a hardlink to that lock file is created and the attribute nlink of the lock file is checked to be 2. If multiple clients manage to create the same lock file nlink would be greater than 2 showing the error. This expensive workaround is described in https://www.time-travellers.org/shane/papers/NFS_considered_harmful.html section III.d) "Exclusive File Creation" Change-Id: I3d2cc48d8eb280d5f7039eb94da37804f903be6a
* | | | FileUtils.toPath to convert File to PathMarc Strapetz2017-11-141-1/+1
|/ / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When invoking File.toPath(), an (unchecked) InvalidPathException may be thrown which should be converted to a checked IOException. For now, we will replace File.toPath() by FileUtils.toPath() only for code which can already handle IOExceptions. Change-Id: I0f0c5fd2a11739e7a02071adae9a5550985d4df6 Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
* / / Fix JGit set core.fileMode to false by default instead of true for non ↵Joan Goyeau2017-07-241-1/+1
|/ / | | | | | | | | | | | | | | Windows OS. Bug: 519887 Change-Id: I4ae0d6783a9dc62f78ead54ddd1ab2b5b66a811c Signed-off-by: Joan Goyeau <joan@goyeau.com>
* / Enable and fix warnings about redundant specification of type argumentsDavid Pursehouse2017-02-201-1/+1
|/ | | | | | | | | | Since the introduction of generic type parameter inference in Java 7, it's not necessary to explicitly specify the type of generic parameters. Enable the warning in Eclipse, and fix all occurrences. Change-Id: I9158caf1beca5e4980b6240ac401f3868520aad0 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
* Don't log error if system git config does not existMatthias Sohn2016-09-051-2/+14
| | | | | | | | | | - enhance FS.readPipe to throw an exception if the external command fails to enable the caller to handle the command failure - reduce log level to warning if system git config does not exist - improve log message Bug: 476639 Change-Id: I94ae3caec22150dde81f1ea8e1e665df55290d42 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* [findBugs] Prevent potential NPE in FS_POSIX.readUmask()Matthias Sohn2016-05-191-1/+1
| | | | | | | BufferedReader.readLine() returns null if the end of the stream has been reached. Change-Id: I83102bbfb1316407247e0f29023077af9e8d9606 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Use java.nio.file consistently in FSMatthias Sohn2015-09-271-40/+0
| | | | | | | | | | | | | | | | Since 4.0 we require Java 7 so there is no longer a need to override the following methods in FS_POSIX, FS_Win32, FS_Win32_Cygwin - lastModified() - setLastModified() - length() - isSymlink() - exists() - isDirectory() - isFile() - isHidden() Hence implement these methods in FS and remove overrides in subclasses. Change-Id: I5dbde6ec806c66c86ac542978918361461021294 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Deprecate FileUtil and move the code to FileUtilsAndrey Loskutov2015-09-271-12/+12
| | | | | | | | | | | | | | As discussed on https://git.eclipse.org/r/53836 it does not make sense to have two similar utility classes in same package with intersecting functionality. To not break the API, all methods from FileUtil are copied to FileUtils, all FileUtil API is made deprecated and redirecting now to FileUtils. Moved simple methods which are available in Java 7 API are made package private and can be removed at any point later entirely (right now they are in use). Bug: 475070 Change-Id: Idffcf9840496c448173af7c052d8898ada68e27b Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Deprecate redundant FileUtil.delete(File), use FileUtils insteadAndrey Loskutov2015-08-261-5/+0
| | | | | | Bug: 475070 Change-Id: I6dc651f4b47e1b2c8d7954ec982e21ae6bb5f7a6 Signed-off-by: Andrey Loskutov <loskutov@gmx.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Move createSymLink/readSymLink to FileUtilsAndrey Loskutov2015-08-171-10/+0
| | | | | | Bug: 475070 Change-Id: I258f4bf291e02ef8e6f867b5d71c04ec902b6bcb Signed-off-by: Andrey Loskutov <loskutov@gmx.de>