[PATCH] Convert shortlog to handle cogito (cg-log) output
From: Ryan Anderson <hidden>
Date: 2016-06-15 22:41:54
Convert "shortlog" to understand cogito's cg-log output format instead of "bk changes" format. Cogito (and by inference, "git" in general) have a different log output format than BitKeeper. This log format seems somewhat simpler to parse. The following patch is a *bare minimum* conversion to make "shortlog" provide corrected output the Cogito script "cg-log". (This is clearly not sufficient, and not intended for application to any rea tree, as a lot of BitKeeper domain knowledge remains, but this should be enough for Linus to provide changelogs in the "shortlog" format again, and hopefully to serve as a template for further modifications by others.) Signed-Off-By: Ryan Anderson <redacted>
--- cogito-tools/shortlog 2005-04-26 04:22:01.000000000 -0400
+++ cogito-tools/git-shortlog 2005-04-26 04:36:52.000000000 -0400@@ -3052,7 +3052,7 @@ } if (defined $address and $opt{multi} - and m{^[^<[:space:]]} and not m{^ChangeSet@}) { + and m{^[^<[:space:]]} and not m{^commit }) { # if we are in multi mode, if we encounter a non-address # left-justified line, flush all data and print the header. The # 'defined $address' trick lets this only trigger to switch back
@@ -3063,13 +3063,14 @@ @prolog = ($_); undef %$log; undef $address; - } elsif (m{^<([^>]+)>} or m{^ChangeSet@[0-9.]+,\s*[-0-9:+ ]+,\s*(\S+)}) { + } elsif (m{^<([^>]+)>} or m{^author (.*) <(.*)>}) { # go figure if a line starts with an address, if so, take it # resolve the address to a name if possible append_item(%$log, @cur); @cur = (); - $address = lc($1); + $address = lc($2); $address =~ s/\[[^]]+\]$//; $name = rmap_address($address, 1); + $name = $1 if ($name eq $address); $author = treat_addr_name($address, $name); $first = 1; $firstpar = 1;
@@ -3093,25 +3094,28 @@ } else { print STDERR " SKIPPED SIGNED-OFF-BY $author\n" if $debug; } - } elsif ($first) { + } elsif ($first && m/^(?:[[:space:]]{4}|\t)(.*)$/) { # we have a "first" line after an address, take it, # strip common redundant tags + + my $comment = $1; # kill "PATCH" tag - s/^\s*\[PATCH\]//; - s/^\s*PATCH//; - s/^\s*[-:]+\s*//; + $comment =~ s/^\s*\[PATCH\]//; + $comment =~ s/^\s*PATCH//; + $comment =~ s/^\s*[-:]+\s*//; # strip trailing colon or period, and if we strip one, # we don't parse further lines as part of the first paragraph - if (s/[:.]+\s*$//) { $firstpar = 0; } + if ($comment =~ s/[:.]+\s*$//) { $firstpar = 0; } # kill leading and trailing whitespace for consistent indentation - s/^\s+//; s/\s+$//; + $comment =~ s/^\s+//; s/\s+$//; - push @cur, $_; + push @cur, $comment; $first = 0; - } elsif (defined $address) { + + } elsif (defined $address && m/^(?:[[:space:]]{4}|\t)(.*)$/ ) { # second or subsequent lines -- if in first paragraph, # append this line to the first log line. if (m/^\s*$/) { $firstpar = 0; }
@@ -3124,6 +3128,10 @@ } # we don't parse further lines as part of the first paragraph if (s/[:.]+\s*$//) { $firstpar = 0; } + + } elsif (m/^(commit|tree|parent|committer) / || m/^\s*$/) { + # Skip unused header lines + } else { # store header before a changelog push @prolog, $_;
--
Ryan Anderson
sometimes Pug Majere