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>

Johannes Schindelin committed Apr 26, 2017 at 21:29 UTC dddbad728c93280fe54ef86699b6d70e2aab44d1
49 files changed +170 -158
Documentation/technical/api-parse-options.txt
+4 -4
@@ -183,13 +183,13 @@ There are some macros to easily define options:
183 scale the provided value by 1024, 1024^2 or 1024^3 respectively.
184 The scaled value is put into `unsigned_long_var`.
185
186 -`OPT_DATE(short, long, &int_var, description)`::
186 +`OPT_DATE(short, long, &timestamp_t_var, description)`::
187 Introduce an option with date argument, see `approxidate()`.
188 - The timestamp is put into `int_var`.
188 + The timestamp is put into `timestamp_t_var`.
189
190 -`OPT_EXPIRY_DATE(short, long, &int_var, description)`::
190 +`OPT_EXPIRY_DATE(short, long, &timestamp_t_var, description)`::
191 Introduce an option with expiry date argument, see `parse_expiry_date()`.
192 - The timestamp is put into `int_var`.
192 + The timestamp is put into `timestamp_t_var`.
193
194 `OPT_CALLBACK(short, long, &var, arg_str, description, func_ptr)`::
195 Introduce an option with argument.
archive-tar.c
+5 -2
@@ -27,9 +27,12 @@ static int write_tar_filter_archive(const struct archiver *ar,
27 */
28 #if ULONG_MAX == 0xFFFFFFFF
29 #define USTAR_MAX_SIZE ULONG_MAX
30 -#define USTAR_MAX_MTIME ULONG_MAX
30 #else
32 -#define USTAR_MAX_SIZE 077777777777UL
31 +#define USTAR_MAX_SIZE 077777777777ULL
32 +#endif
33 +#if TIME_MAX == 0xFFFFFFFF
34 +#define USTAR_MAX_MTIME TIME_MAX
35 +#else
36 #define USTAR_MAX_MTIME 077777777777UL
37 #endif
38
archive-zip.c
+10 -2
@@ -545,9 +545,17 @@ static void write_zip_trailer(const unsigned char *sha1)
545 write_or_die(1, sha1_to_hex(sha1), GIT_SHA1_HEXSZ);
546 }
547
548 -static void dos_time(time_t *time, int *dos_date, int *dos_time)
548 +static void dos_time(timestamp_t *timestamp, int *dos_date, int *dos_time)
549 {
550 - struct tm *t = localtime(time);
550 + time_t time;
551 + struct tm *t;
552 +
553 + if (date_overflows(*timestamp))
554 + die("timestamp too large for this system: %"PRItime,
555 + *timestamp);
556 + time = (time_t)*timestamp;
557 + t = localtime(&time);
558 + *timestamp = time;
559
560 *dos_date = t->tm_mday + (t->tm_mon + 1) * 32 +
561 (t->tm_year + 1900 - 1980) * 512;
archive.h
+1 -1
@@ -9,7 +9,7 @@ struct archiver_args {
9 struct tree *tree;
10 const unsigned char *commit_sha1;
11 const struct commit *commit;
12 - time_t time;
12 + timestamp_t time;
13 struct pathspec pathspec;
14 unsigned int verbose : 1;
15 unsigned int worktree_attributes : 1;
builtin/am.c
+1 -1
@@ -877,7 +877,7 @@ static int hg_patch_to_mail(FILE *out, FILE *in, int keep_cr)
877 if (skip_prefix(sb.buf, "# User ", &str))
878 fprintf(out, "From: %s\n", str);
879 else if (skip_prefix(sb.buf, "# Date ", &str)) {
880 - unsigned long timestamp;
880 + timestamp_t timestamp;
881 long tz, tz2;
882 char *end;
883
builtin/blame.c
+4 -4
@@ -1561,13 +1561,13 @@ finish:
1561 struct commit_info {
1562 struct strbuf author;
1563 struct strbuf author_mail;
1564 - unsigned long author_time;
1564 + timestamp_t author_time;
1565 struct strbuf author_tz;
1566
1567 /* filled only when asked for details */
1568 struct strbuf committer;
1569 struct strbuf committer_mail;
1570 - unsigned long committer_time;
1570 + timestamp_t committer_time;
1571 struct strbuf committer_tz;
1572
1573 struct strbuf summary;
@@ -1578,7 +1578,7 @@ struct commit_info {
1578 */
1579 static void get_ac_line(const char *inbuf, const char *what,
1580 struct strbuf *name, struct strbuf *mail,
1581 - unsigned long *time, struct strbuf *tz)
1581 + timestamp_t *time, struct strbuf *tz)
1582 {
1583 struct ident_split ident;
1584 size_t len, maillen, namelen;
@@ -1837,7 +1837,7 @@ static void assign_blame(struct scoreboard *sb, int opt)
1837 stop_progress(&pi.progress);
1838 }
1839
1840 -static const char *format_time(unsigned long time, const char *tz_str,
1840 +static const char *format_time(timestamp_t time, const char *tz_str,
1841 int show_raw_time)
1842 {
1843 static struct strbuf time_buf = STRBUF_INIT;
builtin/fsck.c
+2 -2
@@ -397,7 +397,7 @@ static int fsck_obj_buffer(const unsigned char *sha1, enum object_type type,
397 static int default_refs;
398
399 static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
400 - unsigned long timestamp)
400 + timestamp_t timestamp)
401 {
402 struct object *obj;
403
@@ -418,7 +418,7 @@ static void fsck_handle_reflog_oid(const char *refname, struct object_id *oid,
418 }
419
420 static int fsck_handle_reflog_ent(struct object_id *ooid, struct object_id *noid,
421 - const char *email, unsigned long timestamp, int tz,
421 + const char *email, timestamp_t timestamp, int tz,
422 const char *message, void *cb_data)
423 {
424 const char *refname = cb_data;
builtin/gc.c
+1 -1
@@ -33,7 +33,7 @@ static int aggressive_window = 250;
33 static int gc_auto_threshold = 6700;
34 static int gc_auto_pack_limit = 50;
35 static int detach_auto = 1;
36 -static unsigned long gc_log_expire_time;
36 +static timestamp_t gc_log_expire_time;
37 static const char *gc_log_expire = "1.day.ago";
38 static const char *prune_expire = "2.weeks.ago";
39 static const char *prune_worktrees_expire = "3.months.ago";
builtin/log.c
+1 -1
@@ -911,7 +911,7 @@ static void gen_message_id(struct rev_info *info, char *base)
911 {
912 struct strbuf buf = STRBUF_INIT;
913 strbuf_addf(&buf, "%s.%"PRItime".git.%s", base,
914 - (unsigned long) time(NULL),
914 + (timestamp_t) time(NULL),
915 git_committer_info(IDENT_NO_NAME|IDENT_NO_DATE|IDENT_STRICT));
916 info->message_id = strbuf_detach(&buf, NULL);
917 }
builtin/merge-base.c
+1 -1
@@ -132,7 +132,7 @@ static void add_one_commit(struct object_id *oid, struct rev_collect *revs)
132 }
133
134 static int collect_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
135 - const char *ident, unsigned long timestamp,
135 + const char *ident, timestamp_t timestamp,
136 int tz, const char *message, void *cbdata)
137 {
138 struct rev_collect *revs = cbdata;
builtin/name-rev.c
+3 -3
@@ -10,7 +10,7 @@
10
11 typedef struct rev_name {
12 const char *tip_name;
13 - unsigned long taggerdate;
13 + timestamp_t taggerdate;
14 int generation;
15 int distance;
16 } rev_name;
@@ -21,7 +21,7 @@ static long cutoff = LONG_MAX;
21 #define MERGE_TRAVERSAL_WEIGHT 65535
22
23 static void name_rev(struct commit *commit,
24 - const char *tip_name, unsigned long taggerdate,
24 + const char *tip_name, timestamp_t taggerdate,
25 int generation, int distance,
26 int deref)
27 {
@@ -146,7 +146,7 @@ static int name_ref(const char *path, const struct object_id *oid, int flags, vo
146 struct name_ref_data *data = cb_data;
147 int can_abbreviate_output = data->tags_only && data->name_only;
148 int deref = 0;
149 - unsigned long taggerdate = ULONG_MAX;
149 + timestamp_t taggerdate = TIME_MAX;
150
151 if (data->tags_only && !starts_with(path, "refs/tags/"))
152 return 0;
builtin/pack-objects.c
+2 -2
@@ -44,7 +44,7 @@ static uint32_t nr_result, nr_written;
44 static int non_empty;
45 static int reuse_delta = 1, reuse_object = 1;
46 static int keep_unreachable, unpack_unreachable, include_tag;
47 -static unsigned long unpack_unreachable_expiration;
47 +static timestamp_t unpack_unreachable_expiration;
48 static int pack_loose_unreachable;
49 static int local;
50 static int have_non_local_packs;
@@ -2675,7 +2675,7 @@ static int has_sha1_pack_kept_or_nonlocal(const unsigned char *sha1)
2675 static struct oid_array recent_objects;
2676
2677 static int loosened_object_can_be_discarded(const struct object_id *oid,
2678 - unsigned long mtime)
2678 + timestamp_t mtime)
2679 {
2680 if (!unpack_unreachable_expiration)
2681 return 0;
builtin/prune.c
+2 -2
@@ -13,7 +13,7 @@ static const char * const prune_usage[] = {
13 };
14 static int show_only;
15 static int verbose;
16 -static unsigned long expire;
16 +static timestamp_t expire;
17 static int show_progress = -1;
18
19 static int prune_tmp_file(const char *fullpath)
@@ -111,7 +111,7 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
111 };
112 char *s;
113
114 - expire = ULONG_MAX;
114 + expire = TIME_MAX;
115 save_commit_buffer = 0;
116 check_replace_refs = 0;
117 ref_paranoia = 1;
builtin/receive-pack.c
+3 -3
@@ -78,7 +78,7 @@ static const char *NONCE_OK = "OK";
78 static const char *NONCE_SLOP = "SLOP";
79 static const char *nonce_status;
80 static long nonce_stamp_slop;
81 -static unsigned long nonce_stamp_slop_limit;
81 +static timestamp_t nonce_stamp_slop_limit;
82 static struct ref_transaction *transaction;
83
84 static enum {
@@ -454,7 +454,7 @@ static void hmac_sha1(unsigned char *out,
454 git_SHA1_Final(out, &ctx);
455 }
456
457 -static char *prepare_push_cert_nonce(const char *path, unsigned long stamp)
457 +static char *prepare_push_cert_nonce(const char *path, timestamp_t stamp)
458 {
459 struct strbuf buf = STRBUF_INIT;
460 unsigned char sha1[20];
@@ -496,7 +496,7 @@ static char *find_header(const char *msg, size_t len, const char *key)
496 static const char *check_nonce(const char *buf, size_t len)
497 {
498 char *nonce = find_header(buf, len, "nonce");
499 - unsigned long stamp, ostamp;
499 + timestamp_t stamp, ostamp;
500 char *bohmac, *expect = NULL;
501 const char *retval = NONCE_BAD;
502
builtin/reflog.c
+12 -12
@@ -16,14 +16,14 @@ static const char reflog_delete_usage[] =
16 static const char reflog_exists_usage[] =
17 "git reflog exists <ref>";
18
19 -static unsigned long default_reflog_expire;
20 -static unsigned long default_reflog_expire_unreachable;
19 +static timestamp_t default_reflog_expire;
20 +static timestamp_t default_reflog_expire_unreachable;
21
22 struct cmd_reflog_expire_cb {
23 struct rev_info revs;
24 int stalefix;
25 - unsigned long expire_total;
26 - unsigned long expire_unreachable;
25 + timestamp_t expire_total;
26 + timestamp_t expire_unreachable;
27 int recno;
28 };
29
@@ -219,7 +219,7 @@ static int keep_entry(struct commit **it, unsigned char *sha1)
219 static void mark_reachable(struct expire_reflog_policy_cb *cb)
220 {
221 struct commit_list *pending;
222 - unsigned long expire_limit = cb->mark_limit;
222 + timestamp_t expire_limit = cb->mark_limit;
223 struct commit_list *leftover = NULL;
224
225 for (pending = cb->mark_list; pending; pending = pending->next)
@@ -284,7 +284,7 @@ static int unreachable(struct expire_reflog_policy_cb *cb, struct commit *commit
284 * Return true iff the specified reflog entry should be expired.
285 */
286 static int should_expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,
287 - const char *email, unsigned long timestamp, int tz,
287 + const char *email, timestamp_t timestamp, int tz,
288 const char *message, void *cb_data)
289 {
290 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
393 static struct reflog_expire_cfg {
394 struct reflog_expire_cfg *next;
395 - unsigned long expire_total;
396 - unsigned long expire_unreachable;
395 + timestamp_t expire_total;
396 + timestamp_t expire_unreachable;
397 char pattern[FLEX_ARRAY];
398 } *reflog_expire_cfg, **reflog_expire_cfg_tail;
399
@@ -415,7 +415,7 @@ static struct reflog_expire_cfg *find_cfg_ent(const char *pattern, size_t len)
415 return ent;
416 }
417
418 -static int parse_expire_cfg_value(const char *var, const char *value, unsigned long *expire)
418 +static int parse_expire_cfg_value(const char *var, const char *value, timestamp_t *expire)
419 {
420 if (!value)
421 return config_error_nonbool(var);
@@ -433,7 +433,7 @@ static int reflog_expire_config(const char *var, const char *value, void *cb)
433 {
434 const char *pattern, *key;
435 int pattern_len;
436 - unsigned long expire;
436 + timestamp_t expire;
437 int slot;
438 struct reflog_expire_cfg *ent;
439
@@ -515,7 +515,7 @@ static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, c
515 static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
516 {
517 struct expire_reflog_policy_cb cb;
518 - unsigned long now = time(NULL);
518 + timestamp_t now = time(NULL);
519 int i, status, do_all;
520 int explicit_expiry = 0;
521 unsigned int flags = 0;
@@ -616,7 +616,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
616 }
617
618 static int count_reflog_ent(struct object_id *ooid, struct object_id *noid,
619 - const char *email, unsigned long timestamp, int tz,
619 + const char *email, timestamp_t timestamp, int tz,
620 const char *message, void *cb_data)
621 {
622 struct expire_reflog_policy_cb *cb = cb_data;
builtin/show-branch.c
+2 -2
@@ -735,7 +735,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
735 base = strtoul(reflog_base, &ep, 10);
736 if (*ep) {
737 /* Ah, that is a date spec... */
738 - unsigned long at;
738 + timestamp_t at;
739 at = approxidate(reflog_base);
740 read_ref_at(ref, flags, at, -1, oid.hash, NULL,
741 NULL, NULL, &base);
@@ -746,7 +746,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
746 char *logmsg;
747 char *nth_desc;
748 const char *msg;
749 - unsigned long timestamp;
749 + timestamp_t timestamp;
750 int tz;
751
752 if (read_ref_at(ref, flags, 0, base+i, oid.hash, &logmsg,
builtin/worktree.c
+2 -2
@@ -30,7 +30,7 @@ struct add_opts {
30
31 static int show_only;
32 static int verbose;
33 -static unsigned long expire;
33 +static timestamp_t expire;
34
35 static int prune_worktree(const char *id, struct strbuf *reason)
36 {
@@ -131,7 +131,7 @@ static int prune(int ac, const char **av, const char *prefix)
131 OPT_END()
132 };
133
134 - expire = ULONG_MAX;
134 + expire = TIME_MAX;
135 ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
136 if (ac)
137 usage_with_options(worktree_usage, options);
bundle.c
+1 -1
@@ -211,7 +211,7 @@ static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
211 unsigned long size;
212 enum object_type type;
213 char *buf = NULL, *line, *lineend;
214 - unsigned long date;
214 + timestamp_t date;
215 int result = 1;
216
217 if (revs->max_age == -1 && revs->min_age == -1)
cache.h
+7 -7
@@ -1476,18 +1476,18 @@ struct date_mode {
1476 #define DATE_MODE(t) date_mode_from_type(DATE_##t)
1477 struct date_mode *date_mode_from_type(enum date_mode_type type);
1478
1479 -const char *show_date(unsigned long time, int timezone, const struct date_mode *mode);
1480 -void show_date_relative(unsigned long time, int tz, const struct timeval *now,
1479 +const char *show_date(timestamp_t time, int timezone, const struct date_mode *mode);
1480 +void show_date_relative(timestamp_t time, int tz, const struct timeval *now,
1481 struct strbuf *timebuf);
1482 int parse_date(const char *date, struct strbuf *out);
1483 -int parse_date_basic(const char *date, unsigned long *timestamp, int *offset);
1484 -int parse_expiry_date(const char *date, unsigned long *timestamp);
1483 +int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset);
1484 +int parse_expiry_date(const char *date, timestamp_t *timestamp);
1485 void datestamp(struct strbuf *out);
1486 #define approxidate(s) approxidate_careful((s), NULL)
1487 -unsigned long approxidate_careful(const char *, int *);
1488 -unsigned long approxidate_relative(const char *date, const struct timeval *now);
1487 +timestamp_t approxidate_careful(const char *, int *);
1488 +timestamp_t approxidate_relative(const char *date, const struct timeval *now);
1489 void parse_date_format(const char *format, struct date_mode *mode);
1490 -int date_overflows(unsigned long date);
1490 +int date_overflows(timestamp_t date);
1491
1492 #define IDENT_STRICT 1
1493 #define IDENT_NO_DATE 2
commit.c
+6 -6
@@ -66,7 +66,7 @@ struct commit *lookup_commit_reference_by_name(const char *name)
66 return commit;
67 }
68
69 -static unsigned long parse_commit_date(const char *buf, const char *tail)
69 +static timestamp_t parse_commit_date(const char *buf, const char *tail)
70 {
71 const char *dateptr;
72
@@ -473,8 +473,8 @@ struct commit_list * commit_list_insert_by_date(struct commit *item, struct comm
473
474 static int commit_list_compare_by_date(const void *a, const void *b)
475 {
476 - unsigned long a_date = ((const struct commit_list *)a)->item->date;
477 - unsigned long b_date = ((const struct commit_list *)b)->item->date;
476 + timestamp_t a_date = ((const struct commit_list *)a)->item->date;
477 + timestamp_t b_date = ((const struct commit_list *)b)->item->date;
478 if (a_date < b_date)
479 return 1;
480 if (a_date > b_date)
@@ -598,7 +598,7 @@ static void record_author_date(struct author_date_slab *author_date,
598 const char *ident_line;
599 size_t ident_len;
600 char *date_end;
601 - unsigned long date;
601 + timestamp_t date;
602
603 ident_line = find_commit_header(buffer, "author", &ident_len);
604 if (!ident_line)
@@ -621,8 +621,8 @@ static int compare_commits_by_author_date(const void *a_, const void *b_,
621 {
622 const struct commit *a = a_, *b = b_;
623 struct author_date_slab *author_date = cb_data;
624 - unsigned long a_date = *(author_date_slab_at(author_date, a));
625 - unsigned long b_date = *(author_date_slab_at(author_date, b));
624 + timestamp_t a_date = *(author_date_slab_at(author_date, a));
625 + timestamp_t b_date = *(author_date_slab_at(author_date, b));
626
627 /* newer commits with larger date first */
628 if (a_date < b_date)
commit.h
+1 -1
@@ -17,7 +17,7 @@ struct commit {
17 struct object object;
18 void *util;
19 unsigned int index;
20 - unsigned long date;
20 + timestamp_t date;
21 struct commit_list *parents;
22 struct tree *tree;
23 };
config.c
+1 -1
@@ -1926,7 +1926,7 @@ int git_config_get_expiry(const char *key, const char **output)
1926 if (ret)
1927 return ret;
1928 if (strcmp(*output, "now")) {
1929 - unsigned long now = approxidate("now");
1929 + timestamp_t now = approxidate("now");
1930 if (approxidate(*output) >= now)
1931 git_die_config(key, _("Invalid %s: '%s'"), key, *output);
1932 }
credential-cache--daemon.c
+6 -6
@@ -8,7 +8,7 @@ static struct tempfile socket_file;
8
9 struct credential_cache_entry {
10 struct credential item;
11 - unsigned long expiration;
11 + timestamp_t expiration;
12 };
13 static struct credential_cache_entry *entries;
14 static int entries_nr;
@@ -47,12 +47,12 @@ static void remove_credential(const struct credential *c)
47 e->expiration = 0;
48 }
49
50 -static int check_expirations(void)
50 +static timestamp_t check_expirations(void)
51 {
52 - static unsigned long wait_for_entry_until;
52 + static timestamp_t wait_for_entry_until;
53 int i = 0;
54 - unsigned long now = time(NULL);
55 - unsigned long next = (unsigned long)-1;
54 + timestamp_t now = time(NULL);
55 + timestamp_t next = TIME_MAX;
56
57 /*
58 * Initially give the client 30 seconds to actually contact us
@@ -159,7 +159,7 @@ static void serve_one_client(FILE *in, FILE *out)
159 static int serve_cache_loop(int fd)
160 {
161 struct pollfd pfd;
162 - unsigned long wakeup;
162 + timestamp_t wakeup;
163
164 wakeup = check_expirations();
165 if (!wakeup)
date.c
+33 -33
@@ -39,7 +39,7 @@ static const char *weekday_names[] = {
39 "Sundays", "Mondays", "Tuesdays", "Wednesdays", "Thursdays", "Fridays", "Saturdays"
40 };
41
42 -static time_t gm_time_t(unsigned long time, int tz)
42 +static time_t gm_time_t(timestamp_t time, int tz)
43 {
44 int minutes;
45
@@ -54,7 +54,7 @@ static time_t gm_time_t(unsigned long time, int tz)
54 * thing, which means that tz -0100 is passed in as the integer -100,
55 * even though it means "sixty minutes off"
56 */
57 -static struct tm *time_to_tm(unsigned long time, int tz)
57 +static struct tm *time_to_tm(timestamp_t time, int tz)
58 {
59 time_t t = gm_time_t(time, tz);
60 return gmtime(&t);
@@ -64,7 +64,7 @@ static struct tm *time_to_tm(unsigned long time, int tz)
64 * What value of "tz" was in effect back then at "time" in the
65 * local timezone?
66 */
67 -static int local_tzoffset(unsigned long time)
67 +static int local_tzoffset(timestamp_t time)
68 {
69 time_t t, t_local;
70 struct tm tm;
@@ -88,11 +88,11 @@ static int local_tzoffset(unsigned long time)
88 return offset * eastwest;
89 }
90
91 -void show_date_relative(unsigned long time, int tz,
91 +void show_date_relative(timestamp_t time, int tz,
92 const struct timeval *now,
93 struct strbuf *timebuf)
94 {
95 - unsigned long diff;
95 + timestamp_t diff;
96 if (now->tv_sec < time) {
97 strbuf_addstr(timebuf, _("in the future"));
98 return;
@@ -140,9 +140,9 @@ void show_date_relative(unsigned long time, int tz,
140 }
141 /* Give years and months for 5 years or so */
142 if (diff < 1825) {
143 - unsigned long totalmonths = (diff * 12 * 2 + 365) / (365 * 2);
144 - unsigned long years = totalmonths / 12;
145 - unsigned long months = totalmonths % 12;
143 + timestamp_t totalmonths = (diff * 12 * 2 + 365) / (365 * 2);
144 + timestamp_t years = totalmonths / 12;
145 + timestamp_t months = totalmonths % 12;
146 if (months) {
147 struct strbuf sb = STRBUF_INIT;
148 strbuf_addf(&sb, Q_("%"PRItime" year", "%"PRItime" years", years), years);
@@ -172,7 +172,7 @@ struct date_mode *date_mode_from_type(enum date_mode_type type)
172 return &mode;
173 }
174
175 -const char *show_date(unsigned long time, int tz, const struct date_mode *mode)
175 +const char *show_date(timestamp_t time, int tz, const struct date_mode *mode)
176 {
177 struct tm *tm;
178 static struct strbuf timebuf = STRBUF_INIT;
@@ -425,7 +425,7 @@ static int is_date(int year, int month, int day, struct tm *now_tm, time_t now,
425 return 0;
426 }
427
428 -static int match_multi_number(unsigned long num, char c, const char *date,
428 +static int match_multi_number(timestamp_t num, char c, const char *date,
429 char *end, struct tm *tm, time_t now)
430 {
431 struct tm now_tm;
@@ -508,7 +508,7 @@ static int match_digit(const char *date, struct tm *tm, int *offset, int *tm_gmt
508 {
509 int n;
510 char *end;
511 - unsigned long num;
511 + timestamp_t num;
512
513 num = parse_timestamp(date, &end, 10);
514
@@ -635,7 +635,7 @@ static int match_tz(const char *date, int *offp)
635 return end - date;
636 }
637
638 -static void date_string(unsigned long date, int offset, struct strbuf *buf)
638 +static void date_string(timestamp_t date, int offset, struct strbuf *buf)
639 {
640 int sign = '+';
641
@@ -650,16 +650,16 @@ static void date_string(unsigned long date, int offset, struct strbuf *buf)
650 * Parse a string like "0 +0000" as ancient timestamp near epoch, but
651 * only when it appears not as part of any other string.
652 */
653 -static int match_object_header_date(const char *date, unsigned long *timestamp, int *offset)
653 +static int match_object_header_date(const char *date, timestamp_t *timestamp, int *offset)
654 {
655 char *end;
656 - unsigned long stamp;
656 + timestamp_t stamp;
657 int ofs;
658
659 if (*date < '0' || '9' < *date)
660 return -1;
661 stamp = parse_timestamp(date, &end, 10);
662 - if (*end != ' ' || stamp == ULONG_MAX || (end[1] != '+' && end[1] != '-'))
662 + if (*end != ' ' || stamp == TIME_MAX || (end[1] != '+' && end[1] != '-'))
663 return -1;
664 date = end + 2;
665 ofs = strtol(date, &end, 10);
@@ -675,11 +675,11 @@ static int match_object_header_date(const char *date, unsigned long *timestamp,
675
676 /* Gr. strptime is crap for this; it doesn't have a way to require RFC2822
677 (i.e. English) day/month names, and it doesn't work correctly with %z. */
678 -int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
678 +int parse_date_basic(const char *date, timestamp_t *timestamp, int *offset)
679 {
680 struct tm tm;
681 int tm_gmt;
682 - unsigned long dummy_timestamp;
682 + timestamp_t dummy_timestamp;
683 int dummy_offset;
684
685 if (!timestamp)
@@ -747,7 +747,7 @@ int parse_date_basic(const char *date, unsigned long *timestamp, int *offset)
747 return 0; /* success */
748 }
749
750 -int parse_expiry_date(const char *date, unsigned long *timestamp)
750 +int parse_expiry_date(const char *date, timestamp_t *timestamp)
751 {
752 int errors = 0;
753
@@ -762,7 +762,7 @@ int parse_expiry_date(const char *date, unsigned long *timestamp)
762 * of the past, and there is nothing from the future
763 * to be kept.
764 */
765 - *timestamp = ULONG_MAX;
765 + *timestamp = TIME_MAX;
766 else
767 *timestamp = approxidate_careful(date, &errors);
768
@@ -771,7 +771,7 @@ int parse_expiry_date(const char *date, unsigned long *timestamp)
771
772 int parse_date(const char *date, struct strbuf *result)
773 {
774 - unsigned long timestamp;
774 + timestamp_t timestamp;
775 int offset;
776 if (parse_date_basic(date, &timestamp, &offset))
777 return -1;
@@ -845,7 +845,7 @@ void datestamp(struct strbuf *out)
845 * Relative time update (eg "2 days ago"). If we haven't set the time
846 * yet, we need to set it from current time.
847 */
848 -static unsigned long update_tm(struct tm *tm, struct tm *now, unsigned long sec)
848 +static time_t update_tm(struct tm *tm, struct tm *now, time_t sec)
849 {
850 time_t n;
851
@@ -1066,7 +1066,7 @@ static const char *approxidate_digit(const char *date, struct tm *tm, int *num,
1066 time_t now)
1067 {
1068 char *end;
1069 - unsigned long number = parse_timestamp(date, &end, 10);
1069 + timestamp_t number = parse_timestamp(date, &end, 10);
1070
1071 switch (*end) {
1072 case ':':
@@ -1114,9 +1114,9 @@ static void pending_number(struct tm *tm, int *num)
1114 }
1115 }
1116
1117 -static unsigned long approxidate_str(const char *date,
1118 - const struct timeval *tv,
1119 - int *error_ret)
1117 +static timestamp_t approxidate_str(const char *date,
1118 + const struct timeval *tv,
1119 + int *error_ret)
1120 {
1121 int number = 0;
1122 int touched = 0;
@@ -1148,12 +1148,12 @@ static unsigned long approxidate_str(const char *date,
1148 pending_number(&tm, &number);
1149 if (!touched)
1150 *error_ret = 1;
1151 - return update_tm(&tm, &now, 0);
1151 + return (timestamp_t)update_tm(&tm, &now, 0);
1152 }
1153
1154 -unsigned long approxidate_relative(const char *date, const struct timeval *tv)
1154 +timestamp_t approxidate_relative(const char *date, const struct timeval *tv)
1155 {
1156 - unsigned long timestamp;
1156 + timestamp_t timestamp;
1157 int offset;
1158 int errors = 0;
1159
@@ -1162,10 +1162,10 @@ unsigned long approxidate_relative(const char *date, const struct timeval *tv)
1162 return approxidate_str(date, tv, &errors);
1163 }
1164
1165 -unsigned long approxidate_careful(const char *date, int *error_ret)
1165 +timestamp_t approxidate_careful(const char *date, int *error_ret)
1166 {
1167 struct timeval tv;
1168 - unsigned long timestamp;
1168 + timestamp_t timestamp;
1169 int offset;
1170 int dummy = 0;
1171 if (!error_ret)
@@ -1180,12 +1180,12 @@ unsigned long approxidate_careful(const char *date, int *error_ret)
1180 return approxidate_str(date, &tv, error_ret);
1181 }
1182
1183 -int date_overflows(unsigned long t)
1183 +int date_overflows(timestamp_t t)
1184 {
1185 time_t sys;
1186
1187 - /* If we overflowed our unsigned long, that's bad... */
1188 - if (t == ULONG_MAX)
1187 + /* If we overflowed our timestamp data type, that's bad... */
1188 + if ((uintmax_t)t >= TIME_MAX)
1189 return 1;
1190
1191 /*
fetch-pack.c
+3 -3
@@ -392,7 +392,7 @@ static int find_common(struct fetch_pack_args *args,
392 if (args->depth > 0)
393 packet_buf_write(&req_buf, "deepen %d", args->depth);
394 if (args->deepen_since) {
395 - unsigned long max_age = approxidate(args->deepen_since);
395 + timestamp_t max_age = approxidate(args->deepen_since);
396 packet_buf_write(&req_buf, "deepen-since %"PRItime, max_age);
397 }
398 if (args->deepen_not) {
@@ -581,7 +581,7 @@ static int mark_complete_oid(const char *refname, const struct object_id *oid,
581 }
582
583 static void mark_recent_complete_commits(struct fetch_pack_args *args,
584 - unsigned long cutoff)
584 + timestamp_t cutoff)
585 {
586 while (complete && cutoff <= complete->item->date) {
587 print_verbose(args, _("Marking %s as complete"),
@@ -668,7 +668,7 @@ static int everything_local(struct fetch_pack_args *args,
668 {
669 struct ref *ref;
670 int retval;
671 - unsigned long cutoff = 0;
671 + timestamp_t cutoff = 0;
672
673 save_commit_buffer = 0;
674
git-compat-util.h
+2
@@ -319,8 +319,10 @@ extern char *gitdirname(char *);
319 #define PRIo32 "o"
320 #endif
321
322 +typedef unsigned long timestamp_t;
323 #define PRItime "lu"
324 #define parse_timestamp strtoul
325 +#define TIME_MAX ULONG_MAX
326
327 #ifndef PATH_SEP
328 #define PATH_SEP ':'
http-backend.c
+2 -2
@@ -90,7 +90,7 @@ static void hdr_int(struct strbuf *hdr, const char *name, uintmax_t value)
90 strbuf_addf(hdr, "%s: %" PRIuMAX "\r\n", name, value);
91 }
92
93 -static void hdr_date(struct strbuf *hdr, const char *name, unsigned long when)
93 +static void hdr_date(struct strbuf *hdr, const char *name, timestamp_t when)
94 {
95 const char *value = show_date(when, 0, DATE_MODE(RFC2822));
96 hdr_str(hdr, name, value);
@@ -105,7 +105,7 @@ static void hdr_nocache(struct strbuf *hdr)
105
106 static void hdr_cache_forever(struct strbuf *hdr)
107 {
108 - unsigned long now = time(NULL);
108 + timestamp_t now = time(NULL);
109 hdr_date(hdr, "Date", now);
110 hdr_date(hdr, "Expires", now + 31536000);
111 hdr_str(hdr, "Cache-Control", "public, max-age=31536000");
parse-options-cb.c
+2 -2
@@ -31,14 +31,14 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
31 int parse_opt_approxidate_cb(const struct option *opt, const char *arg,
32 int unset)
33 {
34 - *(unsigned long *)(opt->value) = approxidate(arg);
34 + *(timestamp_t *)(opt->value) = approxidate(arg);
35 return 0;
36 }
37
38 int parse_opt_expiry_date_cb(const struct option *opt, const char *arg,
39 int unset)
40 {
41 - return parse_expiry_date(arg, (unsigned long *)opt->value);
41 + return parse_expiry_date(arg, (timestamp_t *)opt->value);
42 }
43
44 int parse_opt_color_flag_cb(const struct option *opt, const char *arg,
pretty.c
+1 -1
@@ -405,7 +405,7 @@ static void add_rfc2047(struct strbuf *sb, const char *line, size_t len,
405 const char *show_ident_date(const struct ident_split *ident,
406 const struct date_mode *mode)
407 {
408 - unsigned long date = 0;
408 + timestamp_t date = 0;
409 long tz = 0;
410
411 if (ident->date_begin && ident->date_end)
reachable.c
+4 -5
@@ -55,11 +55,11 @@ static void mark_commit(struct commit *c, void *data)
55
56 struct recent_data {
57 struct rev_info *revs;
58 - unsigned long timestamp;
58 + timestamp_t timestamp;
59 };
60
61 static void add_recent_object(const struct object_id *oid,
62 - unsigned long mtime,
62 + timestamp_t mtime,
63 struct recent_data *data)
64 {
65 struct object *obj;
@@ -139,7 +139,7 @@ static int add_recent_packed(const struct object_id *oid,
139 }
140
141 int add_unseen_recent_objects_to_traversal(struct rev_info *revs,
142 - unsigned long timestamp)
142 + timestamp_t timestamp)
143 {
144 struct recent_data data;
145 int r;
@@ -156,8 +156,7 @@ int add_unseen_recent_objects_to_traversal(struct rev_info *revs,
156 }
157
158 void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
159 - unsigned long mark_recent,
160 - struct progress *progress)
159 + timestamp_t mark_recent, struct progress *progress)
160 {
161 struct connectivity_progress cp;
162
reachable.h
+2 -2
@@ -3,8 +3,8 @@
3
4 struct progress;
5 extern int add_unseen_recent_objects_to_traversal(struct rev_info *revs,
6 - unsigned long timestamp);
6 + timestamp_t timestamp);
7 extern void mark_reachable_objects(struct rev_info *revs, int mark_reflog,
8 - unsigned long mark_recent, struct progress *);
8 + timestamp_t mark_recent, struct progress *);
9
10 #endif
ref-filter.c
+2 -2
@@ -849,7 +849,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
849 {
850 const char *eoemail = strstr(buf, "> ");
851 char *zone;
852 - unsigned long timestamp;
852 + timestamp_t timestamp;
853 long tz;
854 struct date_mode date_mode = { DATE_NORMAL };
855 const char *formatp;
@@ -869,7 +869,7 @@ static void grab_date(const char *buf, struct atom_value *v, const char *atomnam
869 if (!eoemail)
870 goto bad;
871 timestamp = parse_timestamp(eoemail + 2, &zone, 10);
872 - if (timestamp == ULONG_MAX)
872 + if (timestamp == TIME_MAX)
873 goto bad;
874 tz = strtol(zone, NULL, 10);
875 if ((tz == LONG_MIN || tz == LONG_MAX) && errno == ERANGE)
reflog-walk.c
+4 -4
@@ -12,7 +12,7 @@ struct complete_reflogs {
12 struct reflog_info {
13 struct object_id ooid, noid;
14 char *email;
15 - unsigned long timestamp;
15 + timestamp_t timestamp;
16 int tz;
17 char *message;
18 } *items;
@@ -20,7 +20,7 @@ struct complete_reflogs {
20 };
21
22 static int read_one_reflog(struct object_id *ooid, struct object_id *noid,
23 - const char *email, unsigned long timestamp, int tz,
23 + const char *email, timestamp_t timestamp, int tz,
24 const char *message, void *cb_data)
25 {
26 struct complete_reflogs *array = cb_data;
@@ -69,7 +69,7 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)
69 }
70
71 static int get_reflog_recno_by_time(struct complete_reflogs *array,
72 - unsigned long timestamp)
72 + timestamp_t timestamp)
73 {
74 int i;
75 for (i = array->nr - 1; i >= 0; i--)
@@ -141,7 +141,7 @@ void init_reflog_walk(struct reflog_walk_info **info)
141 int add_reflog_for_walk(struct reflog_walk_info *info,
142 struct commit *commit, const char *name)
143 {
144 - unsigned long timestamp = 0;
144 + timestamp_t timestamp = 0;
145 int recno = -1;
146 struct string_list_item *item;
147 struct complete_reflogs *reflogs;
refs.c
+7 -7
@@ -712,7 +712,7 @@ int is_branch(const char *refname)
712
713 struct read_ref_at_cb {
714 const char *refname;
715 - unsigned long at_time;
715 + timestamp_t at_time;
716 int cnt;
717 int reccnt;
718 unsigned char *sha1;
@@ -721,15 +721,15 @@ struct read_ref_at_cb {
721 unsigned char osha1[20];
722 unsigned char nsha1[20];
723 int tz;
724 - unsigned long date;
724 + timestamp_t date;
725 char **msg;
726 - unsigned long *cutoff_time;
726 + timestamp_t *cutoff_time;
727 int *cutoff_tz;
728 int *cutoff_cnt;
729 };
730
731 static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
732 - const char *email, unsigned long timestamp, int tz,
732 + const char *email, timestamp_t timestamp, int tz,
733 const char *message, void *cb_data)
734 {
735 struct read_ref_at_cb *cb = cb_data;
@@ -776,7 +776,7 @@ static int read_ref_at_ent(struct object_id *ooid, struct object_id *noid,
776 }
777
778 static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid,
779 - const char *email, unsigned long timestamp,
779 + const char *email, timestamp_t timestamp,
780 int tz, const char *message, void *cb_data)
781 {
782 struct read_ref_at_cb *cb = cb_data;
@@ -796,9 +796,9 @@ static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid
796 return 1;
797 }
798
799 -int read_ref_at(const char *refname, unsigned int flags, unsigned long at_time, int cnt,
799 +int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, int cnt,
800 unsigned char *sha1, char **msg,
801 - unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)
801 + timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt)
802 {
803 struct read_ref_at_cb cb;
804
refs.h
+4 -4
@@ -317,9 +317,9 @@ int safe_create_reflog(const char *refname, int force_create, struct strbuf *err
317
318 /** Reads log for the value of ref during at_time. **/
319 int read_ref_at(const char *refname, unsigned int flags,
320 - unsigned long at_time, int cnt,
320 + timestamp_t at_time, int cnt,
321 unsigned char *sha1, char **msg,
322 - unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt);
322 + timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt);
323
324 /** Check if a particular reflog exists */
325 int refs_reflog_exists(struct ref_store *refs, const char *refname);
@@ -356,7 +356,7 @@ int delete_reflog(const char *refname);
356 /* iterate over reflog entries */
357 typedef int each_reflog_ent_fn(
358 struct object_id *old_oid, struct object_id *new_oid,
359 - const char *committer, unsigned long timestamp,
359 + const char *committer, timestamp_t timestamp,
360 int tz, const char *msg, void *cb_data);
361
362 int refs_for_each_reflog_ent(struct ref_store *refs, const char *refname,
@@ -616,7 +616,7 @@ typedef void reflog_expiry_prepare_fn(const char *refname,
616 typedef int reflog_expiry_should_prune_fn(unsigned char *osha1,
617 unsigned char *nsha1,
618 const char *email,
619 - unsigned long timestamp, int tz,
619 + timestamp_t timestamp, int tz,
620 const char *message, void *cb_data);
621 typedef void reflog_expiry_cleanup_fn(void *cb_data);
622
refs/files-backend.c
+2 -2
@@ -3237,7 +3237,7 @@ static int show_one_reflog_ent(struct strbuf *sb, each_reflog_ent_fn fn, void *c
3237 {
3238 struct object_id ooid, noid;
3239 char *email_end, *message;
3240 - unsigned long timestamp;
3240 + timestamp_t timestamp;
3241 int tz;
3242 const char *p = sb->buf;
3243
@@ -4114,7 +4114,7 @@ struct expire_reflog_cb {
4114 };
4115
4116 static int expire_reflog_ent(struct object_id *ooid, struct object_id *noid,
4117 - const char *email, unsigned long timestamp, int tz,
4117 + const char *email, timestamp_t timestamp, int tz,
4118 const char *message, void *cb_data)
4119 {
4120 struct expire_reflog_cb *cb = cb_data;
revision.c
+3 -3
@@ -884,7 +884,7 @@ static void cherry_pick_list(struct commit_list *list, struct rev_info *revs)
884 /* How many extra uninteresting commits we want to see.. */
885 #define SLOP 5
886
887 -static int still_interesting(struct commit_list *src, unsigned long date, int slop,
887 +static int still_interesting(struct commit_list *src, timestamp_t date, int slop,
888 struct commit **interesting_cache)
889 {
890 /*
@@ -1018,7 +1018,7 @@ static void limit_left_right(struct commit_list *list, struct rev_info *revs)
1018 static int limit_list(struct rev_info *revs)
1019 {
1020 int slop = SLOP;
1021 - unsigned long date = ~0ul;
1021 + timestamp_t date = TIME_MAX;
1022 struct commit_list *list = revs->commits;
1023 struct commit_list *newlist = NULL;
1024 struct commit_list **p = &newlist;
@@ -1215,7 +1215,7 @@ static void handle_one_reflog_commit(struct object_id *oid, void *cb_data)
1215 }
1216
1217 static int handle_one_reflog_ent(struct object_id *ooid, struct object_id *noid,
1218 - const char *email, unsigned long timestamp, int tz,
1218 + const char *email, timestamp_t timestamp, int tz,
1219 const char *message, void *cb_data)
1220 {
1221 handle_one_reflog_commit(ooid, cb_data);
revision.h
+2 -2
@@ -181,8 +181,8 @@ struct rev_info {
181 /* special limits */
182 int skip_count;
183 int max_count;
184 - unsigned long max_age;
185 - unsigned long min_age;
184 + timestamp_t max_age;
185 + timestamp_t min_age;
186 int min_parents;
187 int max_parents;
188 int (*include_check)(struct commit *, void *);
sha1_name.c
+3 -3
@@ -660,8 +660,8 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1,
660
661 if (reflog_len) {
662 int nth, i;
663 - unsigned long at_time;
664 - unsigned long co_time;
663 + timestamp_t at_time;
664 + timestamp_t co_time;
665 int co_tz, co_cnt;
666
667 /* Is it asking for N-th entry, or approxidate? */
@@ -1054,7 +1054,7 @@ struct grab_nth_branch_switch_cbdata {
1054 };
1055
1056 static int grab_nth_branch_switch(struct object_id *ooid, struct object_id *noid,
1057 - const char *email, unsigned long timestamp, int tz,
1057 + const char *email, timestamp_t timestamp, int tz,
1058 const char *message, void *cb_data)
1059 {
1060 struct grab_nth_branch_switch_cbdata *cb = cb_data;
t/helper/test-date.c
+4 -4
@@ -27,7 +27,7 @@ static void show_dates(const char **argv, const char *format)
27 parse_date_format(format, &mode);
28 for (; *argv; argv++) {
29 char *arg;
30 - time_t t;
30 + timestamp_t t;
31 int tz;
32
33 /*
@@ -48,7 +48,7 @@ static void parse_dates(const char **argv, struct timeval *now)
48 struct strbuf result = STRBUF_INIT;
49
50 for (; *argv; argv++) {
51 - unsigned long t;
51 + timestamp_t t;
52 int tz;
53
54 strbuf_reset(&result);
@@ -65,7 +65,7 @@ static void parse_dates(const char **argv, struct timeval *now)
65 static void parse_approxidate(const char **argv, struct timeval *now)
66 {
67 for (; *argv; argv++) {
68 - time_t t;
68 + timestamp_t t;
69 t = approxidate_relative(*argv, now);
70 printf("%s -> %s\n", *argv, show_date(t, 0, DATE_MODE(ISO8601)));
71 }
@@ -96,7 +96,7 @@ int cmd_main(int argc, const char **argv)
96 else if (!strcmp(*argv, "approxidate"))
97 parse_approxidate(argv+1, &now);
98 else if (!strcmp(*argv, "is64bit"))
99 - return sizeof(unsigned long) == 8 ? 0 : 1;
99 + return sizeof(timestamp_t) == 8 ? 0 : 1;
100 else if (!strcmp(*argv, "time_t-is64bit"))
101 return sizeof(time_t) == 8 ? 0 : 1;
102 else
t/helper/test-parse-options.c
+1 -1
@@ -5,7 +5,7 @@
5 static int boolean = 0;
6 static int integer = 0;
7 static unsigned long magnitude = 0;
8 -static unsigned long timestamp;
8 +static timestamp_t timestamp;
9 static int abbrev = 7;
10 static int verbose = -1; /* unspecified */
11 static int dry_run = 0, quiet = 0;
t/helper/test-ref-store.c
+1 -1
@@ -138,7 +138,7 @@ static int cmd_for_each_reflog(struct ref_store *refs, const char **argv)
138 }
139
140 static int each_reflog(struct object_id *old_oid, struct object_id *new_oid,
141 - const char *committer, unsigned long timestamp,
141 + const char *committer, timestamp_t timestamp,
142 int tz, const char *msg, void *cb_data)
143 {
144 printf("%s %s %s %"PRItime" %d %s\n",
tag.c
+1 -1
@@ -97,7 +97,7 @@ struct tag *lookup_tag(const unsigned char *sha1)
97 return object_as_type(obj, OBJ_TAG, 0);
98 }
99
100 -static unsigned long parse_tag_date(const char *buf, const char *tail)
100 +static timestamp_t parse_tag_date(const char *buf, const char *tail)
101 {
102 const char *dateptr;
103
tag.h
+1 -1
@@ -9,7 +9,7 @@ struct tag {
9 struct object object;
10 struct object *tagged;
11 char *tag;
12 - unsigned long date;
12 + timestamp_t date;
13 };
14
15 extern struct tag *lookup_tag(const unsigned char *sha1);
upload-pack.c
+2 -2
@@ -35,7 +35,7 @@ static const char * const upload_pack_usage[] = {
35 #define CLIENT_SHALLOW (1u << 18)
36 #define HIDDEN_REF (1u << 19)
37
38 -static unsigned long oldest_have;
38 +static timestamp_t oldest_have;
39
40 static int deepen_relative;
41 static int multi_ack;
@@ -735,7 +735,7 @@ static void receive_needs(void)
735 struct string_list deepen_not = STRING_LIST_INIT_DUP;
736 int depth = 0;
737 int has_non_tip = 0;
738 - unsigned long deepen_since = 0;
738 + timestamp_t deepen_since = 0;
739 int deepen_rev_list = 0;
740
741 shallow_nr = 0;
vcs-svn/fast_export.c
+2 -2
@@ -68,7 +68,7 @@ void fast_export_modify(const char *path, uint32_t mode, const char *dataref)
68 }
69
70 void fast_export_begin_note(uint32_t revision, const char *author,
71 - const char *log, unsigned long timestamp, const char *note_ref)
71 + const char *log, timestamp_t timestamp, const char *note_ref)
72 {
73 static int firstnote = 1;
74 size_t loglen = strlen(log);
@@ -93,7 +93,7 @@ static char gitsvnline[MAX_GITSVN_LINE_LEN];
93 void fast_export_begin_commit(uint32_t revision, const char *author,
94 const struct strbuf *log,
95 const char *uuid, const char *url,
96 - unsigned long timestamp, const char *local_ref)
96 + timestamp_t timestamp, const char *local_ref)
97 {
98 static const struct strbuf empty = STRBUF_INIT;
99 if (!log)
vcs-svn/fast_export.h
+2 -2
@@ -11,10 +11,10 @@ void fast_export_delete(const char *path);
11 void fast_export_modify(const char *path, uint32_t mode, const char *dataref);
12 void fast_export_note(const char *committish, const char *dataref);
13 void fast_export_begin_note(uint32_t revision, const char *author,
14 - const char *log, unsigned long timestamp, const char *note_ref);
14 + const char *log, timestamp_t timestamp, const char *note_ref);
15 void fast_export_begin_commit(uint32_t revision, const char *author,
16 const struct strbuf *log, const char *uuid,const char *url,
17 - unsigned long timestamp, const char *local_ref);
17 + timestamp_t timestamp, const char *local_ref);
18 void fast_export_end_commit(uint32_t revision);
19 void fast_export_data(uint32_t mode, off_t len, struct line_buffer *input);
20 void fast_export_buf_to_data(const struct strbuf *data);
vcs-svn/svndump.c
+1 -1
@@ -47,7 +47,7 @@ static struct {
47
48 static struct {
49 uint32_t revision;
50 - unsigned long timestamp;
50 + timestamp_t timestamp;
51 struct strbuf log, author, note;
52 } rev_ctx;
53
wt-status.c
+1 -1
@@ -1387,7 +1387,7 @@ struct grab_1st_switch_cbdata {
1387 };
1388
1389 static int grab_1st_switch(struct object_id *ooid, struct object_id *noid,
1390 - const char *email, unsigned long timestamp, int tz,
1390 + const char *email, timestamp_t timestamp, int tz,
1391 const char *message, void *cb_data)
1392 {
1393 struct grab_1st_switch_cbdata *cb = cb_data;