{"thread":{"id":"400","subject":"Trying to use AUTHOR_DATE","startedAt":"2005-04-29T23:14:01Z","lastAt":"2005-04-30T03:47:59Z","messageCount":5,"participants":["tony.luck@intel.com","H. Peter Anvin","Edgar Toernig"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"2214","messageId":"200504292314.j3TNE1P23342@unix-os.sc.intel.com","threadId":"400","inReplyTo":null,"subject":"Trying to use AUTHOR_DATE","fromName":"","fromEmail":"tony.luck@intel.com","sentAt":"2005-04-29T23:14:01Z","receivedAt":"2005-04-29T23:14:01Z","isPatch":false,"sender":{"key":"tony.luck@intel.com","avatar":"https://avatars.githubusercontent.com/u/5446021?v=4"},"body":"I'm using cogito-0.8 (036bb73c6dd1871101ca19557298684ab9832f81) and trying\nto set AUTHOR_DATE based on the \"Date:\" from the patch e-mail.  But, it\nappears that commit-tree is munging this based on my timezone.\n\nHere's what I set in the environment before invoking cg-commit:\n\n  AUTHOR_DATE=\"29 Apr 2005 02:02:00 -0700\"\n\nand here's what cg-log reports on the \"author\" line:\n\n  Fri, 29 Apr 2005 10:02:00 -0700\n\nMy /etc/localtime is set for \"US/Pacific\" ... which is where the 8 hours\ncomes from (I think).  If I set \"TZ=GMT0BST\" as well in the environment of\ncg-commit to override /etc/localtime, then the author time comes out ok,\nbut then the \"committer\" time gets messed up.\n\n-Tony\n"},{"id":"2215","messageId":"4272C4DE.8090806@zytor.com","threadId":"400","inReplyTo":"200504292314.j3TNE1P23342@unix-os.sc.intel.com","subject":"Re: Trying to use AUTHOR_DATE","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-04-29T23:35:58Z","receivedAt":"2005-04-29T23:35:58Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"tony.luck@intel.com wrote:\n> I'm using cogito-0.8 (036bb73c6dd1871101ca19557298684ab9832f81) and trying\n> to set AUTHOR_DATE based on the \"Date:\" from the patch e-mail.  But, it\n> appears that commit-tree is munging this based on my timezone.\n> \n> Here's what I set in the environment before invoking cg-commit:\n> \n>   AUTHOR_DATE=\"29 Apr 2005 02:02:00 -0700\"\n> \n> and here's what cg-log reports on the \"author\" line:\n> \n>   Fri, 29 Apr 2005 10:02:00 -0700\n> \n> My /etc/localtime is set for \"US/Pacific\" ... which is where the 8 hours\n> comes from (I think).  If I set \"TZ=GMT0BST\" as well in the environment of\n> cg-commit to override /etc/localtime, then the author time comes out ok,\n> but then the \"committer\" time gets messed up.\n> \n\nThere was a time-parsing bug somewhere, where mktime() got invoked on a \nUTC date.  I proposed changing it to curl_gettime() instead.\n\n\t-hpa\n"},{"id":"2220","messageId":"200504300021.j3U0La023762@unix-os.sc.intel.com","threadId":"400","inReplyTo":"4272C4DE.8090806@zytor.com","subject":"Re: Trying to use AUTHOR_DATE","fromName":"","fromEmail":"tony.luck@intel.com","sentAt":"2005-04-30T00:21:36Z","receivedAt":"2005-04-30T00:21:36Z","isPatch":false,"sender":{"key":"tony.luck@intel.com","avatar":"https://avatars.githubusercontent.com/u/5446021?v=4"},"body":"> There was a time-parsing bug somewhere, where mktime() got invoked on a \n> UTC date.  I proposed changing it to curl_gettime() instead.\n\nHere's a patch to switch to using curl_getdate():\n\nSigned-off-by: Tony Luck <tony.luck@intel.com>\n\n---\n\n Makefile      |    1 \n commit-tree.c |  143 ++++------------------------------------------------------\n 2 files changed, 11 insertions(+), 133 deletions(-)\n\nMakefile: d73bea1cbb9451a89b03d6066bf2ed7fec32fd31\n--- k/Makefile\n+++ l/Makefile\n@@ -92,6 +92,7 @@ $(LIB_FILE): $(LIB_OBJS)\n rpush: rsh.c\n rpull: rsh.c\n http-pull: LIBS += -lcurl\n+commit-tree: LIBS += -lcurl\n \n \n ifneq (,$(wildcard .git))\ncommit-tree.c: 23de13361944ad7ba7c5320cf7cdd04e81842c60\n--- k/commit-tree.c\n+++ l/commit-tree.c\n@@ -10,6 +10,7 @@\n #include <string.h>\n #include <ctype.h>\n #include <time.h>\n+#include <curl/curl.h>\n \n #define BLOCKING (1ul << 14)\n \n@@ -80,146 +81,22 @@ static void remove_special(char *p)\n \t}\n }\n \n-static const char *month_names[] = {\n-        \"Jan\", \"Feb\", \"Mar\", \"Apr\", \"May\", \"Jun\",\n-        \"Jul\", \"Aug\", \"Sep\", \"Oct\", \"Nov\", \"Dec\"\n-};\n-\n-static const char *weekday_names[] = {\n-        \"Sun\", \"Mon\", \"Tue\", \"Wed\", \"Thu\", \"Fri\", \"Sat\"\n-};\n-\n-\n-static char *skipfws(char *str)\n-{\n-\twhile (isspace(*str))\n-\t\tstr++;\n-\treturn str;\n-}\n-\n-\t\n /* Gr. strptime is crap for this; it doesn't have a way to require RFC2822\n    (i.e. English) day/month names, and it doesn't work correctly with %z. */\n-static void parse_rfc2822_date(char *date, char *result, int maxlen)\n+static void parse_date(char *date, time_t *now, char *result, int maxlen)\n {\n-\tstruct tm tm;\n \tchar *p;\n-\tint i, offset;\n \ttime_t then;\n \n-\tmemset(&tm, 0, sizeof(tm));\n-\n-\t/* Skip day-name */\n-\tp = skipfws(date);\n-\tif (!isdigit(*p)) {\n-\t\tfor (i=0; i<7; i++) {\n-\t\t\tif (!strncmp(p,weekday_names[i],3) && p[3] == ',') {\n-\t\t\t\tp = skipfws(p+4);\n-\t\t\t\tgoto day;\n-\t\t\t}\n-\t\t}\n-\t\treturn;\n-\t}\t\t\t\t\t\n-\n-\t/* day */\n- day:\n-\ttm.tm_mday = strtoul(p, &p, 10);\n-\n-\tif (tm.tm_mday < 1 || tm.tm_mday > 31)\n-\t\treturn;\n-\n-\tif (!isspace(*p))\n-\t\treturn;\n-\n-\tp = skipfws(p);\n-\n-\t/* month */\n-\n-\tfor (i=0; i<12; i++) {\n-\t\tif (!strncmp(p, month_names[i], 3) && isspace(p[3])) {\n-\t\t\ttm.tm_mon = i;\n-\t\t\tp = skipfws(p+strlen(month_names[i]));\n-\t\t\tgoto year;\n-\t\t}\n-\t}\n-\treturn; /* Error -- bad month */\n-\n-\t/* year */\n- year:\t\n-\ttm.tm_year = strtoul(p, &p, 10);\n-\n-\tif (!tm.tm_year && !isspace(*p))\n-\t\treturn;\n-\n-\tif (tm.tm_year > 1900)\n-\t\ttm.tm_year -= 1900;\n-\t\t\n-\tp=skipfws(p);\n-\n-\t/* hour */\n-\tif (!isdigit(*p))\n-\t\treturn;\n-\ttm.tm_hour = strtoul(p, &p, 10);\n-\t\n-\tif (!tm.tm_hour > 23)\n-\t\treturn;\n-\n-\tif (*p != ':')\n-\t\treturn; /* Error -- bad time */\n-\tp++;\n-\n-\t/* minute */\n-\tif (!isdigit(*p))\n-\t\treturn;\n-\ttm.tm_min = strtoul(p, &p, 10);\n-\t\n-\tif (!tm.tm_min > 59)\n+\tif ((then = curl_getdate(date, now)) == 0)\n \t\treturn;\n \n-\tif (isspace(*p))\n-\t\tgoto zone;\n-\n-\tif (*p != ':')\n-\t\treturn; /* Error -- bad time */\n-\tp++;\n-\n-\t/* second */\n-\tif (!isdigit(*p))\n-\t\treturn;\n-\ttm.tm_sec = strtoul(p, &p, 10);\n-\t\n-\tif (!tm.tm_sec > 59)\n-\t\treturn;\n-\n-\tif (!isspace(*p))\n-\t\treturn;\n-\n- zone:\n-\tp = skipfws(p);\n-\n-\tif (*p == '-')\n-\t\toffset = -60;\n-\telse if (*p == '+')\n-\t\toffset = 60;\n-\telse\n-\t       return;\n-\n-\tif (!isdigit(p[1]) || !isdigit(p[2]) || !isdigit(p[3]) || !isdigit(p[4]))\n-\t\treturn;\n-\n-\ti = strtoul(p+1, NULL, 10);\n-\toffset *= ((i % 100) + ((i / 100) * 60));\n-\n-\tif (*(skipfws(p + 5)))\n-\t\treturn;\n-\n-\tthen = mktime(&tm); /* mktime appears to ignore the GMT offset, stupidly */\n-\tif (then == -1)\n-\t\treturn;\n-\n-\tthen -= offset;\n-\n-\tsnprintf(result, maxlen, \"%lu %5.5s\", then, p);\n+\t/* find the timezone at the end */\n+\tp = date + strlen(date);\n+\twhile (p > date && isdigit(*--p))\n+\t\t;\n+\tif ((*p == '+' || *p == '-') && strlen(p) == 5)\n+\t\tsnprintf(result, maxlen, \"%lu %5.5s\", then, p);\n }\n \n static void check_valid(unsigned char *sha1, const char *expect)\n@@ -298,7 +175,7 @@ int main(int argc, char **argv)\n \temail = getenv(\"AUTHOR_EMAIL\") ? : realemail;\n \taudate = getenv(\"AUTHOR_DATE\");\n \tif (audate)\n-\t\tparse_rfc2822_date(audate, date, sizeof(date));\n+\t\tparse_date(audate, &now, date, sizeof(date));\n \n \tremove_special(gecos); remove_special(realgecos); remove_special(commitgecos);\n \tremove_special(email); remove_special(realemail); remove_special(commitemail);\n"},{"id":"2232","messageId":"20050430052318.1bd4b189.froese@gmx.de","threadId":"400","inReplyTo":"200504300021.j3U0La023762@unix-os.sc.intel.com","subject":"Re: Trying to use AUTHOR_DATE","fromName":"Edgar Toernig","fromEmail":"froese@gmx.de","sentAt":"2005-04-30T03:23:18Z","receivedAt":"2005-04-30T03:23:18Z","isPatch":false,"sender":{"key":"froese@gmx.de","avatar":null},"body":"tony.luck@intel.com wrote:\n>\n> > There was a time-parsing bug somewhere, where mktime() got invoked on a \n> > UTC date.  I proposed changing it to curl_gettime() instead.\n> \n> Here's a patch to switch to using curl_getdate():\n\nAnother dependency :-(   I can live without http-pull but not\nwithout commit-tree.\n\nWhat's wrong with the patch I sent to fix this:\n\n\thttp://marc.theaimsgroup.com/?m=111446501003389\n\n> +\t/* find the timezone at the end */\n> +\tp = date + strlen(date);\n> +\twhile (p > date && isdigit(*--p))\n> +\t\t;\n> +\tif ((*p == '+' || *p == '-') && strlen(p) == 5)\n> +\t\tsnprintf(result, maxlen, \"%lu %5.5s\", then, p);\n\nThis will choke on dates from Linus which have a trailing comment:\n\n\tDate: Fri, 29 Apr 2005 15:26:14 -0700 (PDT)\n\nCiao, ET.\n"},{"id":"2234","messageId":"4272FFEF.2090701@zytor.com","threadId":"400","inReplyTo":"20050430052318.1bd4b189.froese@gmx.de","subject":"Re: Trying to use AUTHOR_DATE","fromName":"H. Peter Anvin","fromEmail":"hpa@zytor.com","sentAt":"2005-04-30T03:47:59Z","receivedAt":"2005-04-30T03:47:59Z","isPatch":false,"sender":{"key":"hpa@zytor.com","avatar":null},"body":"Edgar Toernig wrote:\n> \n> Another dependency :-(   I can live without http-pull but not\n> without commit-tree.\n> \n\nThen feel free to rip curl_getdate out of the libcurl sources and making \nthem standalone.\n\n\t-hpa\n"}]}