{"thread":{"id":"46897","subject":"Git for Windows: mingw.c's strange usage of creation time as ctime?","startedAt":"2017-10-04T01:05:30Z","lastAt":"2017-10-04T08:23:47Z","messageCount":3,"participants":["Marc Strapetz","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"329629","messageId":"08983090-07d2-cfe4-dd90-ab4887b83893@syntevo.com","threadId":"46897","inReplyTo":null,"subject":"Git for Windows: mingw.c's strange usage of creation time as ctime?","fromName":"Marc Strapetz","fromEmail":"marc.strapetz@syntevo.com","sentAt":"2017-10-03T22:29:27Z","receivedAt":"2017-10-04T01:05:30Z","isPatch":false,"sender":{"key":"marc.strapetz@syntevo.com","avatar":"https://avatars.githubusercontent.com/u/3380730?v=4"},"body":"compat/mingw.c assigns the Windows file creation time [1] to Git's ctime \nfields at line 591 and at line 705:\n\nbuf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));\n\nftCreationTime > ftLastWriteTime is actually possible after copying a \nfile, so it makes sense to include this timestamp somehow in the Index, \nbut I think it would be better to use the maximum of ftLastWriteTime and \nftCreationTime here which is less confusing and closer to Unix's ctime:\n\nbuf->st_ctime = max(buf->st_mtime,\n                     filetime_to_time_t(&(fdata.ftCreationTime));\n\n-Marc\n\n[1] \nhttps://msdn.microsoft.com/en-us/library/windows/desktop/aa365739(v=vs.85).aspx\n\n"},{"id":"329635","messageId":"20171004022352.GJ19555@aiede.mtv.corp.google.com","threadId":"46897","inReplyTo":"08983090-07d2-cfe4-dd90-ab4887b83893@syntevo.com","subject":"Re: Git for Windows: mingw.c's strange usage of creation time as ctime?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2017-10-04T02:23:52Z","receivedAt":"2017-10-04T02:24:00Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"+git-for-windows\nHi Marc,\n\nMarc Strapetz wrote:\n\n> compat/mingw.c assigns the Windows file creation time [1] to Git's\n> ctime fields at line 591 and at line 705:\n>\n> buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));\n>\n> ftCreationTime > ftLastWriteTime is actually possible after copying\n> a file, so it makes sense to include this timestamp somehow in the\n> Index, but I think it would be better to use the maximum of\n> ftLastWriteTime and ftCreationTime here which is less confusing and\n> closer to Unix's ctime:\n>\n> buf->st_ctime = max(buf->st_mtime,\n>                     filetime_to_time_t(&(fdata.ftCreationTime));\n\nCan you say more about the practical effect?  Is this causing a bug in\npractice, is it a bug waiting to happen, or is it making the code\ndifficult to understand without any ill effect expected at run time?\n(Any of those three is a valuable kind of feedback to offer --- I'm\njust trying to figure out which one you mean.)\n\nBy the way, do you have core.trustctime set to true or false?\n\nThanks,\nJonathan\n\n> -Marc\n>\n> [1] https://msdn.microsoft.com/en-us/library/windows/desktop/aa365739(v=vs.85).aspx\n"},{"id":"329664","messageId":"6e1afdc2-2edb-8060-87b0-7d2ced201e02@syntevo.com","threadId":"46897","inReplyTo":"20171004022352.GJ19555@aiede.mtv.corp.google.com","subject":"Re: Git for Windows: mingw.c's strange usage of creation time as ctime?","fromName":"Marc Strapetz","fromEmail":"marc.strapetz@syntevo.com","sentAt":"2017-10-04T07:57:10Z","receivedAt":"2017-10-04T08:23:47Z","isPatch":false,"sender":{"key":"marc.strapetz@syntevo.com","avatar":"https://avatars.githubusercontent.com/u/3380730?v=4"},"body":"Hello Jonathan,\n\nOn 04.10.2017 04:23, Jonathan Nieder wrote:\n> +git-for-windows\n> Hi Marc,\n> \n> Marc Strapetz wrote:\n> \n>> compat/mingw.c assigns the Windows file creation time [1] to Git's\n>> ctime fields at line 591 and at line 705:\n>>\n>> buf->st_ctime = filetime_to_time_t(&(fdata.ftCreationTime));\n>>\n>> ftCreationTime > ftLastWriteTime is actually possible after copying\n>> a file, so it makes sense to include this timestamp somehow in the\n>> Index, but I think it would be better to use the maximum of\n>> ftLastWriteTime and ftCreationTime here which is less confusing and\n>> closer to Unix's ctime:\n>>\n>> buf->st_ctime = max(buf->st_mtime,\n>>                      filetime_to_time_t(&(fdata.ftCreationTime));\n> \n> Can you say more about the practical effect?  Is this causing a bug in\n> practice, is it a bug waiting to happen, or is it making the code\n> difficult to understand without any ill effect expected at run time?\n\nIt's mainly about understanding: as a Windows guy it is quite tempting \nto read \"ctime\" as \"creationTime\" and getting this confirmed in code \nabove. (I guess) based on this understanding I wrote wrong Java code 8 \nyears ago for all platforms. My bad of course that I was not digging \ninto Unix sources here.\n\nIn practice, .git/index timestamps will become more similar to Linux, \ngetting rid of \"strange\" old ctime values.\n\nDrawback will be that after such a code update every Index entry will \nappear as outdated and the initial \"git status\" will have to compare all \nfile contents. If this is not acceptable, a comment for the two \noffending lines would make sense.\n\n> By the way, do you have core.trustctime set to true or false?\n\nIt seems to be set to true by default on Windows and usually I'm not \nchanging it.\n\n-Marc\n\n\n\n"}]}