Merge branch 'master' into stable-7.6 * master: Add AddCommand #addFilepatterns methods Bazel: Pin jcl-over-slf4j to SLF4J_VERSION Change-Id: I09c2ce5ecc00a0811fbea636200e3565083c2089
diff --git a/MODULE.bazel b/MODULE.bazel index c8f5319..37077bc 100644 --- a/MODULE.bazel +++ b/MODULE.bazel
@@ -81,6 +81,7 @@ "org.openjdk.jmh:jmh-core:" + JMH_VERSION, "org.openjdk.jmh:jmh-generator-annprocess:" + JMH_VERSION, "org.slf4j:slf4j-api:" + SLF4J_VERSION, + "org.slf4j:jcl-over-slf4j:" + SLF4J_VERSION, "org.slf4j:slf4j-simple:" + SLF4J_VERSION, "org.tukaani:xz:1.11", ],
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/category.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/category.xml index 08294c7..ead448d 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/category.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.repository/category.xml
@@ -216,6 +216,12 @@ <bundle id="slf4j.simple.source"> <category name="JGit-dependency-bundles"/> </bundle> + <bundle id="jcl.over.slf4j"> + <category name="JGit-dependency-bundles"/> + </bundle> + <bundle id="jcl.over.slf4j.source"> + <category name="JGit-dependency-bundles"/> + </bundle> <bundle id="org.tukaani.xz"> <category name="JGit-dependency-bundles"/> </bundle>
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.34.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.34.target index 2d3f362..24715ea 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.34.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.34.target
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <?pde?> <!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl --> -<target name="jgit-4.34" sequenceNumber="1771451400"> +<target name="jgit-4.34" sequenceNumber="1772188163"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/> @@ -58,6 +58,12 @@ <version>2.0.17</version> <type>jar</type> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>2.0.17</version> + <type>jar</type> + </dependency> </dependencies> </location> <location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="error" type="Maven" label="sshd">
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.35.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.35.target index 5ec0fcc..b53ad33 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.35.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.35.target
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <?pde?> <!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl --> -<target name="jgit-4.35" sequenceNumber="1771451400"> +<target name="jgit-4.35" sequenceNumber="1772188163"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/> @@ -58,6 +58,12 @@ <version>2.0.17</version> <type>jar</type> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>2.0.17</version> + <type>jar</type> + </dependency> </dependencies> </location> <location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="error" type="Maven" label="sshd">
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.36.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.36.target index 3a8524f..269dd9a 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.36.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.36.target
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <?pde?> <!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl --> -<target name="jgit-4.36" sequenceNumber="1771451400"> +<target name="jgit-4.36" sequenceNumber="1772188163"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/> @@ -58,6 +58,12 @@ <version>2.0.17</version> <type>jar</type> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>2.0.17</version> + <type>jar</type> + </dependency> </dependencies> </location> <location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="error" type="Maven" label="sshd">
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.37.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.37.target index 8129842..9474a6b 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.37.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.37.target
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <?pde?> <!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl --> -<target name="jgit-4.37" sequenceNumber="1771451400"> +<target name="jgit-4.37" sequenceNumber="1772188163"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/> @@ -58,6 +58,12 @@ <version>2.0.17</version> <type>jar</type> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>2.0.17</version> + <type>jar</type> + </dependency> </dependencies> </location> <location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="error" type="Maven" label="sshd">
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.38.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.38.target index bdaac33..250c5a0 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.38.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.38.target
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <?pde?> <!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl --> -<target name="jgit-4.38" sequenceNumber="1771451400"> +<target name="jgit-4.38" sequenceNumber="1772188163"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/> @@ -58,6 +58,12 @@ <version>2.0.17</version> <type>jar</type> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>2.0.17</version> + <type>jar</type> + </dependency> </dependencies> </location> <location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="error" type="Maven" label="sshd">
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.39.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.39.target index 995e06b..1682581 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.39.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.39.target
@@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8" standalone="no"?> <?pde?> <!-- generated with https://github.com/eclipse-cbi/targetplatform-dsl --> -<target name="jgit-4.39" sequenceNumber="1771451400"> +<target name="jgit-4.39" sequenceNumber="1772188163"> <locations> <location includeMode="slicer" includeAllPlatforms="false" includeSource="true" includeConfigurePhase="true" type="InstallableUnit"> <unit id="com.jcraft.jsch" version="0.1.55.v20230916-1400"/> @@ -58,6 +58,12 @@ <version>2.0.17</version> <type>jar</type> </dependency> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>2.0.17</version> + <type>jar</type> + </dependency> </dependencies> </location> <location includeDependencyDepth="none" includeDependencyScopes="compile" includeSource="true" missingManifest="error" type="Maven" label="sshd">
diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/maven/dependencies.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/maven/dependencies.tpd index 314de5d..d5d06dc 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/maven/dependencies.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/maven/dependencies.tpd
@@ -263,6 +263,11 @@ artifactId = "slf4j-simple" version = "2.0.17" } + dependency { + groupId = "org.slf4j" + artifactId = "jcl-over-slf4j" + version = "2.0.17" + } } maven xz
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java index 2266772..0d87109 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/api/AddCommandTest.java
@@ -27,6 +27,7 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.nio.file.Files; +import java.util.List; import java.util.Set; import java.util.concurrent.TimeUnit; @@ -110,6 +111,46 @@ public void testAddExistingSingleFile() throws IOException, GitAPIException { } @Test + public void testAddExistingMultipleFiles() + throws IOException, GitAPIException { + File file = new File(db.getWorkTree(), "a.txt"); + FileUtils.createNewFile(file); + file = new File(db.getWorkTree(), "b.txt"); + FileUtils.createNewFile(file); + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { + writer.print("content"); + } + + try (Git git = new Git(db)) { + git.add().addFilepatterns("a.txt", "b.txt").call(); + + assertEquals( + "[a.txt, mode:100644, content:][b.txt, mode:100644, content:content]", + indexState(CONTENT)); + } + } + + @Test + public void testAddExistingMultipleFilesCollection() + throws IOException, GitAPIException { + File file = new File(db.getWorkTree(), "a.txt"); + FileUtils.createNewFile(file); + file = new File(db.getWorkTree(), "b.txt"); + FileUtils.createNewFile(file); + try (PrintWriter writer = new PrintWriter(file, UTF_8.name())) { + writer.print("content"); + } + + try (Git git = new Git(db)) { + git.add().addFilepatterns(List.of("a.txt", "b.txt")).call(); + + assertEquals( + "[a.txt, mode:100644, content:][b.txt, mode:100644, content:content]", + indexState(CONTENT)); + } + } + + @Test public void testAddLink() throws IOException, GitAPIException { assumeTrue(db.getFS().supportsSymlinks()); try (Git git = new Git(db)) {
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java index b4d1cab..23bda6f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/api/AddCommand.java
@@ -20,7 +20,9 @@ import java.text.MessageFormat; import java.time.Instant; import java.util.ArrayList; +import java.util.Collection; import java.util.List; +import java.util.Objects; import org.eclipse.jgit.api.errors.FilterFailedException; import org.eclipse.jgit.api.errors.GitAPIException; @@ -114,6 +116,36 @@ public AddCommand addFilepattern(String filepattern) { } /** + * Add paths to a file/directory whose content should be added. + * + * @param patterns + * repository-relative paths of file/directory to add (with + * <code>/</code> as separator) + * @return {@code this} + * @since 7.6 + */ + public AddCommand addFilepatterns(String... patterns) { + List.of(Objects.requireNonNull(patterns)).forEach(this::addFilepattern); + return this; + } + + /** + * Add paths to a file/directory whose content should be added. + * + * @param patterns + * repository-relative paths of file/directory to add (with + * <code>/</code> as separator) + * @return {@code this} + * @since 7.6 + */ + public AddCommand addFilepatterns(Collection<String> patterns) { + if (patterns != null) { + patterns.forEach(this::addFilepattern); + } + return this; + } + + /** * Allow clients to provide their own implementation of a FileTreeIterator * * @param f
diff --git a/pom.xml b/pom.xml index 57849fa..26f0053 100644 --- a/pom.xml +++ b/pom.xml
@@ -970,6 +970,12 @@ </dependency> <dependency> + <groupId>org.slf4j</groupId> + <artifactId>jcl-over-slf4j</artifactId> + <version>${slf4j-version}</version> + </dependency> + + <dependency> <groupId>com.google.code.gson</groupId> <artifactId>gson</artifactId> <version>${gson-version}</version>