aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2018-08-17 17:46:09 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2018-09-07 00:33:14 +0200
commit2faccd5b3206e996c9e2cafb95d806d50a9b9d4d (patch)
tree8649ea1d0bd8d0bd37710d363911ca4e2179e90a /org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
parentb7351facd51aa8e14d4bd2e74e3f4f0b57c55f6f (diff)
downloadjgit-2faccd5b3206e996c9e2cafb95d806d50a9b9d4d.tar.gz
jgit-2faccd5b3206e996c9e2cafb95d806d50a9b9d4d.zip
Fix handling of option core.supportsAtomicCreateNewFile
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>
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java14
1 files changed, 10 insertions, 4 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
index 76aa697764..9f273d1b84 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java
@@ -371,22 +371,28 @@ public class FS_POSIX extends FS {
return true;
}
Path lockPath = lock.toPath();
- Path link = Files.createLink(Paths.get(lock.getAbsolutePath() + ".lnk"), //$NON-NLS-1$
- lockPath);
+ Path link = null;
try {
+ link = Files.createLink(
+ Paths.get(lock.getAbsolutePath() + ".lnk"), //$NON-NLS-1$
+ lockPath);
Integer nlink = (Integer) (Files.getAttribute(lockPath,
"unix:nlink")); //$NON-NLS-1$
- if (nlink != 2) {
+ if (nlink > 2) {
LOG.warn("nlink of link to lock file {0} was not 2 but {1}", //$NON-NLS-1$
lock.getPath(), nlink);
return false;
+ } else if (nlink < 2) {
+ supportsUnixNLink = false;
}
return true;
} catch (UnsupportedOperationException | IllegalArgumentException e) {
supportsUnixNLink = false;
return true;
} finally {
- Files.delete(link);
+ if (link != null) {
+ Files.delete(link);
+ }
}
}
}