]> source.dussan.org Git - jgit.git/commitdiff
Merge branch 'stable-4.6' into stable-4.7 26/112126/1
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 22 Nov 2017 22:06:50 +0000 (23:06 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 22 Nov 2017 22:07:01 +0000 (23:07 +0100)
* 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>
1  2 
org.eclipse.jgit/.settings/.api_filters
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
org.eclipse.jgit/src/org/eclipse/jgit/lib/ConfigConstants.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java
org.eclipse.jgit/src/org/eclipse/jgit/util/FS_POSIX.java

index 822f1215d5afb39defa0d64b3aab6ec06e74ed3f,c6af42ee281a378d5c8ea1b9f256a1a4a9abc356..c68b9a0935c9b6fd0a5164ae1dce014e849a8296
@@@ -3,59 -3,66 +3,51 @@@
      <resource path="META-INF/MANIFEST.MF">
          <filter id="924844039">
              <message_arguments>
-                 <message_argument value="4.7.1"/>
 -                <message_argument value="4.6.2"/>
 -                <message_argument value="4.6.0"/>
++                <message_argument value="4.7.2"/>
 +                <message_argument value="4.7.0"/>
              </message_arguments>
          </filter>
      </resource>
-     <resource path="src/org/eclipse/jgit/api/ArchiveCommand.java" type="org.eclipse.jgit.api.ArchiveCommand$Format">
-         <filter comment="OSGi semver allows to break implementors in minor releases" id="403804204">
 -    <resource path="src/org/eclipse/jgit/errors/NoPackSignatureException.java" type="org.eclipse.jgit.errors.NoPackSignatureException">
 -        <filter id="1108344834">
 -            <message_arguments>
 -                <message_argument value="4.5"/>
 -                <message_argument value="4.6"/>
 -                <message_argument value="org.eclipse.jgit.errors.NoPackSignatureException"/>
 -            </message_arguments>
 -        </filter>
 -    </resource>
 -    <resource path="src/org/eclipse/jgit/errors/UnsupportedPackIndexVersionException.java" type="org.eclipse.jgit.errors.UnsupportedPackIndexVersionException">
 -        <filter id="1108344834">
++    <resource path="src/org/eclipse/jgit/lib/ConfigConstants.java" type="org.eclipse.jgit.lib.ConfigConstants">
++        <filter id="336658481">
              <message_arguments>
-                 <message_argument value="org.eclipse.jgit.api.ArchiveCommand.Format"/>
-                 <message_argument value="putEntry(T, ObjectId, String, FileMode, ObjectLoader)"/>
 -                <message_argument value="4.5"/>
 -                <message_argument value="4.6"/>
 -                <message_argument value="org.eclipse.jgit.errors.UnsupportedPackIndexVersionException"/>
++                <message_argument value="org.eclipse.jgit.lib.ConfigConstants"/>
++                <message_argument value="CONFIG_KEY_AUTODETACH"/>
              </message_arguments>
          </filter>
--    </resource>
-     <resource path="src/org/eclipse/jgit/errors/NoPackSignatureException.java" type="org.eclipse.jgit.errors.NoPackSignatureException">
-         <filter comment="non-breaking addition of exception classes needed to cleanly fix error handling in PackFile" id="1108344834">
 -    <resource path="src/org/eclipse/jgit/errors/UnsupportedPackVersionException.java" type="org.eclipse.jgit.errors.UnsupportedPackVersionException">
 -        <filter id="1108344834">
++        <filter id="336658481">
              <message_arguments>
--                <message_argument value="4.5"/>
-                 <message_argument value="4.7"/>
-                 <message_argument value="org.eclipse.jgit.errors.NoPackSignatureException"/>
 -                <message_argument value="4.6"/>
 -                <message_argument value="org.eclipse.jgit.errors.UnsupportedPackVersionException"/>
++                <message_argument value="org.eclipse.jgit.lib.ConfigConstants"/>
++                <message_argument value="CONFIG_KEY_LOGEXPIRY"/>
              </message_arguments>
          </filter>
--    </resource>
-     <resource path="src/org/eclipse/jgit/errors/UnsupportedPackIndexVersionException.java" type="org.eclipse.jgit.errors.UnsupportedPackIndexVersionException">
-         <filter comment="non-breaking addition of exception classes needed to cleanly fix error handling in PackFile" id="1108344834">
 -    <resource path="src/org/eclipse/jgit/lib/ConfigConstants.java" type="org.eclipse.jgit.lib.ConfigConstants">
+         <filter id="336658481">
              <message_arguments>
-                 <message_argument value="4.5"/>
-                 <message_argument value="4.7"/>
-                 <message_argument value="org.eclipse.jgit.errors.UnsupportedPackIndexVersionException"/>
+                 <message_argument value="org.eclipse.jgit.lib.ConfigConstants"/>
+                 <message_argument value="CONFIG_KEY_SUPPORTSATOMICFILECREATION"/>
              </message_arguments>
          </filter>
-     </resource>
-     <resource path="src/org/eclipse/jgit/errors/UnsupportedPackVersionException.java" type="org.eclipse.jgit.errors.UnsupportedPackVersionException">
-         <filter comment="non-breaking addition of exception classes needed to cleanly fix error handling in PackFile" id="1108344834">
+         <filter id="1141899266">
              <message_arguments>
                  <message_argument value="4.5"/>
 -                <message_argument value="4.6"/>
 +                <message_argument value="4.7"/>
-                 <message_argument value="org.eclipse.jgit.errors.UnsupportedPackVersionException"/>
+                 <message_argument value="CONFIG_KEY_SUPPORTSATOMICFILECREATION"/>
              </message_arguments>
          </filter>
      </resource>
-     <resource path="src/org/eclipse/jgit/lib/ObjectInserter.java" type="org.eclipse.jgit.lib.ObjectInserter">
-         <filter comment="changed return type of digest() breaking implementors which is ok in minor releases according to OSGi semantic versioning" id="338792546">
+     <resource path="src/org/eclipse/jgit/util/FS.java" type="org.eclipse.jgit.util.FS">
+         <filter id="1141899266">
              <message_arguments>
-                 <message_argument value="org.eclipse.jgit.lib.ObjectInserter"/>
-                 <message_argument value="digest()"/>
+                 <message_argument value="4.5"/>
 -                <message_argument value="4.6"/>
++                <message_argument value="4.7"/>
+                 <message_argument value="createNewFile(File)"/>
              </message_arguments>
          </filter>
-     </resource>
-     <resource path="src/org/eclipse/jgit/transport/http/HttpConnection.java" type="org.eclipse.jgit.transport.http.HttpConnection">
-         <filter comment="OSGi semantic versioning rules allow to break implementors in minor releases" id="403767336">
+         <filter id="1141899266">
              <message_arguments>
-                 <message_argument value="org.eclipse.jgit.transport.http.HttpConnection"/>
-                 <message_argument value="HTTP_MOVED_PERM"/>
+                 <message_argument value="4.5"/>
 -                <message_argument value="4.6"/>
++                <message_argument value="4.7"/>
+                 <message_argument value="supportsAtomicCreateNewFile()"/>
              </message_arguments>
          </filter>
      </resource>
index 0780d2b5608d8afc2acffb57ccda0ba3844e43f0,f63c437e4eb9b9fb6530a445ba1b2e64b93f5e17..76aa697764497ee66cf074092440e98f6ad3af21
@@@ -301,4 -337,55 +337,56 @@@ public class FS_POSIX extends FS 
                        return hookPath.toFile();
                return null;
        }
+       @Override
+       public boolean supportsAtomicCreateNewFile() {
+               if (supportsAtomicCreateNewFile == null) {
+                       determineAtomicFileCreationSupport();
+               }
+               return supportsAtomicCreateNewFile.booleanValue();
+       }
++      @Override
+       @SuppressWarnings("boxing")
+       /**
+        * An implementation of the File#createNewFile() semantics which works also
+        * on NFS. If the config option
+        * {@code core.supportsAtomicCreateNewFile = true} (which is the default)
+        * then simply File#createNewFile() is called.
+        *
+        * But if {@code core.supportsAtomicCreateNewFile = 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.
+        *
+        * @see https://www.time-travellers.org/shane/papers/NFS_considered_harmful.html
+        * @since 4.5
+        */
+       public boolean createNewFile(File lock) throws IOException {
+               if (!lock.createNewFile()) {
+                       return false;
+               }
+               if (supportsAtomicCreateNewFile() || !supportsUnixNLink) {
+                       return true;
+               }
+               Path lockPath = lock.toPath();
+               Path link = Files.createLink(Paths.get(lock.getAbsolutePath() + ".lnk"), //$NON-NLS-1$
+                               lockPath);
+               try {
+                       Integer nlink = (Integer) (Files.getAttribute(lockPath,
+                                       "unix:nlink")); //$NON-NLS-1$
+                       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;
+                       }
+                       return true;
+               } catch (UnsupportedOperationException | IllegalArgumentException e) {
+                       supportsUnixNLink = false;
+                       return true;
+               } finally {
+                       Files.delete(link);
+               }
+       }
  }