From: René Scharfe <hidden> Date: 2016-06-15 22:45:49
The patch after the next one will use it.
Signed-off-by: Rene Scharfe <redacted>
---
pretty.c | 24 +++++++++++++++---------
1 files changed, 15 insertions(+), 9 deletions(-)
@@ -181,6 +181,20 @@ static int is_empty_line(const char *line, int *len_p)return!len;}+staticconstchar*skip_empty_lines(constchar*msg)+{+for(;;){+intlinelen=get_one_line(msg);+intll=linelen;+if(!linelen)+break;+if(!is_empty_line(msg,&ll))+break;+msg+=linelen;+}+returnmsg;+}+staticvoidadd_merge_info(enumcmit_fmtfmt,structstrbuf*sb,conststructcommit*commit,intabbrev){
@@ -850,15 +864,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,}/* Skip excess blank lines at the beginning of body, if any... */-for(;;){-intlinelen=get_one_line(msg);-intll=linelen;-if(!linelen)-break;-if(!is_empty_line(msg,&ll))-break;-msg+=linelen;-}+msg=skip_empty_lines(msg);/* These formats treat the title line specially. */if(fmt==CMIT_FMT_ONELINE||fmt==CMIT_FMT_EMAIL)
From: René Scharfe <hidden> Date: 2016-06-15 22:45:49
The next patch will use it.
In the version that was factored out, we can't rely on the len of the
struct strbuf to find out if a line separator needs to be added, as
it might already contain something. Add a guard variable ("first")
instead.
Signed-off-by: Rene Scharfe <redacted>
---
pretty.c | 42 ++++++++++++++++++++++++------------------
1 files changed, 24 insertions(+), 18 deletions(-)
From: René Scharfe <hidden> Date: 2016-06-15 22:45:49
git log --pretty=format:%s (and tformat:) used to display the first
line of the subject, unlike the other --pretty options, which would
construct a subject line from all lines of the first paragraph of
the commit message.
For consistency and increased code reuse, change format: to do the
same as the other options.
Before:
$ git log --pretty=oneline v1.6.1 | md5sum
7c0896d2a94fc3315a0372b9b3373a8f -
$ git log --pretty=tformat:"%H %s" v1.6.1 | md5sum
298903b1c065002e15daa5329213c51f -
After:
$ git log --pretty=tformat:"%H %s" v1.6.1 | md5sum
7c0896d2a94fc3315a0372b9b3373a8f -
$ git log --pretty=oneline v1.6.1 | md5sum
7c0896d2a94fc3315a0372b9b3373a8f -
Signed-off-by: Rene Scharfe <redacted>
---
pretty.c | 53 ++++++++++++++++++++++++++++++++++-------------------
1 files changed, 34 insertions(+), 19 deletions(-)
@@ -424,13 +424,15 @@ struct chunk {structformat_commit_context{conststructcommit*commit;enumdate_modedmode;+unsignedcommit_header_parsed:1;+unsignedcommit_message_parsed:1;/* These offsets are relative to the start of the commit message. */-intcommit_header_parsed;-structchunksubject;structchunkauthor;structchunkcommitter;structchunkencoding;+size_tmessage_off;+size_tsubject_off;size_tbody_off;/* The following ones are relative to the result struct strbuf. */
@@ -650,6 +655,16 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,case'e':/* encoding */strbuf_add(sb,msg+c->encoding.off,c->encoding.len);return1;+}++/* Now we need to parse the commit message. */+if(!c->commit_message_parsed)+parse_commit_message(c);++switch(placeholder[0]){+case's':/* subject */+format_subject(sb,msg+c->subject_off," ");+return1;case'b':/* body */strbuf_addstr(sb,msg+c->body_off);return1;
From: Markus Heidelberg <hidden> Date: 2016-06-15 22:45:50
Hello,
I hope I got the In-Reply-To right, the message was sent before my
subscription to this list.
René Scharfe, 27.12.2008:
git log --pretty=format:%s (and tformat:) used to display the first
line of the subject, unlike the other --pretty options, which would
construct a subject line from all lines of the first paragraph of
the commit message.
And that can be very annoying when working on repositories with a
history not formatted after the recommendations of git (empty line after
the summary). Then the output of commands like
"git log --pretty=oneline", "git format-patch" and "git show-branch"
is unreadable.
Sorry, I haven't tested your patch set, what is the output of
git-shortlog like now?
For consistency and increased code reuse, change format: to do the
same as the other options.
What's wrong with using the first line instead of the first paragraph
for the other pretty options and for cases where only a small subject
line is desired? A sentence would be broken into a small uncomplete part
for the subject for example. What else?
Markus
For consistency and increased code reuse, change format: to do the
same as the other options.
What's wrong with using the first line instead of the first paragraph
for the other pretty options and for cases where only a small subject
line is desired?
From: René Scharfe <hidden> Date: 2016-06-15 22:45:50
Markus Heidelberg schrieb:
quoted
git log --pretty=format:%s (and tformat:) used to display the first
line of the subject, unlike the other --pretty options, which would
construct a subject line from all lines of the first paragraph of
the commit message.
And that can be very annoying when working on repositories with a
history not formatted after the recommendations of git (empty line after
the summary). Then the output of commands like
"git log --pretty=oneline", "git format-patch" and "git show-branch"
is unreadable.
Sorry, I haven't tested your patch set, what is the output of
git-shortlog like now?
It's unchanged since it has it's own commit message parser.
quoted
For consistency and increased code reuse, change format: to do the
same as the other options.
What's wrong with using the first line instead of the first paragraph
for the other pretty options and for cases where only a small subject
line is desired? A sentence would be broken into a small uncomplete part
for the subject for example. What else?
I'm inching towards the goal of being able to replicate all of the other
--pretty flavours with format: (or tformat:) strings.
--pretty=oneline used to print only the first line, but was changed to
the way it's now in 4234a761 more than a year ago. In my mind,
"subject" is defined by "what oneline is printing", so I think changing
the format: placeholder %s to show the whole first paragraph is a bug fix.
If you actually like the old behaviour then perhaps a new placeholder
(%S ?) should be introduced instead?
René
On Sun, Dec 28, 2008 at 09:09:09AM +0900, Nanako Shiraishi [off-list ref] wrote:
The last message mentions a bug in "git rebase" that internally uses
"git am" when replaying the changes. It was corrected later with:
http://thread.gmane.org/gmane.linux.ports.sh.devel/3833/focus=79735
Reading the discussion in the messages in this thread will help
understanding the issues, after understanding why "the first line" was
problematic, as discussed in the other threads.
Actually in that thread I asked if a patch that would make this
configurable would be ever accepted (so I would work on it), but I got
no answer. In the meantime I just learned to live with this, partially
because the vim highlight script highlights anything written to the
second line as red. ;-)
From: Markus Heidelberg <hidden> Date: 2016-06-15 22:45:50
Nanako Shiraishi, 28.12.2008:
Quoting Markus Heidelberg [off-list ref]:
quoted
quoted
For consistency and increased code reuse, change format: to do the
same as the other options.
What's wrong with using the first line instead of the first paragraph
for the other pretty options and for cases where only a small subject
line is desired?
There were too many issues. The mail archive tells us that there were
considerable discussions and thoughts behind the current behavior:
Many thanks for all the pointers. I thought there were reasons, but this
thread just made me ask.
Markus
From: Markus Heidelberg <hidden> Date: 2016-06-15 22:45:50
René Scharfe, 28.12.2008:
Markus Heidelberg schrieb:
quoted
quoted
For consistency and increased code reuse, change format: to do the
same as the other options.
What's wrong with using the first line instead of the first paragraph
for the other pretty options and for cases where only a small subject
line is desired? A sentence would be broken into a small uncomplete part
for the subject for example. What else?
I'm inching towards the goal of being able to replicate all of the other
--pretty flavours with format: (or tformat:) strings.
--pretty=oneline used to print only the first line, but was changed to
the way it's now in 4234a761 more than a year ago. In my mind,
"subject" is defined by "what oneline is printing", so I think changing
the format: placeholder %s to show the whole first paragraph is a bug fix.
Yes, now I think so, too. I had also noticed the unexpectedly different
behaviour once.
If you actually like the old behaviour then perhaps a new placeholder
(%S ?) should be introduced instead?
I don't need it. I rather asked regarding the old behaviour for oneline
and so, but reading that there are strong intentions for their
behaviour, it's fine.
Markus
From: René Scharfe <hidden> Date: 2016-06-15 22:45:50
René Scharfe schrieb:
Markus Heidelberg schrieb:
quoted
Sorry, I haven't tested your patch set, what is the output of
git-shortlog like now?
It's unchanged since it has it's own commit message parser.
... which displays the first line of the commit message, unlike
--pretty=oneline. Here's a quick fix. I probably won't have time
to come up with something prettier this year.
René
builtin-shortlog.c | 9 ++++++---
pretty.c | 4 ++--
2 files changed, 8 insertions(+), 5 deletions(-)
From: Junio C Hamano <hidden> Date: 2016-06-15 22:45:52
René Scharfe [off-list ref] writes:
quoted
It's unchanged since it has it's own commit message parser.
... which displays the first line of the commit message, unlike
--pretty=oneline. Here's a quick fix. I probably won't have time
to come up with something prettier this year.
I think the code is pretty enough ;-) I just need to come up with a patch
description and forge your Sign-off.
Thanks.
From: René Scharfe <hidden> Date: 2016-06-15 22:45:52
The commit message parser of git shortlog used to treat only the first
non-empty line of the commit message as the subject. Other log commands
(e.g. --pretty=oneline) show the whole first paragraph instead (unwrapped
into a single line).
For consistency, this patch borrows format_subject() from pretty.c to
make shortlog do the same.
Signed-off-by: Rene Scharfe <redacted>
---
builtin-shortlog.c | 9 ++++++---
pretty.c | 4 ++--
2 files changed, 8 insertions(+), 5 deletions(-)
From: Junio C Hamano <hidden> Date: 2016-06-15 22:45:53
René Scharfe [off-list ref] writes:
The commit message parser of git shortlog used to treat only the first
non-empty line of the commit message as the subject. Other log commands
(e.g. --pretty=oneline) show the whole first paragraph instead (unwrapped
into a single line).
For consistency, this patch borrows format_subject() from pretty.c to
make shortlog do the same.