Can't "calculate distance"
Describe the bug
Using the Maven plugin under Java 16 produces:
[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:4.0.0:revision (default) on project missioncontrol-ui: Could not complete Mojo execution...: Unable to calculate distance between [commit f976ff5a182d64ad40c3fddd5a26c52a01c35b87 1615476615 ----sp] and [commit 88c9bb3a19a570c30f2e55ab7f9a74d2647ef221 1615471284 ----sp]: Missing commit 8cb5a9485154c19fc4eb6866653394f34bbf6f5d -> [Help 1]
Steps to Reproduce
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.4</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>initialize</phase>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
<includeOnlyProperty>^git.branch$</includeOnlyProperty>
<includeOnlyProperty>^git.tags$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
</configuration>
</plugin>
Hi, thanks for reporting your problem! Just curious:
- Have you tested the issue occurs with other java versions too? E.g. java 12? For me this sounds unrelated to the java version used.
- Are you operating on a shallow clone? Or rebased recently?
- Does the problem still exists when running the plugin with the native git binary? E.g. by adding
<useNativeGit>false</useNativeGit>to the configuration section?
Today I got this error for the first time in 3 years.
[ERROR] Failed to execute goal pl.project13.maven:git-commit-id-plugin:3.0.1:revision (get-the-git-infos) on project integration-test-base: Could not complete Mojo execution...: Unable to calculate distance between [commit 588c76345f1fffc5d159cfe90a22cca5ceb162cc 1627017891 ----sp] and [commit 8f67ef47a6d465675f4559306bfa25d3530069a0 1626458946 ----sp]: Missing commit 14c7b7588854455277cc09839911a22ea96851cd
The commit 14c7b7588854455277cc09839911a22ea96851cd is a 4 month old commit that is definitely present - I can checkout a new branch from it.
Java 11, git-commit-id-plugin v 2.2.6 and 3.0.1.
With <useNativeGit>false</useNativeGit> it fails with the same error.
With <useNativeGit>true</useNativeGit> it all works without an issue.
My machine has git version 2.32.0.
Hi, thanks for the follow-up and sorry that the JGit Implementation breaks. Are you perhaps performing a shallow clone? I rephrased the name of the ticket, since it's not a Java 16 issue...it's a general issue with the plugin.
It's not a shallow clone.
The system that has this issue also has git maintenance running regularly.
0 1-23 * * * "/usr/lib/git-core/git" --exec-path="/usr/lib/git-core" for-each-repo --config=maintenance.repo maintenance run --schedule=hourly
0 0 * * 1-6 "/usr/lib/git-core/git" --exec-path="/usr/lib/git-core" for-each-repo --config=maintenance.repo maintenance run --schedule=daily
0 0 * * 0 "/usr/lib/git-core/git" --exec-path="/usr/lib/git-core" for-each-repo --config=maintenance.repo maintenance run --schedule=weekly
https://git-scm.com/docs/git-maintenance
I think this maintenance has overly compacted something and now JGit fails.
On another system without git maintenance there is no issue. Also if I do a fresh clone - again there is no issue.
Interesting. Thanks for the update. It seems that a while back we also had this issue appearing in the wild (https://github.com/git-commit-id/git-commit-id-maven-plugin/issues/63). However it seems that "we" never really understood it's root cause. Let me keep this open and explore it when I have more free time again :-)