Skip to content

Add sha256 object format support - #140

Closed
linsein wants to merge 2 commits into
gogs:v2from
linsein:feat-sha256
Closed

linsein wants to merge 2 commits into
gogs:v2from
linsein:feat-sha256

Conversation

@linsein

@linsein linsein commented Jul 8, 2026

Copy link
Copy Markdown

Describe the pull request

Link to the issue: #138

ObjectFormat struct

  • Add the ObjectFormat struct.
  • Add the *Repository.ObjectFormat method.
  • Add an ObjectFormat member to the InitOption struct

Oid interface

  • Add the Oid interface to represent the Object ID of a Git repository.
  • Add the SHA256 struct.
  • Replace *SHA1 with Oid in other struct fields, method parameters, and return types.
  • Rename the file sha1.go to oid.go.

Add SHA256 Repository testing

  • Add the test_sha256 build tag to control testing variables and constants.
  • Replace hard-coded hashes with the testrepoMarks map.

Others

  • Fix TestReceivePack and TestUploadPack failures occurring on Git client v2.54.0 by updating the string matching patterns.

Checklist

  • I agree to follow the Code of Conduct by submitting this pull request.
  • I have read and acknowledge the Contributing guide.
  • I have added test cases to cover the new code.

@linsein
linsein requested a review from a team as a code owner July 8, 2026 05:50
@linsein

linsein commented Jul 8, 2026

Copy link
Copy Markdown
Author

Just noticed that the sha256 object format was experimentally supported in Git 2.29 and marked as stable in 2.51.
If using a version of Git earlier than 2.29, users will get error: unknown option 'object-format=sha256'.

Should I give a friendlier error message? Or is it too early to add sha256 support?

@unknwon

unknwon commented Jul 16, 2026

Copy link
Copy Markdown
Member

Just noticed that the sha256 object format was experimentally supported in Git 2.29 and marked as stable in 2.51. If using a version of Git earlier than 2.29, users will get error: unknown option 'object-format=sha256'.

Should I give a friendlier error message? Or is it too early to add sha256 support?

no we can just claim v2 requires Git 2.51, no issue.

unknwon added a commit to gogs/gogs that referenced this pull request Nov 12, 2026
Object IDs in internal/git are now an Oid, either a *SHA1 or a *SHA256,
following gogs/git-module#140. Tree listings are parsed without assuming
the length of an ID, and the empty ID of a reference update is
recognized in either object format.

Repositories can be created with a chosen object format from the web
form and the API. Routes, references and links accept 64-character
commit IDs, and a migration widens the database columns that store
commit IDs to 64 characters.

Co-authored-by: Linsen Zhou <i@lin.moe>
unknwon added a commit to gogs/gogs that referenced this pull request Nov 12, 2026
Object IDs in internal/git are now an Oid, either a *SHA1 or a *SHA256,
following gogs/git-module#140. Tree listings are parsed without assuming
the length of an ID, and the empty ID of a reference update is
recognized in either object format.

Repositories can be created with a chosen object format from the web
form and the API. Routes, references and links accept 64-character
commit IDs, and a migration widens the database columns that store
commit IDs to 64 characters.

Co-authored-by: Linsen Zhou <i@lin.moe>
unknwon added a commit to gogs/gogs that referenced this pull request Nov 12, 2026
Object IDs in internal/git are now an Oid, either a *SHA1 or a *SHA256,
following gogs/git-module#140. Tree listings are parsed without assuming
the length of an ID, and the empty ID of a reference update is
recognized in either object format.

Repositories can be created with a chosen object format from the web
form and the API. Routes, references and links accept 64-character
commit IDs, and a migration widens the database columns that store
commit IDs to 64 characters.

Co-authored-by: Linsen Zhou <i@lin.moe>
@unknwon

unknwon commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

I ported this pr and finished and co-authored you in gogs/gogs#8496

@unknwon unknwon closed this Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants