Skip to content

Commit 45c956b

Browse files
ryu1kgitster
authored andcommitted
git-svn: fix localtime=true on non-glibc environments
git svn uses POSIX::strftime('%s', $sec, $min, ...) to make unix epoch time. But lowercase %s formatting character is a GNU extention. This causes problem in git svn fetch --localtime on non-glibc systems, such as msys or cygwin. Using Time::Local::timelocal($sec, $min, ...) fixes it. Signed-off-by: Ryuichi Kokubo <[email protected]> Signed-off-by: Eric Wong <[email protected]> Notes: lowercase %s format character in strftime is a GNU extension and not widely supported. POSIX::strftime affected by underlying crt's strftime because POSIX::strftime just calls crt's one. Time::Local is good function to replace POSIX::strftime because it's a perl core module function. Document about Time::Local. http://perldoc.perl.org/Time/Local.html These are specifications of strftime. The GNU C Library Reference Manual. http://www.gnu.org/software/libc/manual/html_node/Formatting-Calendar-Time.html perl POSIX module's strftime document. It does not have '%s'. http://perldoc.perl.org/POSIX.html strftime document of Microsort Windows C Run-Time library. https://msdn.microsoft.com/en-us/library/fe06s4ak.aspx The Open Group's old specification does not have '%s' too. http://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html On my environment, following problems happened. - msys : git svn fetch does not progress at all with perl.exe consuming CPU. - cygwin : git svn fetch progresses but time stamp information is dropped. Every commits have unix epoch timestamp. I would like to thank git developer and contibutors. git helps me so much everyday. Thank you. Signed-off-by: Junio C Hamano <[email protected]>
1 parent fdf96a2 commit 45c956b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

perl/Git/SVN.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use IPC::Open3;
1414
use Memoize; # core since 5.8.0, Jul 2002
1515
use Memoize::Storable;
1616
use POSIX qw(:signal_h);
17+
use Time::Local;
1718

1819
use Git qw(
1920
command
@@ -1332,7 +1333,7 @@ sub parse_svn_date {
13321333
$ENV{TZ} = 'UTC';
13331334

13341335
my $epoch_in_UTC =
1335-
POSIX::strftime('%s', $S, $M, $H, $d, $m - 1, $Y - 1900);
1336+
Time::Local::timelocal($S, $M, $H, $d, $m - 1, $Y - 1900);
13361337

13371338
# Determine our local timezone (including DST) at the
13381339
# time of $epoch_in_UTC. $Git::SVN::Log::TZ stored the

0 commit comments

Comments
 (0)