{"thread":{"id":"17336","subject":"[PATCH] Use time_t for timestamps returned by approxidate() instead of unsigned","startedAt":"2009-01-22T23:07:02Z","lastAt":"2009-01-24T17:32:14Z","messageCount":8,"participants":["Tim Henigan","Markus Heidelberg","Johannes Schindelin","Wincent Colaiuta"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"101726","messageId":"1232665622-5110-1-git-send-email-tim.henigan@gmail.com","threadId":"17336","inReplyTo":null,"subject":"[PATCH] Use time_t for timestamps returned by approxidate() instead of unsigned","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2009-01-22T23:07:02Z","receivedAt":"2009-01-22T23:07:02Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"Use time_t for timestamps returned by approxidate() instead of unsigned\nlong.  All references to approxidate were checked as well as references\nto OPT_DATE.\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n\nThis is the first patch I have submitted, so please be brutal in your review so that I may learn ;).\n\nThis patch is intended to close one of the \"Janitor\" tasks listed in the GitWiki.  The change from unsigned long to time_t reached further than I originally anticipated as I looked into all the places where timestamps are used.  Please let me know if I should limit the scope of the changes to only the immediate consumers of values returned by approxidate().\n\nThere is at least one place in the code (builtin-for-each-ref.c:370) where what looks like a timestamp is compared against ULONG_MAX.  At first glance this sounds like a bad idea, but within the context of that function (grab_date) it appears to be safe.\n\n-Tim\n\n Documentation/technical/api-parse-options.txt |    4 ++--\n builtin-gc.c                                  |    2 +-\n builtin-prune.c                               |    2 +-\n builtin-reflog.c                              |    4 ++--\n builtin-show-branch.c                         |    2 +-\n cache.h                                       |    2 +-\n date.c                                        |    2 +-\n parse-options.c                               |    2 +-\n reflog-walk.c                                 |    4 ++--\n refs.c                                        |    2 +-\n refs.h                                        |    2 +-\n revision.h                                    |    4 ++--\n sha1_name.c                                   |    2 +-\n test-parse-options.c                          |    2 +-\n 14 files changed, 18 insertions(+), 18 deletions(-)\n mode change 100644 => 100755 builtin-gc.c\n mode change 100644 => 100755 builtin-reflog.c\n mode change 100644 => 100755 builtin-show-branch.c\n mode change 100644 => 100755 cache.h\n mode change 100644 => 100755 date.c\n mode change 100644 => 100755 parse-options.c\n mode change 100644 => 100755 reflog-walk.c\n mode change 100644 => 100755 refs.c\n mode change 100644 => 100755 refs.h\n mode change 100644 => 100755 revision.c\n mode change 100644 => 100755 revision.h\n mode change 100644 => 100755 sha1_name.c\n\ndiff --git a/Documentation/technical/api-parse-options.txt b/Documentation/technical/api-parse-options.txt\nindex 539863b..c1dd29d 100644\n--- a/Documentation/technical/api-parse-options.txt\n+++ b/Documentation/technical/api-parse-options.txt\n@@ -125,9 +125,9 @@ There are some macros to easily define options:\n \tIntroduce an option with integer argument.\n \tThe integer is put into `int_var`.\n \n-`OPT_DATE(short, long, &int_var, description)`::\n+`OPT_DATE(short, long, &time_var, description)`::\n \tIntroduce an option with date argument, see `approxidate()`.\n-\tThe timestamp is put into `int_var`.\n+\tThe timestamp is put into `time_var`.\n \n `OPT_CALLBACK(short, long, &var, arg_str, description, func_ptr)`::\n \tIntroduce an option with argument.\ndiff --git a/builtin-gc.c b/builtin-gc.c\nold mode 100644\nnew mode 100755\nindex a201438..eea891b\n--- a/builtin-gc.c\n+++ b/builtin-gc.c\n@@ -58,7 +58,7 @@ static int gc_config(const char *var, const char *value, void *cb)\n \t}\n \tif (!strcmp(var, \"gc.pruneexpire\")) {\n \t\tif (value && strcmp(value, \"now\")) {\n-\t\t\tunsigned long now = approxidate(\"now\");\n+\t\t\ttime_t now = approxidate(\"now\");\n \t\t\tif (approxidate(value) >= now)\n \t\t\t\treturn error(\"Invalid %s: '%s'\", var, value);\n \t\t}\ndiff --git a/builtin-prune.c b/builtin-prune.c\nindex 545e9c1..a0f1a63 100644\n--- a/builtin-prune.c\n+++ b/builtin-prune.c\n@@ -13,7 +13,7 @@ static const char * const prune_usage[] = {\n };\n static int show_only;\n static int verbose;\n-static unsigned long expire;\n+static time_t expire;\n \n static int prune_tmp_object(const char *path, const char *filename)\n {\ndiff --git a/builtin-reflog.c b/builtin-reflog.c\nold mode 100644\nnew mode 100755\nindex d95f515..bae0c3e\n--- a/builtin-reflog.c\n+++ b/builtin-reflog.c\n@@ -361,7 +361,7 @@ static struct reflog_expire_cfg *find_cfg_ent(const char *pattern, size_t len)\n \treturn ent;\n }\n \n-static int parse_expire_cfg_value(const char *var, const char *value, unsigned long *expire)\n+static int parse_expire_cfg_value(const char *var, const char *value, time_t *expire)\n {\n \tif (!value)\n \t\treturn config_error_nonbool(var);\n@@ -380,7 +380,7 @@ static int parse_expire_cfg_value(const char *var, const char *value, unsigned l\n static int reflog_expire_config(const char *var, const char *value, void *cb)\n {\n \tconst char *lastdot = strrchr(var, '.');\n-\tunsigned long expire;\n+\ttime_t expire;\n \tint slot;\n \tstruct reflog_expire_cfg *ent;\n \ndiff --git a/builtin-show-branch.c b/builtin-show-branch.c\nold mode 100644\nnew mode 100755\nindex 306b850..695d553\n--- a/builtin-show-branch.c\n+++ b/builtin-show-branch.c\n@@ -716,7 +716,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\t\tbase = strtoul(reflog_base, &ep, 10);\n \t\t\tif (*ep) {\n \t\t\t\t/* Ah, that is a date spec... */\n-\t\t\t\tunsigned long at;\n+\t\t\t\ttime_t at;\n \t\t\t\tat = approxidate(reflog_base);\n \t\t\t\tread_ref_at(ref, at, -1, sha1, NULL,\n \t\t\t\t\t    NULL, NULL, &base);\ndiff --git a/cache.h b/cache.h\nold mode 100644\nnew mode 100755\nindex 8d965b8..397adf1\n--- a/cache.h\n+++ b/cache.h\n@@ -699,7 +699,7 @@ enum date_mode {\n const char *show_date(unsigned long time, int timezone, enum date_mode mode);\n int parse_date(const char *date, char *buf, int bufsize);\n void datestamp(char *buf, int bufsize);\n-unsigned long approxidate(const char *);\n+time_t approxidate(const char *);\n enum date_mode parse_date_format(const char *format);\n \n #define IDENT_WARN_ON_NO_NAME  1\ndiff --git a/date.c b/date.c\nold mode 100644\nnew mode 100755\nindex 950b88f..5971266\n--- a/date.c\n+++ b/date.c\n@@ -841,7 +841,7 @@ static const char *approxidate_digit(const char *date, struct tm *tm, int *num)\n \treturn end;\n }\n \n-unsigned long approxidate(const char *date)\n+time_t approxidate(const char *date)\n {\n \tint number = 0;\n \tstruct tm tm, now;\ndiff --git a/parse-options.c b/parse-options.c\nold mode 100644\nnew mode 100755\nindex 9eb55cc..0501ee2\n--- a/parse-options.c\n+++ b/parse-options.c\n@@ -480,7 +480,7 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)\n int parse_opt_approxidate_cb(const struct option *opt, const char *arg,\n \t\t\t     int unset)\n {\n-\t*(unsigned long *)(opt->value) = approxidate(arg);\n+\t*(time_t *)(opt->value) = approxidate(arg);\n \treturn 0;\n }\n \ndiff --git a/reflog-walk.c b/reflog-walk.c\nold mode 100644\nnew mode 100755\nindex f751fdc..73b4932\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -68,7 +68,7 @@ static struct complete_reflogs *read_complete_reflog(const char *ref)\n }\n \n static int get_reflog_recno_by_time(struct complete_reflogs *array,\n-\tunsigned long timestamp)\n+\ttime_t timestamp)\n {\n \tint i;\n \tfor (i = array->nr - 1; i >= 0; i--)\n@@ -139,7 +139,7 @@ void init_reflog_walk(struct reflog_walk_info** info)\n int add_reflog_for_walk(struct reflog_walk_info *info,\n \t\tstruct commit *commit, const char *name)\n {\n-\tunsigned long timestamp = 0;\n+\ttime_t timestamp = 0;\n \tint recno = -1;\n \tstruct string_list_item *item;\n \tstruct complete_reflogs *reflogs;\ndiff --git a/refs.c b/refs.c\nold mode 100644\nnew mode 100755\nindex 33ced65..63327b8\n--- a/refs.c\n+++ b/refs.c\n@@ -1347,7 +1347,7 @@ static char *ref_msg(const char *line, const char *endp)\n \treturn xmemdupz(line, ep - line);\n }\n \n-int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)\n+int read_ref_at(const char *ref, time_t at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)\n {\n \tconst char *logfile, *logdata, *logend, *rec, *lastgt, *lastrec;\n \tchar *tz_c;\ndiff --git a/refs.h b/refs.h\nold mode 100644\nnew mode 100755\nindex 06ad260..262728c\n--- a/refs.h\n+++ b/refs.h\n@@ -55,7 +55,7 @@ extern void unlock_ref(struct ref_lock *lock);\n extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, const char *msg);\n \n /** Reads log for the value of ref during at_time. **/\n-extern int read_ref_at(const char *ref, unsigned long at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt);\n+extern int read_ref_at(const char *ref, time_t at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt);\n \n /* iterate over reflog entries */\n typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, const char *, unsigned long, int, const char *, void *);\ndiff --git a/revision.c b/revision.c\nold mode 100644\nnew mode 100755\ndiff --git a/revision.h b/revision.h\nold mode 100644\nnew mode 100755\nindex 7cf8487..660607b\n--- a/revision.h\n+++ b/revision.h\n@@ -106,8 +106,8 @@ struct rev_info {\n \t/* special limits */\n \tint skip_count;\n \tint max_count;\n-\tunsigned long max_age;\n-\tunsigned long min_age;\n+\ttime_t max_age;\n+\ttime_t min_age;\n \n \t/* diff info for patches and for paths limiting */\n \tstruct diff_options diffopt;\ndiff --git a/sha1_name.c b/sha1_name.c\nold mode 100644\nnew mode 100755\nindex 159c2ab..fe915c8\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -339,7 +339,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)\n \n \tif (reflog_len) {\n \t\tint nth, i;\n-\t\tunsigned long at_time;\n+\t\ttime_t at_time;\n \t\tunsigned long co_time;\n \t\tint co_tz, co_cnt;\n \ndiff --git a/test-parse-options.c b/test-parse-options.c\nindex 61d2c39..c8d110d 100644\n--- a/test-parse-options.c\n+++ b/test-parse-options.c\n@@ -3,7 +3,7 @@\n \n static int boolean = 0;\n static int integer = 0;\n-static unsigned long timestamp;\n+static time_t timestamp;\n static int abbrev = 7;\n static int verbose = 0, dry_run = 0, quiet = 0;\n static char *string = NULL;\n-- \n1.6.0.6\n\n\n>From 22354d185e5c89a5b492898b9b5eba429fed85d3 Mon Sep 17 00:00:00 2001\nFrom: Tim Henigan <tim.henigan@gmail.com>\nDate: Thu, 22 Jan 2009 16:08:42 -0500\nSubject: [PATCH] Further changes to migrate timestamp vars in the code from type unsigned long to time_t.\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n builtin-cat-file.c    |    2 +-\n builtin-reflog.c      |   18 +++++++++---------\n builtin-show-branch.c |    2 +-\n date.c                |    4 ++--\n refs.c                |    6 +++---\n refs.h                |    2 +-\n sha1_name.c           |    2 +-\n 7 files changed, 18 insertions(+), 18 deletions(-)\n\ndiff --git a/builtin-cat-file.c b/builtin-cat-file.c\nindex 8fad19d..1d7a361 100644\n--- a/builtin-cat-file.c\n+++ b/builtin-cat-file.c\n@@ -42,7 +42,7 @@ static void pprint_tag(const unsigned char *sha1, const char *buf, unsigned long\n \t\t\t\t\t */\n \t\t\t\t\tconst char *sp = tagger;\n \t\t\t\t\tchar *ep;\n-\t\t\t\t\tunsigned long date;\n+\t\t\t\t\ttime_t date;\n \t\t\t\t\tlong tz;\n \t\t\t\t\twhile (sp < cp && *sp != '>')\n \t\t\t\t\t\tsp++;\ndiff --git a/builtin-reflog.c b/builtin-reflog.c\nindex bae0c3e..74284af 100755\n--- a/builtin-reflog.c\n+++ b/builtin-reflog.c\n@@ -17,8 +17,8 @@ static const char reflog_expire_usage[] =\n static const char reflog_delete_usage[] =\n \"git reflog delete [--verbose] [--dry-run] [--rewrite] [--updateref] <refs>...\";\n \n-static unsigned long default_reflog_expire;\n-static unsigned long default_reflog_expire_unreachable;\n+static time_t default_reflog_expire;\n+static time_t default_reflog_expire_unreachable;\n \n struct cmd_reflog_expire_cb {\n \tstruct rev_info revs;\n@@ -27,8 +27,8 @@ struct cmd_reflog_expire_cb {\n \tint rewrite;\n \tint updateref;\n \tint verbose;\n-\tunsigned long expire_total;\n-\tunsigned long expire_unreachable;\n+\ttime_t expire_total;\n+\ttime_t expire_unreachable;\n \tint recno;\n };\n \n@@ -210,7 +210,7 @@ static int keep_entry(struct commit **it, unsigned char *sha1)\n }\n \n static int expire_reflog_ent(unsigned char *osha1, unsigned char *nsha1,\n-\t\tconst char *email, unsigned long timestamp, int tz,\n+\t\tconst char *email, time_t timestamp, int tz,\n \t\tconst char *message, void *cb_data)\n {\n \tstruct expire_reflog_cb *cb = cb_data;\n@@ -335,8 +335,8 @@ static int collect_reflog(const char *ref, const unsigned char *sha1, int unused\n \n static struct reflog_expire_cfg {\n \tstruct reflog_expire_cfg *next;\n-\tunsigned long expire_total;\n-\tunsigned long expire_unreachable;\n+\ttime_t expire_total;\n+\ttime_t expire_unreachable;\n \tsize_t len;\n \tchar pattern[FLEX_ARRAY];\n } *reflog_expire_cfg, **reflog_expire_cfg_tail;\n@@ -462,7 +462,7 @@ static void set_reflog_expiry_param(struct cmd_reflog_expire_cb *cb, int slot, c\n static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n {\n \tstruct cmd_reflog_expire_cb cb;\n-\tunsigned long now = time(NULL);\n+\ttime_t now = time(NULL);\n \tint i, status, do_all;\n \tint explicit_expiry = 0;\n \n@@ -554,7 +554,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)\n }\n \n static int count_reflog_ent(unsigned char *osha1, unsigned char *nsha1,\n-\t\tconst char *email, unsigned long timestamp, int tz,\n+\t\tconst char *email, time_t timestamp, int tz,\n \t\tconst char *message, void *cb_data)\n {\n \tstruct cmd_reflog_expire_cb *cb = cb_data;\ndiff --git a/builtin-show-branch.c b/builtin-show-branch.c\nindex 695d553..73b3dc0 100755\n--- a/builtin-show-branch.c\n+++ b/builtin-show-branch.c\n@@ -726,7 +726,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)\n \t\tfor (i = 0; i < reflog; i++) {\n \t\t\tchar *logmsg, *m;\n \t\t\tconst char *msg;\n-\t\t\tunsigned long timestamp;\n+\t\t\ttime_t timestamp;\n \t\t\tint tz;\n \n \t\t\tif (read_ref_at(ref, 0, base+i, sha1, &logmsg,\ndiff --git a/date.c b/date.c\nindex 5971266..d185ea6 100755\n--- a/date.c\n+++ b/date.c\n@@ -84,13 +84,13 @@ static int local_tzoffset(unsigned long time)\n \treturn offset * eastwest;\n }\n \n-const char *show_date(unsigned long time, int tz, enum date_mode mode)\n+const char *show_date(time_t time, int tz, enum date_mode mode)\n {\n \tstruct tm *tm;\n \tstatic char timebuf[200];\n \n \tif (mode == DATE_RELATIVE) {\n-\t\tunsigned long diff;\n+\t\ttime_t diff;\n \t\tstruct timeval now;\n \t\tgettimeofday(&now, NULL);\n \t\tif (now.tv_sec < time)\ndiff --git a/refs.c b/refs.c\nindex 63327b8..159d136 100755\n--- a/refs.c\n+++ b/refs.c\n@@ -1347,13 +1347,13 @@ static char *ref_msg(const char *line, const char *endp)\n \treturn xmemdupz(line, ep - line);\n }\n \n-int read_ref_at(const char *ref, time_t at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt)\n+int read_ref_at(const char *ref, time_t at_time, int cnt, unsigned char *sha1, char **msg, time_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt)\n {\n \tconst char *logfile, *logdata, *logend, *rec, *lastgt, *lastrec;\n \tchar *tz_c;\n \tint logfd, tz, reccnt = 0;\n \tstruct stat st;\n-\tunsigned long date;\n+\ttime_t date;\n \tunsigned char logged_sha1[20];\n \tvoid *log_mapped;\n \tsize_t mapsz;\n@@ -1467,7 +1467,7 @@ int for_each_reflog_ent(const char *ref, each_reflog_ent_fn fn, void *cb_data)\n \twhile (fgets(buf, sizeof(buf), logfp)) {\n \t\tunsigned char osha1[20], nsha1[20];\n \t\tchar *email_end, *message;\n-\t\tunsigned long timestamp;\n+\t\ttime_t timestamp;\n \t\tint len, tz;\n \n \t\t/* old SP new SP name <email> SP time TAB msg LF */\ndiff --git a/refs.h b/refs.h\nindex 262728c..604d5a3 100755\n--- a/refs.h\n+++ b/refs.h\n@@ -55,7 +55,7 @@ extern void unlock_ref(struct ref_lock *lock);\n extern int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1, const char *msg);\n \n /** Reads log for the value of ref during at_time. **/\n-extern int read_ref_at(const char *ref, time_t at_time, int cnt, unsigned char *sha1, char **msg, unsigned long *cutoff_time, int *cutoff_tz, int *cutoff_cnt);\n+extern int read_ref_at(const char *ref, time_t at_time, int cnt, unsigned char *sha1, char **msg, time_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt);\n \n /* iterate over reflog entries */\n typedef int each_reflog_ent_fn(unsigned char *osha1, unsigned char *nsha1, const char *, unsigned long, int, const char *, void *);\ndiff --git a/sha1_name.c b/sha1_name.c\nindex fe915c8..8a65def 100755\n--- a/sha1_name.c\n+++ b/sha1_name.c\n@@ -340,7 +340,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)\n \tif (reflog_len) {\n \t\tint nth, i;\n \t\ttime_t at_time;\n-\t\tunsigned long co_time;\n+\t\ttime_t co_time;\n \t\tint co_tz, co_cnt;\n \n \t\t/* Is it asking for N-th entry, or approxidate? */\n-- \n1.6.0.6\n\n\n>From 7fb1e3d6390d46433e7ce10841bf11cab3b1d0ff Mon Sep 17 00:00:00 2001\nFrom: Tim Henigan <tim.henigan@gmail.com>\nDate: Thu, 22 Jan 2009 17:08:06 -0500\nSubject: [PATCH] Final changes to convert unsigned longs to time_t\n\nSigned-off-by: Tim Henigan <tim.henigan@gmail.com>\n---\n cache.h       |    2 +-\n date.c        |    8 ++++----\n pretty.c      |    4 ++--\n reflog-walk.c |    2 +-\n 4 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 397adf1..a18730c 100755\n--- a/cache.h\n+++ b/cache.h\n@@ -696,7 +696,7 @@ enum date_mode {\n \tDATE_RFC2822\n };\n \n-const char *show_date(unsigned long time, int timezone, enum date_mode mode);\n+const char *show_date(time_t time, int timezone, enum date_mode mode);\n int parse_date(const char *date, char *buf, int bufsize);\n void datestamp(char *buf, int bufsize);\n time_t approxidate(const char *);\ndiff --git a/date.c b/date.c\nindex d185ea6..59b4426 100755\n--- a/date.c\n+++ b/date.c\n@@ -37,7 +37,7 @@ static const char *weekday_names[] = {\n \t\"Sundays\", \"Mondays\", \"Tuesdays\", \"Wednesdays\", \"Thursdays\", \"Fridays\", \"Saturdays\"\n };\n \n-static time_t gm_time_t(unsigned long time, int tz)\n+static time_t gm_time_t(time_t time, int tz)\n {\n \tint minutes;\n \n@@ -52,7 +52,7 @@ static time_t gm_time_t(unsigned long time, int tz)\n  * thing, which means that tz -0100 is passed in as the integer -100,\n  * even though it means \"sixty minutes off\"\n  */\n-static struct tm *time_to_tm(unsigned long time, int tz)\n+static struct tm *time_to_tm(time_t time, int tz)\n {\n \ttime_t t = gm_time_t(time, tz);\n \treturn gmtime(&t);\n@@ -62,7 +62,7 @@ static struct tm *time_to_tm(unsigned long time, int tz)\n  * What value of \"tz\" was in effect back then at \"time\" in the\n  * local timezone?\n  */\n-static int local_tzoffset(unsigned long time)\n+static int local_tzoffset(time_t time)\n {\n \ttime_t t, t_local;\n \tstruct tm tm;\n@@ -632,7 +632,7 @@ void datestamp(char *buf, int bufsize)\n \tdate_string(now, offset, buf, bufsize);\n }\n \n-static void update_tm(struct tm *tm, unsigned long sec)\n+static void update_tm(struct tm *tm, time_t sec)\n {\n \ttime_t n = mktime(tm) - sec;\n \tlocaltime_r(&n, tm);\ndiff --git a/pretty.c b/pretty.c\nindex cc460b5..6ab3222 100644\n--- a/pretty.c\n+++ b/pretty.c\n@@ -126,7 +126,7 @@ void pp_user_info(const char *what, enum cmit_fmt fmt, struct strbuf *sb,\n {\n \tchar *date;\n \tint namelen;\n-\tunsigned long time;\n+\ttime_t time;\n \tint tz;\n \tconst char *filler = \"    \";\n \n@@ -330,7 +330,7 @@ static size_t format_person_part(struct strbuf *sb, char part,\n \t/* currently all placeholders have same length */\n \tconst int placeholder_len = 2;\n \tint start, end, tz = 0;\n-\tunsigned long date = 0;\n+\ttime_t date = 0;\n \tchar *ep;\n \n \t/* advance 'end' to point to email start delimiter */\ndiff --git a/reflog-walk.c b/reflog-walk.c\nindex 73b4932..1bc9675 100755\n--- a/reflog-walk.c\n+++ b/reflog-walk.c\n@@ -11,7 +11,7 @@ struct complete_reflogs {\n \tstruct reflog_info {\n \t\tunsigned char osha1[20], nsha1[20];\n \t\tchar *email;\n-\t\tunsigned long timestamp;\n+\t\ttime_t timestamp;\n \t\tint tz;\n \t\tchar *message;\n \t} *items;\n-- \n1.6.0.6\n"},{"id":"101730","messageId":"200901240622.59069.markus.heidelberg@web.de","threadId":"17336","inReplyTo":"1232665622-5110-1-git-send-email-tim.henigan@gmail.com","subject":"Re: [PATCH] Use time_t for timestamps returned by approxidate() instead of unsigned","fromName":"Markus Heidelberg","fromEmail":"markus.heidelberg@web.de","sentAt":"2009-01-24T05:22:58Z","receivedAt":"2009-01-24T05:22:58Z","isPatch":true,"sender":{"key":"markus.heidelberg@web.de","avatar":"https://avatars.githubusercontent.com/u/6334512?v=4"},"body":"Tim Henigan, 23.01.2009:\n> Signed-off-by: Tim Henigan <tim.henigan@gmail.com>\n> ---\n>  mode change 100644 => 100755 builtin-gc.c\n>  mode change 100644 => 100755 builtin-reflog.c\n>  mode change 100644 => 100755 builtin-show-branch.c\n>  mode change 100644 => 100755 cache.h\n>  mode change 100644 => 100755 date.c\n>  mode change 100644 => 100755 parse-options.c\n>  mode change 100644 => 100755 reflog-walk.c\n>  mode change 100644 => 100755 refs.c\n>  mode change 100644 => 100755 refs.h\n>  mode change 100644 => 100755 revision.c\n>  mode change 100644 => 100755 revision.h\n>  mode change 100644 => 100755 sha1_name.c\n\nOops\n"},{"id":"101731","messageId":"alpine.DEB.1.00.0901240726070.13232@racer","threadId":"17336","inReplyTo":"1232665622-5110-1-git-send-email-tim.henigan@gmail.com","subject":"Re: [PATCH] Use time_t for timestamps returned by approxidate() instead of unsigned","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-24T06:27:00Z","receivedAt":"2009-01-24T06:27:00Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 22 Jan 2009, Tim Henigan wrote:\n\n> Use time_t for timestamps returned by approxidate() instead of unsigned \n> long.  All references to approxidate were checked as well as references \n> to OPT_DATE.\n\nHmm.  I vaguely remember Linus mentioning recently that unsigned long is \nthe appropriate data type for the Unix Epoch...\n\nCiao,\nDscho\n"},{"id":"101747","messageId":"32c343770901240813k2eeb19b0q65b533f829cb44d4@mail.gmail.com","threadId":"17336","inReplyTo":"alpine.DEB.1.00.0901240726070.13232@racer","subject":"Re: [PATCH] Use time_t for timestamps returned by approxidate() instead of unsigned","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2009-01-24T16:13:18Z","receivedAt":"2009-01-24T16:13:18Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"On Sat, Jan 24, 2009 at 1:27 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>\n> Hi,\n>\n> On Thu, 22 Jan 2009, Tim Henigan wrote:\n>\n> > Use time_t for timestamps returned by approxidate() instead of unsigned\n> > long.  All references to approxidate were checked as well as references\n> > to OPT_DATE.\n>\n> Hmm.  I vaguely remember Linus mentioning recently that unsigned long is\n> the appropriate data type for the Unix Epoch...\n\nYou are correct. I just found a post on this list where Linus\nspecifically rejected a similar patch from another contributor.  A\nquote from https://kerneltrap.org/mailarchive/git/2008/11/6/4014124:\n\n    \" \"time_t\" is one of those totally broken unix types. The\nstandards say that\n    it's an \"arithmetic\" type, but leaves it open to be just about anything.\n    Traditionally, it's a signed integer (bad), and in theory it could even be\n    a floating point value, I think.\n\n    And in _all_ such cases, it's actually better to cast it to \"unsigned\n    long\" than keep time in a system-dependent format that is most likely\n    either _already_ \"unsigned long\", or alternatively broken.\"\n\nShould I update the GitWiki page to remove this Janitor task or do you\nkeep it as a test to see if people are properly searching the mail\narchives?\n\nSorry to waste your time on the patch review.\n\nThanks,\nTim\n"},{"id":"101749","messageId":"643EB4C4-D3A9-41B9-AE1B-00D71B4CA9F9@wincent.com","threadId":"17336","inReplyTo":"32c343770901240813k2eeb19b0q65b533f829cb44d4@mail.gmail.com","subject":"Re: [PATCH] Use time_t for timestamps returned by approxidate() instead of unsigned","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2009-01-24T16:37:09Z","receivedAt":"2009-01-24T16:37:09Z","isPatch":true,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 24/1/2009, a las 17:13, Tim Henigan escribió:\n\n> Should I update the GitWiki page to remove this Janitor task or do you\n> keep it as a test to see if people are properly searching the mail\n> archives?\n\nI don't know of too many projects which intentionally publish  \nmisleading information to \"test\" would-be contributors. I think  \nediting the wiki would be a good idea.\n\nCheers,\nWincent\n"},{"id":"101750","messageId":"alpine.DEB.1.00.0901241757140.13232@racer","threadId":"17336","inReplyTo":"32c343770901240813k2eeb19b0q65b533f829cb44d4@mail.gmail.com","subject":"Re: [PATCH] Use time_t for timestamps returned by approxidate() instead of unsigned","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-24T16:58:08Z","receivedAt":"2009-01-24T16:58:08Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 24 Jan 2009, Tim Henigan wrote:\n\n> On Sat, Jan 24, 2009 at 1:27 AM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n> >\n> > On Thu, 22 Jan 2009, Tim Henigan wrote:\n> >\n> > > Use time_t for timestamps returned by approxidate() instead of \n> > > unsigned long.  All references to approxidate were checked as well \n> > > as references to OPT_DATE.\n> >\n> > Hmm.  I vaguely remember Linus mentioning recently that unsigned long \n> > is the appropriate data type for the Unix Epoch...\n> \n> You are correct. I just found a post on this list where Linus \n> specifically rejected a similar patch from another contributor.  A quote \n> from https://kerneltrap.org/mailarchive/git/2008/11/6/4014124:\n> \n>     \" \"time_t\" is one of those totally broken unix types. The standards \n>     say that it's an \"arithmetic\" type, but leaves it open to be just \n>     about anything. Traditionally, it's a signed integer (bad), and in \n>     theory it could even be a floating point value, I think.\n> \n>     And in _all_ such cases, it's actually better to cast it to \n>     \"unsigned long\" than keep time in a system-dependent format that is \n>     most likely either _already_ \"unsigned long\", or alternatively \n>     broken.\"\n\nThanks.  I should have searched that post myself, but I was too tired...\n\n> Should I update the GitWiki page to remove this Janitor task or do you\n> keep it as a test to see if people are properly searching the mail\n> archives?\n\nYes, please!\n\n> Sorry to waste your time on the patch review.\n\nSorry that we wasted your time by letting that page go stale...\n\nCiao,\nDscho\n"},{"id":"101752","messageId":"32c343770901240914n3fc76fe0vbe844e50cbc0bbf@mail.gmail.com","threadId":"17336","inReplyTo":"alpine.DEB.1.00.0901241757140.13232@racer","subject":"Re: [PATCH] Use time_t for timestamps returned by approxidate() instead of unsigned","fromName":"Tim Henigan","fromEmail":"tim.henigan@gmail.com","sentAt":"2009-01-24T17:14:47Z","receivedAt":"2009-01-24T17:14:47Z","isPatch":true,"sender":{"key":"tim.henigan@gmail.com","avatar":"https://avatars.githubusercontent.com/u/42022?v=4"},"body":"On Sat, Jan 24, 2009 at 11:58 AM, Johannes Schindelin\n<Johannes.Schindelin@gmx.de> wrote:\n>> Should I update the GitWiki page to remove this Janitor task or do you\n>> keep it as a test to see if people are properly searching the mail\n>> archives?\n>\n> Yes, please!\n\nI did some more digging and found this last comment on the subject by Linus:\nhttps://kerneltrap.org/mailarchive/git/2008/11/6/4014344\n\nGiven this, should the janitor task simply be deleted (since using\nunsigned longs are safe until year 2038 is considered) or should it be\nupdated to change all timestamps to 64-bit values?\n\nAlso, there are still ~37 references to time_t in the code (e.g. the\nindex_state struct in cache.h).  Should these be phased out in favor\nof unsigned longs (or perhaps 64-bit types)?\n\nPerhaps the Janitor task should be changed to do this so that all the\ncode handles timestamps consistently?  (btw, I will volunteer to do\nthis if desired).\n\nThanks,\nTim\n"},{"id":"101753","messageId":"alpine.DEB.1.00.0901241829210.13232@racer","threadId":"17336","inReplyTo":"32c343770901240914n3fc76fe0vbe844e50cbc0bbf@mail.gmail.com","subject":"Re: [PATCH] Use time_t for timestamps returned by approxidate() instead of unsigned","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-01-24T17:32:14Z","receivedAt":"2009-01-24T17:32:14Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 24 Jan 2009, Tim Henigan wrote:\n\n> On Sat, Jan 24, 2009 at 11:58 AM, Johannes Schindelin\n> <Johannes.Schindelin@gmx.de> wrote:\n>\n> >> Should I update the GitWiki page to remove this Janitor task or do \n> >> you keep it as a test to see if people are properly searching the \n> >> mail archives?\n> >\n> > Yes, please!\n> \n> I did some more digging and found this last comment on the subject by \n> Linus: https://kerneltrap.org/mailarchive/git/2008/11/6/4014344\n> \n> Given this, should the janitor task simply be deleted (since using \n> unsigned longs are safe until year 2038 is considered) or should it be \n> updated to change all timestamps to 64-bit values?\n> \n> Also, there are still ~37 references to time_t in the code (e.g. the \n> index_state struct in cache.h).  Should these be phased out in favor of \n> unsigned longs (or perhaps 64-bit types)?\n\nCorrect me if I am wrong: there are two different uses of times.  One to \noutput dates (which is where we use unsigned long), and one where we \ncompare dates in file stats (where we use time_t).\n\nI haven't looked at the code, though, so this might be incorrect.\n\nIf it is correct, though, I think that we should stay with time_t for the \ncases where we have to compare to time_t anyway (as the stat() calls give \nus the time in that datatype).\n\nBTW the Janitor task was added by Pasky, so he should say something.  \nPasky?\n\nCiao,\nDscho\n"}]}