* [PATCH] shortlog: take the first populated line of the description
@ 2008-03-05 14:24 Andy Whitcroft
2008-03-05 14:48 ` Johannes Schindelin
2008-03-05 18:47 ` Nicolas Pitre
0 siblings, 2 replies; 8+ messages in thread
From: Andy Whitcroft @ 2008-03-05 14:24 UTC (permalink / raw)
To: git
Way back the perl version of shortlog would take the first populated line
of the commit body. The builtin version mearly takes the first line.
This leads to empty shortlog entries when there is some viable text in
the commit.
Reinstate this behaviour igoring all lines with nothing but whitespace.
Signed-off-by: Andy Whitcroft <apw@shadowen.org>
---
This seems to be an improvement, returning to the original
behaviour. I cannot think of any good reason not to take the first
populated line for a shortlog. The alternative less agressive
compromise might be to skip only completly empty lines at the
start, but I am not sure that adds any value.
I seem to get a lot of these in converted SVN commits.
Comments?
-apw
---
builtin-shortlog.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/builtin-shortlog.c b/builtin-shortlog.c
index af31aba..b22b0ed 100644
--- a/builtin-shortlog.c
+++ b/builtin-shortlog.c
@@ -70,11 +70,12 @@ static void insert_one_record(struct shortlog *log,
else
free(buffer);
+ /* Skip any leading whitespace, including any blank lines. */
+ while (*oneline && isspace(*oneline))
+ oneline++;
eol = strchr(oneline, '\n');
if (!eol)
eol = oneline + strlen(oneline);
- while (*oneline && isspace(*oneline) && *oneline != '\n')
- oneline++;
if (!prefixcmp(oneline, "[PATCH")) {
char *eob = strchr(oneline, ']');
if (eob && (!eol || eob < eol))
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH] shortlog: take the first populated line of the description
2008-03-05 14:24 [PATCH] shortlog: take the first populated line of the description Andy Whitcroft
@ 2008-03-05 14:48 ` Johannes Schindelin
2008-03-05 16:43 ` Andy Whitcroft
2008-03-05 18:47 ` Nicolas Pitre
1 sibling, 1 reply; 8+ messages in thread
From: Johannes Schindelin @ 2008-03-05 14:48 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: git
Hi,
On Wed, 5 Mar 2008, Andy Whitcroft wrote:
> diff --git a/builtin-shortlog.c b/builtin-shortlog.c
> index af31aba..b22b0ed 100644
> --- a/builtin-shortlog.c
> +++ b/builtin-shortlog.c
> @@ -70,11 +70,12 @@ static void insert_one_record(struct shortlog *log,
> else
> free(buffer);
>
> + /* Skip any leading whitespace, including any blank lines. */
> + while (*oneline && isspace(*oneline))
> + oneline++;
> eol = strchr(oneline, '\n');
> if (!eol)
> eol = oneline + strlen(oneline);
> - while (*oneline && isspace(*oneline) && *oneline != '\n')
> - oneline++;
> if (!prefixcmp(oneline, "[PATCH")) {
> char *eob = strchr(oneline, ']');
> if (eob && (!eol || eob < eol))
Why do you move the code around? Makes it harder to read your patch.
Besides, you now strip empty lines at the beginning of the commit
messages, right? Who produces such a thing?
Ciao,
Dscho
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] shortlog: take the first populated line of the description
2008-03-05 14:48 ` Johannes Schindelin
@ 2008-03-05 16:43 ` Andy Whitcroft
2008-03-05 16:51 ` Johannes Schindelin
0 siblings, 1 reply; 8+ messages in thread
From: Andy Whitcroft @ 2008-03-05 16:43 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
On Wed, Mar 05, 2008 at 03:48:00PM +0100, Johannes Schindelin wrote:
> Hi,
>
> On Wed, 5 Mar 2008, Andy Whitcroft wrote:
>
> > diff --git a/builtin-shortlog.c b/builtin-shortlog.c
> > index af31aba..b22b0ed 100644
> > --- a/builtin-shortlog.c
> > +++ b/builtin-shortlog.c
> > @@ -70,11 +70,12 @@ static void insert_one_record(struct shortlog *log,
> > else
> > free(buffer);
> >
> > + /* Skip any leading whitespace, including any blank lines. */
> > + while (*oneline && isspace(*oneline))
> > + oneline++;
> > eol = strchr(oneline, '\n');
> > if (!eol)
> > eol = oneline + strlen(oneline);
> > - while (*oneline && isspace(*oneline) && *oneline != '\n')
> > - oneline++;
> > if (!prefixcmp(oneline, "[PATCH")) {
> > char *eob = strchr(oneline, ']');
> > if (eob && (!eol || eob < eol))
>
> Why do you move the code around? Makes it harder to read your patch.
> Besides, you now strip empty lines at the beginning of the commit
> messages, right? Who produces such a thing?
I've not moved the code as such. I added a loop to drop the leading
whitespace. That made the second loop redundant as its job is already
done, so I killed it.
The point of the patch is to strip the empty lines at the start of
the commit. I am ending up with them in my repo mostly due to
imcompetant users of SVN I suspect. The main driver is that I have
those and the original non-C version coped and the builtin does not.
Now if people think that its a stupid idea I might suggest it could be
optional?
-apw
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] shortlog: take the first populated line of the description
2008-03-05 16:43 ` Andy Whitcroft
@ 2008-03-05 16:51 ` Johannes Schindelin
0 siblings, 0 replies; 8+ messages in thread
From: Johannes Schindelin @ 2008-03-05 16:51 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: git
Hi,
On Wed, 5 Mar 2008, Andy Whitcroft wrote:
> On Wed, Mar 05, 2008 at 03:48:00PM +0100, Johannes Schindelin wrote:
>
> > On Wed, 5 Mar 2008, Andy Whitcroft wrote:
> >
> > > diff --git a/builtin-shortlog.c b/builtin-shortlog.c
> > > index af31aba..b22b0ed 100644
> > > --- a/builtin-shortlog.c
> > > +++ b/builtin-shortlog.c
> > > @@ -70,11 +70,12 @@ static void insert_one_record(struct shortlog *log,
> > > else
> > > free(buffer);
> > >
> > > + /* Skip any leading whitespace, including any blank lines. */
> > > + while (*oneline && isspace(*oneline))
> > > + oneline++;
> > > eol = strchr(oneline, '\n');
> > > if (!eol)
> > > eol = oneline + strlen(oneline);
> > > - while (*oneline && isspace(*oneline) && *oneline != '\n')
> > > - oneline++;
> > > if (!prefixcmp(oneline, "[PATCH")) {
> > > char *eob = strchr(oneline, ']');
> > > if (eob && (!eol || eob < eol))
> >
> > Why do you move the code around? Makes it harder to read your patch.
> > Besides, you now strip empty lines at the beginning of the commit
> > messages, right? Who produces such a thing?
>
> I've not moved the code as such.
Well, it sure looks like that. Maybe you want to make it look like that
even more?
> The point of the patch is to strip the empty lines at the start of the
> commit. I am ending up with them in my repo mostly due to imcompetant
> users of SVN I suspect. The main driver is that I have those and the
> original non-C version coped and the builtin does not.
>
> Now if people think that its a stupid idea I might suggest it could be
> optional?
No, I think with an explanation like this in the commit message, it is
good as-is.
Ciao,
Dscho
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] shortlog: take the first populated line of the description
2008-03-05 14:24 [PATCH] shortlog: take the first populated line of the description Andy Whitcroft
2008-03-05 14:48 ` Johannes Schindelin
@ 2008-03-05 18:47 ` Nicolas Pitre
2008-03-05 21:27 ` Junio C Hamano
1 sibling, 1 reply; 8+ messages in thread
From: Nicolas Pitre @ 2008-03-05 18:47 UTC (permalink / raw)
To: Andy Whitcroft; +Cc: git
On Wed, 5 Mar 2008, Andy Whitcroft wrote:
>
> Way back the perl version of shortlog would take the first populated line
> of the commit body. The builtin version mearly takes the first line.
> This leads to empty shortlog entries when there is some viable text in
> the commit.
>
> Reinstate this behaviour igoring all lines with nothing but whitespace.
>
> Signed-off-by: Andy Whitcroft <apw@shadowen.org>
> ---
>
> This seems to be an improvement, returning to the original
> behaviour. I cannot think of any good reason not to take the first
> populated line for a shortlog. The alternative less agressive
> compromise might be to skip only completly empty lines at the
> start, but I am not sure that adds any value.
>
> I seem to get a lot of these in converted SVN commits.
>
> Comments?
Maybe it is the SVN conversion that needs fixing?
Nicolas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] shortlog: take the first populated line of the description
2008-03-05 18:47 ` Nicolas Pitre
@ 2008-03-05 21:27 ` Junio C Hamano
2008-03-05 21:47 ` Nicolas Pitre
0 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2008-03-05 21:27 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Andy Whitcroft, git, Johannes Schindelin
Nicolas Pitre <nico@cam.org> writes:
> On Wed, 5 Mar 2008, Andy Whitcroft wrote:
> ...
>> ... I cannot think of any good reason not to take the first
>> populated line for a shortlog. The alternative less agressive
>> compromise might be to skip only completly empty lines at the
>> start, but I am not sure that adds any value.
>>
>> I seem to get a lot of these in converted SVN commits.
>>
>> Comments?
>
> Maybe it is the SVN conversion that needs fixing?
I thought about saying the same, but I am of two minds.
It is likely that you would want to clean-up when importing,
especially when you are planning to abandon the other system and
switch to git. But you may want to have an import that is as
close to the original as possible, excess blank lines in the log
messages and all.
I think Andy's fix to make the output side take away
unnecessary blank lines is unconditionally good.
I've added these three lines at the end of the log message.
This is often useful when dealing with commits imported from foreign SCMs
that do not tidy up the log message of useless blank lines at the
beginning.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] shortlog: take the first populated line of the description
2008-03-05 21:27 ` Junio C Hamano
@ 2008-03-05 21:47 ` Nicolas Pitre
2008-03-05 22:14 ` Junio C Hamano
0 siblings, 1 reply; 8+ messages in thread
From: Nicolas Pitre @ 2008-03-05 21:47 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Andy Whitcroft, git, Johannes Schindelin
On Wed, 5 Mar 2008, Junio C Hamano wrote:
> Nicolas Pitre <nico@cam.org> writes:
>
> > On Wed, 5 Mar 2008, Andy Whitcroft wrote:
> > ...
> >> ... I cannot think of any good reason not to take the first
> >> populated line for a shortlog. The alternative less agressive
> >> compromise might be to skip only completly empty lines at the
> >> start, but I am not sure that adds any value.
> >>
> >> I seem to get a lot of these in converted SVN commits.
> >>
> >> Comments?
> >
> > Maybe it is the SVN conversion that needs fixing?
>
> I thought about saying the same, but I am of two minds.
>
> It is likely that you would want to clean-up when importing,
> especially when you are planning to abandon the other system and
> switch to git. But you may want to have an import that is as
> close to the original as possible, excess blank lines in the log
> messages and all.
I don't think excess blank lines at the _beginning_ of the commit log
has any value worth preserving though.
> I think Andy's fix to make the output side take away
> unnecessary blank lines is unconditionally good.
It is not "bad" in itself. However that feels like papering over
another problem which IMHO has greater merits to be fixed. We have
given special semantics to the first line of a commit log in many other
places now, so unless all those places are also made aware of
substandard commit logs too, I think it would be more productive to make
sure those logs are semi sensible upon entering Git in the first place
instead.
Nicolas
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] shortlog: take the first populated line of the description
2008-03-05 21:47 ` Nicolas Pitre
@ 2008-03-05 22:14 ` Junio C Hamano
0 siblings, 0 replies; 8+ messages in thread
From: Junio C Hamano @ 2008-03-05 22:14 UTC (permalink / raw)
To: Nicolas Pitre; +Cc: Andy Whitcroft, git, Johannes Schindelin
Nicolas Pitre <nico@cam.org> writes:
> On Wed, 5 Mar 2008, Junio C Hamano wrote:
>
>> I think Andy's fix to make the output side take away
>> unnecessary blank lines is unconditionally good.
>
> It is not "bad" in itself. However that feels like papering over
> another problem which IMHO has greater merits to be fixed. We have
> given special semantics to the first line of a commit log in many other
> places now, so unless all those places are also made aware of
> substandard commit logs too, I think it would be more productive to make
> sure those logs are semi sensible upon entering Git in the first place
> instead.
My understanding of the current status when I wrote that message
was that everybody at commit.c layer (that is, everybody except
shortlog) strips such garbage. Do you have a specific broken
one in mind?
I suspect --pretty=format:%s might be broken; I didn't check.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-03-05 22:15 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-05 14:24 [PATCH] shortlog: take the first populated line of the description Andy Whitcroft
2008-03-05 14:48 ` Johannes Schindelin
2008-03-05 16:43 ` Andy Whitcroft
2008-03-05 16:51 ` Johannes Schindelin
2008-03-05 18:47 ` Nicolas Pitre
2008-03-05 21:27 ` Junio C Hamano
2008-03-05 21:47 ` Nicolas Pitre
2008-03-05 22:14 ` Junio C Hamano
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).