[PATCH v2 1/2] git-cvsimport: use localtime for converting timestamps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



cvsps formats timestamps for the local timezone in its output.
Using timegm() to convert to epoch-relative only works because
cvsimport overrides TZ to "UTC".  Using timelocal() does not change
the behavior of the script as is, but it does ensure cvsimport
behaves sanely if run with another TZ value.

Also, use localtime() for generating the commit timestamp instead of
gmtime().  Again, this has no affect on the script as is since TZ
is hard-wired to "UTC".  But using localtime() would allow someone
to change the value of TZ with what is likely the desired effect
(i.e., timestamps are written to the Git commit with local timezone
offset.)

Signed-off-by: Chris Rorvick <chris@xxxxxxxxxxx>
---
 git-cvsimport.perl |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index 8032f23..2f5da9e 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -582,7 +582,7 @@ sub pdate($) {
 	m#(\d{2,4})/(\d\d)/(\d\d)\s(\d\d):(\d\d)(?::(\d\d))?#
 		or die "Unparseable date: $d\n";
 	my $y=$1; $y-=1900 if $y>1900;
-	return timegm($6||0,$5,$4,$3,$2-1,$y);
+	return timelocal($6||0,$5,$4,$3,$2-1,$y);
 }
 
 sub pmode($) {
@@ -844,7 +844,7 @@ sub commit {
 		}
 	}
 
-	my $commit_date = strftime("+0000 %Y-%m-%d %H:%M:%S",gmtime($date));
+	my $commit_date = strftime("%z %Y-%m-%d %H:%M:%S",localtime($date));
 	$ENV{GIT_AUTHOR_NAME} = $author_name;
 	$ENV{GIT_AUTHOR_EMAIL} = $author_email;
 	$ENV{GIT_AUTHOR_DATE} = $commit_date;
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]