From: Miklos Vajna <vmiklos@frugalware.org>
To: Junio C Hamano <gitster@pobox.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
Git Mailing List <git@vger.kernel.org>,
Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH] format-patch: Make sure the subject is always a one-liner
Date: Wed, 16 Apr 2008 03:06:05 +0200 [thread overview]
Message-ID: <20080416010605.GG8387@genesis.frugalware.org> (raw)
In-Reply-To: <20080416003725.GF8387@genesis.frugalware.org>
If the commit message has no empty line after the first line, we need to
insert a newline after the first, so that the newlines won't be removed
from the commit message for example when they are applied using git-am.
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
On Wed, Apr 16, 2008 at 02:37:25AM +0200, Miklos Vajna <vmiklos@frugalware.org> wrote:
> If we are at it, I had a similar bugreport: If one doesn't use an
> empty
> line after the first line in the commit message, a git-format-patch +
> git-am combo will strip newlines from the commit message:
>
> http://article.gmane.org/gmane.comp.version-control.git/73755
>
> There, you suggested to modify git-format-patch, but I haven't come up
> with such a patch nor anybody else.
>
> Actually I recently tried to make one but I got lost in pretty.c and
> log-tree.c. :-)
Ok, here is a try. It does the trick for me, but this it the first time
I touch pretty.c so feel free to point out if I did something wrong ;-)
Thanks.
pretty.c | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/pretty.c b/pretty.c
index 6c04176..45a5679 100644
--- a/pretty.c
+++ b/pretty.c
@@ -653,6 +653,7 @@ void pp_title_line(enum cmit_fmt fmt,
strbuf_init(&title, 80);
+ int check_empty = 1;
for (;;) {
const char *line = *msg_p;
int linelen = get_one_line(line);
@@ -666,7 +667,10 @@ void pp_title_line(enum cmit_fmt fmt,
if (fmt == CMIT_FMT_EMAIL) {
strbuf_addch(&title, '\n');
}
- strbuf_addch(&title, ' ');
+ if (check_empty && strcmp(line, "\n")) {
+ check_empty = 0;
+ strbuf_addch(&title, '\n');
+ }
}
strbuf_add(&title, line, linelen);
}
--
1.5.5
next prev parent reply other threads:[~2008-04-16 1:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20080415172333.GA29489@linux-sh.org>
2008-04-15 18:01 ` [GIT PULL] sh updates for 2.6.25 Linus Torvalds
2008-04-15 18:18 ` Linus Torvalds
2008-04-15 18:30 ` Paul Mundt
2008-04-15 19:56 ` Linus Torvalds
2008-04-16 18:54 ` Alex Riesen
2008-04-16 20:02 ` Junio C Hamano
2008-04-16 20:17 ` Linus Torvalds
2008-04-15 18:41 ` Junio C Hamano
2008-04-15 18:43 ` Jakub Narebski
2008-04-16 0:37 ` Miklos Vajna
2008-04-16 1:06 ` Miklos Vajna [this message]
2008-04-16 3:25 ` Junio C Hamano
2008-04-16 8:44 ` Miklos Vajna
2008-04-16 19:58 ` Re* " Junio C Hamano
2008-04-16 20:22 ` Jakub Narebski
2008-04-17 21:38 ` Miklos Vajna
2008-04-27 19:04 ` David Woodhouse
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080416010605.GG8387@genesis.frugalware.org \
--to=vmiklos@frugalware.org \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jnareb@gmail.com \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).