Skip to content

Conversation

@weihanglo
Copy link
Member

@weihanglo weihanglo commented Jan 3, 2026

Blocked on libgit2/libgit2#7182


This adds an unstable-sha256 Cargo feature,
as a follow-up of #1201

Also adds some smoke tests for affected operations/types.

Part of #1090

Insta-stable

  • NEW ObjectFormat enum with variants Sha1
  • NEW Repository::object_format() to query hash algorithm
  • NEW Index::with_object_format to create with different format

Behind unstable-sha256

  • NEW ObjectFormat enum with variants Sha1 and Sha256
  • NEW RepositoryInitOptions::object_format() method to set hash algo
  • CHANGED Diff::from_buffer to accept a extra object format argument
  • CHANGED Index::open to accept a extra object format argument
  • CHANGED Indexer::new to accept a extra object format argument
  • CHANGED Oid::from_str to accept a extra object format argument
  • CHANGED Oid::hash_{object,file} to accept a extra object format argument
  • REMOVED Index::new to avoid misuse.
  • REMOVED impl std::FromStr for Oid to avoid misuse

This is not behind any experimental flag.
Should be fine exposing directly
`git_oid_iszero` has been deprecated.
Raw git_oid binding has an extra field for object format kind.
The old all-zeroed struct is now an valid oid when the feature
`unstable-sha256` is enabled.

This adds an warning to the `Oid::zero` function that it should only be
used an output parameter when talking to C API. If you need valid zeroed
input parameter, use libgit2 constants `GIT_OID_SHA*_ZERO` instead.
This adds an `unstable-sha256` Cargo feature,
as a follow-up of rust-lang#1201

Also adds some smoke tests for affected operations/types.

## Insta-stable

* **NEW** `ObjectFormat` enum with variants `Sha1`
* **NEW** `Repository::object_format()` to query hash algorithm
* **NEW** `Index::with_object_format` to create with different format

## Behind `unstable-sha256

* **NEW** `ObjectFormat` enum with variants `Sha1` and `Sha256`
* **NEW** `RepositoryInitOptions::object_format()` method to set hash algo
* **CHANGED** `Diff::from_buffer` to accept a extra object format argument
* **CHANGED** `Index::open` to accept a extra object format argument
* **CHANGED** `Indexer::new` to accept a extra object format argument
* **CHANGED** `Oid::from_str` to accept a extra object format argument
* **CHANGED** `Oid::hash_{object,file}` to accept a extra object format argument
* **REMOVED** `Index::new` to avoid misuse.
* **REMOVED** `impl std::FromStr for Oid` to avoid misuse
@rustbot
Copy link
Collaborator

rustbot commented Jan 11, 2026

☔ The latest upstream changes (possibly 991c346) made this pull request unmergeable. Please resolve the merge conflicts.

@rustbot rustbot added the S-waiting-on-author Status: Waiting on PR author label Jan 11, 2026
@weihanglo weihanglo closed this Jan 11, 2026
@weihanglo weihanglo deleted the sha256-git2 branch January 11, 2026 20:36
@weihanglo weihanglo restored the sha256-git2 branch January 11, 2026 20:36
@weihanglo
Copy link
Member Author

Accidentally deleted the branch. Anyway, this is still waiting for a new release of libgit2 with some of my patches. Will post a new one when time comes.

@weihanglo weihanglo deleted the sha256-git2 branch January 11, 2026 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: Waiting on PR author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants