{"thread":{"id":"1237","subject":"Why O_EXCL would make this difference? I am puzzled..","startedAt":"2005-07-14T08:17:41Z","lastAt":"2005-07-14T16:52:48Z","messageCount":3,"participants":["Junio C Hamano","Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"6124","messageId":"7v8y09g5sq.fsf@assigned-by-dhcp.cox.net","threadId":"1237","inReplyTo":null,"subject":"Why O_EXCL would make this difference? I am puzzled..","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-07-14T08:17:41Z","receivedAt":"2005-07-14T08:17:41Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"The bisect search found that the commit\n\n\tMake \"git-checkout\" create files with O_EXCL\n\nmakes the test t1005 fail.  But it is getting late so I give up\nto figuire this out tonight.\n"},{"id":"6136","messageId":"Pine.LNX.4.58.0507140904440.19183@g5.osdl.org","threadId":"1237","inReplyTo":"7v8y09g5sq.fsf@assigned-by-dhcp.cox.net","subject":"Re: Why O_EXCL would make this difference? I am puzzled..","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-07-14T16:08:59Z","receivedAt":"2005-07-14T16:08:59Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 14 Jul 2005, Junio C Hamano wrote:\n>\n> The bisect search found that the commit\n> \n> \tMake \"git-checkout\" create files with O_EXCL\n> \n> makes the test t1005 fail.  But it is getting late so I give up\n> to figuire this out tonight.\n\nAhh, thanks for noticing.\n\nIt says\n\n\t* expecting success: rm -f .git/index &&\n\t     rm -fr DF &&\n\t     mkdir DF &&\n\t     echo DF/DF >DF/DF &&\n\t     git-update-cache --add DF/DF &&\n\t     read_tree_twoway $treeDFDF $treeDF &&\n\t     git-ls-files --stage >DFDFcheck.out &&\n\t     diff -u DF.out DFDFcheck.out &&\n\t     check_cache_at DF clean && # different from pure 2-way\n\t     :\n\t100644 052efc3abbc31348f7abd34535b1953d38273257 3       DF\n\t100644 b90ea14b2dd74b6f377c10870b3757344bbe077c 1       DF/DF\n\t100644 b90ea14b2dd74b6f377c10870b3757344bbe077c 2       DF/DF\n\tAdding DF\n\terror: git-checkout-cache: unable to create file DF (File exists)\n\tRemoving DF/DF\n\t100644 052efc3abbc31348f7abd34535b1953d38273257 0       DF\n\tDF: dirty\n\t* FAIL 24: DF vs DF/DF case test (#2) rm -f .git/index &&\n\nWhich is strange. If the path already exists, the \"lstat(path, &st)\" \nshould have returned 0 in checkout_entry (which is the only caller of \n\"write_entry()\"), and that code does an \"unlink(path)\" before it calls \nwrite-entry. So I was sure O_EXCL wouldn't make any difference, but I'm \nobviously wrong, wrong, wrong.\n\nI'll strace the dang thing.\n\n\t\tLinus\n"},{"id":"6137","messageId":"Pine.LNX.4.58.0507140944580.19183@g5.osdl.org","threadId":"1237","inReplyTo":"Pine.LNX.4.58.0507140904440.19183@g5.osdl.org","subject":"Re: Why O_EXCL would make this difference? I am puzzled..","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-07-14T16:52:48Z","receivedAt":"2005-07-14T16:52:48Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 14 Jul 2005, Linus Torvalds wrote:\n> \n> I'll strace the dang thing.\n\nIt's the \"Adding\" case in git-merge-one-file-script, which does\n\n\tgit-checkout-cache -u -f -- \"$4\"\n\nand it's because of this:\n\n\tlstat64(\"DF\", {st_mode=S_IFDIR|0775, st_size=4096, ...}) = 0\n\tunlink(\"DF\")                            = -1 EISDIR (Is a directory)\n\t.. unpack the object ..\n\topen(\"DF\", O_WRONLY|O_CREAT|O_TRUNC|O_EXCL, 0666) = -1 EEXIST (File exists)\n\nie the problem is that we actually _have_ a test for this, but it's:\n\n\tif (errno == EISDIR && force) {\n\nbut if the directory already exists, we do that wrong.\n\nBtw, this also shows a different problem: the symlink handling doesn't do \nany of this, so you cannot even force a directory to become a symlink.\n\nI think both problems can be fixed by just moving the (EISDIR && force) \ntest down to the \"unlink()\".\n\nWill try.\n\n\t\tLinus\n"}]}