From 224194b2ad4e1b8e54dfd08a69179a7d5b54cd31 Mon Sep 17 00:00:00 2001 From: Michael Osipov Date: Thu, 28 Mar 2024 21:22:46 +0100 Subject: [PATCH] Don't use buggy clone --- .../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 @@ protected ScmResult executeCommand( 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);