Skip to content

JGit unable to read sha256 IDs #73

Open

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.

Activity

  1. mitr15fan15v commented on Jul 19, 2024

    @mitr15fan15v

    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

  2. msohn commented on Jul 30, 2024

    @msohn
    Member

    JGit doesn't yet support SHA-256 object IDs

  3. theoparis commented on Sep 22, 2024

    @theoparis

    Why is this closed if this is not implemented?

  4. added
    enhancement
    on Sep 23, 2024
  5. msohn commented on Sep 23, 2024

    @msohn
    Member

    reopened and marked as enhancement request

  6. reopened this on Sep 23, 2024
  7. bk2204 commented on Oct 1, 2025

    @bk2204

    I'll just note that Git 3.0 will make SHA-256 the default algorithm for new repositories. The estimated release timeframe is approximately a year from now, although the exact details are being discussed on the Git list.

  8. stevenschlansker commented on Jan 28, 2026

    @stevenschlansker

    We found that this issue blocks OpenGrok using repos with SHA-256 hashes enabled.

  9. joestr commented on Sep 23, 2026

    @joestr

    Can this issue be prioritised somehow?

  10. joestr commented on Oct 2, 2026

    @joestr

    I opened a change request on GerritHub: https://eclipse.gerrithub.io/c/eclipse-jgit/jgit/+/1252947

  11. sebthom commented on Oct 14, 2026

    @sebthom

    I would appreciate if this would get addressed. Current user experience is aweful. When one tries to clone a repo with SHA256 the UI shows wild cryptic error messages and when you import a project cloned on the console constantly other kinds of exceptions and errors are poping up. If implementing support is not feasible right now, then please at least raise exceptions with meaningful error messages that are actionable by users.

  12. Geolykt commented on Oct 14, 2026

    @Geolykt

    16. I would appreciate if this would get addressed. Current user experience is aweful. When one tries to clone a repo with SHA256 the UI shows wild cryptic error messages and when you import a project cloned on the console constantly other kinds of exceptions and errors are poping up. If implementing support is not feasible right now, then please at least raise exceptions with meaningful error messages that are actionable by users.

    What UI are you referring to for reference? jgit by itself has no UI iirc

  13. sebthom commented on Oct 15, 2026

    @sebthom

    What UI are you referring to for reference? jgit by itself has no UI iirc

    Its most prominent consumer ... EGit. But egit cannot show anything more meaningful if the underlying library does not provide proper execpetions.

  14. joestr commented on Oct 19, 2026

    @joestr

    What UI are you referring to for reference? jgit by itself has no UI iirc

    Also Apache Netbeans goes haywire if it encounters SHA256 repos.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions