{"thread":{"id":"16201","subject":"[PATCH 2/4] Changed timestamps to time_t in header files","startedAt":"2008-11-06T17:48:44Z","lastAt":"2008-11-06T21:04:27Z","messageCount":9,"participants":["david@statichacks.org","Linus Torvalds","David Bryson","Daniel Stenberg"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"95070","messageId":"1225993728-4779-1-git-send-email-david@statichacks.org","threadId":"16201","inReplyTo":null,"subject":"[PATCH 0/4] replace unsinged long with time_t","fromName":"","fromEmail":"david@statichacks.org","sentAt":"2008-11-06T17:48:44Z","receivedAt":"2008-11-06T17:48:44Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"From: David Bryson <david@statichacks.org>\n\nHere is a patch set from the Janitor page to replace unsigned long with time_t.\nSince it overlaps slightly with a patch I made previously, I wrote this to\napply to next.  Comments welcome.\n\nDavid Bryson (4):\n  Changed timestamps to time_t instead of unsigned\n  Changed timestamps to time_t in header files\n  Changed timestamps to time_t instead of unsigned long for\n    approxidate()\n  Changed timestamps to time_t\n\n builtin-gc.c          |    2 +-\n builtin-prune.c       |    2 +-\n builtin-reflog.c      |   14 +++++++-------\n builtin-show-branch.c |    4 ++--\n cache.h               |    2 +-\n parse-options.c       |    2 +-\n refs.h                |    2 +-\n revision.h            |    4 ++--\n 8 files changed, 16 insertions(+), 16 deletions(-)\n"},{"id":"95071","messageId":"1225993728-4779-2-git-send-email-david@statichacks.org","threadId":"16201","inReplyTo":"1225993728-4779-1-git-send-email-david@statichacks.org","subject":"[PATCH 1/4] Changed timestamps to time_t instead of unsigned","fromName":"","fromEmail":"david@statichacks.org","sentAt":"2008-11-06T17:48:45Z","receivedAt":"2008-11-06T17:48:45Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"From: David Bryson <david@statichacks.org>\n\n---\n builtin-prune.c       |    2 +-\n builtin-reflog.c      |    8 ++++----\n builtin-show-branch.c |    4 ++--\n parse-options.c       |    2 +-\n 4 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin-prune.c b/builtin-prune.c\nindex 7b4ec80..e1d46f0 100644\n--- a/builtin-prune.c\n+++ b/builtin-prune.c\n@@ -12,7 +12,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\nindex 6b3667e..fdf78a9 100644\n--- a/builtin-reflog.c\n+++ b/builtin-reflog.c\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@@ -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\nindex 306b850..73b3dc0 100644\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);\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/parse-options.c b/parse-options.c\nindex fd08bb4..4581b50 100644\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 \n-- \n1.6.0.1\n"},{"id":"95067","messageId":"1225993728-4779-3-git-send-email-david@statichacks.org","threadId":"16201","inReplyTo":"1225993728-4779-2-git-send-email-david@statichacks.org","subject":"[PATCH 2/4] Changed timestamps to time_t in header files","fromName":"","fromEmail":"david@statichacks.org","sentAt":"2008-11-06T17:48:46Z","receivedAt":"2008-11-06T17:48:46Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"From: David Bryson <david@statichacks.org>\n\n---\n cache.h    |    2 +-\n refs.h     |    2 +-\n revision.h |    4 ++--\n 3 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex a3c77f0..2c114f8 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -625,7 +625,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/refs.h b/refs.h\nindex 06ad260..97c4bfe 100644\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, unsigned long 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/revision.h b/revision.h\nindex 2fdb2dd..7cc9dbd 100644\n--- a/revision.h\n+++ b/revision.h\n@@ -103,8 +103,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;\n-- \n1.6.0.1\n"},{"id":"95068","messageId":"1225993728-4779-4-git-send-email-david@statichacks.org","threadId":"16201","inReplyTo":"1225993728-4779-3-git-send-email-david@statichacks.org","subject":"[PATCH 3/4] Changed timestamps to time_t instead of unsigned long for approxidate()","fromName":"","fromEmail":"david@statichacks.org","sentAt":"2008-11-06T17:48:47Z","receivedAt":"2008-11-06T17:48:47Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"From: David Bryson <david@statichacks.org>\n\n---\n builtin-gc.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/builtin-gc.c b/builtin-gc.c\nindex 7af65bb..168f484 100644\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}\n-- \n1.6.0.1\n"},{"id":"95069","messageId":"1225993728-4779-5-git-send-email-david@statichacks.org","threadId":"16201","inReplyTo":"1225993728-4779-4-git-send-email-david@statichacks.org","subject":"[PATCH 4/4] Changed timestamps to time_t","fromName":"","fromEmail":"david@statichacks.org","sentAt":"2008-11-06T17:48:48Z","receivedAt":"2008-11-06T17:48:48Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"From: David Bryson <david@statichacks.org>\n\nSome static values and return codes from approxidate()\nhave now been changed from unsigned long to time_t\n---\n builtin-reflog.c |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin-reflog.c b/builtin-reflog.c\nindex fdf78a9..f8ee25a 100644\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@@ -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-- \n1.6.0.1\n"},{"id":"95073","messageId":"alpine.LFD.2.00.0811061000430.3419@nehalem.linux-foundation.org","threadId":"16201","inReplyTo":"1225993728-4779-1-git-send-email-david@statichacks.org","subject":"Re: [PATCH 0/4] replace unsinged long with time_t","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-11-06T18:13:46Z","receivedAt":"2008-11-06T18:13:46Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 6 Nov 2008, david@statichacks.org wrote:\n> \n> Here is a patch set from the Janitor page to replace unsigned long with time_t.\n\nI actually don't much like this.\n\n\"time_t\" is one of those totally broken unix types. The standards say that \nit's an \"arithmetic\" type, but leaves it open to be just about anything. \nTraditionally, it's a signed integer (bad), and in theory it could even be \na floating point value, I think.\n\nAnd in _all_ such cases, it's actually better to cast it to \"unsigned \nlong\" than keep time in a system-dependent format that is most likely \neither _already_ \"unsigned long\", or alternatively broken.\n\nIOW, \"unsigned long\" is practically always either the same, or better \nthan, time_t. Do you actually have a platform where that isn't the case?\n\nAnd we do end up casting it to \"unsigned long\" in the end anyway - the \ndate format in the commit is fundamentally not a signed one, and we use \n\"%lu\" to print those things. Again, if we were to use \"time_t\", we'd now \nhave a huge and fundamental confusion about how to print them out, and \nwhat to do if they were negative.\n\nSo \"time_t\" really is a pretty damn worthless type. It's not _quite_ as \nbroken as \"socklen_t\" (which is just a broken name for \"int\", and anybody \nwho declares it to be anythign else is a total moron), but it's close.\n\nIn theory, some platform might have a 64-but \"unsigned long long\" time_t \neven if the architecture is 32-bit (apparently windows used to do that if \nyou included <time64.h>, for example), but since we wouldn't take \nadvantage of that anyway, even then there is no real advantage.\n\n\t\t\t\tLinus\n"},{"id":"95074","messageId":"20081106183722.GL10996@eratosthenes.cryptobackpack.org","threadId":"16201","inReplyTo":"alpine.LFD.2.00.0811061000430.3419@nehalem.linux-foundation.org","subject":"Re: [PATCH 0/4] replace unsinged long with time_t","fromName":"David Bryson","fromEmail":"david@statichacks.org","sentAt":"2008-11-06T18:37:22Z","receivedAt":"2008-11-06T18:37:22Z","isPatch":true,"sender":{"key":"david@statichacks.org","avatar":"https://gravatar.com/avatar/b8796a0b286799d99dcbaea3fd3e8675648cc094ff10b07bae8fe3bc0ac40b9c?d=mp&s=160"},"body":"Hi,\n\nOn Thu, Nov 06, 2008 at 10:13:46AM -0800 or thereabouts, Linus Torvalds wrote:\n> So \"time_t\" really is a pretty damn worthless type. It's not _quite_ as \n> broken as \"socklen_t\" (which is just a broken name for \"int\", and anybody \n> who declares it to be anythign else is a total moron), but it's close.\n\nI have always thought that time_t and similar were braindead, but hey\nthe Janitor page listed it as desireable so what do I know ?\n\n> In theory, some platform might have a 64-but \"unsigned long long\" time_t \n> even if the architecture is 32-bit (apparently windows used to do that if \n> you included <time64.h>, for example), but since we wouldn't take \n> advantage of that anyway, even then there is no real advantage.\n\nHaving a problem between 32 and 64 bit implementations does seem\nundesireable.\n\nhttp://git.or.cz/gitwiki/Janitor?action=info\n\nJanitor wiki log says Pasky added the time_t conversion section.  Care\nto explain the reason for the request Pasky ?\n\nDave\n"},{"id":"95075","messageId":"alpine.LFD.2.00.0811061042530.3419@nehalem.linux-foundation.org","threadId":"16201","inReplyTo":"20081106183722.GL10996@eratosthenes.cryptobackpack.org","subject":"Re: [PATCH 0/4] replace unsinged long with time_t","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2008-11-06T18:45:47Z","receivedAt":"2008-11-06T18:45:47Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 6 Nov 2008, David Bryson wrote:\n> \n> I have always thought that time_t and similar were braindead, but hey\n> the Janitor page listed it as desireable so what do I know ?\n\nIt might be worth it to make the internal git time always be 64-bit.\n\nIt was kind of a long-term plan anyway: git doesn't really ever have to \nwork with dates in the future (and things like \"approxidate()\" actually \nknow that and use it to guess what date you must be talking about), so \neven a 32-bit \"unsigned long\" is expected to work well until 2038, but at \n_some_ point we'd need to guarantee 64-bit epoch times.\n\nIt just wasn't something I was in a huge hurry over. Others have to worry \nabout dates from the future long before wrap-around, git really doesn't. \nBut from a janitorial standpoint, I certainly wouldn't totally hate using \na known 64-bit type for dates.\n\n\t\t\tLinus\n"},{"id":"95079","messageId":"alpine.LRH.1.10.0811062203120.19166@yvahk3.pbagnpgbe.fr","threadId":"16201","inReplyTo":"alpine.LFD.2.00.0811061000430.3419@nehalem.linux-foundation.org","subject":"Re: [PATCH 0/4] replace unsinged long with time_t","fromName":"Daniel Stenberg","fromEmail":"daniel@haxx.se","sentAt":"2008-11-06T21:04:27Z","receivedAt":"2008-11-06T21:04:27Z","isPatch":true,"sender":{"key":"daniel@haxx.se","avatar":"https://gravatar.com/avatar/69fdca87edd17cee21ca2e79fc2ff671d644603c3dc27167430f3cd3dbab7ba8?d=mp&s=160"},"body":"On Thu, 6 Nov 2008, Linus Torvalds wrote:\n\n> In theory, some platform might have a 64-but \"unsigned long long\" time_t \n> even if the architecture is 32-bit (apparently windows used to do that if \n> you included <time64.h>, for example), but since we wouldn't take advantage \n> of that anyway, even then there is no real advantage.\n\nIt could also be worth to notice that there are even 64-bit architectures that \nfeature 32-bit 'time_t'...\n\n-- \n\n  / daniel.haxx.se\n"}]}