Skip to content

Fixes #5405 - binary file handling in the Commit Composer#5440

Open
nshepperd wants to merge 1 commit into
gitkraken:mainfrom
nshepperd:bug/b5405
Open

Fixes #5405 - binary file handling in the Commit Composer#5440
nshepperd wants to merge 1 commit into
gitkraken:mainfrom
nshepperd:bug/b5405

Conversation

@nshepperd

Copy link
Copy Markdown

Description

Fixes #5405.

The composer (legacy/non-compose-tools path) collects its diffs without --binary, so binary changes are carried only as Binary files ... differ placeholders, which git apply rejects when the composed commits are replayed.

  • Adds a binary option to the git diff providers (--binary → full GIT binary patch blocks) and uses it for the composer's diffs
  • Emits binary hunks verbatim when building patches
  • Redacts the base85 bodies before hunks reach the webview or AI prompts (they can run to many MB); apply always uses the un-redacted hunks

Verified with the repro from #5405 (I used Recompose Commits from here...).

Maybe this is actually a new feature since legacy compose never supported binary...? IDK, it looked like a bug when originally I filed it :)

Checklist

  • [o] I have followed the guidelines in the Contributing document
  • [o] My changes follow the coding style of this project
  • [o] My changes build without any errors or warnings
  • [o] My changes have been formatted and linted
  • [o] My changes include any required corresponding changes to the documentation (including CHANGELOG.md and README.md)
  • [o] My changes have been rebased and squashed to the minimal number (typically 1) of relevant commits
  • [o] My changes have a descriptive commit message with a short title, including a Fixes $XXX - or Closes #XXX - prefix to auto-close the issue that your PR addresses

Composing or recomposing changes that include a binary file failed at
commit time with "error: cannot apply binary patch to '<file>' without
full index line". The composer collected diffs without `--binary`, so
binary changes were carried only as `Binary files ... differ`
placeholders, which `git apply` rejects when the composed commits are
replayed.

- Adds a `binary` option to the git diff providers that passes
  `--binary`, emitting full `GIT binary patch` blocks (with full index
  lines) instead of the placeholder markers
- Collects composer diffs with `--binary`, so binary changes are
  committed byte-identically
- Redacts the base85 binary patch bodies before hunks are sent to the
  composer webview or embedded in AI prompts; apply uses the original
  un-redacted hunks, so no data is lost

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nshepperd

nshepperd commented Jul 4, 2026

Copy link
Copy Markdown
Author

Oh right, I also have a bunch of e2e integration tests (mostly written by Claude Fable) for the bugs that I've found, including this one. I could separate out the test for binary file handling and include it in this PR as a regression test if you want. Or make a separate PR that has all of them, idk. Right now they are at https://github.com/nshepperd/vscode-gitlens/tree/e2e-compose-tests

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.

Commit Composer (Preview) fails on commits containing binary files: "cannot apply binary patch without full index line"

1 participant