eclipse-jgit / jgit

JGit, the Java implementation of git
https://www.eclipse.org/jgit/
Other
121 stars 34 forks source link

JGit unable to read sha256 IDs #73

Closed BrotherPatrix closed 1 month ago

BrotherPatrix commented 1 month ago

Version

6.10.0.202406032230-r

Operating System

Linux/Unix

Bug description

I'm having trouble in trying to work with a git repository using JGit and I believe that because this repository is with objectFormat sha256, this may break functionality.

Actual behavior

java.lang.RuntimeException: org.eclipse.jgit.api.errors.JGitInternalException: An exception occurred while trying to add the Id of HEAD
    at gss.dms.versioning.Versioning.useJGit(Versioning.java:119)
    at gss.dms.versioning.Versioning.calculateVersion(Versioning.java:85)
    at gss.dms.versioning.VersioningApplication.call(VersioningApplication.java:44)
    at gss.dms.versioning.VersioningApplication.call(VersioningApplication.java:16)
    at picocli.CommandLine.executeUserObject(CommandLine.java:2045)
    at picocli.CommandLine.access$1500(CommandLine.java:148)
    at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2465)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2457)
    at picocli.CommandLine$RunLast.handle(CommandLine.java:2419)
    at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2277)
    at picocli.CommandLine$RunLast.execute(CommandLine.java:2421)
    at picocli.CommandLine.execute(CommandLine.java:2174)
    at gss.dms.versioning.VersioningApplication.main(VersioningApplication.java:53)
Caused by: org.eclipse.jgit.api.errors.JGitInternalException: An exception occurred while trying to add the Id of HEAD
    at org.eclipse.jgit.api.LogCommand.call(LogCommand.java:135)
    at gss.dms.versioning.Versioning.useJGit(Versioning.java:98)
    ... 12 more
Caused by: java.io.IOException: Cannot read file .../.git/packed-refs
    at org.eclipse.jgit.internal.storage.file.RefDirectory.readPackedRefs(RefDirectory.java:1003)
    at org.eclipse.jgit.internal.storage.file.RefDirectory.refreshPackedRefs(RefDirectory.java:975)
    at org.eclipse.jgit.internal.storage.file.RefDirectory.getPackedRefs(RefDirectory.java:966)
    at org.eclipse.jgit.internal.storage.file.RefDirectory.firstExactRef(RefDirectory.java:353)
    at org.eclipse.jgit.lib.RefDatabase.findRef(RefDatabase.java:281)
    at org.eclipse.jgit.lib.Repository.findRef(Repository.java:1102)
    at org.eclipse.jgit.lib.Repository.resolve(Repository.java:815)
    at org.eclipse.jgit.lib.Repository.resolve(Repository.java:473)
    at org.eclipse.jgit.api.LogCommand.call(LogCommand.java:127)
    ... 13 more
Caused by: org.eclipse.jgit.errors.InvalidObjectIdException: Invalid id: 6cd515c54340f94cd4150ef3653ca154c0fb2e010ea255017bc82c2ec156c056
    at org.eclipse.jgit.lib.ObjectId.fromString(ObjectId.java:203)
    at org.eclipse.jgit.internal.storage.file.RefDirectory.parsePackedRefs(RefDirectory.java:1049)
    at org.eclipse.jgit.internal.storage.file.RefDirectory.lambda$2(RefDirectory.java:994)
    at org.eclipse.jgit.util.FileUtils.readWithRetries(FileUtils.java:733)
    at org.eclipse.jgit.internal.storage.file.RefDirectory.readPackedRefs(RefDirectory.java:985)
    ... 21 more

Expected behavior

I expected JGit to be able to read this .git folder.

Relevant log output

No response

Other information

I've done some research and it seems that this repository has object format sha256 instead of sha1 which leads me to believe that JGit does not support this hashing algorithm yet.

To further test this, I've installed the latest Eclipse 2024-06 available with EGit installed and I tried to add the project and I get the exact same errors.

Another bit of information that I can provide is that the repository was created using a Forgejo server and the person that created it confirmed that he selected sha256 as object format.

I've added this as a bug, because this is unclear to me if it was on a roadmap or not, but feel free to change it to a feature request.

mitr15fan15v commented 1 month ago

Missing Features There are some missing features:

signing push shallow and partial cloning support for remote helpers support for credential helpers support for multiple working trees (git-worktree) using external diff tools support for HTTPS client certificates SHA-256 object IDs git protocol V2 (client side): packfile-uris multi-pack index split index

msohn commented 1 month ago

JGit doesn't yet support SHA-256 object IDs