All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix git-archimport on empty summary
@ 2007-02-28  7:03 Paolo Bonzini
  2007-02-28 19:29 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Paolo Bonzini @ 2007-02-28  7:03 UTC (permalink / raw)
  To: git

I got this while importing bonzini@gnu.org--2004b/lightning--stable--1.2 
(archive available at 
http://www.inf.unisi.ch/phd/bonzini/webdav/bonzini@gnu.org--2004b via 
webdav).

The patch seems pretty obvious to me, and Martin Langhoff has already 
seen it in private e-mail.

Thanks,

Paolo

2007-02-27  Paolo Bonzini  <bonzini@gnu.org>

         * git-archimport (parselog): Cope with an empty summary.

--- /usr/bin/git-archimport     2007-01-09 21:15:39.000000000 +0100
+++ ./git-archimport    2007-02-27 14:28:33.000000000 +0100
@@ -780,7 +780,11 @@
      }

      # post-processing:
-    $ps->{summary} = join("\n",@{$ps->{summary}})."\n";
+    if (defined $ps->{summary}) {
+        $ps->{summary} = join("\n",@{$ps->{summary}})."\n";
+    } else {
+        $ps->{summary} = "\n";
+    }
      $ps->{message} = join("\n",@$log);

      # skip Arch control files, unescape pika-escaped files

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix git-archimport on empty summary
  2007-02-28  7:03 [PATCH] Fix git-archimport on empty summary Paolo Bonzini
@ 2007-02-28 19:29 ` Junio C Hamano
  2007-02-28 20:02   ` Paolo Bonzini
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2007-02-28 19:29 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: git

Paolo Bonzini <bonzini@gnu.org> writes:

> The patch seems pretty obvious to me, and Martin Langhoff has already
> seen it in private e-mail.
>    
> Thanks,
>
> Paolo
>
> 2007-02-27  Paolo Bonzini  <bonzini@gnu.org>
>
>         * git-archimport (parselog): Cope with an empty summary.
>

I would have liked a proposed commit message that is more in
line with the rest of the git.git history.

The patch seems pretty obvious and does not do any _worse_ than
the existing code.

> --- /usr/bin/git-archimport     2007-01-09 21:15:39.000000000 +0100
> +++ ./git-archimport    2007-02-27 14:28:33.000000000 +0100
> @@ -780,7 +780,11 @@
>      }
>
>      # post-processing:
> -    $ps->{summary} = join("\n",@{$ps->{summary}})."\n";
> +    if (defined $ps->{summary}) {
> +        $ps->{summary} = join("\n",@{$ps->{summary}})."\n";
> +    } else {
> +        $ps->{summary} = "\n";
> +    }
>      $ps->{message} = join("\n",@$log);
>
>      # skip Arch control files, unescape pika-escaped files

However, I see that the result is used this way:

    my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) 
        or die $!;
    print WRITER $ps->{summary},"\n";
    print WRITER $ps->{message},"\n";

What's the arch way of formatting log messages?  Are summary
lines expected to be multi-line?  I see that there is a
continuation line handling that builds @{$ps->{summary}} array.
What does a summary line like this mean to an arch person?

	Summary: Fix git-archimport's handling of a commit that
	 lack a "Summary:" line.
 	Creator: Paolo Bonzini <bonzini@gnu.org>

Does it mean the Summary is logically two lines, or it is
logically one line but linewrapped into two physical lines?  If
that is the case, I would almost suggest to update the part your
patch touches to read like:

	chomp(@$log);
	while ($_ = shift @$log) {
        	...
	}
	# drop leading empty lines from the log message
	while (@$log && $log->[0] ne '') {
        	shift @$log;
	}
	if (exists $ps->{summary} && @{$ps->{summary}}) {
        	$ps->{summary} = join(' ', @{$ps->{summary}});
        }
	else {
        	$ps->{summary} = $log->[0] . '...';
	}
	$ps->{message} = join("\n",@$log);

and then update the user of these two to:

    my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) 
        or die $!;
    print WRITER $ps->{summary},"\n\n";
    print WRITER $ps->{message},"\n";

That way, you will always have a one-line that can sensibly
serve as a summary to appear in "git shortlog".

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Fix git-archimport on empty summary
  2007-02-28 19:29 ` Junio C Hamano
@ 2007-02-28 20:02   ` Paolo Bonzini
  0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2007-02-28 20:02 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 836 bytes --]


> I would have liked a proposed commit message that is more in
> line with the rest of the git.git history.

Oops, sorry.  I guess that shows where I come from, and I hope that the 
attached one is better.

> However, I see that the result is used this way:
> 
>     my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) 
>         or die $!;
>     print WRITER $ps->{summary},"\n";
>     print WRITER $ps->{message},"\n";
> 
> What's the arch way of formatting log messages?  Are summary
> lines expected to be multi-line?

No, but the message is formatted as RFC-822, and I can guess Martin was 
just being defensive.  I've never seen a multi-line summary, but I fully 
agree with you that it's better to get the whole summary on the first line.

Patch attached, tested using the same arch import as before.

Thanks,

Paolo

[-- Attachment #2: git-archimport-empty-summary.patch --]
[-- Type: text/plain, Size: 1825 bytes --]

git-archimport: support empty summaries, put summary on a single line.

Don't fail if the summary line in an arch commit is empty.  In this case,
try to use the first line in the commit message followed by an ellipsis.
In addition, if the summary is multi-line, it is joined on a single line.


diff --git a/git-archimport.perl b/git-archimport.perl
index 66aaeae..0fcb156 100755
--- a/git-archimport.perl
+++ b/git-archimport.perl
@@ -553,7 +553,7 @@ foreach my $ps (@psets) {
 
     my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) 
         or die $!;
-    print WRITER $ps->{summary},"\n";
+    print WRITER $ps->{summary},"\n\n";
     print WRITER $ps->{message},"\n";
     
     # make it easy to backtrack and figure out which Arch revision this was:
@@ -755,7 +755,8 @@ sub parselog {
             $ps->{tag} = $1;
             $key = undef;
         } elsif (/^Summary:\s*(.*)$/ ) {
-            # summary can be multiline as long as it has a leading space
+            # summary can be multiline as long as it has a leading space.
+	    # we squeeze it onto a single line, though.
             $ps->{summary} = [ $1 ];
             $key = 'summary';
         } elsif (/^Creator: (.*)\s*<([^\>]+)>/) {
@@ -787,8 +788,18 @@ sub parselog {
         }
     }
    
-    # post-processing:
-    $ps->{summary} = join("\n",@{$ps->{summary}})."\n";
+    # drop leading empty lines from the log message
+    while (@$log && $log->[0] eq '') {
+	shift @$log;
+    }
+    if (exists $ps->{summary} && @{$ps->{summary}}) {
+	$ps->{summary} = join(' ', @{$ps->{summary}});
+    }
+    elsif (@$log == 0) {
+	$ps->{summary} = 'empty commit message';
+    } else {
+	$ps->{summary} = $log->[0] . '...';
+    }
     $ps->{message} = join("\n",@$log);
     
     # skip Arch control files, unescape pika-escaped files

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-02-28 20:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-28  7:03 [PATCH] Fix git-archimport on empty summary Paolo Bonzini
2007-02-28 19:29 ` Junio C Hamano
2007-02-28 20:02   ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.