Skip to content

Avoid reading full binary files during detection - #3763

Open
puneetdixit200 wants to merge 1 commit into
sharkdp:masterfrom
puneetdixit200:fix-binary-detection-prefix
Open

puneetdixit200 wants to merge 1 commit into
sharkdp:masterfrom
puneetdixit200:fix-binary-detection-prefix

Conversation

@puneetdixit200

Copy link
Copy Markdown

Summary

  • cap initial binary detection reads at an 8 KiB prefix for newline-free binary files
  • keep text and UTF-16 first-line handling unchanged by continuing to read full text lines
  • skip default interactive binary line printing while preserving loop-through, show-all, and --binary=as-text paths

Fixes #2262

Tests

  • env CARGO_TARGET_DIR=/tmp/bat-target cargo test --lib input::
  • env CARGO_TARGET_DIR=/tmp/bat-target cargo test --lib controller::tests::
  • env CARGO_TARGET_DIR=/tmp/bat-target cargo test binary --test integration_tests
  • env CARGO_TARGET_DIR=/tmp/bat-target cargo test
  • env CARGO_TARGET_DIR=/tmp/bat-target cargo clippy --all-targets --all-features -- -D warnings
  • cargo fmt --check
  • git diff --check

@puneetdixit200
puneetdixit200 force-pushed the fix-binary-detection-prefix branch 2 times, most recently from 27372e0 to 1718c2a Compare May 22, 2026 05:14

This branch has not been deployed

No deployments
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.

Detect binary file takes too long

1 participant