Current-Users archive

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

git and bad timezone handling



In testing bup, I found that git creates bizarre timezone values near
the transition to DST.  The following script creates a git repository
with two commits, and on several NetBSD systems the second commit has a
very strange timezone; git log output is included.

I am curious if this fails anywhere else, and if anyone has any idea
why.  I am unclear on if this is a git bug or a NetBSD bug.

I may have sent something like this a year ago, but I don't remember
clearly, and I just ran across this again.  Apparently the problem also
does not occur on FreeBSD.

----------------------------------------
commit 16b7bfce9a2adb00dc90c7df5da8d695fe4c025a
Author: Greg Troxel <gdt%lexort.com@localhost>
Date:   Sat Apr 8 21:31:44 1922 +38731400

    date 1394330400

commit d7bfc2fe7bf0f7c8c39c3ec17335fe57a578e546
Author: Greg Troxel <gdt%lexort.com@localhost>
Date:   Sat Mar 8 20:59:59 2014 -0500

    date 1394330399
------------------------------------------ 
#!/bin/sh

# This program tests git's handling of --date with timeval arguments
# near the tranasition to DST in March of 2014, in the EST5EDT timezone.
# Somehow, a timezone offset of 44 years is computed.
# The failure has been observed on netbsd-5, netbsd-7, netbsd-8.
# The failure has been observed not to occur on MacOS 10.12.

set -e
set -x

uname -a
git --version

rm -rf test-repo.git
git init test-repo.git
cd test-repo.git

TZ=EST5EDT
# 1394330399:
#   date -r: Sat Mar  8 20:59:59 EST 2014
#   UTC:     Sun Mar  9 01:59:59 UTC 2014
#   git:     Sat Mar 8 20:59:59 2014 -0500
# 1394330400:
#   date -r: Sat Mar  8 21:00:00 EST 2014
#   UTC:     Sun Mar  9 02:00:00 UTC 2014
#   git:     Wed May 15 04:00:00 2058 +38731400
# 1394334000:
#   date -r: Sat Mar  8 22:00:00 EST 2014
#   UTC:     Sun Mar  9 03:00:00 UTC 2014
#   git:     Sat Mar 8 23:00:00 2014 -0400

#TZ=CST4CDT
# 1394333999:
#   date -r: Sat Mar  8 22:59:59 CST 2014
#   UTC:     Sun Mar  9 02:59:59 UTC 2014
#   git:     Sat Mar 8 22:59:59 2014 -0400
# 1394334000:
#   date -r: Sat Mar  8 23:00:00 CST 2014
#   UTC:     Sun Mar  9 03:00:00 UTC 2014
#   git:     Wed May 15 06:00:00 2058 +38731500
# 1394337599:
#   git:     Wed May 15 07:59:59 2058 +38731600

export TZ

# Create one ok commit, and one bad one.
timeval=1394330399
commit=0
numcommits=2

while [ $commit -lt $numcommits ]; do
    echo $timeval > when
    git add when
    git commit --date $timeval -m "date $timeval"

    timeval=`expr $timeval + 1`
    commit=`expr $commit + 1`
done

git log
git fsck

Attachment: signature.asc
Description: PGP signature



Home | Main Index | Thread Index | Old Index