Browse Source

Merge branch 'stable-4.11' into stable-5.0

* stable-4.11:
  Silence API warning for new ObjectIdSerializer introduced in 4.11.1
  Ignore API warnings
  Fix photon target platform to use photon version of org.eclipse.osgi
  Update Photon orbit repository to R20180606145124
  Suppress warning for trying to delete non-empty directory
  Fix fetching with duplicate ref updates
  Fetch(Process): should tolerate duplicate refspecs
  FetchCommandTest: test add/update/delete fetch

Change-Id: I2497f99b7d0686a0e0f773c39c8725e813ce9d4a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
stable-5.0
Matthias Sohn 6 years ago
parent
commit
cde0e31381
  1. 11
      org.eclipse.jgit.http.apache/.settings/.api_filters
  2. 2
      org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target
  3. 2
      org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target
  4. 2
      org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target
  5. 11
      org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target
  6. 2
      org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd
  7. 8
      org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180606145124-Photon.tpd
  8. 11
      org.eclipse.jgit.pgm/.settings/.api_filters
  9. 159
      org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java
  10. 11
      org.eclipse.jgit.ui/.settings/.api_filters
  11. 19
      org.eclipse.jgit/.settings/.api_filters
  12. 5
      org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java
  13. 36
      org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java

11
org.eclipse.jgit.http.apache/.settings/.api_filters

@ -1,11 +0,0 @@
<?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.0"/>
<message_argument value="4.11.0"/>
</message_arguments>
</filter>
</resource>
</component>

2
org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?> <?pde?>
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform --> <!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
<target name="jgit-4.5" sequenceNumber="1528375371"> <target name="jgit-4.5" sequenceNumber="1535179254">
<locations> <locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.8.v20171121"/> <unit id="org.eclipse.jetty.client" version="9.4.8.v20171121"/>

2
org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?> <?pde?>
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform --> <!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
<target name="jgit-4.6" sequenceNumber="1528375359"> <target name="jgit-4.6" sequenceNumber="1535179241">
<locations> <locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.8.v20171121"/> <unit id="org.eclipse.jetty.client" version="9.4.8.v20171121"/>

2
org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?> <?pde?>
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform --> <!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
<target name="jgit-4.7" sequenceNumber="1528375339"> <target name="jgit-4.7" sequenceNumber="1535179221">
<locations> <locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.8.v20171121"/> <unit id="org.eclipse.jetty.client" version="9.4.8.v20171121"/>

11
org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?pde?> <?pde?>
<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform --> <!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform -->
<target name="jgit-4.8" sequenceNumber="1528872727"> <target name="jgit-4.8" sequenceNumber="1535179205">
<locations> <locations>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.jetty.client" version="9.4.8.v20171121"/> <unit id="org.eclipse.jetty.client" version="9.4.8.v20171121"/>
@ -33,6 +33,8 @@
<unit id="org.apache.commons.logging.source" version="1.1.1.v201101211721"/> <unit id="org.apache.commons.logging.source" version="1.1.1.v201101211721"/>
<unit id="org.apache.httpcomponents.httpcore" version="4.4.6.v20170210-0925"/> <unit id="org.apache.httpcomponents.httpcore" version="4.4.6.v20170210-0925"/>
<unit id="org.apache.httpcomponents.httpcore.source" version="4.4.6.v20170210-0925"/> <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.6.v20170210-0925"/>
<unit id="org.apache.httpcomponents.httpclient" version="4.5.2.v20180410-1551"/>
<unit id="org.apache.httpcomponents.httpclient.source" version="4.5.2.v20180410-1551"/>
<unit id="org.apache.log4j" version="1.2.15.v201012070815"/> <unit id="org.apache.log4j" version="1.2.15.v201012070815"/>
<unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/> <unit id="org.apache.log4j.source" version="1.2.15.v201012070815"/>
<unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/> <unit id="org.kohsuke.args4j" version="2.33.0.v20160323-2218"/>
@ -66,14 +68,9 @@
<unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/> <unit id="com.jcraft.jzlib.source" version="1.1.1.v201205102305"/>
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20180606145124/repository"/> <repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20180606145124/repository"/>
</location> </location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.apache.httpcomponents.httpclient" version="4.5.2.v20170210-0925"/>
<unit id="org.apache.httpcomponents.httpclient.source" version="4.5.2.v20170210-0925"/>
<repository location="http://download.eclipse.org/tools/orbit/downloads/drops/R20170919201930/repository/"/>
</location>
<location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit">
<unit id="org.eclipse.osgi" version="0.0.0"/> <unit id="org.eclipse.osgi" version="0.0.0"/>
<repository location="http://download.eclipse.org/releases/oxygen/"/> <repository location="http://download.eclipse.org/releases/photon/"/>
</location> </location>
</locations> </locations>
</target> </target>

2
org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd

@ -3,6 +3,6 @@ target "jgit-4.8" with source configurePhase
include "projects/jetty-9.4.8.tpd" include "projects/jetty-9.4.8.tpd"
include "orbit/R20180606145124-Photon.tpd" include "orbit/R20180606145124-Photon.tpd"
location "http://download.eclipse.org/releases/oxygen/" { location "http://download.eclipse.org/releases/photon/" {
org.eclipse.osgi lazy org.eclipse.osgi lazy
} }

8
org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180606145124-Photon.tpd

@ -12,6 +12,8 @@ location "http://download.eclipse.org/tools/orbit/downloads/drops/R2018060614512
org.apache.commons.logging.source [1.1.1.v201101211721,1.1.1.v201101211721] org.apache.commons.logging.source [1.1.1.v201101211721,1.1.1.v201101211721]
org.apache.httpcomponents.httpcore [4.4.6.v20170210-0925,4.4.6.v20170210-0925] org.apache.httpcomponents.httpcore [4.4.6.v20170210-0925,4.4.6.v20170210-0925]
org.apache.httpcomponents.httpcore.source [4.4.6.v20170210-0925,4.4.6.v20170210-0925] org.apache.httpcomponents.httpcore.source [4.4.6.v20170210-0925,4.4.6.v20170210-0925]
org.apache.httpcomponents.httpclient [4.5.2.v20180410-1551,4.5.2.v20180410-1551]
org.apache.httpcomponents.httpclient.source [4.5.2.v20180410-1551,4.5.2.v20180410-1551]
org.apache.log4j [1.2.15.v201012070815,1.2.15.v201012070815] org.apache.log4j [1.2.15.v201012070815,1.2.15.v201012070815]
org.apache.log4j.source [1.2.15.v201012070815,1.2.15.v201012070815] org.apache.log4j.source [1.2.15.v201012070815,1.2.15.v201012070815]
org.kohsuke.args4j [2.33.0.v20160323-2218,2.33.0.v20160323-2218] org.kohsuke.args4j [2.33.0.v20160323-2218,2.33.0.v20160323-2218]
@ -44,9 +46,3 @@ location "http://download.eclipse.org/tools/orbit/downloads/drops/R2018060614512
com.jcraft.jzlib [1.1.1.v201205102305,1.1.1.v201205102305] com.jcraft.jzlib [1.1.1.v201205102305,1.1.1.v201205102305]
com.jcraft.jzlib.source [1.1.1.v201205102305,1.1.1.v201205102305] com.jcraft.jzlib.source [1.1.1.v201205102305,1.1.1.v201205102305]
} }
location "http://download.eclipse.org/tools/orbit/downloads/drops/R20170919201930/repository/" {
// platform uses this outdated version of httpclient in Photon
org.apache.httpcomponents.httpclient [4.5.2.v20170210-0925,4.5.2.v20170210-0925]
org.apache.httpcomponents.httpclient.source [4.5.2.v20170210-0925,4.5.2.v20170210-0925]
}

11
org.eclipse.jgit.pgm/.settings/.api_filters

@ -1,11 +0,0 @@
<?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.0"/>
<message_argument value="4.11.0"/>
</message_arguments>
</filter>
</resource>
</component>

159
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java

@ -49,7 +49,9 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.File; import java.io.File;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import org.eclipse.jgit.junit.JGitTestUtil; import org.eclipse.jgit.junit.JGitTestUtil;
import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.junit.RepositoryTestCase;
@ -61,6 +63,7 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig; import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.transport.FetchResult; import org.eclipse.jgit.transport.FetchResult;
import org.eclipse.jgit.transport.RefSpec;
import org.eclipse.jgit.transport.RemoteConfig; import org.eclipse.jgit.transport.RemoteConfig;
import org.eclipse.jgit.transport.TagOpt; import org.eclipse.jgit.transport.TagOpt;
import org.eclipse.jgit.transport.TrackingRefUpdate; import org.eclipse.jgit.transport.TrackingRefUpdate;
@ -125,6 +128,91 @@ public class FetchCommandTest extends RepositoryTestCase {
res.getTrackingRefUpdate("refs/heads/master").getResult()); res.getTrackingRefUpdate("refs/heads/master").getResult());
} }
@Test
public void fetchAddsBranches() throws Exception {
final String branch1 = "b1";
final String branch2 = "b2";
final String remoteBranch1 = "test/" + branch1;
final String remoteBranch2 = "test/" + branch2;
remoteGit.commit().setMessage("commit").call();
Ref branchRef1 = remoteGit.branchCreate().setName(branch1).call();
remoteGit.commit().setMessage("commit").call();
Ref branchRef2 = remoteGit.branchCreate().setName(branch2).call();
String spec = "refs/heads/*:refs/remotes/test/*";
git.fetch().setRemote("test").setRefSpecs(spec).call();
assertEquals(branchRef1.getObjectId(), db.resolve(remoteBranch1));
assertEquals(branchRef2.getObjectId(), db.resolve(remoteBranch2));
}
@Test
public void fetchDoesntDeleteBranches() throws Exception {
final String branch1 = "b1";
final String branch2 = "b2";
final String remoteBranch1 = "test/" + branch1;
final String remoteBranch2 = "test/" + branch2;
remoteGit.commit().setMessage("commit").call();
Ref branchRef1 = remoteGit.branchCreate().setName(branch1).call();
remoteGit.commit().setMessage("commit").call();
Ref branchRef2 = remoteGit.branchCreate().setName(branch2).call();
String spec = "refs/heads/*:refs/remotes/test/*";
git.fetch().setRemote("test").setRefSpecs(spec).call();
assertEquals(branchRef1.getObjectId(), db.resolve(remoteBranch1));
assertEquals(branchRef2.getObjectId(), db.resolve(remoteBranch2));
remoteGit.branchDelete().setBranchNames(branch1).call();
git.fetch().setRemote("test").setRefSpecs(spec).call();
assertEquals(branchRef1.getObjectId(), db.resolve(remoteBranch1));
assertEquals(branchRef2.getObjectId(), db.resolve(remoteBranch2));
}
@Test
public void fetchUpdatesBranches() throws Exception {
final String branch1 = "b1";
final String branch2 = "b2";
final String remoteBranch1 = "test/" + branch1;
final String remoteBranch2 = "test/" + branch2;
remoteGit.commit().setMessage("commit").call();
Ref branchRef1 = remoteGit.branchCreate().setName(branch1).call();
remoteGit.commit().setMessage("commit").call();
Ref branchRef2 = remoteGit.branchCreate().setName(branch2).call();
String spec = "refs/heads/*:refs/remotes/test/*";
git.fetch().setRemote("test").setRefSpecs(spec).call();
assertEquals(branchRef1.getObjectId(), db.resolve(remoteBranch1));
assertEquals(branchRef2.getObjectId(), db.resolve(remoteBranch2));
remoteGit.commit().setMessage("commit").call();
branchRef2 = remoteGit.branchCreate().setName(branch2).setForce(true).call();
git.fetch().setRemote("test").setRefSpecs(spec).call();
assertEquals(branchRef1.getObjectId(), db.resolve(remoteBranch1));
assertEquals(branchRef2.getObjectId(), db.resolve(remoteBranch2));
}
@Test
public void fetchPrunesBranches() throws Exception {
final String branch1 = "b1";
final String branch2 = "b2";
final String remoteBranch1 = "test/" + branch1;
final String remoteBranch2 = "test/" + branch2;
remoteGit.commit().setMessage("commit").call();
Ref branchRef1 = remoteGit.branchCreate().setName(branch1).call();
remoteGit.commit().setMessage("commit").call();
Ref branchRef2 = remoteGit.branchCreate().setName(branch2).call();
String spec = "refs/heads/*:refs/remotes/test/*";
git.fetch().setRemote("test").setRefSpecs(spec).call();
assertEquals(branchRef1.getObjectId(), db.resolve(remoteBranch1));
assertEquals(branchRef2.getObjectId(), db.resolve(remoteBranch2));
remoteGit.branchDelete().setBranchNames(branch1).call();
git.fetch().setRemote("test").setRefSpecs(spec)
.setRemoveDeletedRefs(true).call();
assertNull(db.resolve(remoteBranch1));
assertEquals(branchRef2.getObjectId(), db.resolve(remoteBranch2));
}
@Test @Test
public void fetchShouldAutoFollowTag() throws Exception { public void fetchShouldAutoFollowTag() throws Exception {
remoteGit.commit().setMessage("commit").call(); remoteGit.commit().setMessage("commit").call();
@ -248,4 +336,75 @@ public class FetchCommandTest extends RepositoryTestCase {
assertEquals("origin/HEAD should be unchanged", originHeadId, assertEquals("origin/HEAD should be unchanged", originHeadId,
clonedRepo.resolve("refs/remotes/origin/HEAD")); clonedRepo.resolve("refs/remotes/origin/HEAD"));
} }
@Test
public void fetchAddRefsWithDuplicateRefspec() throws Exception {
final String branchName = "branch";
final String remoteBranchName = "test/" + branchName;
remoteGit.commit().setMessage("commit").call();
Ref branchRef = remoteGit.branchCreate().setName(branchName).call();
final String spec1 = "+refs/heads/*:refs/remotes/test/*";
final String spec2 = "refs/heads/*:refs/remotes/test/*";
final StoredConfig config = db.getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "test");
remoteConfig.addFetchRefSpec(new RefSpec(spec1));
remoteConfig.addFetchRefSpec(new RefSpec(spec2));
remoteConfig.update(config);
git.fetch().setRemote("test").setRefSpecs(spec1).call();
assertEquals(branchRef.getObjectId(), db.resolve(remoteBranchName));
}
@Test
public void fetchPruneRefsWithDuplicateRefspec()
throws Exception {
final String branchName = "branch";
final String remoteBranchName = "test/" + branchName;
remoteGit.commit().setMessage("commit").call();
Ref branchRef = remoteGit.branchCreate().setName(branchName).call();
final String spec1 = "+refs/heads/*:refs/remotes/test/*";
final String spec2 = "refs/heads/*:refs/remotes/test/*";
final StoredConfig config = db.getConfig();
RemoteConfig remoteConfig = new RemoteConfig(config, "test");
remoteConfig.addFetchRefSpec(new RefSpec(spec1));
remoteConfig.addFetchRefSpec(new RefSpec(spec2));
remoteConfig.update(config);
git.fetch().setRemote("test").setRefSpecs(spec1).call();
assertEquals(branchRef.getObjectId(), db.resolve(remoteBranchName));
remoteGit.branchDelete().setBranchNames(branchName).call();
git.fetch().setRemote("test").setRefSpecs(spec1)
.setRemoveDeletedRefs(true).call();
assertNull(db.resolve(remoteBranchName));
}
@Test
public void fetchUpdateRefsWithDuplicateRefspec() throws Exception {
final String tagName = "foo";
remoteGit.commit().setMessage("commit").call();
Ref tagRef1 = remoteGit.tag().setName(tagName).call();
List<RefSpec> refSpecs = new ArrayList<>();
refSpecs.add(new RefSpec("+refs/heads/*:refs/remotes/origin/*"));
refSpecs.add(new RefSpec("+refs/tags/*:refs/tags/*"));
// Updating tags via the RefSpecs and setting TagOpt.FETCH_TAGS (or
// AUTO_FOLLOW) will result internally in *two* updates for the same
// ref.
git.fetch().setRemote("test").setRefSpecs(refSpecs)
.setTagOpt(TagOpt.AUTO_FOLLOW).call();
assertEquals(tagRef1.getObjectId(), db.resolve(tagName));
remoteGit.commit().setMessage("commit 2").call();
Ref tagRef2 = remoteGit.tag().setName(tagName).setForceUpdate(true)
.call();
FetchResult result = git.fetch().setRemote("test").setRefSpecs(refSpecs)
.setTagOpt(TagOpt.FETCH_TAGS).call();
assertEquals(2, result.getTrackingRefUpdates().size());
TrackingRefUpdate update = result
.getTrackingRefUpdate(Constants.R_TAGS + tagName);
assertEquals(RefUpdate.Result.FORCED, update.getResult());
assertEquals(tagRef2.getObjectId(), db.resolve(tagName));
}
} }

11
org.eclipse.jgit.ui/.settings/.api_filters

@ -1,11 +0,0 @@
<?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.0"/>
<message_argument value="4.11.0"/>
</message_arguments>
</filter>
</resource>
</component>

19
org.eclipse.jgit/.settings/.api_filters

@ -1,19 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.jgit" version="2">
<resource path="src/org/eclipse/jgit/lib/ObjectIdSerializer.java" type="org.eclipse.jgit.lib.ObjectIdSerializer">
<filter id="1141899266">
<message_arguments>
<message_argument value="4.11"/>
<message_argument value="5.0"/>
<message_argument value="readWithoutMarker(InputStream)"/>
</message_arguments>
</filter>
<filter id="1141899266">
<message_arguments>
<message_argument value="4.11"/>
<message_argument value="5.0"/>
<message_argument value="writeWithoutMarker(OutputStream, AnyObjectId)"/>
</message_arguments>
</filter>
</resource>
</component>

5
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java

@ -65,6 +65,7 @@ import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.InterruptedIOException; import java.io.InterruptedIOException;
import java.nio.file.DirectoryNotEmptyException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.security.DigestInputStream; import java.security.DigestInputStream;
@ -1287,6 +1288,10 @@ public class RefDirectory extends RefDatabase {
for (int i = 0; i < depth; ++i) { for (int i = 0; i < depth; ++i) {
try { try {
Files.delete(dir.toPath()); Files.delete(dir.toPath());
} catch (DirectoryNotEmptyException e) {
// Don't log; normal case when there are other refs with the
// same prefix
break;
} catch (IOException e) { } catch (IOException e) {
LOG.warn("Unable to remove path {}", dir, e); LOG.warn("Unable to remove path {}", dir, e);
break; break;

36
org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java

@ -203,12 +203,10 @@ class FetchProcess {
((BatchingProgressMonitor) monitor).setDelayStart( ((BatchingProgressMonitor) monitor).setDelayStart(
250, TimeUnit.MILLISECONDS); 250, TimeUnit.MILLISECONDS);
} }
if (transport.isRemoveDeletedRefs()) if (transport.isRemoveDeletedRefs()) {
deleteStaleTrackingRefs(result, batch); deleteStaleTrackingRefs(result, batch);
for (TrackingRefUpdate u : localUpdates) {
result.add(u);
batch.addCommand(u.asReceiveCommand());
} }
addUpdateBatchCommands(result, batch);
for (ReceiveCommand cmd : batch.getCommands()) { for (ReceiveCommand cmd : batch.getCommands()) {
cmd.updateType(walk); cmd.updateType(walk);
if (cmd.getType() == UPDATE_NONFASTFORWARD if (cmd.getType() == UPDATE_NONFASTFORWARD
@ -221,8 +219,11 @@ class FetchProcess {
if (cmd.getResult() == NOT_ATTEMPTED) if (cmd.getResult() == NOT_ATTEMPTED)
cmd.setResult(OK); cmd.setResult(OK);
} }
} else } else {
batch.execute(walk, monitor); batch.execute(walk, monitor);
}
} catch (TransportException e) {
throw e;
} catch (IOException err) { } catch (IOException err) {
throw new TransportException(MessageFormat.format( throw new TransportException(MessageFormat.format(
JGitText.get().failureUpdatingTrackingRef, JGitText.get().failureUpdatingTrackingRef,
@ -239,6 +240,23 @@ class FetchProcess {
} }
} }
private void addUpdateBatchCommands(FetchResult result,
BatchRefUpdate batch) throws TransportException {
Map<String, ObjectId> refs = new HashMap<>();
for (TrackingRefUpdate u : localUpdates) {
// Try to skip duplicates if they'd update to the same object ID
ObjectId existing = refs.get(u.getLocalName());
if (existing == null) {
refs.put(u.getLocalName(), u.getNewObjectId());
result.add(u);
batch.addCommand(u.asReceiveCommand());
} else if (!existing.equals(u.getNewObjectId())) {
throw new TransportException(MessageFormat
.format(JGitText.get().duplicateRef, u.getLocalName()));
}
}
}
private void fetchObjects(ProgressMonitor monitor) private void fetchObjects(ProgressMonitor monitor)
throws TransportException { throws TransportException {
try { try {
@ -479,15 +497,17 @@ class FetchProcess {
private void deleteStaleTrackingRefs(FetchResult result, private void deleteStaleTrackingRefs(FetchResult result,
BatchRefUpdate batch) throws IOException { BatchRefUpdate batch) throws IOException {
Set<Ref> processed = new HashSet<>();
for (Ref ref : localRefs().values()) { for (Ref ref : localRefs().values()) {
if (ref.isSymbolic()) { if (ref.isSymbolic()) {
continue; continue;
} }
final String refname = ref.getName(); String refname = ref.getName();
for (RefSpec spec : toFetch) { for (RefSpec spec : toFetch) {
if (spec.matchDestination(refname)) { if (spec.matchDestination(refname)) {
final RefSpec s = spec.expandFromDestination(refname); RefSpec s = spec.expandFromDestination(refname);
if (result.getAdvertisedRef(s.getSource()) == null) { if (result.getAdvertisedRef(s.getSource()) == null
&& processed.add(ref)) {
deleteTrackingRef(result, batch, s, ref); deleteTrackingRef(result, batch, s, ref);
} }
} }

Loading…
Cancel
Save