]> source.dussan.org Git - jgit.git/commitdiff
Merge branch 'stable-4.11' into stable-5.0 97/148797/2 stable-5.0
authorMatthias Sohn <matthias.sohn@sap.com>
Tue, 3 Sep 2019 13:54:54 +0000 (15:54 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 3 Sep 2019 13:59:39 +0000 (15:59 +0200)
* stable-4.11:
  Prepare 4.11.10-SNAPSHOT builds
  JGit v4.11.9.201909030838-r
  Bazel: Update bazlets to the latest master revision
  Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file
  BatchRefUpdate: repro racy atomic update, and fix it
  Delete unused FileTreeIteratorWithTimeControl
  Fix RacyGitTests#testRacyGitDetection
  Change RacyGitTests to create a racy git situation in a stable way
  Silence API warnings

Change-Id: Ifb6a4dbea2f48fd2ffa66eb737d61920aefedfbd
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
1  2 
org.eclipse.jgit.http.apache/.settings/.api_filters
org.eclipse.jgit.pgm/.settings/.api_filters
org.eclipse.jgit.test/tst/org/eclipse/jgit/lib/RacyGitTests.java
org.eclipse.jgit.ui/.settings/.api_filters
org.eclipse.jgit/.settings/.api_filters

index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..bc002ad3d0f6d0eec444c13e90aaa58e1974530a
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,11 @@@
++<?xml version="1.0" encoding="UTF-8" standalone="no"?>
++<component id="org.eclipse.jgit.http.apache" version="2">
++    <resource path="META-INF/MANIFEST.MF">
++        <filter id="925892614">
++            <message_arguments>
++                <message_argument value="5.0.4"/>
++                <message_argument value="4.11.0"/>
++            </message_arguments>
++        </filter>
++    </resource>
++</component>
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..736a9ab1ee22be38795c0b59870a9515e3bbe84e
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,11 @@@
++<?xml version="1.0" encoding="UTF-8" standalone="no"?>
++<component id="org.eclipse.jgit.pgm" version="2">
++    <resource path="META-INF/MANIFEST.MF">
++        <filter id="925892614">
++            <message_arguments>
++                <message_argument value="5.0.4"/>
++                <message_argument value="4.11.0"/>
++            </message_arguments>
++        </filter>
++    </resource>
++</component>
index 8d9ccab1bd8c170f560dbb5b226fa49960dab4e7,552b7a1e99ec94dc73a2b5f4ca6a5466e8f9b348..6bc8ff78bdea3888614b9c64fa0174c7cfc77914
@@@ -144,41 -78,56 +78,53 @@@ public class RacyGitTests extends Repos
  
                // wait to ensure that file-modTimes and therefore index entry modTime
                // doesn't match the modtime of index-file after next persistance
-               modTimes.add(valueOf(fsTick(lastFile)));
+               fsTick(b);
  
                // now add both files to the index. No racy git expected
-               resetIndex(new FileTreeIteratorWithTimeControl(db, modTimes));
+               resetIndex(new FileTreeIterator(db));
  
                assertEquals(
-                               "[a, mode:100644, time:t0, length:1, content:a]" +
-                               "[b, mode:100644, time:t0, length:1, content:b]",
+                               "[a, mode:100644, time:t0, length:1, content:a]"
+                                               + "[b, mode:100644, time:t0, length:1, content:b]",
                                indexState(SMUDGE | MOD_TIME | LENGTH | CONTENT));
  
-               // Remember the last modTime of index file. All modifications times of
-               // further modification are translated to this value so it looks that
-               // files have been modified in the same time slot as the index file
-               modTimes.add(Long.valueOf(db.getIndexFile().lastModified()));
+               // wait to ensure the file 'a' is updated at t1.
+               fsTick(db.getIndexFile());
  
-               // modify one file
-               addToWorkDir("a", "a2");
-               // now update the index the index. 'a' has to be racily clean -- because
-               // it's modification time is exactly the same as the previous index file
-               // mod time.
-               resetIndex(new FileTreeIteratorWithTimeControl(db, modTimes));
+               // Create a racy git situation. This is a situation that the index is
+               // updated and then a file is modified within the same tick of the
+               // filesystem timestamp resolution. By changing the index file
+               // artificially, we create a fake racy situation.
+               File updatedA = writeToWorkDir("a", "a2");
+               long newLastModified = updatedA.lastModified() + 100;
+               assertTrue(updatedA.setLastModified(newLastModified));
+               resetIndex(new FileTreeIterator(db));
+               assertTrue(db.getIndexFile().setLastModified(newLastModified));
  
-               db.readDirCache();
-               // although racily clean a should not be reported as being dirty
+               DirCache dc = db.readDirCache();
+               // check index state: although racily clean a should not be reported as
+               // being dirty since we forcefully reset the index to match the working
+               // tree
                assertEquals(
-                               "[a, mode:100644, time:t1, smudged, length:0, content:a2]" +
-                               "[b, mode:100644, time:t0, length:1, content:b]",
-                               indexState(SMUDGE|MOD_TIME|LENGTH|CONTENT));
+                               "[a, mode:100644, time:t1, smudged, length:0, content:a2]"
+                                               + "[b, mode:100644, time:t0, length:1, content:b]",
+                               indexState(SMUDGE | MOD_TIME | LENGTH | CONTENT));
+               // compare state of files in working tree with index to check that
+               // FileTreeIterator.isModified() works as expected
+               FileTreeIterator f = new FileTreeIterator(db.getWorkTree(), db.getFS(),
+                               db.getConfig().get(WorkingTreeOptions.KEY));
+               assertTrue(f.findFile("a"));
+               try (ObjectReader reader = db.newObjectReader()) {
+                       assertFalse(f.isModified(dc.getEntry("a"), false, reader));
+               }
        }
  
-       private File addToWorkDir(String path, String content) throws IOException {
+       private File writeToWorkDir(String path, String content) throws IOException {
                File f = new File(db.getWorkTree(), path);
 -              FileOutputStream fos = new FileOutputStream(f);
 -              try {
 +              try (FileOutputStream fos = new FileOutputStream(f)) {
                        fos.write(content.getBytes(Constants.CHARACTER_ENCODING));
                        return f;
 -              } finally {
 -                      fos.close();
                }
        }
  }
index 0000000000000000000000000000000000000000,0000000000000000000000000000000000000000..b4788bacdf6cec58d1db88178ebf97d0db18f0d4
new file mode 100644 (file)
--- /dev/null
--- /dev/null
@@@ -1,0 -1,0 +1,11 @@@
++<?xml version="1.0" encoding="UTF-8" standalone="no"?>
++<component id="org.eclipse.jgit.ui" version="2">
++    <resource path="META-INF/MANIFEST.MF">
++        <filter id="925892614">
++            <message_arguments>
++                <message_argument value="5.0.4"/>
++                <message_argument value="4.11.0"/>
++            </message_arguments>
++        </filter>
++    </resource>
++</component>
index af6030dc5291e7f5b85e2929f97f048912b5f65a,304fab07619995572a23d9c9e41fd1086647b3a1..404b45d152267037a369d61baf58a97f3a84ad01
@@@ -1,13 -1,13 +1,5 @@@
  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  <component id="org.eclipse.jgit" version="2">
-     <resource path="META-INF/MANIFEST.MF">
-         <filter id="924844039">
 -    <resource path="src/org/eclipse/jgit/diff/DiffEntry.java" type="org.eclipse.jgit.diff.DiffEntry">
 -        <filter id="336658481">
--            <message_arguments>
-                 <message_argument value="5.0.4"/>
-                 <message_argument value="5.0.0"/>
 -                <message_argument value="org.eclipse.jgit.diff.DiffEntry"/>
 -                <message_argument value="diffAttribute"/>
--            </message_arguments>
--        </filter>
--    </resource>
      <resource path="src/org/eclipse/jgit/errors/PackInvalidException.java" type="org.eclipse.jgit.errors.PackInvalidException">
          <filter id="1142947843">
              <message_arguments>
              </message_arguments>
          </filter>
      </resource>
 -    <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.lib.ConfigConstants"/>
 -                <message_argument value="CONFIG_KEY_REQUIRED"/>
 -            </message_arguments>
 -        </filter>
 -        <filter id="336658481">
 -            <message_arguments>
 -                <message_argument value="org.eclipse.jgit.lib.ConfigConstants"/>
 -                <message_argument value="CONFIG_SECTION_LFS"/>
 -            </message_arguments>
 -        </filter>
 -    </resource>
+     <resource path="src/org/eclipse/jgit/lib/Constants.java" type="org.eclipse.jgit.lib.Constants">
+         <filter id="1141899266">
+             <message_arguments>
+                 <message_argument value="4.7"/>
 -                <message_argument value="4.11"/>
++                <message_argument value="5.0"/>
+                 <message_argument value="LOCK_SUFFIX"/>
+             </message_arguments>
+         </filter>
+     </resource>
      <resource path="src/org/eclipse/jgit/lib/GitmoduleEntry.java" type="org.eclipse.jgit.lib.GitmoduleEntry">
          <filter id="1109393411">
              <message_arguments>
              </message_arguments>
          </filter>
      </resource>
 -    <resource path="src/org/eclipse/jgit/merge/ResolveMerger.java" type="org.eclipse.jgit.merge.ResolveMerger">
 -        <filter id="336658481">
 -            <message_arguments>
 -                <message_argument value="org.eclipse.jgit.merge.ResolveMerger"/>
 -                <message_argument value="workingTreeOptions"/>
 -            </message_arguments>
 -        </filter>
 -    </resource>
 -    <resource path="src/org/eclipse/jgit/storage/pack/PackStatistics.java" type="org.eclipse.jgit.storage.pack.PackStatistics$Accumulator">
 -        <filter id="336658481">
 -            <message_arguments>
 -                <message_argument value="org.eclipse.jgit.storage.pack.PackStatistics.Accumulator"/>
 -                <message_argument value="advertised"/>
 -            </message_arguments>
 -        </filter>
 -        <filter id="336658481">
 -            <message_arguments>
 -                <message_argument value="org.eclipse.jgit.storage.pack.PackStatistics.Accumulator"/>
 -                <message_argument value="haves"/>
 -            </message_arguments>
 -        </filter>
 -        <filter id="336658481">
++    <resource path="src/org/eclipse/jgit/lib/ObjectIdSerializer.java" type="org.eclipse.jgit.lib.ObjectIdSerializer">
++        <filter id="1141899266">
+             <message_arguments>
 -                <message_argument value="org.eclipse.jgit.storage.pack.PackStatistics.Accumulator"/>
 -                <message_argument value="timeNegotiating"/>
++                <message_argument value="4.11"/>
++                <message_argument value="5.0"/>
++                <message_argument value="readWithoutMarker(InputStream)"/>
+             </message_arguments>
+         </filter>
 -        <filter id="336658481">
++        <filter id="1141899266">
+             <message_arguments>
 -                <message_argument value="org.eclipse.jgit.storage.pack.PackStatistics.Accumulator"/>
 -                <message_argument value="wants"/>
++                <message_argument value="4.11"/>
++                <message_argument value="5.0"/>
++                <message_argument value="writeWithoutMarker(OutputStream, AnyObjectId)"/>
+             </message_arguments>
+         </filter>
+     </resource>
      <resource path="src/org/eclipse/jgit/util/FS.java" type="org.eclipse.jgit.util.FS">
          <filter id="1141899266">
              <message_arguments>