diff options
author | Junio C Hamano <gitster@pobox.com> | 2014-04-08 11:59:05 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2014-04-08 11:59:06 -0700 |
commit | bdb830c44567ebbdec497e6af21b87d4e43539cc (patch) | |
tree | 1a56e047fa97260f688394304d36b2ff3d1c6ace /compat | |
parent | git-p4: explicitly specify that HEAD is a revision (diff) | |
parent | t4212: loosen far-in-future test for AIX (diff) | |
download | tgif-bdb830c44567ebbdec497e6af21b87d4e43539cc.tar.xz |
Merge branch 'jk/commit-dates-parsing-fix'
Finishing touches for portability.
* 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.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/compat/gmtime.c b/compat/gmtime.c new file mode 100644 index 0000000000..e8362dd2b9 --- /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; +} |