Skip to content

fix: support SHA-256 git repositories in --diff - #4143

Merged
keith-hall merged 2 commits into
sharkdp:masterfrom
BlueX888:contrib/sha256-git-diff
Nov 21, 2026
Merged

keith-hall merged 2 commits into
sharkdp:masterfrom
BlueX888:contrib/sha256-git-diff

Conversation

@BlueX888

Copy link
Copy Markdown
Contributor

In a repository created with git init --object-format=sha256, bat --diff printed no line content and --style=changes showed no change-marker column, both with exit code 0 — indistinguishable from "no changes". bat builds gix with default-features = false and only sha1 + blob-diff; gix gates SHA-256 repository support behind its sha256 feature, so gix cannot open the repository and get_git_diff() returns None.

Enabling the sha256 feature restores diff mode and the change-marker column in SHA-256 repositories; SHA-1 repositories are unchanged. The lockfile change is limited to the seven RustCrypto crates pulled in by that feature.

Tests:

  • New diff_is_calculated_in_sha256_repository creates a git init --object-format=sha256 repository, commits, modifies a tracked file, and asserts get_git_diff returns the added line. It fails on master and passes here.
  • cargo test --locked --lib — 155 passed; cargo test --locked --test integration_tests diff — 5 passed.
  • cargo fmt --check; cargo clippy --locked --all-targets --all-features -- -D warnings.
  • CLI before/after: bat --diff and --style=changes show the changed line in a SHA-256 repository; a SHA-1 repository behaves as before.
  • CHANGELOG.md Bugfixes entry added per the repository's changelog workflow.

gix was built without its `sha256` feature, so repositories created with
`git init --object-format=sha256` could not be opened and `get_git_diff`
returned None. `--diff` then printed no content and `--style=changes` showed
no change markers, both with exit code 0.

Enable the gix `sha256` feature and add a regression test.
@keith-hall
keith-hall merged commit dbc11b6 into sharkdp:master Nov 21, 2026
24 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