git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Convert shortlog to handle cogito (cg-log) output
@ 2005-04-26  8:39 Ryan Anderson
  0 siblings, 0 replies; only message in thread
From: Ryan Anderson @ 2005-04-26  8:39 UTC (permalink / raw)
  To: Matthias Andree; +Cc: Linus Torvalds, git


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 <ryan@michonline.com>

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-04-26  8:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-26  8:39 [PATCH] Convert shortlog to handle cogito (cg-log) output Ryan Anderson

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).