{"thread":{"id":"31817","subject":"[PATCH] git-cvsimport: allow author-specific timezones","startedAt":"2012-10-15T00:30:54Z","lastAt":"2012-10-16T15:49:41Z","messageCount":6,"participants":["Chris Rorvick","Junio C Hamano","Jeff King"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"201195","messageId":"1350261054-5171-1-git-send-email-crorvick@cogcap.com","threadId":"31817","inReplyTo":null,"subject":"[PATCH] git-cvsimport: allow author-specific timezones","fromName":"Chris Rorvick","fromEmail":"crorvick@cogcap.com","sentAt":"2012-10-15T00:30:54Z","receivedAt":"2012-10-15T00:30:54Z","isPatch":true,"sender":{"key":"crorvick@cogcap.com","avatar":null},"body":"From: Chris Rorvick <chris@rorvick.com>\n\nCVS patchsets are imported with timestamps having an offset of +0000\n(UTC).  The cvs-authors file is already used to translate the CVS\nusername to full name and email in the corresponding commit.  Extend\nthis file to support an optional timezone for calculating a user-\nspecific timestamp offset.\n\nSigned-off-by: Chris Rorvick <chris@rorvick.com>\n---\n\nThis supercedes the patches submitted for using the local timezone in\ncommits.\n\n Documentation/git-cvsimport.txt    |   5 +-\n git-cvsimport.perl                 |  22 ++-\n t/t9604-cvsimport-timestamps.sh    |  92 +++++++++++++\n t/t9604/cvsroot/.gitattributes     |   1 +\n t/t9604/cvsroot/CVSROOT/.gitignore |   2 +\n t/t9604/cvsroot/module/a,v         | 265 +++++++++++++++++++++++++++++++++++++\n 6 files changed, 381 insertions(+), 6 deletions(-)\n create mode 100775 t/t9604-cvsimport-timestamps.sh\n create mode 100664 t/t9604/cvsroot/.gitattributes\n create mode 100664 t/t9604/cvsroot/CVSROOT/.gitignore\n create mode 100664 t/t9604/cvsroot/module/a,v\n\ndiff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt\nindex 6695ab3..35dc636 100644\n--- a/Documentation/git-cvsimport.txt\n+++ b/Documentation/git-cvsimport.txt\n@@ -141,13 +141,14 @@ This option can be used several times to provide several detection regexes.\n +\n ---------\n \texon=Andreas Ericsson <ae@op5.se>\n-\tspawn=Simon Pawn <spawn@frog-pond.org>\n+\tspawn=Simon Pawn <spawn@frog-pond.org> America/Chicago\n \n ---------\n +\n 'git cvsimport' will make it appear as those authors had\n their GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL set properly\n-all along.\n+all along.  If a timezone is specified, GIT_AUTHOR_DATE will\n+have the corresponding offset applied.\n +\n For convenience, this data is saved to `$GIT_DIR/cvs-authors`\n each time the '-A' option is provided and read from that same\ndiff --git a/git-cvsimport.perl b/git-cvsimport.perl\nindex 8032f23..ceb119d 100755\n--- a/git-cvsimport.perl\n+++ b/git-cvsimport.perl\n@@ -31,7 +31,7 @@ $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-my (%conv_author_name, %conv_author_email);\n+my (%conv_author_name, %conv_author_email, %conv_author_tz);\n \n sub usage(;$) {\n \tmy $msg = shift;\n@@ -59,6 +59,14 @@ sub read_author_info($) {\n \t\t\t$conv_author_name{$user} = $2;\n \t\t\t$conv_author_email{$user} = $3;\n \t\t}\n+\t\t# or with an optional timezone:\n+\t\t#   spawn=Simon Pawn <spawn@frog-pond.org> America/Chicago\n+\t\telsif (m/^(\\S+?)\\s*=\\s*(.+?)\\s*<(.+)>\\s*(\\S+?)\\s*$/) {\n+\t\t\t$user = $1;\n+\t\t\t$conv_author_name{$user} = $2;\n+\t\t\t$conv_author_email{$user} = $3;\n+\t\t\t$conv_author_tz{$user} = $4;\n+\t\t}\n \t\t# However, we also read from CVSROOT/users format\n \t\t# to ease migration.\n \t\telsif (/^(\\w+):(['\"]?)(.+?)\\2\\s*$/) {\n@@ -84,7 +92,9 @@ sub write_author_info($) {\n \t  die(\"Failed to open $file for writing: $!\");\n \n \tforeach (keys %conv_author_name) {\n-\t\tprint $f \"$_=$conv_author_name{$_} <$conv_author_email{$_}>\\n\";\n+\t\tprint $f \"$_=$conv_author_name{$_} <$conv_author_email{$_}>\";\n+\t\tprint $f \" $conv_author_tz{$_}\" if ($conv_author_tz{$_});\n+\t\tprint $f \"\\n\";\n \t}\n \tclose ($f);\n }\n@@ -795,7 +805,7 @@ sub write_tree () {\n \treturn $tree;\n }\n \n-my ($patchset,$date,$author_name,$author_email,$branch,$ancestor,$tag,$logmsg);\n+my ($patchset,$date,$author_name,$author_email,$author_tz,$branch,$ancestor,$tag,$logmsg);\n my (@old,@new,@skipped,%ignorebranch,@commit_revisions);\n \n # commits that cvsps cannot place anywhere...\n@@ -844,7 +854,9 @@ sub commit {\n \t\t}\n \t}\n \n-\tmy $commit_date = strftime(\"+0000 %Y-%m-%d %H:%M:%S\",gmtime($date));\n+\t$ENV{'TZ'}=$author_tz;\n+\tmy $commit_date = strftime(\"%s %z\", localtime($date));\n+\t$ENV{'TZ'}=\"UTC\";\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@@ -945,12 +957,14 @@ while (<CVS>) {\n \t\t}\n \t\t$state=3;\n \t} elsif ($state == 3 and s/^Author:\\s+//) {\n+\t\t$author_tz = \"UTC\";\n \t\ts/\\s+$//;\n \t\tif (/^(.*?)\\s+<(.*)>/) {\n \t\t    ($author_name, $author_email) = ($1, $2);\n \t\t} elsif ($conv_author_name{$_}) {\n \t\t\t$author_name = $conv_author_name{$_};\n \t\t\t$author_email = $conv_author_email{$_};\n+\t\t\t$author_tz = $conv_author_tz{$_} if ($conv_author_tz{$_});\n \t\t} else {\n \t\t    $author_name = $author_email = $_;\n \t\t}\ndiff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh\nnew file mode 100644\nindex 0000000..fb7459c\n--- /dev/null\n+++ b/t/t9604-cvsimport-timestamps.sh\n@@ -0,0 +1,92 @@\n+#!/bin/sh\n+\n+test_description='git cvsimport timestamps'\n+. ./lib-cvs.sh\n+\n+setup_cvs_test_repository t9604\n+\n+test_expect_success 'check timestamps are UTC (TZ=America/Chicago)' '\n+\n+    TZ=America/Chicago git cvsimport -p\"-x\" -C module-1 module &&\n+    git cvsimport -p\"-x\" -C module-1 module &&\n+    (cd module-1 &&\n+        git log --pretty=\"format:%s %ai\" -- >../actual-1 &&\n+        echo \"\" >>../actual-1\n+    ) &&\n+    echo \"Rev 16 2011-11-06 07:00:01 +0000\n+Rev 15 2011-11-06 06:59:59 +0000\n+Rev 14 2011-03-13 08:00:01 +0000\n+Rev 13 2011-03-13 07:59:59 +0000\n+Rev 12 2010-12-01 00:00:00 +0000\n+Rev 11 2010-11-01 00:00:00 +0000\n+Rev 10 2010-10-01 00:00:00 +0000\n+Rev  9 2010-09-01 00:00:00 +0000\n+Rev  8 2010-08-01 00:00:00 +0000\n+Rev  7 2010-07-01 00:00:00 +0000\n+Rev  6 2010-06-01 00:00:00 +0000\n+Rev  5 2010-05-01 00:00:00 +0000\n+Rev  4 2010-04-01 00:00:00 +0000\n+Rev  3 2010-03-01 00:00:00 +0000\n+Rev  2 2010-02-01 00:00:00 +0000\n+Rev  1 2010-01-01 00:00:00 +0000\" >expect-1 &&\n+    test_cmp actual-1 expect-1\n+'\n+\n+test_expect_success 'check timestamps are UTC (TZ=Australia/Sydney)' '\n+\n+    TZ=America/Chicago git cvsimport -p\"-x\" -C module-2 module &&\n+    git cvsimport -p\"-x\" -C module-2 module &&\n+    (cd module-2 &&\n+        git log --pretty=\"format:%s %ai\" -- >../actual-2 &&\n+        echo \"\" >>../actual-2\n+    ) &&\n+    echo \"Rev 16 2011-11-06 07:00:01 +0000\n+Rev 15 2011-11-06 06:59:59 +0000\n+Rev 14 2011-03-13 08:00:01 +0000\n+Rev 13 2011-03-13 07:59:59 +0000\n+Rev 12 2010-12-01 00:00:00 +0000\n+Rev 11 2010-11-01 00:00:00 +0000\n+Rev 10 2010-10-01 00:00:00 +0000\n+Rev  9 2010-09-01 00:00:00 +0000\n+Rev  8 2010-08-01 00:00:00 +0000\n+Rev  7 2010-07-01 00:00:00 +0000\n+Rev  6 2010-06-01 00:00:00 +0000\n+Rev  5 2010-05-01 00:00:00 +0000\n+Rev  4 2010-04-01 00:00:00 +0000\n+Rev  3 2010-03-01 00:00:00 +0000\n+Rev  2 2010-02-01 00:00:00 +0000\n+Rev  1 2010-01-01 00:00:00 +0000\" >expect-2 &&\n+    test_cmp actual-2 expect-2\n+'\n+\n+test_expect_success 'check timestamps with author-specific timezones' '\n+\n+    echo \"user1=User One <user1@domain.org>\n+user2=User Two <user2@domain.org> America/Chicago\n+user3=User Three <user3@domain.org> Australia/Sydney\n+user4=User Four <user4@domain.org> Asia/Shanghai\" >cvs-authors &&\n+    git cvsimport -p\"-x\" -A cvs-authors -C module-3 module &&\n+    (cd module-3 &&\n+        git log --pretty=\"format:%s %ai\" -- >../actual-3 &&\n+        echo \"\" >>../actual-3\n+    ) &&\n+    echo \"Rev 16 2011-11-06 01:00:01 -0600\n+Rev 15 2011-11-06 01:59:59 -0500\n+Rev 14 2011-03-13 03:00:01 -0500\n+Rev 13 2011-03-13 01:59:59 -0600\n+Rev 12 2010-12-01 08:00:00 +0800\n+Rev 11 2010-11-01 11:00:00 +1100\n+Rev 10 2010-09-30 19:00:00 -0500\n+Rev  9 2010-09-01 00:00:00 +0000\n+Rev  8 2010-08-01 08:00:00 +0800\n+Rev  7 2010-07-01 10:00:00 +1000\n+Rev  6 2010-05-31 19:00:00 -0500\n+Rev  5 2010-05-01 00:00:00 +0000\n+Rev  4 2010-04-01 08:00:00 +0800\n+Rev  3 2010-03-01 11:00:00 +1100\n+Rev  2 2010-01-31 18:00:00 -0600\n+Rev  1 2010-01-01 00:00:00 +0000\" >expect-3 &&\n+    test_cmp actual-3 expect-3\n+'\n+\n+test_done\ndiff --git a/t/t9604/cvsroot/.gitattributes b/t/t9604/cvsroot/.gitattributes\nnew file mode 100644\nindex 0000000..562b12e\n--- /dev/null\n+++ b/t/t9604/cvsroot/.gitattributes\n@@ -0,0 +1 @@\n+* -whitespace\ndiff --git a/t/t9604/cvsroot/CVSROOT/.gitignore b/t/t9604/cvsroot/CVSROOT/.gitignore\nnew file mode 100644\nindex 0000000..3bb9b34\n--- /dev/null\n+++ b/t/t9604/cvsroot/CVSROOT/.gitignore\n@@ -0,0 +1,2 @@\n+history\n+val-tags\ndiff --git a/t/t9604/cvsroot/module/a,v b/t/t9604/cvsroot/module/a,v\nnew file mode 100644\nindex 0000000..7165de7\n--- /dev/null\n+++ b/t/t9604/cvsroot/module/a,v\n@@ -0,0 +1,265 @@\n+head\t1.16;\n+access;\n+symbols;\n+locks; strict;\n+comment\t@# @;\n+\n+\n+1.16\n+date\t2011.11.06.07.00.01;\tauthor user2;\tstate Exp;\n+branches;\n+next\t1.15;\n+\n+1.15\n+date\t2011.11.06.06.59.59;\tauthor user2;\tstate Exp;\n+branches;\n+next\t1.14;\n+\n+1.14\n+date\t2011.03.13.08.00.01;\tauthor user2;\tstate Exp;\n+branches;\n+next\t1.13;\n+\n+1.13\n+date\t2011.03.13.07.59.59;\tauthor user2;\tstate Exp;\n+branches;\n+next\t1.12;\n+\n+1.12\n+date\t2010.12.01.00.00.00;\tauthor user4;\tstate Exp;\n+branches;\n+next\t1.11;\n+\n+1.11\n+date\t2010.11.01.00.00.00;\tauthor user3;\tstate Exp;\n+branches;\n+next\t1.10;\n+\n+1.10\n+date\t2010.10.01.00.00.00;\tauthor user2;\tstate Exp;\n+branches;\n+next\t1.9;\n+\n+1.9\n+date\t2010.09.01.00.00.00;\tauthor user1;\tstate Exp;\n+branches;\n+next\t1.8;\n+\n+1.8\n+date\t2010.08.01.00.00.00;\tauthor user4;\tstate Exp;\n+branches;\n+next\t1.7;\n+\n+1.7\n+date\t2010.07.01.00.00.00;\tauthor user3;\tstate Exp;\n+branches;\n+next\t1.6;\n+\n+1.6\n+date\t2010.06.01.00.00.00;\tauthor user2;\tstate Exp;\n+branches;\n+next\t1.5;\n+\n+1.5\n+date\t2010.05.01.00.00.00;\tauthor user1;\tstate Exp;\n+branches;\n+next\t1.4;\n+\n+1.4\n+date\t2010.04.01.00.00.00;\tauthor user4;\tstate Exp;\n+branches;\n+next\t1.3;\n+\n+1.3\n+date\t2010.03.01.00.00.00;\tauthor user3;\tstate Exp;\n+branches;\n+next\t1.2;\n+\n+1.2\n+date\t2010.02.01.00.00.00;\tauthor user2;\tstate Exp;\n+branches;\n+next\t1.1;\n+\n+1.1\n+date\t2010.01.01.00.00.00;\tauthor user1;\tstate Exp;\n+branches;\n+next\t;\n+\n+\n+desc\n+@@\n+\n+\n+1.16\n+log\n+@Rev 16\n+@\n+text\n+@Rev 16\n+@\n+\n+\n+1.15\n+log\n+@Rev 15\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 15\n+@\n+\n+\n+1.14\n+log\n+@Rev 14\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 14\n+@\n+\n+\n+1.13\n+log\n+@Rev 13\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 13\n+@\n+\n+\n+1.12\n+log\n+@Rev 12\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 12\n+@\n+\n+\n+1.11\n+log\n+@Rev 11\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 11\n+@\n+\n+\n+1.10\n+log\n+@Rev 10\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 10\n+@\n+\n+\n+1.9\n+log\n+@Rev  9\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 9\n+@\n+\n+\n+1.8\n+log\n+@Rev  8\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 8\n+@\n+\n+\n+1.7\n+log\n+@Rev  7\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 7\n+@\n+\n+\n+1.6\n+log\n+@Rev  6\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 6\n+@\n+\n+\n+1.5\n+log\n+@Rev  5\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 5\n+@\n+\n+\n+1.4\n+log\n+@Rev  4\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 4\n+@\n+\n+\n+1.3\n+log\n+@Rev  3\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 3\n+@\n+\n+\n+1.2\n+log\n+@Rev  2\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 2\n+@\n+\n+\n+1.1\n+log\n+@Rev  1\n+@\n+text\n+@d1 1\n+a1 1\n+Rev 1\n+@\n+\n-- \n1.8.0.rc1.20.gdb5c9b7.dirty\n"},{"id":"201273","messageId":"7vpq4jws4d.fsf@alter.siamese.dyndns.org","threadId":"31817","inReplyTo":"1350261054-5171-1-git-send-email-crorvick@cogcap.com","subject":"Re: [PATCH] git-cvsimport: allow author-specific timezones","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-15T17:40:50Z","receivedAt":"2012-10-15T17:40:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Rorvick <crorvick@cogcap.com> writes:\n\n> From: Chris Rorvick <chris@rorvick.com>\n>\n> CVS patchsets are imported with timestamps having an offset of +0000\n> (UTC).  The cvs-authors file is already used to translate the CVS\n> username to full name and email in the corresponding commit.  Extend\n> this file to support an optional timezone for calculating a user-\n> specific timestamp offset.\n>\n> Signed-off-by: Chris Rorvick <chris@rorvick.com>\n> ---\n>\n> This supercedes the patches submitted for using the local timezone in\n> commits.\n>\n>  Documentation/git-cvsimport.txt    |   5 +-\n>  git-cvsimport.perl                 |  22 ++-\n>  t/t9604-cvsimport-timestamps.sh    |  92 +++++++++++++\n>  t/t9604/cvsroot/.gitattributes     |   1 +\n>  t/t9604/cvsroot/CVSROOT/.gitignore |   2 +\n>  t/t9604/cvsroot/module/a,v         | 265 +++++++++++++++++++++++++++++++++++++\n>  6 files changed, 381 insertions(+), 6 deletions(-)\n>  create mode 100775 t/t9604-cvsimport-timestamps.sh\n\nOK, a new test script has its executable bit set (correct).\n\n>  create mode 100664 t/t9604/cvsroot/.gitattributes\n>  create mode 100664 t/t9604/cvsroot/CVSROOT/.gitignore\n>  create mode 100664 t/t9604/cvsroot/module/a,v\n>\n> diff --git a/Documentation/git-cvsimport.txt b/Documentation/git-cvsimport.txt\n> index 6695ab3..35dc636 100644\n> --- a/Documentation/git-cvsimport.txt\n> +++ b/Documentation/git-cvsimport.txt\n> @@ -141,13 +141,14 @@ This option can be used several times to provide several detection regexes.\n>  +\n>  ---------\n>  \texon=Andreas Ericsson <ae@op5.se>\n> -\tspawn=Simon Pawn <spawn@frog-pond.org>\n> +\tspawn=Simon Pawn <spawn@frog-pond.org> America/Chicago\n>  \n>  ---------\n>  +\n>  'git cvsimport' will make it appear as those authors had\n>  their GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL set properly\n> -all along.\n> +all along.  If a timezone is specified, GIT_AUTHOR_DATE will\n> +have the corresponding offset applied.\n\nThe description above the context reads:\n\n    -A <author-conv-file>::\n            CVS by default uses the Unix username when writing its\n            commit logs. Using this option and an author-conv-file\n            in this format\n\nwhich probably need to be updated to describe what \"this format\" is\na bit better.\n\n\t... an author-conv-file that maps the name recorded in CVS\n\tto author name, author e-mail and an optional timezone for\n\tthe author\n\nor something.\n\n>  For convenience, this data is saved to `$GIT_DIR/cvs-authors`\n>  each time the '-A' option is provided and read from that same\n\n> @@ -844,7 +854,9 @@ sub commit {\n>  \t\t}\n>  \t}\n>  \n> -\tmy $commit_date = strftime(\"+0000 %Y-%m-%d %H:%M:%S\",gmtime($date));\n> +\t$ENV{'TZ'}=$author_tz;\n> +\tmy $commit_date = strftime(\"%s %z\", localtime($date));\n\nWith this, because it updates $commit_date, the specified timezone\napplies to both AUTHOR and COMMITTER dates (which is correct---I am\njust pointing it out).\n\n> diff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh\n> new file mode 100644\n\nHuh?  What happened to the executable bit we saw earlier?\n\n> index 0000000..fb7459c\n> --- /dev/null\n> +++ b/t/t9604-cvsimport-timestamps.sh\n> @@ -0,0 +1,92 @@\n> +#!/bin/sh\n> +\n> +test_description='git cvsimport timestamps'\n> +. ./lib-cvs.sh\n> +\n> +setup_cvs_test_repository t9604\n> +\n> +test_expect_success 'check timestamps are UTC (TZ=America/Chicago)' '\n> +\n> +    TZ=America/Chicago git cvsimport -p\"-x\" -C module-1 module &&\n> +    git cvsimport -p\"-x\" -C module-1 module &&\n> +    (cd module-1 &&\n> +        git log --pretty=\"format:%s %ai\" -- >../actual-1 &&\n> +        echo \"\" >>../actual-1\n> +    ) &&\n> +    echo \"Rev 16 2011-11-06 07:00:01 +0000\n> +Rev 15 2011-11-06 06:59:59 +0000\n> +Rev 14 2011-03-13 08:00:01 +0000\n> +Rev 13 2011-03-13 07:59:59 +0000\n> +Rev 12 2010-12-01 00:00:00 +0000\n> +Rev 11 2010-11-01 00:00:00 +0000\n> +Rev 10 2010-10-01 00:00:00 +0000\n> +Rev  9 2010-09-01 00:00:00 +0000\n> +Rev  8 2010-08-01 00:00:00 +0000\n> +Rev  7 2010-07-01 00:00:00 +0000\n> +Rev  6 2010-06-01 00:00:00 +0000\n> +Rev  5 2010-05-01 00:00:00 +0000\n> +Rev  4 2010-04-01 00:00:00 +0000\n> +Rev  3 2010-03-01 00:00:00 +0000\n> +Rev  2 2010-02-01 00:00:00 +0000\n> +Rev  1 2010-01-01 00:00:00 +0000\" >expect-1 &&\n> +    test_cmp actual-1 expect-1\n> +'\n\nA handful of issues.\n\n    - (style) Please use one tab for one level of indent;\n    - (style) Learn to use <<-\\HERE document to make list easier to\n      read; \n    - You shouldn't have to choose --pretty=format which places LF\n      in between records and add another LF yourself.  Instead, you\n      can use --pretty=tformat that uses LF as record terminator, or\n      its short-hand form --format=\"...\";\n    - I am not sure what you are gaining out of the trailing \"--\".\n\nSee below for a suggested way to lay this out better.\n\n> +test_expect_success 'check timestamps are UTC (TZ=Australia/Sydney)' '\n> +\n> +    TZ=America/Chicago git cvsimport -p\"-x\" -C module-2 module &&\n\nThis look identical to the first one, but even with a trivial change\nto use Australia/Sydney instead of Chicago, I am not sure what the\ntest buys us.\n\n> +test_expect_success 'check timestamps with author-specific timezones' '\n> +\n> +    echo \"user1=User One <user1@domain.org>\n> +user2=User Two <user2@domain.org> America/Chicago\n> +user3=User Three <user3@domain.org> Australia/Sydney\n> +user4=User Four <user4@domain.org> Asia/Shanghai\" >cvs-authors &&\n> +    git cvsimport -p\"-x\" -A cvs-authors -C module-3 module &&\n> +    (cd module-3 &&\n> +        git log --pretty=\"format:%s %ai\" -- >../actual-3 &&\n> +        echo \"\" >>../actual-3\n> +    ) &&\n> +    echo \"Rev 16 2011-11-06 01:00:01 -0600\n> +Rev 15 2011-11-06 01:59:59 -0500\n> +Rev 14 2011-03-13 03:00:01 -0500\n> +Rev 13 2011-03-13 01:59:59 -0600\n> +...\n> +Rev  2 2010-01-31 18:00:00 -0600\n> +Rev  1 2010-01-01 00:00:00 +0000\" >expect-3 &&\n> +    test_cmp actual-3 expect-3\n> +'\n\nIn addition to the same comments as above, this one would benefit\nhaving %an in its output to illustrate that the code is handling\nlocations with daylight saving time correctly.  It would make it\nstand out that Rev 16 is done during the standard time while Rev 15\nis done during the DST.  It would look more like this (with the\nstyle fix):\n\ntest_expect_success 'check timestamps with author-specific timezones' '\n\tcat >cvs-authors <<-EOF &&\n\tuser1=User One <user1@domain.org>\n\tuser2=User Two <user2@domain.org> America/Chicago\n\tuser3=User Three <user3@domain.org> Australia/Sydney\n\tuser4=User Four <user4@domain.org> Asia/Shanghai\n\tEOF\n\tgit cvsimport -p\"-x\" -A cvs-authors -C module-3 module &&\n\t(\n\t\tcd module-3 &&\n\t\tgit log --format=\"%s %ai %an\"\n\t) >actual-3 &&\n\tcat >expect-3 <<-\\EOF\n\tRev 16 2011-11-06 01:00:01 -0600 User Two\n\tRev 15 2011-11-06 01:59:59 -0500 User Two\n\tRev 14 2011-03-13 03:00:01 -0500 User Two\n\t...\n\tRev  2 2010-01-31 18:00:00 -0600 User Two\n\tRev  1 2010-01-01 00:00:00 +0000 User One\n\tEOF\n\ttest_cmp actual-3 expect-3\n'\n"},{"id":"201305","messageId":"CAEUsAPY3fJJSzX8WPRVQPNOF0A0KAMCXr1u0ZzjEFvXDF=v6JA@mail.gmail.com","threadId":"31817","inReplyTo":"7vpq4jws4d.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-cvsimport: allow author-specific timezones","fromName":"Chris Rorvick","fromEmail":"chris@rorvick.com","sentAt":"2012-10-16T02:26:05Z","receivedAt":"2012-10-16T02:26:05Z","isPatch":true,"sender":{"key":"chris@rorvick.com","avatar":"https://avatars.githubusercontent.com/u/824726?v=4"},"body":"On Mon, Oct 15, 2012 at 12:40 PM, Junio C Hamano <gitster@pobox.com> wrote:\n>> diff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh\n>> new file mode 100644\n>\n> Huh?  What happened to the executable bit we saw earlier?\n\nUh, yeah.  Sorry about that.\n\n>> +test_expect_success 'check timestamps are UTC (TZ=Australia/Sydney)' '\n>> +\n>> +    TZ=America/Chicago git cvsimport -p\"-x\" -C module-2 module &&\n>\n> This look identical to the first one, but even with a trivial change\n> to use Australia/Sydney instead of Chicago, I am not sure what the\n> test buys us.\n\nThis is left over from when I was using the script to test the \"use\nlocal timezone\" option.  It was useless there, too, but did provide\nsome symmetry.  :-)  Removed.\n\nIt occurred to me that the success of the unit test depends on the\nhost platform's zoneinfo database.  I think this problem is inherent\nwith this functionality.  Should the unit test attempt to detect\nsupport for the used timezones and short circuit if this fails?  Not\nsure exactly how I'd do this, but wondering if it's worth thinking\nabout.\n\nI've made all the other recommended changes, I'll resubmit shortly.\n\nThanks,\n\nChris\n"},{"id":"201308","messageId":"7v4nlvulc2.fsf@alter.siamese.dyndns.org","threadId":"31817","inReplyTo":"CAEUsAPY3fJJSzX8WPRVQPNOF0A0KAMCXr1u0ZzjEFvXDF=v6JA@mail.gmail.com","subject":"Re: [PATCH] git-cvsimport: allow author-specific timezones","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-16T03:50:21Z","receivedAt":"2012-10-16T03:50: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> It occurred to me that the success of the unit test depends on the\n> host platform's zoneinfo database.  I think this problem is inherent\n> with this functionality.  Should the unit test attempt to detect\n> support for the used timezones and short circuit if this fails?  Not\n> sure exactly how I'd do this, but wondering if it's worth thinking\n> about.\n\nYeah, that did indeed cross my mind.\n\nYou could say TZ=QST6QDT or something silly like that but that in\nturn has to assume your tzset() is POSIX.1 compliant anyway.\n\nWe should at least protect the tests with prerequiste, perhaps like\nthis.\n\n t/t9604-cvsimport-timestamps.sh | 53 ++++++++++++++++++-----------------------\n 1 file changed, 23 insertions(+), 30 deletions(-)\n\ndiff --git i/t/t9604-cvsimport-timestamps.sh w/t/t9604-cvsimport-timestamps.sh\nindex 6af41b7..f7683da 100755\n--- i/t/t9604-cvsimport-timestamps.sh\n+++ w/t/t9604-cvsimport-timestamps.sh\n@@ -3,9 +3,30 @@\n test_description='git cvsimport timestamps'\n . ./lib-cvs.sh\n \n+# Can your Perl grok these TZ settings correctly?\n+test_lazy_prereq TZNAME '\n+\tperl -e '\\''\n+\t\tuse POSIX qw(strftime);\n+\t\twhile (<STDIN>) {\n+\t\t\tmy ($zone, $time, $expect) = split(q/ /);\n+\t\t\t$ENV{TZ} = $zone;\n+\t\t\tif (strftime(q/%z/, localtime($time)) ne $expect) {\n+\t\t\t\texit(1);\n+\t\t\t}\n+\t\t}\n+\t\texit(0);\n+\t'\\'' <<-\\EOF\n+\tAmerica/Chicago 1345174000 -0500\n+\tAmerica/Chicago 1329622000 -0600\n+\tAustralia/Sydney 1345174000 +1000\n+\tAustralia/Sydney 1329622000 +1100\n+\tAsia/Shanghai 1329622000 +0800\n+\tEOF\n+'\n+\n setup_cvs_test_repository t9604\n \n-test_expect_success 'check timestamps are UTC (TZ=America/Chicago)' '\n+test_expect_success TZNAME 'check timestamps are UTC (TZ=America/Chicago)' '\n \tTZ=America/Chicago git cvsimport -p\"-x\" -C module-1 module &&\n \tgit cvsimport -p\"-x\" -C module-1 module &&\n \t(\n"},{"id":"201313","messageId":"20121016063152.GB22941@sigill.intra.peff.net","threadId":"31817","inReplyTo":"7v4nlvulc2.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] git-cvsimport: allow author-specific timezones","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-10-16T06:31:52Z","receivedAt":"2012-10-16T06:31:52Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Oct 15, 2012 at 08:50:21PM -0700, Junio C Hamano wrote:\n\n> Chris Rorvick <chris@rorvick.com> writes:\n> \n> > It occurred to me that the success of the unit test depends on the\n> > host platform's zoneinfo database.  I think this problem is inherent\n> > with this functionality.  Should the unit test attempt to detect\n> > support for the used timezones and short circuit if this fails?  Not\n> > sure exactly how I'd do this, but wondering if it's worth thinking\n> > about.\n> \n> Yeah, that did indeed cross my mind.\n> \n> You could say TZ=QST6QDT or something silly like that but that in\n> turn has to assume your tzset() is POSIX.1 compliant anyway.\n\nWe use EST5 in t0006 (it was originally just \"EST\" but IRIX complained).\nIt's been in the test suite for two years without a problem, so it may\nbe simple and safe enough to just use that.\n\n-Peff\n"},{"id":"201346","messageId":"7vzk3mto16.fsf@alter.siamese.dyndns.org","threadId":"31817","inReplyTo":"20121016063152.GB22941@sigill.intra.peff.net","subject":"Re: [PATCH] git-cvsimport: allow author-specific timezones","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-10-16T15:49:41Z","receivedAt":"2012-10-16T15:49:41Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Mon, Oct 15, 2012 at 08:50:21PM -0700, Junio C Hamano wrote:\n>\n>> Chris Rorvick <chris@rorvick.com> writes:\n>> \n>> > It occurred to me that the success of the unit test depends on the\n>> > host platform's zoneinfo database.  I think this problem is inherent\n>> > with this functionality.  Should the unit test attempt to detect\n>> > support for the used timezones and short circuit if this fails?  Not\n>> > sure exactly how I'd do this, but wondering if it's worth thinking\n>> > about.\n>> \n>> Yeah, that did indeed cross my mind.\n>> \n>> You could say TZ=QST6QDT or something silly like that but that in\n>> turn has to assume your tzset() is POSIX.1 compliant anyway.\n>\n> We use EST5 in t0006 (it was originally just \"EST\" but IRIX complained).\n> It's been in the test suite for two years without a problem, so it may\n> be simple and safe enough to just use that.\n\nSounds good.  As the test vector for the last piece seems to be\ndesigned to show that the dst conversion correctly works, we would\nneed to use STD$nDST formats, though.\n"}]}