{"thread":{"id":"7012","subject":"[PATCH] Fix git-archimport on empty summary","startedAt":"2007-02-28T07:03:04Z","lastAt":"2007-02-28T20:02:02Z","messageCount":3,"participants":["Paolo Bonzini","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"35782","messageId":"es39f9$sqh$1@sea.gmane.org","threadId":"7012","inReplyTo":null,"subject":"[PATCH] Fix git-archimport on empty summary","fromName":"Paolo Bonzini","fromEmail":"bonzini@gnu.org","sentAt":"2007-02-28T07:03:04Z","receivedAt":"2007-02-28T07:03:04Z","isPatch":true,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"I got this while importing bonzini@gnu.org--2004b/lightning--stable--1.2 \n(archive available at \nhttp://www.inf.unisi.ch/phd/bonzini/webdav/bonzini@gnu.org--2004b via \nwebdav).\n\nThe patch seems pretty obvious to me, and Martin Langhoff has already \nseen it in private e-mail.\n\nThanks,\n\nPaolo\n\n2007-02-27  Paolo Bonzini  <bonzini@gnu.org>\n\n         * git-archimport (parselog): Cope with an empty summary.\n\n--- /usr/bin/git-archimport     2007-01-09 21:15:39.000000000 +0100\n+++ ./git-archimport    2007-02-27 14:28:33.000000000 +0100\n@@ -780,7 +780,11 @@\n      }\n\n      # post-processing:\n-    $ps->{summary} = join(\"\\n\",@{$ps->{summary}}).\"\\n\";\n+    if (defined $ps->{summary}) {\n+        $ps->{summary} = join(\"\\n\",@{$ps->{summary}}).\"\\n\";\n+    } else {\n+        $ps->{summary} = \"\\n\";\n+    }\n      $ps->{message} = join(\"\\n\",@$log);\n\n      # skip Arch control files, unescape pika-escaped files\n"},{"id":"35875","messageId":"7vd53u13p3.fsf@assigned-by-dhcp.cox.net","threadId":"7012","inReplyTo":"es39f9$sqh$1@sea.gmane.org","subject":"Re: [PATCH] Fix git-archimport on empty summary","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-02-28T19:29:12Z","receivedAt":"2007-02-28T19:29:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paolo Bonzini <bonzini@gnu.org> writes:\n\n> The patch seems pretty obvious to me, and Martin Langhoff has already\n> seen it in private e-mail.\n>    \n> Thanks,\n>\n> Paolo\n>\n> 2007-02-27  Paolo Bonzini  <bonzini@gnu.org>\n>\n>         * git-archimport (parselog): Cope with an empty summary.\n>\n\nI would have liked a proposed commit message that is more in\nline with the rest of the git.git history.\n\nThe patch seems pretty obvious and does not do any _worse_ than\nthe existing code.\n\n> --- /usr/bin/git-archimport     2007-01-09 21:15:39.000000000 +0100\n> +++ ./git-archimport    2007-02-27 14:28:33.000000000 +0100\n> @@ -780,7 +780,11 @@\n>      }\n>\n>      # post-processing:\n> -    $ps->{summary} = join(\"\\n\",@{$ps->{summary}}).\"\\n\";\n> +    if (defined $ps->{summary}) {\n> +        $ps->{summary} = join(\"\\n\",@{$ps->{summary}}).\"\\n\";\n> +    } else {\n> +        $ps->{summary} = \"\\n\";\n> +    }\n>      $ps->{message} = join(\"\\n\",@$log);\n>\n>      # skip Arch control files, unescape pika-escaped files\n\nHowever, I see that the result is used this way:\n\n    my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) \n        or die $!;\n    print WRITER $ps->{summary},\"\\n\";\n    print WRITER $ps->{message},\"\\n\";\n\nWhat's the arch way of formatting log messages?  Are summary\nlines expected to be multi-line?  I see that there is a\ncontinuation line handling that builds @{$ps->{summary}} array.\nWhat does a summary line like this mean to an arch person?\n\n\tSummary: Fix git-archimport's handling of a commit that\n\t lack a \"Summary:\" line.\n \tCreator: Paolo Bonzini <bonzini@gnu.org>\n\nDoes it mean the Summary is logically two lines, or it is\nlogically one line but linewrapped into two physical lines?  If\nthat is the case, I would almost suggest to update the part your\npatch touches to read like:\n\n\tchomp(@$log);\n\twhile ($_ = shift @$log) {\n        \t...\n\t}\n\t# drop leading empty lines from the log message\n\twhile (@$log && $log->[0] ne '') {\n        \tshift @$log;\n\t}\n\tif (exists $ps->{summary} && @{$ps->{summary}}) {\n        \t$ps->{summary} = join(' ', @{$ps->{summary}});\n        }\n\telse {\n        \t$ps->{summary} = $log->[0] . '...';\n\t}\n\t$ps->{message} = join(\"\\n\",@$log);\n\nand then update the user of these two to:\n\n    my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) \n        or die $!;\n    print WRITER $ps->{summary},\"\\n\\n\";\n    print WRITER $ps->{message},\"\\n\";\n\nThat way, you will always have a one-line that can sensibly\nserve as a summary to appear in \"git shortlog\".\n"},{"id":"35883","messageId":"45E5DFBA.9070400@lu.unisi.ch","threadId":"7012","inReplyTo":"7vd53u13p3.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Fix git-archimport on empty summary","fromName":"Paolo Bonzini","fromEmail":"paolo.bonzini@lu.unisi.ch","sentAt":"2007-02-28T20:02:02Z","receivedAt":"2007-02-28T20:02:02Z","isPatch":true,"sender":{"key":"bonzini@gnu.org","avatar":"https://avatars.githubusercontent.com/u/42082?v=4"},"body":"\n> I would have liked a proposed commit message that is more in\n> line with the rest of the git.git history.\n\nOops, sorry.  I guess that shows where I come from, and I hope that the \nattached one is better.\n\n> However, I see that the result is used this way:\n> \n>     my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) \n>         or die $!;\n>     print WRITER $ps->{summary},\"\\n\";\n>     print WRITER $ps->{message},\"\\n\";\n> \n> What's the arch way of formatting log messages?  Are summary\n> lines expected to be multi-line?\n\nNo, but the message is formatted as RFC-822, and I can guess Martin was \njust being defensive.  I've never seen a multi-line summary, but I fully \nagree with you that it's better to get the whole summary on the first line.\n\nPatch attached, tested using the same arch import as before.\n\nThanks,\n\nPaolo\n\n\ngit-archimport: support empty summaries, put summary on a single line.\n\nDon't fail if the summary line in an arch commit is empty.  In this case,\ntry to use the first line in the commit message followed by an ellipsis.\nIn addition, if the summary is multi-line, it is joined on a single line.\n\n\ndiff --git a/git-archimport.perl b/git-archimport.perl\nindex 66aaeae..0fcb156 100755\n--- a/git-archimport.perl\n+++ b/git-archimport.perl\n@@ -553,7 +553,7 @@ foreach my $ps (@psets) {\n \n     my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) \n         or die $!;\n-    print WRITER $ps->{summary},\"\\n\";\n+    print WRITER $ps->{summary},\"\\n\\n\";\n     print WRITER $ps->{message},\"\\n\";\n     \n     # make it easy to backtrack and figure out which Arch revision this was:\n@@ -755,7 +755,8 @@ sub parselog {\n             $ps->{tag} = $1;\n             $key = undef;\n         } elsif (/^Summary:\\s*(.*)$/ ) {\n-            # summary can be multiline as long as it has a leading space\n+            # summary can be multiline as long as it has a leading space.\n+\t    # we squeeze it onto a single line, though.\n             $ps->{summary} = [ $1 ];\n             $key = 'summary';\n         } elsif (/^Creator: (.*)\\s*<([^\\>]+)>/) {\n@@ -787,8 +788,18 @@ sub parselog {\n         }\n     }\n    \n-    # post-processing:\n-    $ps->{summary} = join(\"\\n\",@{$ps->{summary}}).\"\\n\";\n+    # drop leading empty lines from the log message\n+    while (@$log && $log->[0] eq '') {\n+\tshift @$log;\n+    }\n+    if (exists $ps->{summary} && @{$ps->{summary}}) {\n+\t$ps->{summary} = join(' ', @{$ps->{summary}});\n+    }\n+    elsif (@$log == 0) {\n+\t$ps->{summary} = 'empty commit message';\n+    } else {\n+\t$ps->{summary} = $log->[0] . '...';\n+    }\n     $ps->{message} = join(\"\\n\",@$log);\n     \n     # skip Arch control files, unescape pika-escaped files\n"}]}