summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2014-04-09 18:59:38 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-04-09 18:59:38 (GMT)
commitb8a30194dbea86228aa55fb270f3d704cf7924f4 (patch)
tree2a844dbab6da69248532e464e1a16547fe047022 /compat
parent693b407077bf3739b3609400845e3f6854830ee4 (diff)
parentf80d1f95f0adf9909f42eb9e74546963daa4b0c1 (diff)
downloadgit-b8a30194dbea86228aa55fb270f3d704cf7924f4.zip
git-b8a30194dbea86228aa55fb270f3d704cf7924f4.tar.gz
git-b8a30194dbea86228aa55fb270f3d704cf7924f4.tar.bz2
Merge branch 'jk/commit-dates-parsing-fix' into maint
* jk/commit-dates-parsing-fix: t4212: loosen far-in-future test for AIX date: recognize bogus FreeBSD gmtime output
Diffstat (limited to 'compat')
-rw-r--r--compat/gmtime.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/compat/gmtime.c b/compat/gmtime.c
new file mode 100644
index 0000000..e8362dd
--- /dev/null
+++ b/compat/gmtime.c
@@ -0,0 +1,29 @@
+#include "../git-compat-util.h"
+#undef gmtime
+#undef gmtime_r
+
+struct tm *git_gmtime(const time_t *timep)
+{
+ static struct tm result;
+ return git_gmtime_r(timep, &result);
+}
+
+struct tm *git_gmtime_r(const time_t *timep, struct tm *result)
+{
+ struct tm *ret;
+
+ memset(result, 0, sizeof(*result));
+ ret = gmtime_r(timep, result);
+
+ /*
+ * Rather than NULL, FreeBSD gmtime simply leaves the "struct tm"
+ * untouched when it encounters overflow. Since "mday" cannot otherwise
+ * be zero, we can test this very quickly.
+ */
+ if (ret && !ret->tm_mday) {
+ ret = NULL;
+ errno = EOVERFLOW;
+ }
+
+ return ret;
+}