timestamp_t: a new data type for timestamps
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>
This commit is contained in:

committed by
Junio C Hamano

parent
cb71f8bdb5
commit
dddbad728c
12
commit.c
12
commit.c
@ -66,7 +66,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
|
||||
return commit;
|
||||
}
|
||||
|
||||
static unsigned long parse_commit_date(const char *buf, const char *tail)
|
||||
static timestamp_t parse_commit_date(const char *buf, const char *tail)
|
||||
{
|
||||
const char *dateptr;
|
||||
|
||||
@ -473,8 +473,8 @@ struct commit_list * commit_list_insert_by_date(struct commit *item, struct comm
|
||||
|
||||
static int commit_list_compare_by_date(const void *a, const void *b)
|
||||
{
|
||||
unsigned long a_date = ((const struct commit_list *)a)->item->date;
|
||||
unsigned long b_date = ((const struct commit_list *)b)->item->date;
|
||||
timestamp_t a_date = ((const struct commit_list *)a)->item->date;
|
||||
timestamp_t b_date = ((const struct commit_list *)b)->item->date;
|
||||
if (a_date < b_date)
|
||||
return 1;
|
||||
if (a_date > b_date)
|
||||
@ -598,7 +598,7 @@ static void record_author_date(struct author_date_slab *author_date,
|
||||
const char *ident_line;
|
||||
size_t ident_len;
|
||||
char *date_end;
|
||||
unsigned long date;
|
||||
timestamp_t date;
|
||||
|
||||
ident_line = find_commit_header(buffer, "author", &ident_len);
|
||||
if (!ident_line)
|
||||
@ -621,8 +621,8 @@ static int compare_commits_by_author_date(const void *a_, const void *b_,
|
||||
{
|
||||
const struct commit *a = a_, *b = b_;
|
||||
struct author_date_slab *author_date = cb_data;
|
||||
unsigned long a_date = *(author_date_slab_at(author_date, a));
|
||||
unsigned long b_date = *(author_date_slab_at(author_date, b));
|
||||
timestamp_t a_date = *(author_date_slab_at(author_date, a));
|
||||
timestamp_t b_date = *(author_date_slab_at(author_date, b));
|
||||
|
||||
/* newer commits with larger date first */
|
||||
if (a_date < b_date)
|
||||
|
Reference in New Issue
Block a user