git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: What's cooking in git.git (Oct 2012, #09; Mon, 29)

From
Jeff King <peff@peff.net>
Date
Nov 2, 2012, 09:56 UTC
Message-ID
<20121102095632.GA30221@sigill.intra.peff.net>
In-Reply-To
<20121102094259.GA28414@sigill.intra.peff.net>
On Fri, Nov 02, 2012 at 05:43:00AM -0400, Jeff King wrote:
Show 12 quoted lines
> Yeah, I think that is it. IIRC, Ramsay is on cygwin, and I noticed this
> in perl 5.16's POSIX.xs:
>
> [...]
>    * (4) The CRT strftime() "%Z" implementation calls __tzset(). That
>    * calls CRT tzset(), but only the first time it is called, and in turn
>    * that uses CRT getenv("TZ") to retrieve the timezone info from the CRT
>    * local copy of the environment and hence gets the original setting as
>    * perl never updates the CRT copy when assigning to $ENV{TZ}.
> [...]
> I wonder if Ramsay has an older perl that does not do this special
> hackery right. I'll see if I can dig up where it first appeared.
It looks like that code went into perl 5.11.

I wonder, even with this fix, though, if we need to be calling tzset to reliably update from the environment. It sounds like it _should_ happen automatically, except that if the CRT is calling the internal tzset, it would not do the perl "grab from $ENV" magic. Calling tzset would make sure the internal TZ is up to date.

Ramsay, what happens with this patch on top?
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index ceb119d..4c44050 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -24,11 +24,12 @@ use File::Basename qw(basename dirname);
 use Time::Local;
 use IO::Socket;
 use IO::Pipe;
-use POSIX qw(strftime dup2 ENOENT);
+use POSIX qw(strftime tzset dup2 ENOENT);
 use IPC::Open2;
 
 $SIG{'PIPE'}="IGNORE";
 $ENV{'TZ'}="UTC";
+tzset();
 
 our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,@opt_M,$opt_A,$opt_S,$opt_L, $opt_a, $opt_r, $opt_R);
 my (%conv_author_name, %conv_author_email, %conv_author_tz);
@@ -855,8 +856,10 @@ sub commit {
 	}
 
 	$ENV{'TZ'}=$author_tz;
+	tzset();
 	my $commit_date = strftime("%s %z", localtime($date));
 	$ENV{'TZ'}="UTC";
+	tzset();
 	$ENV{GIT_AUTHOR_NAME} = $author_name;
 	$ENV{GIT_AUTHOR_EMAIL} = $author_email;
 	$ENV{GIT_AUTHOR_DATE} = $commit_date;
Previous: Jeff KingNext: Ramsay Jones
Message 5 of 10 in “What's cooking in git.git (Oct 2012, #09; Mon, 29)”
  1. Jeff KingOct 29, 2012
  2. Ramsay JonesNov 1, 2012
  3. Chris RorvickNov 2, 2012
  4. Jeff KingNov 2, 2012
  5. Jeff KingNov 2, 2012
  6. Ramsay JonesNov 2, 2012
  7. Jeff KingNov 4, 2012
  8. Ramsay JonesNov 10, 2012
  9. Jeff KingNov 11, 2012
  10. Ramsay JonesNov 13, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.