Hello all, I've written a little script that will format the changes as reported by git-log in a ChangeLog-like format. Entries look like this: <date>\t<author>\n\t<sha1>: <subject> An example taken from Gits own recent history: 2007-10-30 Junio C Hamano 9c51414: Merge branch 'maint' into HEAD 7eedc1c: Merge branch 'nd/worktree' into HEAD 9725bb8: Merge branch 'cc/skip' into HEAD 7ae4dd0: Merge branch 'jk/send-pack' into HEAD 7e9a464: Merge branch 'lt/rename' into HEAD 6beb669: Merge branch 'jn/web' into HEAD 791e421: Merge branch 'ds/gitweb' into HEAD 5153399: Merge branch 'js/rebase' into HEAD 0bdb5af: Update GIT 1.5.3.5 Release Notes 2007-10-30 Gerrit Pape fee9832: No longer install git-svnimport, move to contrib/examples I intend to use it for releases of my software, and I though others might like it as well. I haven't implemented any help yet, but if any-one would like some documentation, I'll be glad to provide it. rlc diff --git a/Makefile b/Makefile index 71479a2..cf2cb32 100644 --- a/Makefile +++ b/Makefile @@ -226,7 +226,7 @@ SCRIPT_PERL = \ git-add--interactive.perl \ git-archimport.perl git-cvsimport.perl git-relink.perl \ git-cvsserver.perl git-remote.perl git-cvsexportcommit.perl \ - git-send-email.perl git-svn.perl + git-send-email.perl git-svn.perl git-changelog.perl SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \ $(patsubst %.perl,%,$(SCRIPT_PERL)) \ diff --git a/git-changelog.perl b/git-changelog.perl new file mode 100755 index 0000000..bffa1ab --- /dev/null +++ b/git-changelog.perl @@ -0,0 +1,68 @@ +#!/usr/bin/perl -w + +use strict; + +sub fetch_log { + my $command='git log --pretty=format:"%ai|%an|%h|%s" '; + foreach (@_) { + $command .= ' ' . $_; + } + $command .= " |"; + my $fh; + open $fh, $command + or die "Failed to fetch logs"; + # logs are presented as lines in which fields are separated by pipes. + # the fields are the date in ISO format (so the date as we want it extends to the + # first space), the name of the author, the abbreviated SHA1 hash and the subject line + my $date_time; + my $date; + my $cruft; + my $author; + my $hash; + my $subject; + my $prev_date=""; + my @cache; # a cache of the changes for the current date (i.e. while $prev_date eq $date) + my %entry; # a cache entry; $entry{'author'} is the entry and @$entry{'changes'} are the changes for the author in question + while (<$fh>) { + ($date_time, $author, $hash, $subject) = split(/\|/); + ($date, $cruft) = split(/\s/, $date_time, 2); + chomp $author; + + if ($date ne $prev_date) + { + foreach (@cache) + { + # print out the line with the date and the author + my $changes = $_->{'changes'}; + print "\n" . $prev_date . "\t" . $_->{'author'} . "\n" if ($#{$changes} != -1); + foreach (@{$changes}) + { + print "\t" . $_->{'hash'} . ': ' . $_->{'subject'}; + } + } + $prev_date = $date; + @cache = (); + } + # try to find an entry with the same author in the cache + my $found = -1; + my $i; + for ($i = 0; $i <= $#cache && $found == -1; $i++) + { + if ($cache[$i]->{'author'} eq $author) + { + $found = $i; + } + } + if ($found == -1) + { + my $changes = (); + push @cache, { 'author', $author, 'changes', $changes }; + $found = $#cache; + } + push @{$cache[$found]->{'changes'}}, { 'hash', $hash, 'subject', $subject }; + } +} + +fetch_log @ARGV; + + -- Ronald Landheer-Cieslak Software Architect http://www.landheer-cieslak.com/ New White Paper: "Three Good Reasons to Plan Ahead" - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html