Skip to content

Commit

Permalink
cvsimport: format commit timestamp ourselves without using strftime
Browse files Browse the repository at this point in the history
Some implementations of strftime(3) lack support for "%z".  Also
there is no need for %s in git-cvsimport as the supplied time is
already in seconds since the epoch.

For %z, use the function get_tz_offset provided by Git.pm instead.

Signed-off-by: Ben Walton <bdwalton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Ben Walton authored and Junio C Hamano committed Feb 9, 2013
1 parent 75f7b5d commit 48c9162
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion git-cvsimport.perl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use IO::Pipe;
use POSIX qw(strftime tzset dup2 ENOENT);
use IPC::Open2;
use Git qw(get_tz_offset);

$SIG{'PIPE'}="IGNORE";
set_timezone('UTC');
Expand Down Expand Up @@ -864,7 +865,9 @@ sub commit {
}

set_timezone($author_tz);
my $commit_date = strftime("%s %z", localtime($date));
# $date is in the seconds since epoch format
my $tz_offset = get_tz_offset($date);
my $commit_date = "$date $tz_offset";
set_timezone('UTC');
$ENV{GIT_AUTHOR_NAME} = $author_name;
$ENV{GIT_AUTHOR_EMAIL} = $author_email;
Expand Down

0 comments on commit 48c9162

Please sign in to comment.