{"thread":{"id":"326","subject":"[PATCH] Convert shortlog to handle cogito (cg-log) output","startedAt":"2005-04-26T08:39:50Z","lastAt":"2005-04-26T08:39:50Z","messageCount":1,"participants":["Ryan Anderson"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"1725","messageId":"20050426083950.GA30167@mythryan2.michonline.com","threadId":"326","inReplyTo":null,"subject":"[PATCH] Convert shortlog to handle cogito (cg-log) output","fromName":"Ryan Anderson","fromEmail":"ryan@michonline.com","sentAt":"2005-04-26T08:39:50Z","receivedAt":"2005-04-26T08:39:50Z","isPatch":true,"sender":{"key":"ryan@michonline.com","avatar":null},"body":"\nConvert \"shortlog\" to understand cogito's cg-log output format instead\nof \"bk changes\" format.\n\nCogito (and by inference, \"git\" in general) have a different log output\nformat than BitKeeper.  This log format seems somewhat simpler to parse.\n\nThe following patch is a *bare minimum* conversion to make \"shortlog\"\nprovide corrected output the Cogito script \"cg-log\".\n\n(This is clearly not sufficient, and not intended for application to any\nrea tree, as a lot of BitKeeper domain knowledge remains, but this\nshould be enough for Linus to provide changelogs in the \"shortlog\"\nformat again, and hopefully to serve as a template for further\nmodifications by others.)\n\nSigned-Off-By: Ryan Anderson <ryan@michonline.com>\n\n--- cogito-tools/shortlog\t2005-04-26 04:22:01.000000000 -0400\n+++ cogito-tools/git-shortlog\t2005-04-26 04:36:52.000000000 -0400\n@@ -3052,7 +3052,7 @@\n       }\n \n     if (defined $address and $opt{multi}\n-\tand m{^[^<[:space:]]} and not m{^ChangeSet@}) {\n+\tand m{^[^<[:space:]]} and not m{^commit }) {\n       # if we are in multi mode, if we encounter a non-address\n       # left-justified line, flush all data and print the header. The\n       # 'defined $address' trick lets this only trigger to switch back\n@@ -3063,13 +3063,14 @@\n       @prolog = ($_);\n       undef %$log;\n       undef $address;\n-    } elsif (m{^<([^>]+)>} or m{^ChangeSet@[0-9.]+,\\s*[-0-9:+ ]+,\\s*(\\S+)}) {\n+    } elsif (m{^<([^>]+)>} or m{^author (.*) <(.*)>}) {\n       # go figure if a line starts with an address, if so, take it\n       # resolve the address to a name if possible\n       append_item(%$log, @cur); @cur = ();\n-      $address = lc($1);\n+      $address = lc($2);\n       $address =~ s/\\[[^]]+\\]$//;\n       $name = rmap_address($address, 1);\n+      $name = $1 if ($name eq $address);\n       $author = treat_addr_name($address, $name);\n       $first = 1;\n       $firstpar = 1;\n@@ -3093,25 +3094,28 @@\n       } else {\n \t  print STDERR \" SKIPPED SIGNED-OFF-BY  $author\\n\" if $debug;\n       }\n-    } elsif ($first) {\n+    } elsif ($first && m/^(?:[[:space:]]{4}|\\t)(.*)$/) {\n       # we have a \"first\" line after an address, take it,\n       # strip common redundant tags\n+      \n+      my $comment = $1;\n \n       # kill \"PATCH\" tag\n-      s/^\\s*\\[PATCH\\]//;\n-      s/^\\s*PATCH//;\n-      s/^\\s*[-:]+\\s*//;\n+      $comment =~ s/^\\s*\\[PATCH\\]//;\n+      $comment =~ s/^\\s*PATCH//;\n+      $comment =~ s/^\\s*[-:]+\\s*//;\n \n       # strip trailing colon or period, and if we strip one,\n       # we don't parse further lines as part of the first paragraph\n-      if (s/[:.]+\\s*$//) { $firstpar = 0; }\n+      if ($comment =~ s/[:.]+\\s*$//) { $firstpar = 0; }\n \n       # kill leading and trailing whitespace for consistent indentation\n-      s/^\\s+//; s/\\s+$//;\n+      $comment =~ s/^\\s+//; s/\\s+$//;\n \n-      push @cur, $_;\n+      push @cur, $comment;\n       $first = 0;\n-    } elsif (defined $address) {\n+\n+    } elsif (defined $address && m/^(?:[[:space:]]{4}|\\t)(.*)$/ ) {\n       # second or subsequent lines -- if in first paragraph,\n       # append this line to the first log line.\n       if (m/^\\s*$/) { $firstpar = 0; }\n@@ -3124,6 +3128,10 @@\n       }\n       # we don't parse further lines as part of the first paragraph\n       if (s/[:.]+\\s*$//) { $firstpar = 0; }\n+\n+    } elsif (m/^(commit|tree|parent|committer) / || m/^\\s*$/) {\n+      # Skip unused header lines\n+\n     } else {\n       # store header before a changelog\n       push @prolog, $_;\n\n\n-- \n\nRyan Anderson\n  sometimes Pug Majere\n"}]}