You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by mi...@apache.org on 2024/04/07 20:34:34 UTC

(maven-scm) 02/04: Don't use buggy clone

This is an automated email from the ASF dual-hosted git repository.

michaelo pushed a commit to branch feature/expose-last-modified-date
in repository https://gitbox.apache.org/repos/asf/maven-scm.git

commit 575625cb35e7714b5a2a5db6e0f05251c6dc3f99
Author: Michael Osipov <mi...@apache.org>
AuthorDate: Thu Mar 28 21:22:46 2024 +0100

    Don't use buggy clone
---
 .../provider/git/gitexe/command/info/GitInfoCommand.java    | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java
index e499a92a4..7e398d526 100644
--- a/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java
+++ b/maven-scm-providers/maven-scm-providers-git/maven-scm-provider-gitexe/src/main/java/org/apache/maven/scm/provider/git/gitexe/command/info/GitInfoCommand.java
@@ -59,13 +59,16 @@ public class GitInfoCommand extends AbstractCommand implements GitCommand {
         if (fileSet.getFileList().isEmpty()) {
             infoItems.add(executeInfoCommand(baseCli, parameters, fileSet.getBasedir()));
         } else {
-            // Insert a separator to make sure that files aren't interpreted as part of the version spec
-            baseCli.createArg().setValue("--");
             // iterate over files
             for (File scmFile : fileSet.getFileList()) {
-                Commandline cliClone = (Commandline) baseCli.clone();
-                GitCommandLineUtils.addTarget(cliClone, Collections.singletonList(scmFile));
-                infoItems.add(executeInfoCommand(cliClone, parameters, scmFile));
+                baseCli = GitCommandLineUtils.getBaseGitCommandLine(fileSet.getBasedir(), "log");
+                baseCli.createArg().setValue("-1"); // only most recent commit matters
+                baseCli.createArg().setValue("--no-merges"); // skip merge commits
+                baseCli.addArg(GitInfoConsumer.getFormatArgument());
+                // Insert a separator to make sure that files aren't interpreted as part of the version spec
+                baseCli.createArg().setValue("--");
+                GitCommandLineUtils.addTarget(baseCli, Collections.singletonList(scmFile));
+                infoItems.add(executeInfoCommand(baseCli, parameters, scmFile));
             }
         }
         return new InfoScmResult(baseCli.toString(), infoItems);