Skip to contentSkip to conversation

Create patches with --full-index --binary

PATCH Applied Manos Pitsidianakis 2 participants 2 messages Aug 27, 2024 – Sep 6, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Create patches with --full-index --binary

If a patch contains binaries, the git show command b4 currently uses will not generate a patch that can be applied by git. Add --full-index --binary flags to correct this.

---
Commits that change binary blobs are not correctly formatted as patches when using b4 send because by default git show doesn't include binary data. The result is an "cannot apply patch without full index" error from git when fetching patches with b4.

This patch adds the necessary flags to amend this.

---
 src/b4/__init__.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)
src/b4/__init__.py +13 -2
index ec230e7ace663516c6bec8cf0ce9fd87f2218d23..e43b836547244c1cffc071067037dbe393ee4042 100644
@@ -3424,8 +3424,19 @@ def git_range_to_patches(gitdir: Optional[str], start: str, end: str,
         if commit in ignore_commits:
             logger.debug('Ignoring commit %s', commit)
             continue
-        ecode, out = git_run_command(gitdir, ['show', '--format=email', '--patch-with-stat', '--encoding=utf-8',
-                                              commit], decode=False)
+        ecode, out = git_run_command(
+            gitdir,
+            [
+                'show',
+                '--format=email',
+                '--full-index',
+                '--binary',
+                '--patch-with-stat',
+                '--encoding=utf-8',
+                commit,
+            ],
+            decode=False,
+        )
         if ecode > 0:
             raise RuntimeError(f'Could not get a patch out of {commit}')
         msg = email.message_from_bytes(out, policy=emlpolicy)

---
base-commit: 99b128995f27cd9aa6fa8adf7588f339919ac14d
change-id: 20240827-fix-binary-patch-91b6bcda8509

Best regards,

Signature · 1 line
γαῖα πυρί μιχθήτω
#1 lore raw
Quoted 5 lines · Manos Pitsidianakis

If a patch contains binaries, the git show command b4 currently uses will not generate a patch that can be applied by git. Add --full-index --binary flags to correct this.

Applied, thanks!

[1/1] Create patches with --full-index --binary

      commit: 23a9ddba10a057bfa9c438c0b50ac36d278ae022

Best regards,

Signature · 1 line
Konstantin Ryabitsev <[email protected]>