WIP: Exclude binary files from JJ diffs #51

Draft
Copilot wants to merge 3 commits from copilot/exclude-binary-files-diff into main
Copilot commented 2025-11-29 17:35:57 +00:00 (Migrated from github.com)

Binary files in JJ diffs were causing context to become too large for the AI model. This PR filters them out, outputting only a minimal notification line instead of the full binary content.

Changes

  • Binary detection: Added is_binary_content() using git's heuristic (null byte check in first 8KB)
  • Diff filtering: Modified get_jj_diff() and get_jj_diff_for_files() to skip binary content for added/deleted/modified files
  • Optimized reads: Check source file first; only read target if source is text (per review feedback)

Output for binary files

Binary file assets/logo.png added
Binary file images/screenshot.png modified
Binary file old-binary.dat deleted

Note on file selection

File selection for JJ already exists via decide_diff_jj() in util.rs - works identically to Git with --select-files flag or automatic prompt when token limit exceeded.

Original prompt

For JJ usage it should NOT include binary files in the diff it uses, because now whenever there is a bin file the context get's to obig of course. That at a minimum. Also just answer me, do we still have the feature to select files for the diff? I think we had that with git but not sure if we removed that fully or just support it for git right now, maybe research if that is also doable for jj


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Binary files in JJ diffs were causing context to become too large for the AI model. This PR filters them out, outputting only a minimal notification line instead of the full binary content. ## Changes - **Binary detection**: Added `is_binary_content()` using git's heuristic (null byte check in first 8KB) - **Diff filtering**: Modified `get_jj_diff()` and `get_jj_diff_for_files()` to skip binary content for added/deleted/modified files - **Optimized reads**: Check source file first; only read target if source is text (per review feedback) ## Output for binary files ``` Binary file assets/logo.png added Binary file images/screenshot.png modified Binary file old-binary.dat deleted ``` ## Note on file selection File selection for JJ already exists via `decide_diff_jj()` in `util.rs` - works identically to Git with `--select-files` flag or automatic prompt when token limit exceeded. <!-- START COPILOT CODING AGENT SUFFIX --> <details> <summary>Original prompt</summary> > For JJ usage it should NOT include binary files in the diff it uses, because now whenever there is a bin file the context get's to obig of course. That at a minimum. Also just answer me, do we still have the feature to select files for the diff? I think we had that with git but not sure if we removed that fully or just support it for git right now, maybe research if that is also doable for jj </details> <!-- START COPILOT CODING AGENT TIPS --> --- 💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.
dikkadev (Migrated from github.com) reviewed 2025-11-29 17:35:57 +00:00
This pull request is marked as a work in progress.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin copilot/exclude-binary-files-diff:copilot/exclude-binary-files-diff
git switch copilot/exclude-binary-files-diff

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff copilot/exclude-binary-files-diff
git switch copilot/exclude-binary-files-diff
git rebase main
git switch main
git merge --ff-only copilot/exclude-binary-files-diff
git switch copilot/exclude-binary-files-diff
git rebase main
git switch main
git merge --no-ff copilot/exclude-binary-files-diff
git switch main
git merge --squash copilot/exclude-binary-files-diff
git switch main
git merge --ff-only copilot/exclude-binary-files-diff
git switch main
git merge copilot/exclude-binary-files-diff
git push origin main
Sign in to join this conversation.
No description provided.