{"thread":{"id":"2235","subject":"git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","startedAt":"2005-10-26T14:11:59Z","lastAt":"2005-10-26T20:12:40Z","messageCount":17,"participants":["Randal L. Schwartz","Johannes Schindelin","Jan Harkes","Linus Torvalds","Horst von Brand","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"10657","messageId":"86y84gfjv4.fsf@blue.stonehenge.com","threadId":"2235","inReplyTo":null,"subject":"git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2005-10-26T14:11:59Z","receivedAt":"2005-10-26T14:11:59Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":"\ngcc -o sha1_file.o -c -g -O2 -Wall -I/usr/local/include -L/usr/local/lib -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1 -DSHA1_HEADER='<openssl/sha.h>' sha1_file.c\nsha1_file.c: In function `move_temp_to_file':\nsha1_file.c:1247: error: `ENOTSUP' undeclared (first use in this function)\nsha1_file.c:1247: error: (Each undeclared identifier is reported only once\nsha1_file.c:1247: error: for each function it appears in.)\ngmake: *** [sha1_file.o] Error 1\n\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"},{"id":"10659","messageId":"86u0f4fjah.fsf@blue.stonehenge.com","threadId":"2235","inReplyTo":"86y84gfjv4.fsf@blue.stonehenge.com","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2005-10-26T14:24:22Z","receivedAt":"2005-10-26T14:24:22Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Randal\" == Randal L Schwartz <merlyn@stonehenge.com> writes:\n\nRandal> gcc -o sha1_file.o -c -g -O2 -Wall -I/usr/local/include -L/usr/local/lib -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1 -DSHA1_HEADER='<openssl/sha.h>' sha1_file.c\nRandal> sha1_file.c: In function `move_temp_to_file':\nRandal> sha1_file.c:1247: error: `ENOTSUP' undeclared (first use in this function)\nRandal> sha1_file.c:1247: error: (Each undeclared identifier is reported only once\nRandal> sha1_file.c:1247: error: for each function it appears in.)\nRandal> gmake: *** [sha1_file.o] Error 1\n\ngot it... a bit messy, but here it is:\n\nSubject: [PATCH] fix for openbsd\n\n---\n\n sha1_file.c |    6 +++++-\n 1 files changed, 5 insertions(+), 1 deletions(-)\n\napplies-to: b16bae041dfd1c1081873f2e88a5f82858fb2051\n28dcc3eaf13856585a81a24f1b4393032f825053\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 7fdc469..1079ca5 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1244,7 +1244,11 @@ int move_temp_to_file(const char *tmpfil\n \t\t * When this succeeds, we just return 0. We have nothing\n \t\t * left to unlink.\n \t\t */\n-\t\tif ((ret == EXDEV || ret == ENOTSUP) && !rename(tmpfile, filename))\n+\t\tif ((ret == EXDEV\n+#ifdef ENOTSUP\n+                     || ret == ENOTSUP\n+#endif\n+\t\t     ) && !rename(tmpfile, filename))\n \t\t\treturn 0;\n \t\tret = errno;\n \t}\n---\n0.99.8.GIT\n\n\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"},{"id":"10662","messageId":"Pine.LNX.4.63.0510261708280.2803@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2235","inReplyTo":"86u0f4fjah.fsf@blue.stonehenge.com","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-26T15:09:34Z","receivedAt":"2005-10-26T15:09:34Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 26 Oct 2005, Randal L. Schwartz wrote:\n\n> Randal> sha1_file.c:1247: error: `ENOTSUP' undeclared (first use in this \n> function)\n\nI thought ENOTSUP is POSIX standard?\n\nWhat does your man page for link() say? If it is not supported, what value \nwill be in errno?\n\nCiao,\nDscho\n"},{"id":"10663","messageId":"86mzkwfh54.fsf@blue.stonehenge.com","threadId":"2235","inReplyTo":"Pine.LNX.4.63.0510261708280.2803@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2005-10-26T15:10:47Z","receivedAt":"2005-10-26T15:10:47Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Johannes\" == Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\nJohannes> Hi,\nJohannes> On Wed, 26 Oct 2005, Randal L. Schwartz wrote:\n\nRandal> sha1_file.c:1247: error: `ENOTSUP' undeclared (first use in this \n>> function)\n\nJohannes> I thought ENOTSUP is POSIX standard?\n\nJohannes> What does your man page for link() say? If it is not supported, what value \nJohannes> will be in errno?\n\nEOPNOTSUPP\n\nProbably a BSD thing.\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"},{"id":"10665","messageId":"Pine.LNX.4.63.0510261725150.8507@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2235","inReplyTo":"86mzkwfh54.fsf@blue.stonehenge.com","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-26T15:26:20Z","receivedAt":"2005-10-26T15:26:20Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 26 Oct 2005, Randal L. Schwartz wrote:\n\n> >>>>> \"Johannes\" == Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> Johannes> What does your man page for link() say? If it is not \n> Johannes> supported, what value will be in errno?\n> \n> EOPNOTSUPP\n\nHow about this, then:\n\n---\n\nSubject: [PATCH] Support EOPNOTSUPP of OpenBSD\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n Makefile |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\napplies-to: 01ba9ea9d9dfba5ae94c32691ac8d9fdd859fccf\neaebda7362215aa0c7349e9971848c0535782a40\ndiff --git a/Makefile b/Makefile\nindex 4877abb..5cb7194 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -211,6 +211,7 @@ ifeq ($(uname_S),OpenBSD)\n \tNO_STRCASESTR = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tPLATFORM_DEFINES += -I/usr/local/include -L/usr/local/lib\n+\tPLATFORM_DEFINES += -DENOTSUP=EOPNOTSUPP\n endif\n ifneq (,$(findstring arm,$(uname_M)))\n \tARM_SHA1 = YesPlease\n---\n0.99.8.GIT\n"},{"id":"10666","messageId":"86irvkfg80.fsf@blue.stonehenge.com","threadId":"2235","inReplyTo":"Pine.LNX.4.63.0510261725150.8507@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2005-10-26T15:30:39Z","receivedAt":"2005-10-26T15:30:39Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Johannes\" == Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\nJohannes> Hi,\nJohannes> On Wed, 26 Oct 2005, Randal L. Schwartz wrote:\n\n>> >>>>> \"Johannes\" == Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n>> \nJohannes> What does your man page for link() say? If it is not \nJohannes> supported, what value will be in errno?\n>> \n>> EOPNOTSUPP\n\nInteresting... google for \"ENOTSUPP EOPNOTSUPP\".  Apparently\nhits like this:\n\n<http://sources.redhat.com/ml/bug-glibc/2002-08/msg00013.html>\n\nshows that on some platforms, they may have both.  This is not as\neasy as it looks.  Maybe define an extra || condition to handle either\nor both?\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"},{"id":"10669","messageId":"Pine.LNX.4.64.0510260910290.10477@g5.osdl.org","threadId":"2235","inReplyTo":"86u0f4fjah.fsf@blue.stonehenge.com","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-10-26T16:11:41Z","receivedAt":"2005-10-26T16:11:41Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 26 Oct 2005, Randal L. Schwartz wrote:\n> \n> got it... a bit messy, but here it is:\n> \n> Subject: [PATCH] fix for openbsd\n\nI think we might as well do it for any error, and skip the test of the \nactual errno entirely.\n\n\t\tLinus\n"},{"id":"10668","messageId":"20051026161552.GA11483@delft.aura.cs.cmu.edu","threadId":"2235","inReplyTo":"86irvkfg80.fsf@blue.stonehenge.com","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Jan Harkes","fromEmail":"jaharkes@cs.cmu.edu","sentAt":"2005-10-26T16:15:52Z","receivedAt":"2005-10-26T16:15:52Z","isPatch":false,"sender":{"key":"jaharkes@cs.cmu.edu","avatar":"https://gravatar.com/avatar/cf95aecd150ca8ef33d6edc337ac4bb9e13aa4246fc3679257d578c7fddc1633?d=mp&s=160"},"body":"On Wed, Oct 26, 2005 at 08:30:39AM -0700, Randal L. Schwartz wrote:\n> >> >>>>> \"Johannes\" == Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> Johannes> What does your man page for link() say? If it is not \n> Johannes> supported, what value will be in errno?\n> >> \n> >> EOPNOTSUPP\n> \n> Interesting... google for \"ENOTSUPP EOPNOTSUPP\".  Apparently\n> hits like this:\n> \n> <http://sources.redhat.com/ml/bug-glibc/2002-08/msg00013.html>\n> \n> shows that on some platforms, they may have both.  This is not as\n> easy as it looks.  Maybe define an extra || condition to handle either\n> or both?\n\nIt looks like glibc assumes that the kernel doesn't have ENOTSUP and\ndefines it as EOPNOTSUPP in <bits/errno.h>. So even if the kernel does\nreturn different values, any glibc linked application probably wouldn't\nbe able to test for the ENOTSUP error.\n\nChecking the SuSv2 manpage for link(2), it doesn't mention either of\nthese error codes. But does mention EPERM as a valid error when the\nfilesystem doesn't support hardlinks.\n    http://www.opengroup.org/onlinepubs/007908799/xsh/link.html\n\nMy local manual page for link(2) agrees with that definition,\n\n\tEPERM  oldpath is a directory.\n\n\tEPERM  The  filesystem  containing oldpath and newpath does not support\n\t       the creation of hard links.\n\nI also took a look at the Linux 2.4/2.6 kernel sources, and msdos, fat\nand vfat all do not set a function for 'dir->i_op->link'. In that case,\nvfs_link() will return EPERM.\n\nSo I don't know where ENOTSUP/EOPNOTSUPP would be coming from. From the\nfew places I looked, I don't think the original patch can be right. Not\nsure yet if I want to change Coda's return value to EPERM as well, the\nthing is that we do support hardlinks, just not between different\ndirectories, but I guess EXDEV isn't really accurate either.\n\nJan\n"},{"id":"10670","messageId":"Pine.LNX.4.63.0510261842580.29044@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2235","inReplyTo":"Pine.LNX.4.64.0510260910290.10477@g5.osdl.org","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-26T16:43:35Z","receivedAt":"2005-10-26T16:43:35Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 26 Oct 2005, Linus Torvalds wrote:\n\n> On Wed, 26 Oct 2005, Randal L. Schwartz wrote:\n> > \n> > got it... a bit messy, but here it is:\n> > \n> > Subject: [PATCH] fix for openbsd\n> \n> I think we might as well do it for any error, and skip the test of the \n> actual errno entirely.\n\nHah! I beat you at your own game! (I already sent out a totally untested \npatch ;-)\n\nCiao,\nDscho\n"},{"id":"10671","messageId":"Pine.LNX.4.63.0510261844020.29044@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2235","inReplyTo":"20051026161552.GA11483@delft.aura.cs.cmu.edu","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-26T16:46:45Z","receivedAt":"2005-10-26T16:46:45Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 26 Oct 2005, Jan Harkes wrote:\n\n> Checking the SuSv2 manpage for link(2), it doesn't mention either of\n> these error codes. But does mention EPERM as a valid error when the\n> filesystem doesn't support hardlinks.\n>     http://www.opengroup.org/onlinepubs/007908799/xsh/link.html\n> \n> My local manual page for link(2) agrees with that definition,\n> \n> \tEPERM  oldpath is a directory.\n> \n> \tEPERM  The  filesystem  containing oldpath and newpath does not support\n> \t       the creation of hard links.\n\nOn my iBook, connecting a USB stick (FAT formatted), link() sets \nerrno=ENOTSUP. I checked the man page, and erroneously thought that they \ngot it right.\n\n*turns his eyes helplessly to the sky*\n\nCiao,\nDscho\n"},{"id":"10672","messageId":"20051026165515.GA16616@delft.aura.cs.cmu.edu","threadId":"2235","inReplyTo":"20051026161552.GA11483@delft.aura.cs.cmu.edu","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Jan Harkes","fromEmail":"jaharkes@cs.cmu.edu","sentAt":"2005-10-26T16:55:15Z","receivedAt":"2005-10-26T16:55:15Z","isPatch":false,"sender":{"key":"jaharkes@cs.cmu.edu","avatar":"https://gravatar.com/avatar/cf95aecd150ca8ef33d6edc337ac4bb9e13aa4246fc3679257d578c7fddc1633?d=mp&s=160"},"body":"On Wed, Oct 26, 2005 at 12:15:52PM -0400, Jan Harkes wrote:\n> Checking the SuSv2 manpage for link(2), it doesn't mention either of\n> these error codes. But does mention EPERM as a valid error when the\n> filesystem doesn't support hardlinks.\n>     http://www.opengroup.org/onlinepubs/007908799/xsh/link.html\n\nRe-reading this, I seem to have misinterpreted the text. EPERM is\nreturned when the filesystem doesn't allow hard linking a directory.\nI guess the closest error would actually be EMLINK, assuming that a\nfilesystem that doesn't support hardlinks would have LINK_MAX set to 1.\n\n    Linux returns EPERM\n    Coda returns EXDEV\n    BSDs seem to return EOPNOTSUPP.\n    MacOS X/Darwin doesn't mention it in their manpages.\n\nSimply falling back on rename when there is any error, as Linus\nsuggested, seems like a pretty good solution right now. Rename should\ngive the same set of errors except when the link target already existed.\n\nJan\n\n\ndiff --git a/sha1_file.c b/sha1_file.c\nindex e456799..0eba58c 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1234,15 +1234,14 @@ int move_temp_to_file(const char *tmpfil\n \tint ret = link_temp_to_file(tmpfile, filename);\n \tif (ret) {\n \t\t/*\n-\t\t * Coda hack - coda doesn't like cross-directory links,\n-\t\t * so we fall back to a rename, which will mean that it\n-\t\t * won't be able to check collisions, but that's not a\n-\t\t * big deal.\n+\t\t * The file system may not support hardlinks, so we fall back\n+\t\t * to a rename. We won't be able to check for collisions, but\n+\t\t * that's not a big deal.\n \t\t *\n \t\t * When this succeeds, we just return 0. We have nothing\n \t\t * left to unlink.\n \t\t */\n-\t\tif (ret == EXDEV && !rename(tmpfile, filename))\n+\t\tif (ret && ret != EEXIST && !rename(tmpfile, filename))\n \t\t\treturn 0;\n \t}\n \tunlink(tmpfile);\n"},{"id":"10673","messageId":"Pine.LNX.4.63.0510261901140.9686@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"2235","inReplyTo":"20051026165515.GA16616@delft.aura.cs.cmu.edu","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2005-10-26T17:03:32Z","receivedAt":"2005-10-26T17:03:32Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Wed, 26 Oct 2005, Jan Harkes wrote:\n\n> -\t\tif (ret == EXDEV && !rename(tmpfile, filename))\n> +\t\tif (ret && ret != EEXIST && !rename(tmpfile, filename))\n\nWe don't need to test for ret, as we're already in a \"if (ret)\" block.  \nWhat would happen if ret==EEXIST, and we try to rename() nevertheless? It \nshould fail, too, right?\n\nCiao,\nDscho\n"},{"id":"10674","messageId":"200510261722.j9QHMLGY006576@laptop11.inf.utfsm.cl","threadId":"2235","inReplyTo":"86u0f4fjah.fsf@blue.stonehenge.com","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Horst von Brand","fromEmail":"vonbrand@inf.utfsm.cl","sentAt":"2005-10-26T17:22:21Z","receivedAt":"2005-10-26T17:22:21Z","isPatch":false,"sender":{"key":"vonbrand@inf.utfsm.cl","avatar":"https://avatars.githubusercontent.com/u/211384?v=4"},"body":"Randal L. Schwartz <merlyn@stonehenge.com> wrote:\n> >>>>> \"Randal\" == Randal L Schwartz <merlyn@stonehenge.com> writes:\n> \n> Randal> gcc -o sha1_file.o -c -g -O2 -Wall -I/usr/local/include -L/usr/local/lib -Dstrcasestr=gitstrcasestr -DNO_STRCASESTR=1 -DSHA1_HEADER='<openssl/sha.h>' sha1_file.c\n> Randal> sha1_file.c: In function `move_temp_to_file':\n> Randal> sha1_file.c:1247: error: `ENOTSUP' undeclared (first use in this function)\n> Randal> sha1_file.c:1247: error: (Each undeclared identifier is reported only once\n> Randal> sha1_file.c:1247: error: for each function it appears in.)\n> Randal> gmake: *** [sha1_file.o] Error 1\n> \n> got it... a bit messy, but here it is:\n> \n> Subject: [PATCH] fix for openbsd\n> \n> ---\n> \n>  sha1_file.c |    6 +++++-\n>  1 files changed, 5 insertions(+), 1 deletions(-)\n> \n> applies-to: b16bae041dfd1c1081873f2e88a5f82858fb2051\n> 28dcc3eaf13856585a81a24f1b4393032f825053\n> diff --git a/sha1_file.c b/sha1_file.c\n> index 7fdc469..1079ca5 100644\n> --- a/sha1_file.c\n> +++ b/sha1_file.c\n> @@ -1244,7 +1244,11 @@ int move_temp_to_file(const char *tmpfil\n>  \t\t * When this succeeds, we just return 0. We have nothing\n>  \t\t * left to unlink.\n>  \t\t */\n> -\t\tif ((ret == EXDEV || ret == ENOTSUP) && !rename(tmpfile, filename))\n> +\t\tif ((ret == EXDEV\n> +#ifdef ENOTSUP\n> +                     || ret == ENOTSUP\n> +#endif\n> +\t\t     ) && !rename(tmpfile, filename))\n\nThis is EVIL.... why not just:\n\n  #ifndef ENOTSUP\n  #define ENOTSUP EXDEV\n  #endif\n\nsomeplace where it doesn't hurt the eyes? (The EXDEV makes the ENOTSUPP\nfold away, I presume; not that it should really matter).\n-- \nDr. Horst H. von Brand                   User #22616 counter.li.org\nDepartamento de Informatica                     Fono: +56 32 654431\nUniversidad Tecnica Federico Santa Maria              +56 32 654239\nCasilla 110-V, Valparaiso, Chile                Fax:  +56 32 797513\n"},{"id":"10675","messageId":"Pine.LNX.4.64.0510261025440.10477@g5.osdl.org","threadId":"2235","inReplyTo":"Pine.LNX.4.63.0510261901140.9686@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Linus Torvalds","fromEmail":"torvalds@osdl.org","sentAt":"2005-10-26T17:27:36Z","receivedAt":"2005-10-26T17:27:36Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 26 Oct 2005, Johannes Schindelin wrote:\n> \n> On Wed, 26 Oct 2005, Jan Harkes wrote:\n> \n> > -\t\tif (ret == EXDEV && !rename(tmpfile, filename))\n> > +\t\tif (ret && ret != EEXIST && !rename(tmpfile, filename))\n> \n> We don't need to test for ret, as we're already in a \"if (ret)\" block.  \n> What would happen if ret==EEXIST, and we try to rename() nevertheless? It \n> should fail, too, right?\n\nNo, the rename will succeed and overwrite the existing file.\n\nWhich is strictly correct, but it's the wrong thing if we ever want to do \ncollission detection.\n\nSo I'd actually prefer something like this patch instead.\n\n\t\tLinus\n\n---\ndiff --git a/sha1_file.c b/sha1_file.c\nindex 7fdc469..642f00d 100644\n--- a/sha1_file.c\n+++ b/sha1_file.c\n@@ -1232,19 +1232,20 @@ static int link_temp_to_file(const char \n int move_temp_to_file(const char *tmpfile, char *filename)\n {\n \tint ret = link_temp_to_file(tmpfile, filename);\n-\tif (ret) {\n-\t\t/*\n-\t\t * Coda hack - coda doesn't like cross-directory links,\n-\t\t * so we fall back to a rename, which will mean that it\n-\t\t * won't be able to check collisions, but that's not a\n-\t\t * big deal.\n-\t\t *\n-\t\t * The same holds for FAT formatted media.\n-\t\t *\n-\t\t * When this succeeds, we just return 0. We have nothing\n-\t\t * left to unlink.\n-\t\t */\n-\t\tif ((ret == EXDEV || ret == ENOTSUP) && !rename(tmpfile, filename))\n+\n+\t/*\n+\t * Coda hack - coda doesn't like cross-directory links,\n+\t * so we fall back to a rename, which will mean that it\n+\t * won't be able to check collisions, but that's not a\n+\t * big deal.\n+\t *\n+\t * The same holds for FAT formatted media.\n+\t *\n+\t * When this succeeds, we just return 0. We have nothing\n+\t * left to unlink.\n+\t */\n+\tif (ret && ret != EEXIST) {\n+\t\tif (!rename(tmpfile, filename))\n \t\t\treturn 0;\n \t\tret = errno;\n \t}\n"},{"id":"10678","messageId":"86mzkwdsef.fsf@blue.stonehenge.com","threadId":"2235","inReplyTo":"200510261722.j9QHMLGY006576@laptop11.inf.utfsm.cl","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2005-10-26T18:50:32Z","receivedAt":"2005-10-26T18:50:32Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Horst\" == Horst von Brand <vonbrand@inf.utfsm.cl> writes:\n\nHorst> This is EVIL.... why not just:\n\nHorst>   #ifndef ENOTSUP\nHorst>   #define ENOTSUP EXDEV\nHorst>   #endif\n\nI'd consider that a worse hack.  It affects any place where EXDEV\nis not really equivalent to ENOTSUP.\n\nIt's cleaner to test for the ones that work, building up an OR'ed expression.\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"},{"id":"10681","messageId":"7vr7a8ca8j.fsf@assigned-by-dhcp.cox.net","threadId":"2235","inReplyTo":"86mzkwdsef.fsf@blue.stonehenge.com","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-10-26T20:08:12Z","receivedAt":"2005-10-26T20:08:12Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"merlyn@stonehenge.com (Randal L. Schwartz) writes:\n\n> It's cleaner to test for the ones that work, building up an OR'ed expression.\n\nYou are right.  In this case the only thing we care about is if\nit failed because of EEXIST, so checking that and trying to fall\nback on rename() otherwise seems cleanest, as Linus and others\nsuggests.\n\nI swallowed Linus version.  Thanks for reporting (and also ctype\nfix the other day).\n"},{"id":"10683","messageId":"86ll0gavgn.fsf@blue.stonehenge.com","threadId":"2235","inReplyTo":"7vr7a8ca8j.fsf@assigned-by-dhcp.cox.net","subject":"Re: git 565ebbf79f61873042c22a7126d002c104e056f4 broken on OpenBSD","fromName":"Randal L. Schwartz","fromEmail":"merlyn@stonehenge.com","sentAt":"2005-10-26T20:12:40Z","receivedAt":"2005-10-26T20:12:40Z","isPatch":false,"sender":{"key":"merlyn@stonehenge.com","avatar":"https://gravatar.com/avatar/dc528d210743ff0333e6213f9ee7b33b23f1b7bc1f3c5a8c2d819074ecd7ab19?d=mp&s=160"},"body":">>>>> \"Junio\" == Junio C Hamano <junkio@cox.net> writes:\n\nJunio> I swallowed Linus version.  Thanks for reporting (and also ctype\nJunio> fix the other day).\n\nI apologize that I don't immediately post the patch, but generally\nI figure that maybe Smarter People Than Me might recognize the issue\nbefore I can get around to figuring out what broke.\n\nAfter all, my C is rusty.  My Perl is much better. :)\n\nAlso, I'm learning how git works, to generate diffs and patches, etc.\n\n-- \nRandal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095\n<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>\nPerl/Unix/security consulting, Technical writing, Comedy, etc. etc.\nSee PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!\n"}]}