{"thread":{"id":"31799","subject":"[PATCH v2 0/2] git-cvsimport: support local timezone","startedAt":"2012-10-13T04:11:53Z","lastAt":"2012-10-14T20:58:48Z","messageCount":5,"participants":["Chris Rorvick","Junio C Hamano","Christopher Rorvick"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"201077","messageId":"cover.1350100320.git.chris@rorvick.com","threadId":"31799","inReplyTo":null,"subject":"[PATCH v2 0/2] git-cvsimport: support local timezone","fromName":"Chris Rorvick","fromEmail":"chris@rorvick.com","sentAt":"2012-10-13T04:11:53Z","receivedAt":"2012-10-13T04:11:53Z","isPatch":true,"sender":{"key":"chris@rorvick.com","avatar":"https://avatars.githubusercontent.com/u/824726?v=4"},"body":"Changes to support local timezone offsets in imported commits.  Modified\ndocumentation to clarify behavior of new -l option.\n\nAlso, I split the original patch into two because using\nlocaltime()/timelocal() does not affect current functionality, but makes\nfor sane results if someone monkeys with the hardcoded TZ environment\nsetting.  Also, the problem solved by the second patch could also be\naddressed by simply removing the hardcoded TZ setting in favor of having\nthe user specify in their environment.  Both of these solutions build on\nthe changes made in the first patch, though.\n\nChris Rorvick (2):\n  git-cvsimport: use localtime for converting timestamps\n  git-cvsimport: allow local timezone for commits\n\n Documentation/git-cvsimport.txt |   13 ++++++++++---\n git-cvsimport.perl              |   13 +++++++------\n 2 files changed, 17 insertions(+), 9 deletions(-)\n"},{"id":"201078","messageId":"35710ee78133792f4c79b0afeb56804d745c1de5.1350100320.git.chris@rorvick.com","threadId":"31799","inReplyTo":"cover.1350100320.git.chris@rorvick.com","subject":"[PATCH v2 1/2] git-cvsimport: use localtime for converting timestamps","fromName":"Chris Rorvick","fromEmail":"chris@rorvick.com","sentAt":"2012-10-13T04:11:54Z","receivedAt":"2012-10-13T04:11:54Z","isPatch":true,"sender":{"key":"chris@rorvick.com","avatar":"https://avatars.githubusercontent.com/u/824726?v=4"},"body":"cvsps formats timestamps for the local timezone in its output.\nUsing timegm() to convert to epoch-relative only works because\ncvsimport overrides TZ to \"UTC\".  Using timelocal() does not change\nthe behavior of the script as is, but it does ensure cvsimport\nbehaves sanely if run with another TZ value.\n\nAlso, use localtime() for generating the commit timestamp instead of\ngmtime().  Again, this has no affect on the script as is since TZ\nis hard-wired to \"UTC\".  But using localtime() would allow someone\nto change the value of TZ with what is likely the desired effect\n(i.e., timestamps are written to the Git commit with local timezone\noffset.)\n\nSigned-off-by: Chris Rorvick <chris@rorvick.com>\n---\n git-cvsimport.perl |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8032f23..2f5da9e 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -582,7 +582,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 +844,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":"201079","messageId":"db5c9b72e08ed9d5522f38098d68126e5d3c7e5a.1350100320.git.chris@rorvick.com","threadId":"31799","inReplyTo":"cover.1350100320.git.chris@rorvick.com","subject":"[PATCH v2 2/2] git-cvsimport: allow local timezone for commits","fromName":"Chris Rorvick","fromEmail":"chris@rorvick.com","sentAt":"2012-10-13T04:11:55Z","receivedAt":"2012-10-13T04:11:55Z","isPatch":true,"sender":{"key":"chris@rorvick.com","avatar":"https://avatars.githubusercontent.com/u/824726?v=4"},"body":"CVS patches are imported with the timezone offset of +0000 (UTC).\nAllow timezone offsets to be calculated from the the local timezone by\nadding -l to the command line or specifying cvsimport.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 as an option.\n\nSigned-off-by: Chris Rorvick <chris@rorvick.com>\n---\n Documentation/git-cvsimport.txt |   13 ++++++++++---\n git-cvsimport.perl              |    9 +++++----\n 2 files changed, 15 insertions(+), 7 deletions(-)\n\ndiff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt\nindex 6695ab3..9059ad1 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,13 @@ 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+\tUse the local timezone for computing the timezone offset of commit\n+\ttimestamps instead of the default of +0000 (UTC).  The `TZ`\n+\tenvironment variable can be used to override the default local\n+\ttimezone, possibly useful if you are importing from a non-local\n+\trepository.\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 2f5da9e..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-- \n1.7.1\n"},{"id":"201145","messageId":"7vfw5hzj16.fsf@alter.siamese.dyndns.org","threadId":"31799","inReplyTo":"db5c9b72e08ed9d5522f38098d68126e5d3c7e5a.1350100320.git.chris@rorvick.com","subject":"Re: [PATCH v2 2/2] git-cvsimport: allow local timezone for commits","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-14T06:04:21Z","receivedAt":"2012-10-14T06:04:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Rorvick <chris@rorvick.com> writes:\n\n> CVS patches are imported with the timezone offset of +0000 (UTC).\n> Allow timezone offsets to be calculated from the the local timezone by\n> adding -l to the command line or specifying cvsimport.l in the config.\n\nA single \"I do not like everybody's timestamp is in GMT, so instead\nuse the local timezone I the importer happen to be in\" sounds more\nlike an uninteresting hack with limited application than a useful\nnew feature.  Even back in CVS days, many projects and repositories\nworth converting to Git were multi-people projects that span across\ntimezones.\n\nI am wondering if it is sufficient to enhance existing cvs-authors\nfile to tie a person to a timezone to add a feature like this in a\nmore sensible manner.  I'd assume that in many multi-person project,\none person, even when travelling, tend to record commits in a single\ntimezone (i.e. his or her home timezone).  Even for a single-person\nproject, adding a single entry ot the file is not too much to ask to\nthe user.  Being able to view his human-readable name and timezone\nwould be good value for the amount of trouble.\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 as an option.\n\nThis, just like use of cvs-authors, will never be the default.\n\nWhen you and somebody else import the same history recorded in the\nsame CVS repository, you would want to see the same resulting\nhistory, and that is even more true when these two people may\nperform their import incrementally.  If you switch the default\nin one version of Git, their histories will diverge at a different\nplace depending on when their sysadmins updated Git.\n\nThe repeatability is why the script does not use the local timezone\nthe importer happens to be in.\n\n\n> Signed-off-by: Chris Rorvick <chris@rorvick.com>\n> ---\n>  Documentation/git-cvsimport.txt |   13 ++++++++++---\n>  git-cvsimport.perl              |    9 +++++----\n>  2 files changed, 15 insertions(+), 7 deletions(-)\n>\n> diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt\n> index 6695ab3..9059ad1 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,13 @@ 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> +\tUse the local timezone for computing the timezone offset of commit\n> +\ttimestamps instead of the default of +0000 (UTC).  The `TZ`\n> +\tenvironment variable can be used to override the default local\n> +\ttimezone, possibly useful if you are importing from a non-local\n> +\trepository.\n> +\n>  -u::\n>  \tConvert underscores in tag and branch names to dots.\n>  \n> diff --git a/git-cvsimport.perl b/git-cvsimport.perl\n> index 2f5da9e..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"},{"id":"201193","messageId":"CAEUsAPYbywPJUje8LGsOMYn_oQ-RFxznjZ1KeAsZL=skiDtG3g@mail.gmail.com","threadId":"31799","inReplyTo":"7vfw5hzj16.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v2 2/2] git-cvsimport: allow local timezone for commits","fromName":"Christopher Rorvick","fromEmail":"chris@rorvick.com","sentAt":"2012-10-14T20:58:48Z","receivedAt":"2012-10-14T20:58:48Z","isPatch":true,"sender":{"key":"chris@rorvick.com","avatar":"https://avatars.githubusercontent.com/u/824726?v=4"},"body":"On Sun, Oct 14, 2012 at 1:04 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Chris Rorvick <chris@rorvick.com> writes:\n>\n>> CVS patches are imported with the timezone offset of +0000 (UTC).\n>> Allow timezone offsets to be calculated from the the local timezone by\n>> adding -l to the command line or specifying cvsimport.l in the config.\n>\n> A single \"I do not like everybody's timestamp is in GMT, so instead\n> use the local timezone I the importer happen to be in\" sounds more\n> like an uninteresting hack with limited application than a useful\n> new feature.  Even back in CVS days, many projects and repositories\n> worth converting to Git were multi-people projects that span across\n> timezones.\n>\n> I am wondering if it is sufficient to enhance existing cvs-authors\n> file to tie a person to a timezone to add a feature like this in a\n> more sensible manner.  I'd assume that in many multi-person project,\n> one person, even when travelling, tend to record commits in a single\n> timezone (i.e. his or her home timezone).  Even for a single-person\n> project, adding a single entry ot the file is not too much to ask to\n> the user.  Being able to view his human-readable name and timezone\n> would be good value for the amount of trouble.\n\nThis sounds pretty straight forward.  It had crossed my mind that\nusing the cvs-authors file like this would be a more general solution,\nbut I thought that what I proposed was at least a step in the right\ndirection.  But since anyone that cares about this is almost certainly\nputting together a cvs-authors file anyway, I agree that being able to\nset an alternate default timezone probably isn't a very useful\naddition.\n\nI'll resubmit when I have something working.\n"}]}