Skip to content

Comments

Feat/sha256 libra#74

Merged
genedna merged 3 commits intoweb3infra-foundation:mainfrom
jackieismpc:feat/sha256-libra
Dec 5, 2025
Merged

Feat/sha256 libra#74
genedna merged 3 commits intoweb3infra-foundation:mainfrom
jackieismpc:feat/sha256-libra

Conversation

@jackieismpc
Copy link
Contributor

Summary

#72
This PR introduces initial SHA-256 support for the core commands. The goal is to make it possible to run the existing command set with SHA-256 object IDs, while keeping the current SHA-1 behavior intact and configurable.

Changes

  • Added SHA-256 support to the core command layer so that object IDs can be computed and interpreted using either SHA-1 or SHA-256.
  • Introduced helper functions at the top-level entry points to:
    • Resolve the selected hash algorithm (e.g. from config/CLI/environment).
    • Initialize the global hash kind once during startup.
    • Expose a unified abstraction so downstream code no longer needs to care whether SHA-1 or SHA-256 is used.
  • Refactored existing call sites to rely on the new initialization helpers instead of hard-coded SHA-1 usage.

Behavior and Compatibility

  • Default behavior remains unchanged for existing users (SHA-1 by default), unless SHA-256 is explicitly selected.
  • The new initialization helpers are designed to be reusable, so future hash algorithms (or additional SHA-256-related features) can be integrated with minimal changes to the call sites.

jackieismpc and others added 3 commits December 5, 2025 21:35
Signed-off-by: jackieismpc <jackieismpc@gmail.com>
Signed-off-by: 你的名字 <你的邮箱@example.com>
Signed-off-by: 你的名字 <你的邮箱@example.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces initial SHA-256 support to the Libra Git engine core command layer, enabling the use of SHA-256 object IDs alongside the existing SHA-1 implementation. The changes are substantial and well-structured:

Purpose: Enable SHA-256 as an alternative hash algorithm for Git object IDs while maintaining backward compatibility with SHA-1 as the default.

Key Changes:

  • Replaced the concrete SHA1 type with an abstract ObjectHash type throughout the codebase
  • Added hash algorithm selection during repository initialization (--object-format sha1|sha256)
  • Introduced global hash kind management and initialization helpers
  • Updated all commands, storage, and utility functions to work with the abstract hash type
  • Added comprehensive test coverage for SHA-256 workflows

Reviewed changes

Copilot reviewed 144 out of 145 changed files in this pull request and generated no comments.

Show a summary per file
File Description
third-party/rust/crates/**/BUCK Cleanup of unused third-party dependency definitions and feature flags
tests/command/*.rs Added SHA-256 test cases for core workflows (commit, cherry-pick, checkout, blame, reset)
src/utils/*.rs Updated utility functions to use ObjectHash abstraction
src/internal/*.rs Updated internal types (Branch, Head, Tag, Reflog) to use ObjectHash
src/command/*.rs All commands updated to support both hash algorithms with proper validation
src/command/init.rs Enhanced to accept and validate --object-format parameter, initialize global hash kind
src/command/index_pack.rs Added hash kind validation for pack index operations
src/command/commit.rs Removed hard-coded empty tree hash, made it dynamic based on hash kind

@genedna genedna merged commit aa3796b into web3infra-foundation:main Dec 5, 2025
11 checks passed
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