Control: tags -1 + patch

On Wed, 20 Dec 2017 at 13:22:34 +0100, Guido Günther wrote:
> On Wed, Dec 20, 2017 at 09:56:20PM +1100, Carlos Maddela wrote:
> > diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py
> > index 004c231..d092565 100644
> > --- a/gbp/scripts/common/pq.py
> > +++ b/gbp/scripts/common/pq.py
> > @@ -177,7 +177,7 @@ def write_patch_file(filename, commit_info, diff):
> >                      msg.set_payload(body.encode('us-ascii'))
> >                  except (UnicodeEncodeError):
> >                      msg.set_payload(body, charset)
> > -            patch.write(msg.as_string(unixfrom=False, 
> > maxheaderlen=77).encode('utf-8'))
> > +            patch.write(msg.as_bytes(unixfrom=False))
> 
> Good catch but we need to keep breaking headers at that value to not
> introduce further diff noise. Looking at the docs max_line_length is
> there as well which could work.

The attached (heavily based on what Carlos suggested) seems to work?

I couldn't fetch the latest changes from
https://git.sigxcpu.org/cgit/git-buildpackage/ in a reasonable time
(git fetch doesn't show any progress and didn't seem to be making any
progress) so this is based on an imported .dsc. Please consider moving
the git repository to salsa.debian.org or similar.

Thanks,
    smcv
>From aa913f4e834eed2c9fab76517dd77e6fd3080383 Mon Sep 17 00:00:00 2001
From: Simon McVittie <s...@debian.org>
Date: Tue, 3 Apr 2018 11:49:22 +0100
Subject: [PATCH] pq export: Write out patches as UTF-8 if necessary

Due to behaviour changes in Python, git-buildpackage would previously
write the commit message in the base64 Content-Transfer-Encoding, which
is not very readable. Now it uses 8bit.

Based on a patch from Carlos Maddela.

Closes: #883541
---
 gbp/scripts/common/pq.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gbp/scripts/common/pq.py b/gbp/scripts/common/pq.py
index 004c231..b6033a2 100644
--- a/gbp/scripts/common/pq.py
+++ b/gbp/scripts/common/pq.py
@@ -25,6 +25,7 @@ import time
 from email.message import Message
 from email.header import Header
 from email.charset import Charset, QP
+from email.policy import Compat32
 
 from gbp.git import GitRepositoryError
 from gbp.git.modifier import GitModifier, GitTz
@@ -177,7 +178,8 @@ def write_patch_file(filename, commit_info, diff):
                     msg.set_payload(body.encode('us-ascii'))
                 except (UnicodeEncodeError):
                     msg.set_payload(body, charset)
-            patch.write(msg.as_string(unixfrom=False, maxheaderlen=77).encode('utf-8'))
+            policy = Compat32(max_line_length=77)
+            patch.write(msg.as_bytes(unixfrom=False, policy=policy))
 
             # Write diff
             patch.write(b'---\n')
-- 
2.17.0

Reply via email to