aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-19 13:51:19 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-08-19 13:51:19 -0400
commit37d427737a90bd3057a6f187e929c20475219ae7 (patch)
treec98ca31e5e48755f8b0cae17b7dbd694ee5e6f07
parent0eb41be65707a1e156a59fd25ea9824c1a9e95ce (diff)
downloadpatatt-37d427737a90bd3057a6f187e929c20475219ae7.tar.gz
Call git-mailinfo with line endings normalized to LF
There is a bug in git-mailinfo that will return slightly different results when we have an in-body git header terminated with CRLF vs. when we have it terminated with just LF. Avoid this by always passing stdin contents canonicalized to single-LF. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--patatt/__init__.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/patatt/__init__.py b/patatt/__init__.py
index c75c42c..328dcf6 100644
--- a/patatt/__init__.py
+++ b/patatt/__init__.py
@@ -678,7 +678,9 @@ class PatattMessage:
mf = os.path.join(td, 'm')
pf = os.path.join(td, 'p')
cmdargs = ['git', 'mailinfo', '--encoding=utf-8', '--no-scissors', mf, pf]
- ecode, i, err = _run_command(cmdargs, stdin=payload)
+ # normalize line endings in payload to single lf for consistent results
+ # from git-mailinfo.
+ ecode, i, err = _run_command(cmdargs, stdin=payload.replace(b'\r\n', b'\n'))
if ecode > 0:
logger.debug('FAILED : Failed running git-mailinfo:')
logger.debug(err.decode())