diff options
authorJohannes Schindelin <>2017-04-20 20:52:13 (GMT)
committerJunio C Hamano <>2017-04-21 05:07:15 (GMT)
commita07fb0507fdf745704e54d77aa19780580636f56 (patch)
parente467dc148d0375ed83300589281f749fcbdd690d (diff)
t0006 & t5000: prepare for 64-bit timestamps
Git's source code refers to timestamps as unsigned longs. On 32-bit platforms, as well as on Windows, unsigned long is not large enough to capture dates that are "absurdly far in the future". It is perfectly valid by the C standard, of course, for the `long` data type to refer to 32-bit integers. That is why the `time_t` data type exists: so that it can be 64-bit even if `long` is 32-bit. Git's source code simply uses an incorrect data type for timestamps, is all. The earlier quick fix 6b9c38e14cd (t0006: skip "far in the future" test when unsigned long is not long enough, 2016-07-11) papered over this issue simply by skipping the respective test cases on platforms where they would fail due to the data type in use. This quick fix, however, tests for *long* to be 64-bit or not. What we need, though, is a test that says whether *whatever data type we use for timestamps* is 64-bit or not. The same quick fix was used to handle the similar problem where Git's source code uses `unsigned long` to represent size, instead of `size_t`, conflating the two issues. So let's just add another prerequisite to test specifically whether timestamps are represented by a 64-bit data type or not. Later, after we switch to a larger data type, we can flip that prerequisite to test `time_t` instead of `long`. Signed-off-by: Johannes Schindelin <> Signed-off-by: Junio C Hamano <>
4 files changed, 11 insertions, 6 deletions
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index 506054b..4727bea 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -4,7 +4,8 @@ static const char *usage_msg = "\n"
" test-date relative [time_t]...\n"
" test-date show:<format> [time_t]...\n"
" test-date parse [date]...\n"
-" test-date approxidate [date]...\n";
+" test-date approxidate [date]...\n"
+" test-date is64bit\n";
static void show_relative_dates(const char **argv, struct timeval *now)
@@ -93,6 +94,8 @@ int cmd_main(int argc, const char **argv)
parse_dates(argv+1, &now);
else if (!strcmp(*argv, "approxidate"))
parse_approxidate(argv+1, &now);
+ else if (!strcmp(*argv, "is64bit"))
+ return sizeof(unsigned long) == 8 ? 0 : 1;
return 0;
diff --git a/t/ b/t/
index c0c9108..9539b42 100755
--- a/t/
+++ b/t/
@@ -53,8 +53,8 @@ check_show unix-local "$TIME" '1466000000'
# arbitrary time absurdly far in the future
FUTURE="5758122296 -0400"
-check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" LONG_IS_64BIT
-check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" LONG_IS_64BIT
+check_show iso "$FUTURE" "2152-06-19 18:24:56 -0400" TIME_IS_64BIT
+check_show iso-local "$FUTURE" "2152-06-19 22:24:56 +0000" TIME_IS_64BIT
check_parse() {
echo "$1 -> $2" >expect
diff --git a/t/ b/t/
index 886b695..997aa9d 100755
--- a/t/
+++ b/t/
@@ -390,7 +390,7 @@ test_expect_success TAR_HUGE,LONG_IS_64BIT 'system tar can read our huge size' '
test_cmp expect actual
-test_expect_success LONG_IS_64BIT 'set up repository with far-future commit' '
+test_expect_success TIME_IS_64BIT 'set up repository with far-future commit' '
rm -f .git/index &&
echo content >file &&
git add file &&
@@ -398,11 +398,11 @@ test_expect_success LONG_IS_64BIT 'set up repository with far-future commit' '
git commit -m "tempori parendum"
-test_expect_success LONG_IS_64BIT 'generate tar with future mtime' '
+test_expect_success TIME_IS_64BIT 'generate tar with future mtime' '
git archive HEAD >future.tar
-test_expect_success TAR_HUGE,LONG_IS_64BIT 'system tar can read our future mtime' '
+test_expect_success TAR_HUGE,TIME_IS_64BIT 'system tar can read our future mtime' '
echo 4147 >expect &&
tar_info future.tar | cut -d" " -f2 >actual &&
test_cmp expect actual
diff --git a/t/ b/t/
index 13b5696..beee1d8 100644
--- a/t/
+++ b/t/
@@ -1164,3 +1164,5 @@ build_option () {
test_lazy_prereq LONG_IS_64BIT '
test 8 -le "$(build_option sizeof-long)"
+test_lazy_prereq TIME_IS_64BIT 'test-date is64bit'