{"thread":{"id":"31792","subject":"[PATCH] git-cvsimport: support local timezone","startedAt":"2012-10-11T20:48:17Z","lastAt":"2012-10-12T07:57:54Z","messageCount":4,"participants":["Chris Rorvick","Michael Haggerty","Christopher Rorvick"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"201024","messageId":"1349988497-6158-1-git-send-email-chris@rorvick.com","threadId":"31792","inReplyTo":null,"subject":"[PATCH] git-cvsimport: support local timezone","fromName":"Chris Rorvick","fromEmail":"chris@rorvick.com","sentAt":"2012-10-11T20:48:17Z","receivedAt":"2012-10-11T20:48:17Z","isPatch":true,"sender":{"key":"chris@rorvick.com","avatar":"https://avatars.githubusercontent.com/u/824726?v=4"},"body":"CVS patches are unconditionally imported with a UTC timezone.  Allow\nthe local timezone by adding -l to the command line or specifying\ncvsimport.l in the config.\n\nThis could be made the default behavior, as setting TZ=UTC in the\nenvironment before doing the import is equivalent to the current\nbehavior.  But since a new default may be an unwelcome surprise to\nsome, make this new behavior available os an option.\n\nSigned-off-by: Chris Rorvick <chris@rorvick.com>\n---\n\nI have tested this with various TZ values (including \"UTC\") and confirmed\nthat the <fuzz> + 5min timeout is observed correctly in each case.\n\nChris Rorvick\n\n Documentation/git-cvsimport.txt |   11 ++++++++---\n git-cvsimport.perl              |   13 +++++++------\n 2 files changed, 15 insertions(+), 9 deletions(-)\n\ndiff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt\nindex 6695ab3..41cd289 100644\n--- a/Documentation/git-cvsimport.txt\n+++ b/Documentation/git-cvsimport.txt\n@@ -11,9 +11,9 @@ SYNOPSIS\n [verse]\n 'git cvsimport' [-o <branch-for-HEAD>] [-h] [-v] [-d <CVSROOT>]\n \t      [-A <author-conv-file>] [-p <options-for-cvsps>] [-P <file>]\n-\t      [-C <git_repository>] [-z <fuzz>] [-i] [-k] [-u] [-s <subst>]\n-\t      [-a] [-m] [-M <regex>] [-S <regex>] [-L <commitlimit>]\n-\t      [-r <remote>] [-R] [<CVS_module>]\n+\t      [-C <git_repository>] [-z <fuzz>] [-i] [-k] [-l] [-u]\n+\t      [-s <subst>] [-a] [-m] [-M <regex>] [-S <regex>]\n+\t      [-L <commitlimit>] [-r <remote>] [-R] [<CVS_module>]\n \n \n DESCRIPTION\n@@ -89,6 +89,11 @@ the old cvs2git tool.\n \tto avoid noisy changesets. Highly recommended, but off by default\n \tto preserve compatibility with early imported trees.\n \n+-l::\n+\tApply the local timezone to timestamps.  The `TZ` environment\n+\tvariable can be used to override the default, possibly useful\n+\tif you are importing a non-local repository.\n+\n -u::\n \tConvert underscores in tag and branch names to dots.\n \ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8032f23..927d75c 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -28,9 +28,8 @@ use POSIX qw(strftime dup2 ENOENT);\n use IPC::Open2;\n \n $SIG{'PIPE'}=\"IGNORE\";\n-$ENV{'TZ'}=\"UTC\";\n \n-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);\n+our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_l,$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);\n my (%conv_author_name, %conv_author_email);\n \n sub usage(;$) {\n@@ -40,7 +39,7 @@ sub usage(;$) {\n Usage: git cvsimport     # fetch/update GIT from CVS\n        [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file]\n        [-p opts-for-cvsps] [-P file] [-C GIT_repository] [-z fuzz] [-i] [-k]\n-       [-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L commitlimit]\n+       [-l] [-u] [-s subst] [-a] [-m] [-M regex] [-S regex] [-L commitlimit]\n        [-r remote] [-R] [CVS_module]\n END\n \texit(1);\n@@ -128,7 +127,7 @@ sub read_repo_config {\n \t}\n }\n \n-my $opts = \"haivmkuo:d:p:r:C:z:s:M:P:A:S:L:R\";\n+my $opts = \"haivmkulo:d:p:r:C:z:s:M:P:A:S:L:R\";\n read_repo_config($opts);\n Getopt::Long::Configure( 'no_ignore_case', 'bundling' );\n \n@@ -138,6 +137,8 @@ GetOptions( map { s/:/=s/; /M/ ? \"$_\\@\" : $_ } split( /(?!:)/, $opts ) )\n     or usage();\n usage if $opt_h;\n \n+$ENV{'TZ'}=\"UTC\" unless $opt_l;\n+\n if (@ARGV == 0) {\n \t\tchomp(my $module = `git config --get cvsimport.module`);\n \t\tpush(@ARGV, $module) if $? == 0;\n@@ -582,7 +583,7 @@ sub pdate($) {\n \tm#(\\d{2,4})/(\\d\\d)/(\\d\\d)\\s(\\d\\d):(\\d\\d)(?::(\\d\\d))?#\n \t\tor die \"Unparseable date: $d\\n\";\n \tmy $y=$1; $y-=1900 if $y>1900;\n-\treturn timegm($6||0,$5,$4,$3,$2-1,$y);\n+\treturn timelocal($6||0,$5,$4,$3,$2-1,$y);\n }\n \n sub pmode($) {\n@@ -844,7 +845,7 @@ sub commit {\n \t\t}\n \t}\n \n-\tmy $commit_date = strftime(\"+0000 %Y-%m-%d %H:%M:%S\",gmtime($date));\n+\tmy $commit_date = strftime(\"%z %Y-%m-%d %H:%M:%S\",localtime($date));\n \t$ENV{GIT_AUTHOR_NAME} = $author_name;\n \t$ENV{GIT_AUTHOR_EMAIL} = $author_email;\n \t$ENV{GIT_AUTHOR_DATE} = $commit_date;\n-- \n1.7.1\n"},{"id":"201028","messageId":"50774BA9.40609@alum.mit.edu","threadId":"31792","inReplyTo":"1349988497-6158-1-git-send-email-chris@rorvick.com","subject":"Re: [PATCH] git-cvsimport: support local timezone","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-10-11T22:43:53Z","receivedAt":"2012-10-11T22:43:53Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 10/11/2012 10:48 PM, Chris Rorvick wrote:\n> CVS patches are unconditionally imported with a UTC timezone.  Allow\n> the local timezone by adding -l to the command line or specifying\n> cvsimport.l in the config.\n> \n> This could be made the default behavior, as setting TZ=UTC in the\n> environment before doing the import is equivalent to the current\n> behavior.  But since a new default may be an unwelcome surprise to\n> some, make this new behavior available os an option.\n\nAccording to rcsfile(7), all times in RCS/CVS files are recorded in UTC.\n So why do you need this feature?\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"},{"id":"201033","messageId":"CAEUsAPYaYGDHWkixf9U27_Hsa7QqCWq3csKtBH7MrjnMD6kKJQ@mail.gmail.com","threadId":"31792","inReplyTo":"50774BA9.40609@alum.mit.edu","subject":"Re: [PATCH] git-cvsimport: support local timezone","fromName":"Christopher Rorvick","fromEmail":"chris@rorvick.com","sentAt":"2012-10-12T00:14:44Z","receivedAt":"2012-10-12T00:14:44Z","isPatch":true,"sender":{"key":"chris@rorvick.com","avatar":"https://avatars.githubusercontent.com/u/824726?v=4"},"body":"On Thu, Oct 11, 2012 at 5:43 PM, Michael Haggerty <mhagger@alum.mit.edu> wrote:\n> On 10/11/2012 10:48 PM, Chris Rorvick wrote:\n>> CVS patches are unconditionally imported with a UTC timezone.  Allow\n>> the local timezone by adding -l to the command line or specifying\n>> cvsimport.l in the config.\n>>\n>> This could be made the default behavior, as setting TZ=UTC in the\n>> environment before doing the import is equivalent to the current\n>> behavior.  But since a new default may be an unwelcome surprise to\n>> some, make this new behavior available os an option.\n>\n> According to rcsfile(7), all times in RCS/CVS files are recorded in UTC.\n>  So why do you need this feature?\n>\n> Michael\n\nHi Michael,\n\nPrecisely because of this limitation.  RCS files are not as expressive\nas a Git commit so I need a way to fill in the blanks.\n\nThis is analogous to the cvs-authors file.  The RCS files in a CVS\nrepository say the author of my commits is \"crorvick\" but that is\nneither my name nor email.  cvsimport allows me to overcome this\nlimitation by specifying a mapping from author username to full name\nand email.\n\nLikewise, just because the RCS file has a UTC timestamp does not mean\nthe commit originated in Greenwich, UK.  Git includes the timezone\noffset in its timestamps, so it is reasonable to allow me to specify\nwhat is appropriate.\n\nThis is not a big deal for a one-time import as a simple filter-branch\nrun can fix this pretty quickly.  But this feature would be nice when\nrunning cvsimport incrementally.\n\nThanks!\n\nChris Rorvick\n"},{"id":"201049","messageId":"5077CD82.6000405@alum.mit.edu","threadId":"31792","inReplyTo":"CAEUsAPYaYGDHWkixf9U27_Hsa7QqCWq3csKtBH7MrjnMD6kKJQ@mail.gmail.com","subject":"Re: [PATCH] git-cvsimport: support local timezone","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2012-10-12T07:57:54Z","receivedAt":"2012-10-12T07:57:54Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"On 10/12/2012 02:14 AM, Christopher Rorvick wrote:\n> On Thu, Oct 11, 2012 at 5:43 PM, Michael Haggerty <mhagger@alum.mit.edu> wrote:\n>> On 10/11/2012 10:48 PM, Chris Rorvick wrote:\n>>> CVS patches are unconditionally imported with a UTC timezone.  Allow\n>>> the local timezone by adding -l to the command line or specifying\n>>> cvsimport.l in the config.\n>>>\n>>> This could be made the default behavior, as setting TZ=UTC in the\n>>> environment before doing the import is equivalent to the current\n>>> behavior.  But since a new default may be an unwelcome surprise to\n>>> some, make this new behavior available os an option.\n>>\n>> According to rcsfile(7), all times in RCS/CVS files are recorded in UTC.\n>>  So why do you need this feature?\n> \n> [...]\n> Likewise, just because the RCS file has a UTC timestamp does not mean\n> the commit originated in Greenwich, UK.  Git includes the timezone\n> offset in its timestamps, so it is reasonable to allow me to specify\n> what is appropriate.\n\nAhh, OK, I hadn't realized that git stores (UTC time + time zone).  I\nmistakenly thought you wanted to use a time zone to transform CVS-time\nto git-time, i.e., as if the CVS time were recorded in local time.  Your\nactual goal makes sense.\n\n[And it is something I should consider building into cvs2git.]\n\nMichael\n\n-- \nMichael Haggerty\nmhagger@alum.mit.edu\nhttp://softwareswirl.blogspot.com/\n"}]}