# [PATCH] Fix empty line processing in git-shortlog.perl

4 messages from 2005-11-06 to 2005-11-07. Participants: Petr Baudis, Junio C Hamano.
Thread: https://gitlist.dev/t/2373

## Petr Baudis, 2005-11-06 22:42

Subject: [PATCH] Fix empty line processing in git-shortlog.perl
Message-ID: <20051106224218.22797.97260.stgit@machine.or.cz>
URL: https://gitlist.dev/e/20051106224218.22797.97260.stgit%40machine.or.cz

```
Faced with a commit such as

	commit f1b2646c7f2713c3ea4bce120e1d0d8091808be4
	Author: Adrian Bunk <bunk@r063144.stusta.swh.mhn.de>
	Date:   Sun Nov 6 20:30:38 2005 +0100

	    From: Michal Wronski <wrona@mat.uni.torun.pl>

	    I've jchanged my email. Please apply this patch so as to everybody
	    could send me a remarks about mqueuefs.

	    Signed-off-by: Michal Wronski <Michal.Wronski@motorola.com>
	    Signed-off-by: Adrian Bunk <bunk@stusta.de>

git-shortlog.perl would produce a line with an empty commit title.

This patch fixes that. I believe that just changing the last * to + in the
original regexp would work, but Adrian says it doesn't fix it for him, and
I believe this regexp is way clearer anyway. This is also the original
regexp used before a24e658649170c99fdcb4aaa41545679ad02f755.

Signed-off-by: Petr Baudis <pasky@suse.cz>
---

 git-shortlog.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-shortlog.perl b/git-shortlog.perl
index 0b14f83..7283159 100755
--- a/git-shortlog.perl
+++ b/git-shortlog.perl
@@ -94,7 +94,7 @@ sub changelog_input {
 
 		# skip to non-blank line
 		elsif ($pstate == 3) {
-			next unless /^\s*?(.*)/;
+			next unless /^\s*?(\S.*)$/;
 
 			# skip lines that are obviously not
 			# a 1-line cset description

```

## Petr Baudis, 2005-11-06 22:44

Subject: Re: [PATCH] Fix empty line processing in git-shortlog.perl
Message-ID: <20051106224422.GQ1431@pasky.or.cz>
URL: https://gitlist.dev/e/20051106224422.GQ1431%40pasky.or.cz
In-Reply-To: <20051106224218.22797.97260.stgit@machine.or.cz>

```
Dear diary, on Sun, Nov 06, 2005 at 11:42:18PM CET, I got a letter
where Petr Baudis <pasky@suse.cz> told me that...
> diff --git a/git-shortlog.perl b/git-shortlog.perl
> index 0b14f83..7283159 100755
> --- a/git-shortlog.perl
> +++ b/git-shortlog.perl
> @@ -94,7 +94,7 @@ sub changelog_input {
>  
>  		# skip to non-blank line
>  		elsif ($pstate == 3) {
> -			next unless /^\s*?(.*)/;
> +			next unless /^\s*?(\S.*)$/;
>  
>  			# skip lines that are obviously not
>  			# a 1-line cset description
> 

Whoops, the ? was not part of the original regexp and is obviously
useless. Well, I don't think it really matters, so it is up to you...

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.

```

## Junio C Hamano, 2005-11-07 02:56

Subject: Re: [PATCH] Fix empty line processing in git-shortlog.perl
Message-ID: <7v3bm9upx4.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v3bm9upx4.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <20051106224218.22797.97260.stgit@machine.or.cz>

```
Petr Baudis <pasky@suse.cz> writes:

> Faced with a commit such as
>
> 	commit f1b2646c7f2713c3ea4bce120e1d0d8091808be4
> 	Author: Adrian Bunk <bunk@r063144.stusta.swh.mhn.de>
> 	Date:   Sun Nov 6 20:30:38 2005 +0100
>
> 	    From: Michal Wronski <wrona@mat.uni.torun.pl>
>
> 	    I've jchanged my email. Please apply this patch so as to everybody
> 	    could send me a remarks about mqueuefs.
>
> 	    Signed-off-by: Michal Wronski <Michal.Wronski@motorola.com>
> 	    Signed-off-by: Adrian Bunk <bunk@stusta.de>
>
> git-shortlog.perl would produce a line with an empty commit title.

> This patch fixes that...

> -			next unless /^\s*?(.*)/;
> +			next unless /^\s*?(\S.*)$/;

I suspect /(\S.*)$/ would do the same thing, but in any case
I do not think it is the right fix.

I think the problem is deeper than that.  Shortlog summarizes to
only one line per commit, so I suspect what you would be feeding
it would say something like this for the above example:

        commit f1b2646c7f2713c3ea4bce120e1d0d8091808be4
        Author: Adrian Bunk <bunk@r063144.stusta.swh.mhn.de>

            From: Michal Wronski <wrona@mat.uni.torun.pl>

That is, the commit you quoted is done by 'git log --pretty',
but a typical shortlog invocation would be:

	git log --pretty=short rev1..rev2 | git shortlog

With or without your fix, the command barfs.

Of course, that "From: " line should have been used as the
commit author by the tool that created the commit out of e-mail
Adrian received, but that is a separate issue.

```

## Petr Baudis, 2005-11-07 20:46

Subject: Re: [PATCH] Fix empty line processing in git-shortlog.perl
Message-ID: <20051107204659.GT1431@pasky.or.cz>
URL: https://gitlist.dev/e/20051107204659.GT1431%40pasky.or.cz
In-Reply-To: <7v3bm9upx4.fsf@assigned-by-dhcp.cox.net>

```
Dear diary, on Mon, Nov 07, 2005 at 03:56:07AM CET, I got a letter
where Junio C Hamano <junkio@cox.net> told me that...
> I think the problem is deeper than that.  Shortlog summarizes to
> only one line per commit, so I suspect what you would be feeding
> it would say something like this for the above example:
> 
>         commit f1b2646c7f2713c3ea4bce120e1d0d8091808be4
>         Author: Adrian Bunk <bunk@r063144.stusta.swh.mhn.de>
> 
>             From: Michal Wronski <wrona@mat.uni.torun.pl>
> 
> That is, the commit you quoted is done by 'git log --pretty',
> but a typical shortlog invocation would be:
> 
> 	git log --pretty=short rev1..rev2 | git shortlog
> 
> With or without your fix, the command barfs.
> 
> Of course, that "From: " line should have been used as the
> commit author by the tool that created the commit out of e-mail
> Adrian received, but that is a separate issue.

Well, on a second though, I don't think we should probably handle this
at all, then. The whole logic for this in git-shortlog.perl seems to be
dubious, so would be a requirement that we require the input to be from
--pretty=short ok?

Simpler code, no bugs, everyone happy, errors during applying (like
stale From) immediately noticeable.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
VI has two modes: the one in which it beeps and the one in which
it doesn't.

```
