aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-09-25 20:50:57 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2010-09-25 20:50:57 -0400
commit901a5a786fa3cf107ceb11d2622cf8bb99221f3a (patch)
treebf9546e81f643da35e62e0dc06783695782de994 /src
parentce1dcd468f8a728398424296165a8d87eb36f0d8 (diff)
downloadpostgresql-901a5a786fa3cf107ceb11d2622cf8bb99221f3a.tar.gz
postgresql-901a5a786fa3cf107ceb11d2622cf8bb99221f3a.zip
Minor improvements to git_changelog.
Avoid depending on Date::Calc, which isn't in a basic Perl installation, when we can equally well use Time::Local which is. Also fix the parsing of timestamps to take heed of the timezone. (It looks like cvs2git emitted all commit timestamps with zone GMT, so this refinement might've looked unnecessary when looking at converted data; but it's needed now.) Fix parsing of message bodies so that blank lines that may or may not get emitted by "git log" aren't confused with real data. This avoids strange formatting of the oldest commit on a branch. Check child-process exit status, so that we actually notice if "git log" fails, and so that we don't accumulate zombie children.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/tools/git_changelog22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/tools/git_changelog b/src/tools/git_changelog
index 6d492185f8a..3424cb72bd0 100755
--- a/src/tools/git_changelog
+++ b/src/tools/git_changelog
@@ -27,7 +27,7 @@
use strict;
use warnings;
-require Date::Calc;
+require Time::Local;
require Getopt::Long;
require IPC::Open2;
@@ -51,8 +51,9 @@ my %all_commits_by_branch;
my %commit;
for my $branch (@BRANCHES) {
my $commitnum = 0;
- IPC::Open2::open2(my $git_out, my $git_in, @git, "origin/$branch")
- || die "can't run @git origin/$branch: $!";
+ my $pid =
+ IPC::Open2::open2(my $git_out, my $git_in, @git, "origin/$branch")
+ || die "can't run @git origin/$branch: $!";
while (my $line = <$git_out>) {
if ($line =~ /^commit\s+(.*)/) {
push_commit(\%commit) if %commit;
@@ -69,16 +70,20 @@ for my $branch (@BRANCHES) {
elsif ($line =~ /^Date:\s+(.*)/) {
$commit{'date'} = $1;
}
- elsif ($line =~ /^\s+/) {
+ elsif ($line =~ /^\s\s/) {
$commit{'message'} .= $line;
}
}
+ waitpid($pid, 0);
+ my $child_exit_status = $? >> 8;
+ die "@git origin/$branch failed" if $child_exit_status != 0;
}
my %position;
for my $branch (@BRANCHES) {
$position{$branch} = 0;
}
+
while (1) {
my $best_branch;
my $best_inversions;
@@ -103,7 +108,9 @@ while (1) {
print $winner->{'header'};
print "Commit-Order-Inversions: $best_inversions\n"
if $best_inversions != 0;
+ print "\n";
print $winner->{'message'};
+ print "\n";
$winner->{'done'} = 1;
for my $branch (@BRANCHES) {
my $leader = $all_commits_by_branch{$branch}->[$position{$branch}];
@@ -149,8 +156,11 @@ sub hash_commit {
sub parse_datetime {
my ($dt) = @_;
- $dt =~ /^(\d\d\d\d)-(\d\d)-(\d\d)\s+(\d\d):(\d\d):(\d\d)/;
- return Date::Calc::Mktime($1, $2, $3, $4, $5, $6);
+ $dt =~ /^(\d\d\d\d)-(\d\d)-(\d\d)\s+(\d\d):(\d\d):(\d\d)\s+([-+])(\d\d)(\d\d)$/;
+ my $gm = Time::Local::timegm($6, $5, $4, $3, $2-1, $1);
+ my $tzoffset = ($8 * 60 + $9) * 60;
+ $tzoffset = - $tzoffset if $7 eq '-';
+ return $gm - $tzoffset;
}
sub usage {