Git's source code assumes that unsigned long is at least as precise as
time_t. Which is incorrect, and causes a lot of problems, in particular
where unsigned long is only 32-bit (notably on Windows, even in 64-bit
versions).
So let's just use a more appropriate data type instead. In preparation
for this, we introduce the new `timestamp_t` data type.
By necessity, this is a very, very large patch, as it has to replace all
timestamps' data type in one go.
As we will use a data type that is not necessarily identical to `time_t`,
we need to be very careful to use `time_t` whenever we interact with the
system functions, and `timestamp_t` everywhere else.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Johannes Schindelin8 years agocommitted byJunio C Hamano
* Return true iff the specified reflog entry should be expired.
*/
static int should_expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
const char *email, unsigned long timestamp, int tz,
const char *email, timestamp_t timestamp, int tz,
const char *message, void *cb_data)
{
struct expire_reflog_policy_cb *cb = cb_data;
@ -392,8 +392,8 @@ static int collect_reflog(const char *ref, const struct object_id *oid, int unus
@@ -392,8 +392,8 @@ static int collect_reflog(const char *ref, const struct object_id *oid, int unus
@ -675,11 +675,11 @@ static int match_object_header_date(const char *date, unsigned long *timestamp,
@@ -675,11 +675,11 @@ static int match_object_header_date(const char *date, unsigned long *timestamp,
/* Gr. strptime is crap for this; it doesn't have a way to require RFC2822
(i.e. English) day/month names, and it doesn't work correctly with %z. */
int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset)
{
struct tm tm;
int tm_gmt;
unsigned long dummy_timestamp;
timestamp_t dummy_timestamp;
int dummy_offset;
if (!timestamp)
@ -747,7 +747,7 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
@@ -747,7 +747,7 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
return 0; /* success */
}
int parse_expiry_date(const char *date, unsigned long *timestamp)
int parse_expiry_date(const char *date, timestamp_t *timestamp)
{
int errors = 0;
@ -762,7 +762,7 @@ int parse_expiry_date(const char *date, unsigned long *timestamp)
@@ -762,7 +762,7 @@ int parse_expiry_date(const char *date, unsigned long *timestamp)
* of the past, and there is nothing from the future
* to be kept.
*/
*timestamp = ULONG_MAX;
*timestamp = TIME_MAX;
else
*timestamp = approxidate_careful(date, &errors);
@ -771,7 +771,7 @@ int parse_expiry_date(const char *date, unsigned long *timestamp)
@@ -771,7 +771,7 @@ int parse_expiry_date(const char *date, unsigned long *timestamp)
int parse_date(const char *date, struct strbuf *result)