* [PATCH] format-patch: Generate a newline between the subject header and the message body.
@ 2006-07-13 12:03 Robert Shearman
2006-07-13 19:38 ` Jakub Narebski
2006-07-13 21:31 ` Junio C Hamano
0 siblings, 2 replies; 7+ messages in thread
From: Robert Shearman @ 2006-07-13 12:03 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 556 bytes --]
format-patch previously didn't generate a newline after a subject. This
caused the diffstat to not be displayed in messages without a blank line
and the first blank line to be eaten in messages with a blank line.
This patch inserts a newline in two places - once in the loop to
separate the subject part of the commit message from the body part of
the commit message and another after the loop to counteract the eating
of whitespace at the end of the message.
---
commit.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
[-- Attachment #2: 278bfe08daa6888b9dd7c0e5ca74ad4b3c10e4a4.diff --]
[-- Type: text/x-patch, Size: 1187 bytes --]
diff --git a/commit.c b/commit.c
index 522a6f3..8869b0d 100644
--- a/commit.c
+++ b/commit.c
@@ -655,6 +655,9 @@ unsigned long pretty_print_commit(enum c
continue;
}
+ if (!subject)
+ body = 1;
+
if (is_empty_line(line, &linelen)) {
if (!body)
continue;
@@ -662,8 +665,6 @@ unsigned long pretty_print_commit(enum c
continue;
if (fmt == CMIT_FMT_SHORT)
break;
- } else {
- body = 1;
}
if (subject) {
@@ -694,6 +695,9 @@ unsigned long pretty_print_commit(enum c
memcpy(buf + offset, after_subject, slen);
offset += slen;
after_subject = NULL;
+ } else if (fmt == CMIT_FMT_EMAIL && subject) {
+ /* separate the headers from the body */
+ buf[offset++] = '\n';
}
subject = NULL;
}
@@ -702,6 +706,12 @@ unsigned long pretty_print_commit(enum c
/* Make sure there is an EOLN for the non-oneline case */
if (fmt != CMIT_FMT_ONELINE)
buf[offset++] = '\n';
+ /*
+ * make sure there is another EOLN to separate the headers from whatever
+ * body the caller appends if we haven't already written a body
+ */
+ if (fmt == CMIT_FMT_EMAIL && !body)
+ buf[offset++] = '\n';
buf[offset] = '\0';
return offset;
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] format-patch: Generate a newline between the subject header and the message body.
2006-07-13 12:03 [PATCH] format-patch: Generate a newline between the subject header and the message body Robert Shearman
@ 2006-07-13 19:38 ` Jakub Narebski
2006-07-13 20:03 ` Robert Shearman
2006-07-13 21:31 ` Junio C Hamano
1 sibling, 1 reply; 7+ messages in thread
From: Jakub Narebski @ 2006-07-13 19:38 UTC (permalink / raw)
To: git
Robert Shearman wrote:
>
> format-patch previously didn't generate a newline after a subject. This
> caused the diffstat to not be displayed in messages without a blank line
> and the first blank line to be eaten in messages with a blank line.
Does this _enforce_ separating commit message into subject+empty
line+description? What about commit messages without this structire (e.g.
legacy commit messages from import from other SCM, e.g. GNU ChangeLog
style)?
--
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] format-patch: Generate a newline between the subject header and the message body.
2006-07-13 19:38 ` Jakub Narebski
@ 2006-07-13 20:03 ` Robert Shearman
0 siblings, 0 replies; 7+ messages in thread
From: Robert Shearman @ 2006-07-13 20:03 UTC (permalink / raw)
To: git
Jakub Narebski wrote:
>Robert Shearman wrote:
>
>
>>format-patch previously didn't generate a newline after a subject. This
>>caused the diffstat to not be displayed in messages without a blank line
>>and the first blank line to be eaten in messages with a blank line.
>>
>>
>
>Does this _enforce_ separating commit message into subject+empty
>line+description? What about commit messages without this structire (e.g.
>legacy commit messages from import from other SCM, e.g. GNU ChangeLog
>style)?
>
It only affects commits exported into email style. It has nothing to do
with the structure of GIT commit messages or those of any other SCM.
--
Rob Shearman
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] format-patch: Generate a newline between the subject header and the message body.
2006-07-13 12:03 [PATCH] format-patch: Generate a newline between the subject header and the message body Robert Shearman
2006-07-13 19:38 ` Jakub Narebski
@ 2006-07-13 21:31 ` Junio C Hamano
2006-07-13 21:48 ` Junio C Hamano
1 sibling, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2006-07-13 21:31 UTC (permalink / raw)
To: Robert Shearman; +Cc: git
Robert Shearman <rob@codeweavers.com> writes:
> This patch inserts a newline in two places - once in the loop to
> separate the subject part of the commit message from the body part of
> the commit message and another after the loop to counteract the eating
> of whitespace at the end of the message.
Thanks.
* Please sign your patch.
* This breaks a handful t4013 tests, but all in a good way (in
other words, the expected output files were wrong).
I'll fix up the t/t4013/diff.* files myself.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] format-patch: Generate a newline between the subject header and the message body.
2006-07-13 21:31 ` Junio C Hamano
@ 2006-07-13 21:48 ` Junio C Hamano
2006-07-13 21:55 ` Robert Shearman
0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2006-07-13 21:48 UTC (permalink / raw)
To: Robert Shearman; +Cc: git
Junio C Hamano <junkio@cox.net> writes:
> Robert Shearman <rob@codeweavers.com> writes:
>
>> This patch inserts a newline in two places - once in the loop to
>> separate the subject part of the commit message from the body part of
>> the commit message and another after the loop to counteract the eating
>> of whitespace at the end of the message.
>
> Thanks.
>
> * Please sign your patch.
>
> * This breaks a handful t4013 tests, but all in a good way (in
> other words, the expected output files were wrong).
>
> I'll fix up the t/t4013/diff.* files myself.
Actually, I take that back. This breaks normal commit log
messages by adding extra blank lines. The extra LF is needed
when the commit log does not have any message (just title).
I'll be tweaking a few tests in t4013 to catch future breakage
of this kind.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] format-patch: Generate a newline between the subject header and the message body.
2006-07-13 21:48 ` Junio C Hamano
@ 2006-07-13 21:55 ` Robert Shearman
0 siblings, 0 replies; 7+ messages in thread
From: Robert Shearman @ 2006-07-13 21:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Junio C Hamano wrote:
>Junio C Hamano <junkio@cox.net> writes:
>
>
>
>>Robert Shearman <rob@codeweavers.com> writes:
>>
>>
>>
>>>This patch inserts a newline in two places - once in the loop to
>>>separate the subject part of the commit message from the body part of
>>>the commit message and another after the loop to counteract the eating
>>>of whitespace at the end of the message.
>>>
>>>
>>Thanks.
>>
>> * Please sign your patch.
>>
>> * This breaks a handful t4013 tests, but all in a good way (in
>> other words, the expected output files were wrong).
>>
>>I'll fix up the t/t4013/diff.* files myself.
>>
>>
>
>Actually, I take that back. This breaks normal commit log
>messages by adding extra blank lines. The extra LF is needed
>when the commit log does not have any message (just title).
>
>
Ok, I'll resend with that fixed.
>I'll be tweaking a few tests in t4013 to catch future breakage
>of this kind.
>
Thanks.
--
Rob Shearman
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH] format-patch: Generate a newline between the subject header and the message body
@ 2006-07-13 22:17 Robert Shearman
0 siblings, 0 replies; 7+ messages in thread
From: Robert Shearman @ 2006-07-13 22:17 UTC (permalink / raw)
To: git
[-- Attachment #1: Type: text/plain, Size: 398 bytes --]
format-patch previously didn't generate a newline after a subject. This
caused the diffstat to not be displayed in messages with only one line
for the commit message.
This patch fixes this by adding a newline after the headers if a body
hasn't been added.
Signed-off-by: Robert Shearman <rob@codeweavers.com>
---
commit.c | 11 +++++++++--
1 files changed, 9 insertions(+), 2 deletions(-)
[-- Attachment #2: e4ec67def0af32e4a1704ce5ad941c81136b34e8.diff --]
[-- Type: text/x-patch, Size: 884 bytes --]
diff --git a/commit.c b/commit.c
index 522a6f3..6ac3bf7 100644
--- a/commit.c
+++ b/commit.c
@@ -655,6 +655,9 @@ unsigned long pretty_print_commit(enum c
continue;
}
+ if (!subject)
+ body = 1;
+
if (is_empty_line(line, &linelen)) {
if (!body)
continue;
@@ -662,8 +665,6 @@ unsigned long pretty_print_commit(enum c
continue;
if (fmt == CMIT_FMT_SHORT)
break;
- } else {
- body = 1;
}
if (subject) {
@@ -702,6 +703,12 @@ unsigned long pretty_print_commit(enum c
/* Make sure there is an EOLN for the non-oneline case */
if (fmt != CMIT_FMT_ONELINE)
buf[offset++] = '\n';
+ /*
+ * make sure there is another EOLN to separate the headers from whatever
+ * body the caller appends if we haven't already written a body
+ */
+ if (fmt == CMIT_FMT_EMAIL && !body)
+ buf[offset++] = '\n';
buf[offset] = '\0';
return offset;
}
^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-07-13 22:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-13 12:03 [PATCH] format-patch: Generate a newline between the subject header and the message body Robert Shearman
2006-07-13 19:38 ` Jakub Narebski
2006-07-13 20:03 ` Robert Shearman
2006-07-13 21:31 ` Junio C Hamano
2006-07-13 21:48 ` Junio C Hamano
2006-07-13 21:55 ` Robert Shearman
-- strict thread matches above, loose matches on Subject: below --
2006-07-13 22:17 Robert Shearman
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 NNTP newsgroup(s).