diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target index 6eac67ff0..931e196cf 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.target @@ -1,7 +1,7 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.tpd index 7b0abe3ec..b87917b8a 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10.tpd @@ -1,7 +1,7 @@ target "jgit-4.10" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/2018-12/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.target index a3f3013a7..809099960 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.target @@ -1,7 +1,7 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.tpd index 9cbf9169a..844a1d791 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.11.tpd @@ -1,7 +1,7 @@ target "jgit-4.11" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/2019-03/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12.target index 451ee96fc..69eb63972 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12.target @@ -1,7 +1,7 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12.tpd index e15c357bc..afbf79d53 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.12.tpd @@ -1,7 +1,7 @@ target "jgit-4.12" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/2019-06/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.13.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.13.target index b0b791038..fdbed2d2a 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.13.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.13.target @@ -1,7 +1,7 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.13.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.13.tpd index b2d4aed91..d83e33846 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.13.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.13.tpd @@ -1,7 +1,7 @@ target "jgit-4.13" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/2019-09/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.14.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.14.target index a2e25d5fc..c2ef9d24a 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.14.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.14.target @@ -1,7 +1,7 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.14.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.14.tpd index b5b4ce8bf..f357ccd24 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.14.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.14.tpd @@ -1,7 +1,7 @@ target "jgit-4.14" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/2019-12/201912181000/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.15.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.15.target index 70f5a8223..4034d2a36 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.15.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.15.target @@ -1,7 +1,7 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.15.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.15.tpd index c12e2b768..881fe37e7 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.15.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.15.tpd @@ -1,7 +1,7 @@ target "jgit-4.15" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/2020-03/202003181000/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.16.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.16.target index 804e96f61..34d872cdd 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.16.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.16.target @@ -1,7 +1,7 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.16.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.16.tpd index 2c518b220..9a0759711 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.16.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.16.tpd @@ -1,7 +1,7 @@ target "jgit-4.16" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/2020-06/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17-staging.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17-staging.tpd deleted file mode 100644 index d440efa51..000000000 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17-staging.tpd +++ /dev/null @@ -1,8 +0,0 @@ -target "jgit-4.17-staging" with source configurePhase - -include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" - -location "https://download.eclipse.org/staging/2020-09/" { - org.eclipse.osgi lazy -} diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.target new file mode 100644 index 000000000..3384c2356 --- /dev/null +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.target @@ -0,0 +1,94 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.tpd new file mode 100644 index 000000000..ce79cf45e --- /dev/null +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17.tpd @@ -0,0 +1,8 @@ +target "jgit-4.17" with source configurePhase + +include "projects/jetty-9.4.x.tpd" +include "orbit/S20201118210000.tpd" + +location "https://download.eclipse.org/releases/2020-09/" { + org.eclipse.osgi lazy +} diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17-staging.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18-staging.target similarity index 95% rename from org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17-staging.target rename to org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18-staging.target index 589c7f5d5..5eeab9534 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.17-staging.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18-staging.target @@ -1,7 +1,7 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,15 +80,15 @@ - - + + - + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18-staging.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18-staging.tpd new file mode 100644 index 000000000..0669490bb --- /dev/null +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.18-staging.tpd @@ -0,0 +1,8 @@ +target "jgit-4.18-staging" with source configurePhase + +include "projects/jetty-9.4.x.tpd" +include "orbit/S20201118210000.tpd" + +location "https://download.eclipse.org/staging/2020-12/" { + org.eclipse.osgi lazy +} 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 ac5c0d188..a66fcc082 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 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd index f421ab758..aa58b6857 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd @@ -1,7 +1,7 @@ target "jgit-4.6" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/neon/" { org.eclipse.osgi lazy 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 002f07db7..4b5410a3d 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 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd index 7b59dee0a..e2264e003 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd @@ -1,7 +1,7 @@ target "jgit-4.7" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/oxygen/" { org.eclipse.osgi lazy 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 c0bc168bd..d77642745 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 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + 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 80d1103cb..c92ce5396 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 @@ -1,7 +1,7 @@ target "jgit-4.8" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/photon/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target index d45d3367c..56002b78a 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target @@ -1,7 +1,7 @@ - + @@ -39,8 +39,8 @@ - - + + @@ -80,11 +80,11 @@ - - + + - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd index e73b958c1..06ccecbd5 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd @@ -1,7 +1,7 @@ target "jgit-4.9" with source configurePhase include "projects/jetty-9.4.x.tpd" -include "orbit/S20201027182932.tpd" +include "orbit/S20201118210000.tpd" location "https://download.eclipse.org/releases/2018-09/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20201027182932.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20201118210000.tpd similarity index 91% rename from org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20201027182932.tpd rename to org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20201118210000.tpd index 3276402f8..a00a5e7c8 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20201027182932.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20201118210000.tpd @@ -1,7 +1,7 @@ -target "S20201027182932" with source configurePhase +target "S20201118210000" with source configurePhase // see https://download.eclipse.org/tools/orbit/downloads/ -location "https://download.eclipse.org/tools/orbit/downloads/drops/S20201027182932/repository" { +location "https://download.eclipse.org/tools/orbit/downloads/drops/S20201118210000/repository" { 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.55.v20190404-1902,0.1.55.v20190404-1902] @@ -18,8 +18,8 @@ location "https://download.eclipse.org/tools/orbit/downloads/drops/S202010271829 net.bytebuddy.byte-buddy.source [1.9.0.v20181107-1410,1.9.0.v20181107-1410] net.i2p.crypto.eddsa [0.3.0.v20181102-1323,0.3.0.v20181102-1323] net.i2p.crypto.eddsa.source [0.3.0.v20181102-1323,0.3.0.v20181102-1323] - org.apache.ant [1.10.8.v20200515-1239,1.10.8.v20200515-1239] - org.apache.ant.source [1.10.8.v20200515-1239,1.10.8.v20200515-1239] + org.apache.ant [1.10.9.v20201106-1946,1.10.9.v20201106-1946] + org.apache.ant.source [1.10.9.v20201106-1946,1.10.9.v20201106-1946] org.apache.commons.codec [1.14.0.v20200818-1422,1.14.0.v20200818-1422] org.apache.commons.codec.source [1.14.0.v20200818-1422,1.14.0.v20200818-1422] org.apache.commons.compress [1.19.0.v20200106-2343,1.19.0.v20200106-2343] @@ -59,8 +59,8 @@ location "https://download.eclipse.org/tools/orbit/downloads/drops/S202010271829 org.objenesis.source [2.6.0.v20180420-1519,2.6.0.v20180420-1519] org.slf4j.api [1.7.30.v20200204-2150,1.7.30.v20200204-2150] org.slf4j.api.source [1.7.30.v20200204-2150,1.7.30.v20200204-2150] - org.slf4j.binding.log4j12 [1.7.30.v20201016-1131,1.7.30.v20201016-1131] - org.slf4j.binding.log4j12.source [1.7.30.v20201016-1131,1.7.30.v20201016-1131] + org.slf4j.binding.log4j12 [1.7.30.v20201108-2042,1.7.30.v20201108-2042] + org.slf4j.binding.log4j12.source [1.7.30.v20201108-2042,1.7.30.v20201108-2042] org.tukaani.xz [1.8.0.v20180207-1613,1.8.0.v20180207-1613] org.tukaani.xz.source [1.8.0.v20180207-1613,1.8.0.v20180207-1613] } diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java index e0a1c1d61..f52b715d3 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/PathCheckoutCommandTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011, Kevin Sawicki and others + * Copyright (C) 2011, 2020 Kevin Sawicki and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0 which is available at @@ -24,6 +24,7 @@ import org.eclipse.jgit.errors.NoWorkTreeException; import org.eclipse.jgit.junit.RepositoryTestCase; import org.eclipse.jgit.lib.ConfigConstants; +import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectReader; import org.eclipse.jgit.lib.RepositoryState; import org.eclipse.jgit.lib.StoredConfig; @@ -309,6 +310,16 @@ public void testCheckoutTheirs() throws Exception { assertStageOneToThree(FILE1); } + @Test + public void testCheckoutFileWithConflict() throws Exception { + setupConflictingState(); + assertEquals('[' + FILE1 + ']', + git.status().call().getConflicting().toString()); + git.checkout().setStartPoint(Constants.HEAD).addPath(FILE1).call(); + assertEquals("3", read(FILE1)); + assertTrue(git.status().call().isClean()); + } + @Test public void testCheckoutOursWhenNoBase() throws Exception { String file = "added.txt"; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheEntryTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheEntryTest.java index 5477f565f..8e84dfa31 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheEntryTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCacheEntryTest.java @@ -241,6 +241,46 @@ public void testSetFileMode() { } } + @Test + public void testSetStage() { + DirCacheEntry e = new DirCacheEntry("some/path", DirCacheEntry.STAGE_1); + e.setAssumeValid(true); + e.setCreationTime(2L); + e.setFileMode(FileMode.EXECUTABLE_FILE); + e.setLastModified(EPOCH.plusMillis(3L)); + e.setLength(100L); + e.setObjectId(ObjectId + .fromString("0123456789012345678901234567890123456789")); + e.setUpdateNeeded(true); + e.setStage(DirCacheEntry.STAGE_2); + + assertTrue(e.isAssumeValid()); + assertEquals(2L, e.getCreationTime()); + assertEquals( + ObjectId.fromString("0123456789012345678901234567890123456789"), + e.getObjectId()); + assertEquals(FileMode.EXECUTABLE_FILE, e.getFileMode()); + assertEquals(EPOCH.plusMillis(3L), e.getLastModifiedInstant()); + assertEquals(100L, e.getLength()); + assertEquals(DirCacheEntry.STAGE_2, e.getStage()); + assertTrue(e.isUpdateNeeded()); + assertEquals("some/path", e.getPathString()); + + e.setStage(DirCacheEntry.STAGE_0); + + assertTrue(e.isAssumeValid()); + assertEquals(2L, e.getCreationTime()); + assertEquals( + ObjectId.fromString("0123456789012345678901234567890123456789"), + e.getObjectId()); + assertEquals(FileMode.EXECUTABLE_FILE, e.getFileMode()); + assertEquals(EPOCH.plusMillis(3L), e.getLastModifiedInstant()); + assertEquals(100L, e.getLength()); + assertEquals(DirCacheEntry.STAGE_0, e.getStage()); + assertTrue(e.isUpdateNeeded()); + assertEquals("some/path", e.getPathString()); + } + @Test public void testCopyMetaDataWithStage() { copyMetaDataHelper(false); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCachePathEditTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCachePathEditTest.java index 39a1f0180..5778d28d6 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCachePathEditTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/dircache/DirCachePathEditTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011, Robin Rosenberg and others + * Copyright (C) 2011, 2020 Robin Rosenberg and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0 which is available at @@ -123,6 +123,32 @@ public void testPathEditShouldBeCalledForEachStage() throws Exception { assertEquals(DirCacheEntry.STAGE_3, entries.get(2).getStage()); } + @Test + public void testPathEditWithStagesAndReset() throws Exception { + DirCache dc = DirCache.newInCore(); + DirCacheBuilder builder = new DirCacheBuilder(dc, 3); + builder.add(createEntry("a", DirCacheEntry.STAGE_1)); + builder.add(createEntry("a", DirCacheEntry.STAGE_2)); + builder.add(createEntry("a", DirCacheEntry.STAGE_3)); + builder.finish(); + + DirCacheEditor editor = dc.editor(); + PathEdit edit = new PathEdit("a") { + + @Override + public void apply(DirCacheEntry ent) { + ent.setStage(DirCacheEntry.STAGE_0); + } + }; + editor.add(edit); + editor.finish(); + + assertEquals(1, dc.getEntryCount()); + DirCacheEntry entry = dc.getEntry(0); + assertEquals("a", entry.getPathString()); + assertEquals(DirCacheEntry.STAGE_0, entry.getStage()); + } + @Test public void testFileReplacesTree() throws Exception { DirCache dc = DirCache.newInCore(); diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java index e8d1cd3d7..d007dd451 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/GcBasicPackingTest.java @@ -79,6 +79,29 @@ public void testPack2Commits(boolean aggressive) throws Exception { assertEquals(2, stats.numberOfBitmaps); } + @Theory + public void testPack2Commits_noPackFolder(boolean aggressive) throws Exception { + File packDir = repo.getObjectDatabase().getPackDirectory(); + assertTrue(packDir.delete()); + + BranchBuilder bb = tr.branch("refs/heads/master"); + bb.commit().add("A", "A").add("B", "B").create(); + bb.commit().add("A", "A2").add("B", "B2").create(); + + stats = gc.getStatistics(); + assertEquals(8, stats.numberOfLooseObjects); + assertEquals(0, stats.numberOfPackedObjects); + configureGc(gc, aggressive); + gc.gc(); + stats = gc.getStatistics(); + assertEquals(0, stats.numberOfLooseObjects); + assertEquals(8, stats.numberOfPackedObjects); + assertEquals(1, stats.numberOfPackFiles); + assertEquals(2, stats.numberOfBitmaps); + + assertTrue(packDir.exists()); + } + @Theory public void testPackAllObjectsInOnePack(boolean aggressive) throws Exception { diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/logging/PerformanceLogContextTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/logging/PerformanceLogContextTest.java index e061833d1..f3c1ddec8 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/logging/PerformanceLogContextTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/logging/PerformanceLogContextTest.java @@ -1,6 +1,7 @@ package org.eclipse.jgit.logging; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import org.junit.Test; @@ -37,30 +38,58 @@ public void testCleanEvents() { } @Test - public void testAddEventsTwoThreads() { - TestRunnable thread1 = new TestRunnable("record1", 1); - TestRunnable thread2 = new TestRunnable("record2", 2); + public void testAddEventsTwoThreads() throws InterruptedException { + TestRunnable runnable1 = new TestRunnable("record1", 1); + TestRunnable runnable2 = new TestRunnable("record2", 2); - new Thread(thread1).start(); - new Thread(thread2).start(); + Thread thread1 = new Thread(runnable1); + Thread thread2 = new Thread(runnable2); + + thread1.start(); + thread2.start(); + + thread1.join(); + thread2.join(); + assertEquals(1, runnable1.getEventRecordsCount()); + assertEquals(1, runnable2.getEventRecordsCount()); + assertFalse(runnable1.isThrown()); + assertFalse(runnable2.isThrown()); } private static class TestRunnable implements Runnable { private String name; + private long durationMs; + private long eventRecordsCount; + + private boolean thrown = false; + public TestRunnable(String name, long durationMs) { this.name = name; this.durationMs = durationMs; } + public boolean isThrown() { + return thrown; + } + + public long getEventRecordsCount() { + return eventRecordsCount; + } + @Override public void run() { PerformanceLogRecord record = new PerformanceLogRecord(name, durationMs); - PerformanceLogContext.getInstance().addEvent(record); - assertEquals(1, PerformanceLogContext.getInstance() - .getEventRecords().size()); + try { + PerformanceLogContext.getInstance().addEvent(record); + eventRecordsCount = PerformanceLogContext.getInstance() + .getEventRecords().size(); + PerformanceLogContext.getInstance().cleanEvents(); + } catch (Exception e) { + thrown = true; + } } } } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java index 0dc5d5e7f..847ab0a9a 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/CheckoutCommand.java @@ -1,6 +1,6 @@ /* * Copyright (C) 2010, Chris Aniszczyk - * Copyright (C) 2011, Matthias Sohn and others + * Copyright (C) 2011, 2020 Matthias Sohn and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0 which is available at @@ -503,6 +503,11 @@ private void checkoutPathsFromCommit(TreeWalk treeWalk, DirCache dc, editor.add(new PathEdit(path) { @Override public void apply(DirCacheEntry ent) { + if (ent.getStage() != DirCacheEntry.STAGE_0) { + // A checkout on a conflicting file stages the checked + // out file and resolves the conflict. + ent.setStage(DirCacheEntry.STAGE_0); + } ent.setObjectId(blobId); ent.setFileMode(mode); checkoutPath(ent, r, diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java index 73d2807ea..8c342e267 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEditor.java @@ -1,6 +1,6 @@ /* - * Copyright (C) 2008-2009, Google Inc. - * Copyright (C) 2008, Shawn O. Pearce and others + * Copyright (C) 2008, 2009, Google Inc. + * Copyright (C) 2008, 2020 Shawn O. Pearce and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0 which is available at @@ -139,10 +139,28 @@ private void applyEdits() { : eIdx; fastAdd(ent); } else { - // Apply to all entries of the current path (different stages) lastIdx = cache.nextEntry(eIdx); - for (int i = eIdx; i < lastIdx; i++) { - final DirCacheEntry ent = cache.getEntry(i); + if (lastIdx > eIdx + 1) { + // Apply to all entries of the current path (different + // stages). If any apply() resets the stage to STAGE_0, take + // only that entry and omit all others. + DirCacheEntry[] tmp = new DirCacheEntry[lastIdx - eIdx]; + int n = 0; + for (int i = eIdx; i < lastIdx; i++) { + DirCacheEntry ent = cache.getEntry(i); + e.apply(ent); + if (ent.getStage() == DirCacheEntry.STAGE_0) { + fastAdd(ent); + n = 0; + break; + } + tmp[n++] = ent; + } + for (int i = 0; i < n; i++) { + fastAdd(tmp[i]); + } + } else { + DirCacheEntry ent = cache.getEntry(eIdx); e.apply(ent); fastAdd(ent); } @@ -257,7 +275,9 @@ private static int pdir(byte[] path, int e) { * {@link #apply(DirCacheEntry)} method. The editor will invoke apply once * for each record in the index which matches the path name. If there are * multiple records (for example in stages 1, 2 and 3), the edit instance - * will be called multiple times, once for each stage. + * will be called multiple times, once for each stage. If any of these calls + * resets the stage to 0, only this entry will be taken and entries for + * other stages are discarded. */ public abstract static class PathEdit { final byte[] path; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java index dcb84825f..67edf50f4 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/dircache/DirCacheEntry.java @@ -541,6 +541,24 @@ public int getStage() { return (info[infoOffset + P_FLAGS] >>> 4) & 0x3; } + /** + * Sets the stage of an entry. + * + * @param stage + * to set, in the range [0..3] + * @throws IllegalArgumentException + * if the stage is outside the range [0..3] + * @since 5.10 + */ + public void setStage(int stage) { + if ((stage & ~0x3) != 0) { + throw new IllegalArgumentException( + "Invalid stage, must be in range [0..3]"); //$NON-NLS-1$ + } + byte flags = info[infoOffset + P_FLAGS]; + info[infoOffset + P_FLAGS] = (byte) ((flags & 0xCF) | (stage << 4)); + } + /** * Returns whether this entry should be skipped from the working tree. * diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java index e4324c1a8..741d86e67 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java @@ -1166,6 +1166,7 @@ private PackFile writePack(@NonNull Set want, // create temporary files String id = pw.computeName().getName(); File packdir = repo.getObjectDatabase().getPackDirectory(); + packdir.mkdirs(); tmpPack = File.createTempFile("gc_", ".pack_tmp", packdir); //$NON-NLS-1$ //$NON-NLS-2$ final String tmpBase = tmpPack.getName() .substring(0, tmpPack.getName().lastIndexOf('.')); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/logging/PerformanceLogContext.java b/org.eclipse.jgit/src/org/eclipse/jgit/logging/PerformanceLogContext.java index 4421efd7f..fab0dd102 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/logging/PerformanceLogContext.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/logging/PerformanceLogContext.java @@ -24,10 +24,10 @@ public class PerformanceLogContext { private static final PerformanceLogContext INSTANCE = new PerformanceLogContext(); /** List that stores events as performance logs. */ - private final ThreadLocal> eventRecords = new ThreadLocal<>(); + private static final ThreadLocal> eventRecords = ThreadLocal + .withInitial(ArrayList::new); private PerformanceLogContext() { - eventRecords.set(new ArrayList<>()); } /** @@ -62,6 +62,6 @@ public void addEvent(PerformanceLogRecord record) { * Removes all of the existing records from the current list of events. */ public void cleanEvents() { - eventRecords.get().clear(); + eventRecords.remove(); } } \ No newline at end of file diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java index 52a5576e4..350311ecc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/PacketLineIn.java @@ -1,7 +1,7 @@ /* - * Copyright (C) 2008-2010, Google Inc. - * Copyright (C) 2008-2009, Robin Rosenberg - * Copyright (C) 2008, Shawn O. Pearce and others + * Copyright (C) 2008, 2010 Google Inc. + * Copyright (C) 2008, 2009 Robin Rosenberg + * Copyright (C) 2008, 2020 Shawn O. Pearce and others * * This program and the accompanying materials are made available under the * terms of the Eclipse Distribution License v. 1.0 which is available at @@ -50,7 +50,7 @@ public class PacketLineIn { * strings in the input stream until the marker is reached. */ @Deprecated - public static final String END = new StringBuilder(0).toString(); /* must not string pool */ + public static final String END = new String(); /* must not string pool */ /** * Magic return from {@link #readString()} when a delim packet is found. @@ -60,7 +60,7 @@ public class PacketLineIn { * string is the delimiter. */ @Deprecated - public static final String DELIM = new StringBuilder(0).toString(); /* must not string pool */ + public static final String DELIM = new String(); /* must not string pool */ enum AckNackResult { /** NAK */ diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index bf7b75369..d8cab358e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -1080,8 +1080,9 @@ public Instant lastModifiedInstant(File f) { } /** - * Set the last modified time of a file system object. If the OS/JRE support - * symbolic links, the link is modified, not the target, + * Set the last modified time of a file system object. + *

+ * For symlinks it sets the modified time of the link target. * * @param f * a {@link java.io.File} object. @@ -1097,8 +1098,9 @@ public void setLastModified(File f, long time) throws IOException { } /** - * Set the last modified time of a file system object. If the OS/JRE support - * symbolic links, the link is modified, not the target, + * Set the last modified time of a file system object. + *

+ * For symlinks it sets the modified time of the link target. * * @param p * a {@link Path} object. diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java index c43956e53..aa39a4464 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FileUtils.java @@ -710,6 +710,8 @@ static BasicFileAttributes fileAttributes(File file) throws IOException { } /** + * Set the last modified time of a file system object. + * * @param file * @param time * @throws IOException @@ -720,6 +722,8 @@ static void setLastModified(File file, long time) throws IOException { } /** + * Set the last modified time of a file system object. + * * @param path * @param time * @throws IOException