diff options
15 files changed, 331 insertions, 64 deletions
diff --git a/org.eclipse.jgit.http.apache/.settings/.api_filters b/org.eclipse.jgit.http.apache/.settings/.api_filters deleted file mode 100644 index d1a066418c..0000000000 --- a/org.eclipse.jgit.http.apache/.settings/.api_filters +++ /dev/null @@ -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> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target index 9ae9a28491..6fad8129fa 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target +++ b/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"?> <?pde?> <!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform --> -<target name="jgit-4.5" sequenceNumber="1534608629"> +<target name="jgit-4.5" sequenceNumber="1535206408"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target index 6a6ea8d0a5..a17f16f610 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target +++ b/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"?> <?pde?> <!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform --> -<target name="jgit-4.6" sequenceNumber="1534608635"> +<target name="jgit-4.6" sequenceNumber="1535206398"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target index c271a1c896..c421270f75 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target +++ b/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"?> <?pde?> <!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform --> -<target name="jgit-4.7" sequenceNumber="1534608613"> +<target name="jgit-4.7" sequenceNumber="1535206380"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target index 86342dde54..2e4a812e69 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target +++ b/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"?> <?pde?> <!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform --> -<target name="jgit-4.8" sequenceNumber="1534608610"> +<target name="jgit-4.8" sequenceNumber="1535206368"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/> @@ -70,7 +70,7 @@ </location> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <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> </locations> </target> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd index 9c2d3f9270..341fbd0dc4 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd +++ b/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.11.tpd" include "orbit/S20180730183850-2018-09.tpd" -location "http://download.eclipse.org/releases/oxygen/" { +location "http://download.eclipse.org/releases/photon/" { org.eclipse.osgi lazy } diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9-staging.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9-staging.target new file mode 100644 index 0000000000..9064c1b32c --- /dev/null +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9-staging.target @@ -0,0 +1,76 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<?pde?> +<!-- generated with https://github.com/mbarbero/fr.obeo.releng.targetplatform --> +<target name="jgit-4.9-staging" sequenceNumber="1535206361"> + <locations> + <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> + <unit id="org.eclipse.jetty.client" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.client.source" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.continuation" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.continuation.source" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.http" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.http.source" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.io" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.io.source" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.security" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.security.source" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.server" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.server.source" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.servlet" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.servlet.source" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.util" version="9.4.11.v20180605"/> + <unit id="org.eclipse.jetty.util.source" version="9.4.11.v20180605"/> + <repository id="jetty-9.4.11" location="http://download.eclipse.org/jetty/updates/jetty-bundles-9.x/9.4.11.v20180605"/> + </location> + <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> + <unit id="org.apache.ant" version="1.9.6.v201510161327"/> + <unit id="org.apache.ant.source" version="1.9.6.v201510161327"/> + <unit id="org.apache.commons.codec" version="1.10.0.v20180409-1845"/> + <unit id="org.apache.commons.codec.source" version="1.10.0.v20180409-1845"/> + <unit id="org.apache.commons.compress" version="1.15.0.v20180119-1613"/> + <unit id="org.apache.commons.compress.source" version="1.15.0.v20180119-1613"/> + <unit id="org.apache.commons.logging" version="1.2.0.v20180409-1502"/> + <unit id="org.apache.commons.logging.source" version="1.2.0.v20180409-1502"/> + <unit id="org.apache.httpcomponents.httpclient" version="4.5.5.v20180409-1525"/> + <unit id="org.apache.httpcomponents.httpclient.source" version="4.5.5.v20180409-1525"/> + <unit id="org.apache.httpcomponents.httpcore" version="4.4.9.v20180409-1525"/> + <unit id="org.apache.httpcomponents.httpcore.source" version="4.4.9.v20180409-1525"/> + <unit id="org.apache.log4j" 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.source" version="2.33.0.v20160323-2218"/> + <unit id="org.hamcrest" version="1.1.0.v20090501071000"/> + <unit id="org.hamcrest.core" version="1.3.0.v20180420-1519"/> + <unit id="org.hamcrest.core.source" version="1.3.0.v20180420-1519"/> + <unit id="org.hamcrest.library" version="1.3.0.v20180524-2246"/> + <unit id="org.hamcrest.library.source" version="1.3.0.v20180524-2246"/> + <unit id="javaewah" version="1.1.6.v20160919-1400"/> + <unit id="javaewah.source" version="1.1.6.v20160919-1400"/> + <unit id="org.objenesis" version="1.0.0.v201505121915"/> + <unit id="org.objenesis.source" version="1.0.0.v201505121915"/> + <unit id="org.mockito" version="1.8.4.v201303031500"/> + <unit id="org.mockito.source" version="1.8.4.v201303031500"/> + <unit id="com.google.gson" version="2.8.2.v20180104-1110"/> + <unit id="com.google.gson.source" version="2.8.2.v20180104-1110"/> + <unit id="com.jcraft.jsch" version="0.1.54.v20170116-1932"/> + <unit id="com.jcraft.jsch.source" version="0.1.54.v20170116-1932"/> + <unit id="org.junit" version="4.12.0.v201504281640"/> + <unit id="org.junit.source" version="4.12.0.v201504281640"/> + <unit id="javax.servlet" version="3.1.0.v201410161800"/> + <unit id="javax.servlet.source" version="3.1.0.v201410161800"/> + <unit id="org.tukaani.xz" version="1.6.0.v20170629-1752"/> + <unit id="org.tukaani.xz.source" version="1.6.0.v20170629-1752"/> + <unit id="org.slf4j.api" version="1.7.2.v20121108-1250"/> + <unit id="org.slf4j.api.source" version="1.7.2.v20121108-1250"/> + <unit id="org.slf4j.impl.log4j12" version="1.7.2.v20131105-2200"/> + <unit id="org.slf4j.impl.log4j12.source" version="1.7.2.v20131105-2200"/> + <unit id="com.jcraft.jzlib" 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/S20180730183850/repository"/> + </location> + <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> + <unit id="org.eclipse.osgi" version="0.0.0"/> + <repository location="http://download.eclipse.org/staging/2018-09/"/> + </location> + </locations> +</target> diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9-staging.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9-staging.tpd new file mode 100644 index 0000000000..2319e92740 --- /dev/null +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9-staging.tpd @@ -0,0 +1,8 @@ +target "jgit-4.9-staging" with source configurePhase + +include "projects/jetty-9.4.11.tpd" +include "orbit/S20180730183850-2018-09.tpd" + +location "http://download.eclipse.org/staging/2018-09/" { + org.eclipse.osgi lazy +}
\ No newline at end of file diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180606145124-Photon.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180606145124-Photon.tpd new file mode 100644 index 0000000000..ecec41d8c6 --- /dev/null +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/R20180606145124-Photon.tpd @@ -0,0 +1,48 @@ +target "R20180606145124-Photon" with source configurePhase +// see http://download.eclipse.org/tools/orbit/downloads/ + +location "http://download.eclipse.org/tools/orbit/downloads/drops/R20180606145124/repository" { + org.apache.ant [1.9.6.v201510161327,1.9.6.v201510161327] + org.apache.ant.source [1.9.6.v201510161327,1.9.6.v201510161327] + org.apache.commons.codec [1.9.0.v20170208-1614,1.9.0.v20170208-1614] + org.apache.commons.codec.source [1.9.0.v20170208-1614,1.9.0.v20170208-1614] + org.apache.commons.compress [1.15.0.v20180119-1613,1.15.0.v20180119-1613] + org.apache.commons.compress.source [1.15.0.v20180119-1613,1.15.0.v20180119-1613s] + org.apache.commons.logging [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.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.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.source [2.33.0.v20160323-2218,2.33.0.v20160323-2218] + org.hamcrest [1.1.0.v20090501071000,1.1.0.v20090501071000] + org.hamcrest.core [1.3.0.v20180420-1519,1.3.0.v20180420-1519] + org.hamcrest.core.source [1.3.0.v20180420-1519,1.3.0.v20180420-1519] + org.hamcrest.library [1.3.0.v20180524-2246,1.3.0.v20180524-2246] + org.hamcrest.library.source [1.3.0.v20180524-2246,1.3.0.v20180524-2246] + javaewah [1.1.6.v20160919-1400,1.1.6.v20160919-1400] + javaewah.source [1.1.6.v20160919-1400,1.1.6.v20160919-1400] + org.objenesis [1.0.0.v201505121915,1.0.0.v201505121915] + org.objenesis.source [1.0.0.v201505121915,1.0.0.v201505121915] + org.mockito [1.8.4.v201303031500,1.8.4.v201303031500] + org.mockito.source [1.8.4.v201303031500,1.8.4.v201303031500] + com.google.gson [2.8.2.v20180104-1110,2.8.2.v20180104-1110] + com.google.gson.source [2.8.2.v20180104-1110,2.8.2.v20180104-1110] + com.jcraft.jsch [0.1.54.v20170116-1932,0.1.54.v20170116-1932] + com.jcraft.jsch.source [0.1.54.v20170116-1932,0.1.54.v20170116-1932] + org.junit [4.12.0.v201504281640,4.12.0.v201504281640] + org.junit.source [4.12.0.v201504281640,4.12.0.v201504281640] + javax.servlet [3.1.0.v201410161800,3.1.0.v201410161800] + javax.servlet.source [3.1.0.v201410161800,3.1.0.v201410161800] + org.tukaani.xz [1.6.0.v20170629-1752,1.6.0.v20170629-1752] + org.tukaani.xz.source [1.6.0.v20170629-1752,1.6.0.v20170629-1752] + org.slf4j.api [1.7.2.v20121108-1250,1.7.2.v20121108-1250] + org.slf4j.api.source [1.7.2.v20121108-1250,1.7.2.v20121108-1250] + org.slf4j.impl.log4j12 [1.7.2.v20131105-2200,1.7.2.v20131105-2200] + org.slf4j.impl.log4j12.source [1.7.2.v20131105-2200,1.7.2.v20131105-2200] + com.jcraft.jzlib [1.1.1.v201205102305,1.1.1.v201205102305] + com.jcraft.jzlib.source [1.1.1.v201205102305,1.1.1.v201205102305] +} diff --git a/org.eclipse.jgit.pgm/.settings/.api_filters b/org.eclipse.jgit.pgm/.settings/.api_filters deleted file mode 100644 index facef2df6b..0000000000 --- a/org.eclipse.jgit.pgm/.settings/.api_filters +++ /dev/null @@ -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> diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java index 4c2c0e8d1f..adc4d98488 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/FetchCommandTest.java +++ b/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 java.io.File; +import java.util.ArrayList; import java.util.Collection; +import java.util.List; import org.eclipse.jgit.junit.JGitTestUtil; 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.revwalk.RevCommit; import org.eclipse.jgit.transport.FetchResult; +import org.eclipse.jgit.transport.RefSpec; import org.eclipse.jgit.transport.RemoteConfig; import org.eclipse.jgit.transport.TagOpt; import org.eclipse.jgit.transport.TrackingRefUpdate; @@ -126,6 +129,91 @@ public class FetchCommandTest extends RepositoryTestCase { } @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 public void fetchShouldAutoFollowTag() throws Exception { remoteGit.commit().setMessage("commit").call(); Ref tagRef = remoteGit.tag().setName("foo").call(); @@ -248,4 +336,75 @@ public class FetchCommandTest extends RepositoryTestCase { assertEquals("origin/HEAD should be unchanged", originHeadId, 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)); + } } diff --git a/org.eclipse.jgit.ui/.settings/.api_filters b/org.eclipse.jgit.ui/.settings/.api_filters deleted file mode 100644 index aed9c7a352..0000000000 --- a/org.eclipse.jgit.ui/.settings/.api_filters +++ /dev/null @@ -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> diff --git a/org.eclipse.jgit/.settings/.api_filters b/org.eclipse.jgit/.settings/.api_filters index b7b49bc658..9f4b761495 100644 --- a/org.eclipse.jgit/.settings/.api_filters +++ b/org.eclipse.jgit/.settings/.api_filters @@ -7,22 +7,6 @@ </message_arguments> </filter> </resource> - <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> <resource path="src/org/eclipse/jgit/transport/GitProtocolConstants.java" type="org.eclipse.jgit.transport.GitProtocolConstants"> <filter id="337768515"> <message_arguments> @@ -30,4 +14,4 @@ </message_arguments> </filter> </resource> -</component> +</component>
\ No newline at end of file diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java index 7d2bd4897a..40c6de33fa 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/RefDirectory.java +++ b/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.InputStreamReader; import java.io.InterruptedIOException; +import java.nio.file.DirectoryNotEmptyException; import java.nio.file.Files; import java.nio.file.Path; import java.security.DigestInputStream; @@ -1287,6 +1288,10 @@ public class RefDirectory extends RefDatabase { for (int i = 0; i < depth; ++i) { try { 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) { LOG.warn("Unable to remove path {}", dir, e); //$NON-NLS-1$ break; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java index ff183c8974..c43ab18c35 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchProcess.java @@ -203,12 +203,10 @@ class FetchProcess { ((BatchingProgressMonitor) monitor).setDelayStart( 250, TimeUnit.MILLISECONDS); } - if (transport.isRemoveDeletedRefs()) + if (transport.isRemoveDeletedRefs()) { deleteStaleTrackingRefs(result, batch); - for (TrackingRefUpdate u : localUpdates) { - result.add(u); - batch.addCommand(u.asReceiveCommand()); } + addUpdateBatchCommands(result, batch); for (ReceiveCommand cmd : batch.getCommands()) { cmd.updateType(walk); if (cmd.getType() == UPDATE_NONFASTFORWARD @@ -221,8 +219,11 @@ class FetchProcess { if (cmd.getResult() == NOT_ATTEMPTED) cmd.setResult(OK); } - } else + } else { batch.execute(walk, monitor); + } + } catch (TransportException e) { + throw e; } catch (IOException err) { throw new TransportException(MessageFormat.format( 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) throws TransportException { try { @@ -479,15 +497,17 @@ class FetchProcess { private void deleteStaleTrackingRefs(FetchResult result, BatchRefUpdate batch) throws IOException { + Set<Ref> processed = new HashSet<>(); for (Ref ref : localRefs().values()) { if (ref.isSymbolic()) { continue; } - final String refname = ref.getName(); + String refname = ref.getName(); for (RefSpec spec : toFetch) { if (spec.matchDestination(refname)) { - final RefSpec s = spec.expandFromDestination(refname); - if (result.getAdvertisedRef(s.getSource()) == null) { + RefSpec s = spec.expandFromDestination(refname); + if (result.getAdvertisedRef(s.getSource()) == null + && processed.add(ref)) { deleteTrackingRef(result, batch, s, ref); } } |