Skip to content

fix(lockfile): normalize git commit object IDs to lowercase - #112

Merged
LunaStev merged 1 commit into
wavefnd:masterfrom
isaim0011:fix/normalize-git-commit-ids
Sep 21, 2026
Merged

LunaStev merged 1 commit into
wavefnd:masterfrom
isaim0011:fix/normalize-git-commit-ids

Conversation

@isaim0011

@isaim0011 isaim0011 commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Closes #111

Summary

Git commit object IDs parsed from vex.lock can contain uppercase or mixed-case hexadecimal characters. While validate_commit accepts valid 40-char (SHA-1) or 64-char (SHA-256) hex strings regardless of case, downstream identity checks (such as require_checkout_at and checkout_commit) compare against canonical lowercase hashes output by git rev-parse HEAD.

This PR normalizes commit strings to lowercase during lockfile parsing (commit.to_ascii_lowercase()), ensuring:

  • In-memory representations match git rev-parse HEAD lowercase comparisons.
  • Lockfile contents on disk remain untouched (not rewritten) during read-only or locked operations (--locked, --offline).
  • Invalid characters and unsupported commit lengths remain rejected.

Testing

  • Added unit tests in src/lockfile.rs:
    • normalizes_sha1_and_sha256_git_commits_to_lowercase (tests lowercase, uppercase, and mixed-case for both 40-char SHA-1 and 64-char SHA-256).
    • rejects_abbreviated_invalid_and_unsupported_length_commits (tests non-hex chars, spaces, and invalid lengths: 16, 39, 41, 63, 65 chars).
  • Added integration test in tests/git_lock_reproducibility.rs:
    • git_lock_accepts_uppercase_and_mixed_case_commit_ids_without_recheckout (verifies uppercase and mixed-case commit IDs succeed under --locked and --offline without re-checkout or rewriting vex.lock, and invalid commits are rejected).
  • Verified with full test suite passing (cargo test --locked).

@isaim0011
isaim0011 force-pushed the fix/normalize-git-commit-ids branch from 8e5f048 to f24f2d4 Compare September 21, 2026 07:02
@LunaStev
LunaStev self-requested a review September 21, 2026 07:58

@LunaStev LunaStev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, thanks for the contribution!

The normalization is applied at the right boundary during lockfile parsing, while preserving the original lockfile contents for locked/offline operations. The SHA-1/SHA-256 parser coverage and the local Git regression test also cover the issue well.

@LunaStev
LunaStev merged commit e4fd8fd into wavefnd:master Sep 21, 2026
8 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.

Normalize accepted Git object IDs before checkout identity comparisons

2 participants