The timestamp format used in "cvs log" output does not include a timezone, and must thus be in UTC timezone. The timestamps from git on the other hand contain timezone information for each commit timestamp, but git-cvsserver discarded this information and used the timestamps without adjusting the time accordingly. The patch adds code to apply the timezone offset to produce a UTC timestamp. Signed-off-by: Jonas Berlin <xkr47@xxxxxxxxxxxxxxxxxxxxx> --- Could it perhaps be that git previously reported timestamps in UTC instead of including a timezone? git-cvsserver.perl | 11 ++++++++++- t/t9400-git-cvsserver-server.sh | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletions(-) diff --git a/git-cvsserver.perl b/git-cvsserver.perl index 13dbd27..5ae9933 100755 --- a/git-cvsserver.perl +++ b/git-cvsserver.perl @@ -23,6 +23,7 @@ use Fcntl; use File::Temp qw/tempdir tempfile/; use File::Basename; use Getopt::Long qw(:config require_order no_ignore_case); +use Time::Local; my $VERSION = '@@GIT_VERSION@@'; @@ -1686,7 +1687,15 @@ sub req_log print "M ----------------------------\n"; print "M revision 1.$revision->{revision}\n"; # reformat the date for log output - $revision->{modified} = sprintf('%04d/%02d/%02d %s', $3, $DATE_LIST->{$2}, $1, $4 ) if ( $revision->{modified} =~ /(\d+)\s+(\w+)\s+(\d+)\s+(\S+)/ and defined($DATE_LIST->{$2}) ); + if ( $revision->{modified} =~ /(\d+)\s+(\w+)\s+(\d+)\s+(\d\d):(\d\d):(\d\d) ([-+])(\d\d)(\d\d)/ and defined($DATE_LIST->{$2}) ) + { + my $off = $8 * 3600 + $9 * 60; + my $time = timegm($6, $5, $4, $1, $DATE_LIST->{$2}-1, $3 - 1900); + $off = -$off if ( $7 eq "-" ); + $time -= $off; + my ( $sec, $min, $hour, $mday, $mon, $year ) = gmtime($time); + $revision->{modified} = sprintf('%04d/%02d/%02d %02d:%02d:%02d', $year + 1900, $mon + 1, $mday, $hour, $min, $sec); + } $revision->{author} =~ s/\s+.*//; $revision->{author} =~ s/^(.{8}).*/$1/; print "M date: $revision->{modified}; author: $revision->{author}; state: " . ( $revision->{filehash} eq "deleted" ? "dead" : "Exp" ) . "; lines: +2 -3\n"; diff --git a/t/t9400-git-cvsserver-server.sh b/t/t9400-git-cvsserver-server.sh index 641303e..254eab7 100755 --- a/t/t9400-git-cvsserver-server.sh +++ b/t/t9400-git-cvsserver-server.sh @@ -405,4 +405,28 @@ test_expect_success 'cvs update (merge no-op)' \ GIT_CONFIG="$git_config" cvs -Q update && diff -q merge ../merge' +#------------ +# CVS LOG +#------------ + +cd "$WORKDIR" +test_expect_success 'cvs log (check that timestamps are in UTC)' \ + 'echo stamp > stamp && + git add stamp && + TZ=GMT-01 git commit -q -m "Add stamp" && + git push gitcvs.git >/dev/null && + GIT_STAMP=$(git-show --pretty=format:%ct --name-only stamp | grep -v stamp) && + [ "$GIT_STAMP" ] && + cd cvswork && + GIT_CONFIG="$git_config" cvs -Q update && + CVS_STAMP=$(GIT_CONFIG="$git_config" cvs log stamp | perl -e '\'' + use Time::Local; + while(<>) { + last if(/^date:/); + } + my ($dummy,$y,$m,$d,$H,$M,$S) = split(m!\D+!); + print timegm($S,$M,$H,$d,$m-1,$y-1900); + '\'') && + test "$CVS_STAMP" = "$GIT_STAMP"' + test_done -- 1.5.1.6 - 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