Skip to content

JGit unable to read sha256 IDs #73

@BrotherPatrix

Description

@BrotherPatrix

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions