# [StGIT PATCH] Do not mess-up with commit message formatting when sending email

5 messages from 2008-07-31 to 2008-08-05. Participants: Samuel Tardieu, Karl Hasselström, Catalin Marinas.
Thread: https://gitlist.dev/t/14775

## Samuel Tardieu, 2008-07-31 12:50

Subject: [StGIT PATCH] Do not mess-up with commit message formatting when sending email
Message-ID: <20080731125005.894.10592.stgit@dawn.rfc1149.net>
URL: https://gitlist.dev/e/20080731125005.894.10592.stgit%40dawn.rfc1149.net

```
The short description, which will be used as the email subject,
gets its leading and trailing whitespaces removed.

The long description only gets its trailing whitespaces removed
to preserve commit message formatting, e.g. in the case of a
ChangeLog-style commit message, as well as empty leading lines.

Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
---
 stgit/commands/mail.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index a833efc..bdc3fcc 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -401,8 +401,8 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):
         options.edit_patches = True
 
     descr_lines = descr.split('\n')
-    short_descr = descr_lines[0].rstrip()
-    long_descr = '\n'.join(descr_lines[1:]).lstrip()
+    short_descr = descr_lines[0].strip()
+    long_descr = '\n'.join([l.rstrip() for l in descr_lines[1:]]).lstrip('\n')
 
     authname = p.get_authname();
     authemail = p.get_authemail();

```

## Karl Hasselström, 2008-08-04 14:16

Subject: Re: [StGIT PATCH] Do not mess-up with commit message formatting when sending email
Message-ID: <20080804141640.GB12232@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20080804141640.GB12232%40diana.vm.bytemark.co.uk
In-Reply-To: <20080731125005.894.10592.stgit@dawn.rfc1149.net>

```
On 2008-07-31 14:50:05 +0200, Samuel Tardieu wrote:

> The short description, which will be used as the email subject, gets
> its leading and trailing whitespaces removed.

OK, good.

> The long description only gets its trailing whitespaces removed to
> preserve commit message formatting, e.g. in the case of a
> ChangeLog-style commit message, as well as empty leading lines.

I'd like a better description of this change, please. If I'm not
mistaken, we used to do _only_ left stripping of the body. You change
that to left stripping of only newlines, but also add right stripping
for each line. I'm all for these changes, but the commit message
confused me a lot.

> -    long_descr = '\n'.join(descr_lines[1:]).lstrip()
> +    long_descr = '\n'.join([l.rstrip() for l in descr_lines[1:]]).lstrip('\n')

We require Python 2.4 or later, so you can skip the square brackets
here.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Samuel Tardieu, 2008-08-04 15:19

Subject: [StGIT v2 PATCH] Do not mess-up with commit message formatting when sending email
Message-ID: <20080804151913.4269.74254.stgit@dawn.rfc1149.net>
URL: https://gitlist.dev/e/20080804151913.4269.74254.stgit%40dawn.rfc1149.net
In-Reply-To: <20080804141640.GB12232@diana.vm.bytemark.co.uk>

```
The short description, which will be used as the email subject,
gets its leading and trailing blanks removed.

The long description gets its trailing blanks removed as well
as any leading empty lines. Leading blanks are left untouched
to preserve the formatting.

Signed-off-by: Samuel Tardieu <sam@rfc1149.net>
---
 stgit/commands/mail.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py
index a833efc..61e3f3a 100644
--- a/stgit/commands/mail.py
+++ b/stgit/commands/mail.py
@@ -401,8 +401,8 @@ def __build_message(tmpl, patch, patch_nr, total_nr, msg_id, ref_id, options):
         options.edit_patches = True
 
     descr_lines = descr.split('\n')
-    short_descr = descr_lines[0].rstrip()
-    long_descr = '\n'.join(descr_lines[1:]).lstrip()
+    short_descr = descr_lines[0].strip()
+    long_descr = '\n'.join(l.rstrip() for l in descr_lines[1:]).lstrip('\n')
 
     authname = p.get_authname();
     authemail = p.get_authemail();

```

## Karl Hasselström, 2008-08-04 15:57

Subject: Re: [StGIT v2 PATCH] Do not mess-up with commit message formatting when sending email
Message-ID: <20080804155751.GA15749@diana.vm.bytemark.co.uk>
URL: https://gitlist.dev/e/20080804155751.GA15749%40diana.vm.bytemark.co.uk
In-Reply-To: <20080804151913.4269.74254.stgit@dawn.rfc1149.net>

```
Your round-trip time was shorter than mine by a few orders of
magnitude. ;-)

On 2008-08-04 17:19:14 +0200, Samuel Tardieu wrote:

> The long description gets its trailing blanks removed as well as any
> leading empty lines. Leading blanks are left untouched to preserve
> the formatting.

Thanks, much better. Will apply.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle

```

## Catalin Marinas, 2008-08-05 20:48

Subject: Re: [StGIT v2 PATCH] Do not mess-up with commit message formatting when sending email
Message-ID: <b0943d9e0808051348x7130f26cy4a233ea35ee9a5d0@mail.gmail.com>
URL: https://gitlist.dev/e/b0943d9e0808051348x7130f26cy4a233ea35ee9a5d0%40mail.gmail.com
In-Reply-To: <20080804151913.4269.74254.stgit@dawn.rfc1149.net>

```
2008/8/4 Samuel Tardieu <sam@rfc1149.net>:
> The short description, which will be used as the email subject,
> gets its leading and trailing blanks removed.
>
> The long description gets its trailing blanks removed as well
> as any leading empty lines. Leading blanks are left untouched
> to preserve the formatting.

Thanks.

-- 
Catalin

```
