git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] git-svn: fix localtime=true on non-glibc environments
@ 2015-02-25 16:04 Ryuichi Kokubo
  2015-02-25 18:38 ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Ryuichi Kokubo @ 2015-02-25 16:04 UTC (permalink / raw
  To: git; +Cc: Ryuichi Kokubo

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 <ryu1kkb@gmail.com>

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.
---
 perl/Git/SVN.pm |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index 8e4af71..f243726 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -14,6 +14,7 @@ use IPC::Open3;
 use Memoize;  # core since 5.8.0, Jul 2002
 use Memoize::Storable;
 use POSIX qw(:signal_h);
+use Time::Local;
 
 use Git qw(
     command
@@ -1332,7 +1333,7 @@ sub parse_svn_date {
 		$ENV{TZ} = 'UTC';
 
 		my $epoch_in_UTC =
-		    POSIX::strftime('%s', $S, $M, $H, $d, $m - 1, $Y - 1900);
+		    Time::Local::timelocal($S, $M, $H, $d, $m - 1, $Y - 1900);
 
 		# Determine our local timezone (including DST) at the
 		# time of $epoch_in_UTC.  $Git::SVN::Log::TZ stored the
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-svn: fix localtime=true on non-glibc environments
  2015-02-25 16:04 [PATCH] git-svn: fix localtime=true on non-glibc environments Ryuichi Kokubo
@ 2015-02-25 18:38 ` Junio C Hamano
  2015-02-25 19:42   ` Eric Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Junio C Hamano @ 2015-02-25 18:38 UTC (permalink / raw
  To: Ryuichi Kokubo, Eric Wong; +Cc: git

Ryuichi Kokubo <ryu1kkb@gmail.com> writes:

> 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 <ryu1kkb@gmail.com>

Sounds sensible.

Because we already have "use Time::Local qw(...)" in perl/Git.pm
that is used by git-svn, we know the platforms that are capable
of running the current git-svn do have Time::Local available, so
I do not have worries about new dependency, either.

Eric?

>
> 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.
> ---
>  perl/Git/SVN.pm |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
> index 8e4af71..f243726 100644
> --- a/perl/Git/SVN.pm
> +++ b/perl/Git/SVN.pm
> @@ -14,6 +14,7 @@ use IPC::Open3;
>  use Memoize;  # core since 5.8.0, Jul 2002
>  use Memoize::Storable;
>  use POSIX qw(:signal_h);
> +use Time::Local;
>  
>  use Git qw(
>      command
> @@ -1332,7 +1333,7 @@ sub parse_svn_date {
>  		$ENV{TZ} = 'UTC';
>  
>  		my $epoch_in_UTC =
> -		    POSIX::strftime('%s', $S, $M, $H, $d, $m - 1, $Y - 1900);
> +		    Time::Local::timelocal($S, $M, $H, $d, $m - 1, $Y - 1900);
>  
>  		# Determine our local timezone (including DST) at the
>  		# time of $epoch_in_UTC.  $Git::SVN::Log::TZ stored the

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] git-svn: fix localtime=true on non-glibc environments
  2015-02-25 18:38 ` Junio C Hamano
@ 2015-02-25 19:42   ` Eric Wong
  0 siblings, 0 replies; 3+ messages in thread
From: Eric Wong @ 2015-02-25 19:42 UTC (permalink / raw
  To: Junio C Hamano; +Cc: Ryuichi Kokubo, git

Junio C Hamano <gitster@pobox.com> wrote:
> Ryuichi Kokubo <ryu1kkb@gmail.com> writes:
> 
> > 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 <ryu1kkb@gmail.com>
> 
> Sounds sensible.
> 
> Because we already have "use Time::Local qw(...)" in perl/Git.pm
> that is used by git-svn, we know the platforms that are capable
> of running the current git-svn do have Time::Local available, so
> I do not have worries about new dependency, either.
> 
> Eric?

Looks good, thanks.  Signed-off and queued up.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-02-25 19:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25 16:04 [PATCH] git-svn: fix localtime=true on non-glibc environments Ryuichi Kokubo
2015-02-25 18:38 ` Junio C Hamano
2015-02-25 19:42   ` Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).