bup (in sysutils) has a test that generates 2000 commits with random
times in order to test pruning of of old backups. While running this, I
found bad timezone values. So far, the failure has only been observed
on NetBSD. I have been able to reproduce this with just git, and not
any bup code.
Basically, times between 2100 and 21:59:00 EST on March 8, 2014 are bad.
Times after 22:00:00 do not cause real problems, but are wrongly
reported as DST (which doesn't start until one second after 01:59:59
EST, which is 03:00:00 EDT).
I tested localtime_r, which git uses, and it seems fine. git has code
(see date.c:local_tzoffset()) to determine the timezone, and it seems
overly complicated. I have not yet traced this code with the
problematic inputs.
I am curious if the following script produces any errors on systems
other than NetBSD, or if it produces errors on NetBSD. I am also
curious where the actual bug is :-)
A good and then bad git commit looks like:
commit 5bde17741fc18459dd9f3a1ef751411309107c63
Author: Greg Troxel <gdt%lexort.com@localhost>
Date: Sat Apr 8 21:31:44 1922 +38731400
date 1394330400
commit bfa5eefdc60184b9f801a5872f5683697958b548
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 transition to DST in March of 2014, in the EST5EDT timezone.
# Somehow, a timezone offset of 44 years is computed.
# This script generates bad commits on:
# NetBSD-7, git 2.11.0
# NetBSD-6, git 2.11.0
# NetBSD-5, git 2.10.0
# This script runs with fsck errors on:
# MacOS 10.12.2, git 2,11.0
set -e
#set -x
uname -a
git --version
rm -rf test-repo.git
git init test-repo.git
cd test-repo.git
# detailed notes are from netbsd-7 amd64, git 2.11.0
#TZ=UTC
#all ok
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
timeval=1394330340
steps=0
stepsmax=10000
while [ $steps -lt $stepsmax ]; do
echo $timeval > when
git add when
git commit --date $timeval -m "date $timeval"
timeval=`expr $timeval + 1`
steps=`expr $steps + 1`
done
git log > ../LOG
git fsck > ../LOG.fsck 2>&1
Attachment:
signature.asc
Description: PGP signature