git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <paolo.bonzini@lu.unisi.ch>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] Fix git-archimport on empty summary
Date: Wed, 28 Feb 2007 21:02:02 +0100	[thread overview]
Message-ID: <45E5DFBA.9070400@lu.unisi.ch> (raw)
In-Reply-To: <7vd53u13p3.fsf@assigned-by-dhcp.cox.net>

[-- 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

      reply	other threads:[~2007-02-28 20:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=45E5DFBA.9070400@lu.unisi.ch \
    --to=paolo.bonzini@lu.unisi.ch \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).