{"thread":{"id":"31227","subject":"RE: Porting git to HP NonStop","startedAt":"2012-08-10T15:04:06Z","lastAt":"2012-08-22T21:54:45Z","messageCount":39,"participants":["Joachim Schmitz","Shawn Pearce","Johannes Sixt","Junio C Hamano","Brandon Casey"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"196797","messageId":"003a01cd7709$63725260$2a56f720$@schmitz-digital.de","threadId":"31227","inReplyTo":null,"subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-10T15:04:06Z","receivedAt":"2012-08-10T15:04:06Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: git-owner@vger.kernel.org [mailto:git-owner@vger.kernel.org] On\n> Behalf Of Joachim Schmitz\n> Sent: Friday, August 10, 2012 5:01 PM\n> To: git@vger.kernel.org\n> Cc: rsbecker@nexbridge.com\n> Subject: RE: [PATCH v2] add tests for 'git rebase --keep-empty'\n> \n> Hi folks\n> \n> I'm a brand new subscriper of this mailing list, so please forgive if I\nviolate\n> some protocol or talk about things that had been discussed to death\nearlier.\n\nAhrgl, 1st mistake: wrong subject, sorry\n\n> I'm currently in the process of porting git (1.7.11.4 for now) to the HP\nNonStop\n> platform and found several issues:\n> \n> - HP NonStop is lacking poll(), git is making quite some use of it.\n> My Solution: I 'stole' the implementation from GNUlib, which implements\n> poll() using select().\n> Git should either provide its own poll(), not use it at all or resort to\nusing\n> GNUlib, what do you think?.\n> \n> - HP NonStop is lacking getrlimit(), fsync(), setitimer() and memory\nmapped IO.\n> For now I've commented out the part that used getrlimit() and use a home\n> brewed implementation for fsync(), setitimer() and mmap().\n> \n> - git makes use of some C99 features or at least feature that are not\navailabe in\n> C89, like 'inline'\n> C89 is the default compiler on HP NonStop, but we also habe a c99\ncompiler, so\n> telling configure to search for c99  should help here.\n> \n> - libintl and libiconv sem to get linked in the wrong order, resulting in\n> unresolved symbols.\n> I've just moved the \"ifndef NO_GETTEXT\" section of Makefile to above the\n> \"ifdef NEEDS_LIBICONF\" section.\n> \n> - HP NonStop doesn't have stat.st_blocks, this is used in\nbuiltin/count-objects.c\n> around line 45, not sure yet how to fix that.\n> \n> - HP NonStop doesn't have stat.st_?time.nsec, there are several places\nwhat an\n> \"#ifdef USE_NSEC\" is missing, I can provide a diff if needed (offending\n> files: builtin/fetch-pack.c and read-cache.c).\n> \n> - HP NonStop doesn't know SA_RESTART\n> I fixed that with a \"#define SA_RESTART 0\" in the 3 files affected\n(builtin/log.c,\n> fast-import.c and progress.c)\n> \n> - using C99 but not using #include <strings.h> results in compiler errors\ndue to\n> a missing prototype for strcasecmp() I fixed it by adding that to\ngit-compat-\n> util.h\n> \n> - HP NonStop doesn't have intptr_t and uintpr_t (in its stdint.h) I added\nthem to\n> git-compat-util.h\n> \n> - HP NonStop doesn't need the \" #define _XOPEN_SOURCE 600\", just like\n> __APPLE__, __FreeBSD__ etc, so I added a \"&& !defined(__TANDEM) in git-\n> compat-util.h\n> \n> - there seems to be an issue with compat/fnmatch/fnmatch.c not including\n> string.h, seems that HAVE_STRING_H is not #define'd anywhere.\n> \n> \n> - Once compiled and installed, a simple jojo@\\hpitug:/home/jojo/GitHub $\ngit\n> clone git://github.com/git/git.git fails with:\n> /home/jojo/GitHub/git/.git/branches/: No such file or directory After\ncreating\n> those manually it fails because the directory isn't empty,\n> catch-22\n> After some trial'n'error I found that the culprit seems to be the\nsubdirectories\n> branches, hook and info in /usr/local/share/git-core/templates/, if I\n> remove/rename those, the above command works fine.\n> I have no idea why that is nor how to properly fix it, anyone out there?\n> \n> Bye, Jojo\n"},{"id":"196805","messageId":"CAJo=hJvwih+aOMg6SKP94_1q-az1XV-1Pcf=_fGbvdDcDpC23A@mail.gmail.com","threadId":"31227","inReplyTo":"003a01cd7709$63725260$2a56f720$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2012-08-10T16:27:38Z","receivedAt":"2012-08-10T16:27:38Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Fri, Aug 10, 2012 at 8:04 AM, Joachim Schmitz\n<jojo@schmitz-digital.de> wrote:\n>>\n>> - HP NonStop is lacking poll(), git is making quite some use of it.\n>> My Solution: I 'stole' the implementation from GNUlib, which implements\n>> poll() using select().\n>> Git should either provide its own poll(), not use it at all or resort to\n> using\n>> GNUlib, what do you think?.\n\npoll() is usually better than select() because you don't need to worry\nabout FD_SETSIZE. That said, the compat/ directory contains\nimplementations of some functions. You could contribute a fake poll\nthat uses select if it was under the GPLv2.\n\n>> - HP NonStop is lacking getrlimit(), fsync(), setitimer() and memory\n> mapped IO.\n>> For now I've commented out the part that used getrlimit() and use a home\n>> brewed implementation for fsync(), setitimer() and mmap().\n\nThere is no need to define your own mmap(). Define NO_MMAP=1 in the\nMakefile. Git already has its own fake mmap and knows how to write it\nback to disk when making changes.\n\n>> - git makes use of some C99 features or at least feature that are not\n> availabe in\n>> C89, like 'inline'\n>> C89 is the default compiler on HP NonStop, but we also habe a c99\n> compiler, so\n>> telling configure to search for c99  should help here.\n\nYou could also disable inline by #define inline /**/, but this will\nprobably result in a slower binary.\n\n>> - HP NonStop doesn't have stat.st_blocks, this is used in\n> builtin/count-objects.c\n>> around line 45, not sure yet how to fix that.\n\nIIRC the block count is only used to give the user some notion of how\nmuch disk was wasted by the repository. You could hack a macro that\nredefines this as st_size.\n\n>> - HP NonStop doesn't have stat.st_?time.nsec, there are several places\n> what an\n>> \"#ifdef USE_NSEC\" is missing, I can provide a diff if needed (offending\n>> files: builtin/fetch-pack.c and read-cache.c).\n\nI think this would be appreciated by anyone else that has a similar\nproblem where the platform lacks nsec.\n\n>> - Once compiled and installed, a simple jojo@\\hpitug:/home/jojo/GitHub $\n> git\n>> clone git://github.com/git/git.git fails with:\n>> /home/jojo/GitHub/git/.git/branches/: No such file or directory After\n> creating\n>> those manually it fails because the directory isn't empty,\n>> catch-22\n>> After some trial'n'error I found that the culprit seems to be the\n> subdirectories\n>> branches, hook and info in /usr/local/share/git-core/templates/, if I\n>> remove/rename those, the above command works fine.\n>> I have no idea why that is nor how to properly fix it, anyone out there?\n\nThis sounds like the templates directory was not created correctly\nduring installation, or is being copied incorrectly during the git\ninit process. I would start by comparing the structure and permissions\nof the templates directory on your HP NonStop system to one on a Linux\nsystem and see if there was a mistake made during the installation\nprocess. If the directory matches, I would then use `git init --bare`\nin a new directory to copy in the templates, and see if its the\ntemplate copying code that is making an incorrect copy.\n"},{"id":"196810","messageId":"004701cd771e$21b7cbb0$65276310$@schmitz-digital.de","threadId":"31227","inReplyTo":"CAJo=hJvwih+aOMg6SKP94_1q-az1XV-1Pcf=_fGbvdDcDpC23A@mail.gmail.com","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-10T17:32:35Z","receivedAt":"2012-08-10T17:32:35Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Shawn Pearce [mailto:spearce@spearce.org]\n> Sent: Friday, August 10, 2012 6:28 PM\n> To: Joachim Schmitz\n> Cc: git@vger.kernel.org; rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> On Fri, Aug 10, 2012 at 8:04 AM, Joachim Schmitz <jojo@schmitz-digital.de>\n> wrote:\n> >>\n> >> - HP NonStop is lacking poll(), git is making quite some use of it.\n> >> My Solution: I 'stole' the implementation from GNUlib, which\n> >> implements\n> >> poll() using select().\n> >> Git should either provide its own poll(), not use it at all or resort\n> >> to\n> > using\n> >> GNUlib, what do you think?.\n> \n> poll() is usually better than select() because you don't need to worry\nabout\n> FD_SETSIZE. That said, the compat/ directory contains implementations of\n> some functions. You could contribute a fake poll that uses select if it\nwas under\n> the GPLv2.\n\nThis is what I did. Just to see now that compat/win32/poll.c has exacly the\nsame stuff...\n \n> >> - HP NonStop is lacking getrlimit(), fsync(), setitimer() and memory\n> > mapped IO.\n> >> For now I've commented out the part that used getrlimit() and use a\n> >> home brewed implementation for fsync(), setitimer() and mmap().\n> \n> There is no need to define your own mmap(). Define NO_MMAP=1 in the\n> Makefile. Git already has its own fake mmap and knows how to write it back\nto\n> disk when making changes.\n\nAh, excellent. Esp. as our home brewed implementation is pretty primitive.\n\n> >> - git makes use of some C99 features or at least feature that are not\n> > availabe in\n> >> C89, like 'inline'\n> >> C89 is the default compiler on HP NonStop, but we also habe a c99\n> > compiler, so\n> >> telling configure to search for c99  should help here.\n> \n> You could also disable inline by #define inline /**/, but this will\nprobably result\n> in a slower binary.\n\nEven our C99 compiler doesn't inline, it merly recognizes the keyword and\nthen warns about (unable to inline...)\nBut there are other C99 features used too.\n\n> >> - HP NonStop doesn't have stat.st_blocks, this is used in\n> > builtin/count-objects.c\n> >> around line 45, not sure yet how to fix that.\n> \n> IIRC the block count is only used to give the user some notion of how much\ndisk\n> was wasted by the repository. You could hack a macro that redefines this\nas\n> st_size.\n\nOK, thanks, will try that.\n\n> >> - HP NonStop doesn't have stat.st_?time.nsec, there are several\n> >> places\n> > what an\n> >> \"#ifdef USE_NSEC\" is missing, I can provide a diff if needed\n> >> (offending\n> >> files: builtin/fetch-pack.c and read-cache.c).\n> \n> I think this would be appreciated by anyone else that has a similar\nproblem\n> where the platform lacks nsec.\n\nWill do.\n \n> >> - Once compiled and installed, a simple\n> >> jojo@\\hpitug:/home/jojo/GitHub $\n> > git\n> >> clone git://github.com/git/git.git fails with:\n> >> /home/jojo/GitHub/git/.git/branches/: No such file or directory After\n> > creating\n> >> those manually it fails because the directory isn't empty,\n> >> catch-22\n> >> After some trial'n'error I found that the culprit seems to be the\n> > subdirectories\n> >> branches, hook and info in /usr/local/share/git-core/templates/, if I\n> >> remove/rename those, the above command works fine.\n> >> I have no idea why that is nor how to properly fix it, anyone out\nthere?\n> \n> This sounds like the templates directory was not created correctly during\n> installation, or is being copied incorrectly during the git init process.\nI would\n> start by comparing the structure and permissions of the templates\ndirectory on\n> your HP NonStop system to one on a Linux system and see if there was a\n> mistake made during the installation process. If the directory matches, I\nwould\n\njojo@\\hpitug:/usr/local/share/git-core/templates $ ls -laR\ntotal 41\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 12:10 .\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 08:19 ..\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 07:26 branches\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 07:26 hooks\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 07:26 info\n-rw-r--r--    1 SUPER.SUPER        SUPER         73 Aug 10 07:26 description\n\n./branches:\ntotal 16\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 07:26 .\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 12:10 ..\n\n./hooks:\ntotal 43\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 07:26 .\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 12:10 ..\n-rwxr-xr-x    1 SUPER.SUPER        SUPER        452 Aug 10 07:26\napplypatch-msg.sample\n-rwxr-xr-x    1 SUPER.SUPER        SUPER        896 Aug 10 07:26\ncommit-msg.sample\n-rwxr-xr-x    1 SUPER.SUPER        SUPER        189 Aug 10 07:26\npost-update.sample\n-rwxr-xr-x    1 SUPER.SUPER        SUPER        398 Aug 10 07:26\npre-applypatch.sample\n-rwxr-xr-x    1 SUPER.SUPER        SUPER       1704 Aug 10 07:26\npre-commit.sample\n-rwxr-xr-x    1 SUPER.SUPER        SUPER       4957 Aug 10 07:26\npre-rebase.sample\n-rwxr-xr-x    1 SUPER.SUPER        SUPER       1251 Aug 10 07:26\nprepare-commit-msg.sample\n-rwxr-xr-x    1 SUPER.SUPER        SUPER       3611 Aug 10 07:26\nupdate.sample\n\n./info:\ntotal 17\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 07:26 .\ndrwxr-xr-x    1 SUPER.SUPER        SUPER       4096 Aug 10 12:10 ..\n-rw-r--r--    1 SUPER.SUPER        SUPER        240 Aug 10 07:26 exclude\njojo@\\hpitug:/usr/local/share/git-core/templates $\n\nSUPER.SUPER on NonStop is equivalent to root in UNIX. Everything is readable\nto everybody. Looks OK to me?\n\n> then use `git init --bare` in a new directory to copy in the templates,\nand see if\n> its the template copying code that is making an incorrect copy.\n\n\"git init --bare\" gives the same error. It isn't copying any of the\nsubdirectories, only the file 'description'\n\nBye, Jojo\n"},{"id":"196812","messageId":"CAJo=hJsz3ooDAV-0S-BDknnbQPK9ASEYw8b7t7PyKEtJ5jgxQA@mail.gmail.com","threadId":"31227","inReplyTo":"004701cd771e$21b7cbb0$65276310$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2012-08-10T17:38:06Z","receivedAt":"2012-08-10T17:38:06Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Fri, Aug 10, 2012 at 10:32 AM, Joachim Schmitz\n<jojo@schmitz-digital.de> wrote:\n>> then use `git init --bare` in a new directory to copy in the templates,\n> and see if\n>> its the template copying code that is making an incorrect copy.\n>\n> \"git init --bare\" gives the same error. It isn't copying any of the\n> subdirectories, only the file 'description'\n\nTime to start debugging copy_templates_1 in builtin/init-db.c. :-(\n"},{"id":"196829","messageId":"004d01cd7733$f55d43e0$e017cba0$@schmitz-digital.de","threadId":"31227","inReplyTo":"CAJo=hJvwih+aOMg6SKP94_1q-az1XV-1Pcf=_fGbvdDcDpC23A@mail.gmail.com","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-10T20:08:49Z","receivedAt":"2012-08-10T20:08:49Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Joachim Schmitz [mailto:jojo@schmitz-digital.de]\n> Sent: Friday, August 10, 2012 7:33 PM\n> To: 'Shawn Pearce'\n> Cc: 'git@vger.kernel.org'; 'rsbecker@nexbridge.com'\n> Subject: RE: Porting git to HP NonStop\n> \n> > From: Shawn Pearce [mailto:spearce@spearce.org]\n> > Sent: Friday, August 10, 2012 6:28 PM\n> > To: Joachim Schmitz\n> > Cc: git@vger.kernel.org; rsbecker@nexbridge.com\n> > Subject: Re: Porting git to HP NonStop\n> >\n> > On Fri, Aug 10, 2012 at 8:04 AM, Joachim Schmitz\n> > <jojo@schmitz-digital.de>\n> > wrote:\n<snip>\n> > >> - HP NonStop doesn't have stat.st_blocks, this is used in\n> > > builtin/count-objects.c\n> > >> around line 45, not sure yet how to fix that.\n> >\n> > IIRC the block count is only used to give the user some notion of how\n> > much disk was wasted by the repository. You could hack a macro that\n> > redefines this as st_size.\n> \n> OK, thanks, will try that.\n\nSetting \"NO_ST_BLOCKS_IN_STRUCT_STAT = YesPlease\" in Makefile helps, no need\nfor further hacking ;-).\n\n> > >> - HP NonStop doesn't have stat.st_?time.nsec, there are several\n> > >> places\n> > > what an\n> > >> \"#ifdef USE_NSEC\" is missing, I can provide a diff if needed\n> > >> (offending\n> > >> files: builtin/fetch-pack.c and read-cache.c).\n> >\n> > I think this would be appreciated by anyone else that has a similar\n> > problem where the platform lacks nsec.\n> \n> Will do.\n\nOK, here we go:\n\n/usr/local/bin/diff -EBbu ./builtin/fetch-pack.c.orig ./builtin/fetch-pack.c\n--- ./builtin/fetch-pack.c.orig 2012-07-30 15:50:38 -0500\n+++ ./builtin/fetch-pack.c      2012-08-10 01:50:28 -0500\n@@ -1096,7 +1096,9 @@\n                int fd;\n\n                mtime.sec = st.st_mtime;\n+#ifdef USE_NSEC\n                mtime.nsec = ST_MTIME_NSEC(st);\n+#endif\n                if (stat(shallow, &st)) {\n                        if (mtime.sec)\n                                die(\"shallow file was removed during\nfetch\");\n/usr/local/bin/diff -EBbu ./read-cache.c.orig ./read-cache.c\n--- ./read-cache.c.orig 2012-07-30 15:50:38 -0500\n+++ ./read-cache.c      2012-08-09 10:57:57 -0500\n@@ -72,8 +72,10 @@\n {\n        ce->ce_ctime.sec = (unsigned int)st->st_ctime;\n        ce->ce_mtime.sec = (unsigned int)st->st_mtime;\n+#ifdef USE_NSEC\n        ce->ce_ctime.nsec = ST_CTIME_NSEC(*st);\n        ce->ce_mtime.nsec = ST_MTIME_NSEC(*st);\n+#endif\n        ce->ce_dev = st->st_dev;\n        ce->ce_ino = st->st_ino;\n        ce->ce_uid = st->st_uid;\n@@ -1465,7 +1467,9 @@\n        }\n        strbuf_release(&previous_name_buf);\n        istate->timestamp.sec = st.st_mtime;\n+#ifdef USE_NSEC\n        istate->timestamp.nsec = ST_MTIME_NSEC(st);\n+#endif\n\n        while (src_offset <= mmap_size - 20 - 8) {\n                /* After an array of active_nr index entries,\n@@ -1821,7 +1825,9 @@\n        if (ce_flush(&c, newfd) || fstat(newfd, &st))\n                return -1;\n        istate->timestamp.sec = (unsigned int)st.st_mtime;\n+#ifdef USE_NSEC\n        istate->timestamp.nsec = ST_MTIME_NSEC(st);\n+#endif\n        return 0;\n }\n\nHope this helps?\n\nCould you also consider adding the following:\n\n/usr/local/bin/diff -EBbu ./git-compat-util.h.orig ./git-compat-util.h\n--- ./git-compat-util.h.orig    2012-07-30 15:50:38 -0500\n+++ ./git-compat-util.h 2012-08-10 09:59:56 -0500\n@@ -74,7 +74,8 @@\n # define _XOPEN_SOURCE 500\n # endif\n #elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) &&\n\\\n-      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__)\n+      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) && \\\n+      !defined(__TANDEM)\n #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs\n600 for S_ISLNK() */\n #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */\n #endif\n@@ -98,6 +99,11 @@\n #include <stdlib.h>\n #include <stdarg.h>\n #include <string.h>\n+#ifdef __TANDEM\n+# include <strings.h> /* for strcasecmp() */\n+  typedef long int intptr_t;\n+  typedef unsigned long int uintptr_t;\n+#endif\n #include <errno.h>\n #include <limits.h>\n #include <sys/param.h>\n\nBye, Jojo\n"},{"id":"196856","messageId":"502615C0.1050406@kdbg.org","threadId":"31227","inReplyTo":"CAJo=hJvwih+aOMg6SKP94_1q-az1XV-1Pcf=_fGbvdDcDpC23A@mail.gmail.com","subject":"Re: Porting git to HP NonStop","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-08-11T08:20:16Z","receivedAt":"2012-08-11T08:20:16Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 10.08.2012 18:27, schrieb Shawn Pearce:\n> There is no need to define your own mmap(). Define NO_MMAP=1 in the\n> Makefile. Git already has its own fake mmap and knows how to write it\n> back to disk when making changes.\n\nOr better to say: the fake mmap has functionality that is sufficient for\ngit. In particular, it does *not* write back changes to disk (it\nsupports only MAP_PRIVATE), and the mapped area does not change if the\nfile is changed by a third party.\n\n-- Hannes\n"},{"id":"196958","messageId":"000f01cd79eb$2a0b6e00$7e224a00$@schmitz-digital.de","threadId":"31227","inReplyTo":"CAJo=hJvwih+aOMg6SKP94_1q-az1XV-1Pcf=_fGbvdDcDpC23A@mail.gmail.com","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-14T07:05:18Z","receivedAt":"2012-08-14T07:05:18Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Joachim Schmitz [mailto:jojo@schmitz-digital.de]\n> Sent: Friday, August 10, 2012 10:09 PM\n> To: 'Shawn Pearce'\n> Cc: 'git@vger.kernel.org'; 'rsbecker@nexbridge.com'\n> Subject: RE: Porting git to HP NonStop\n> \n> > From: Joachim Schmitz [mailto:jojo@schmitz-digital.de]\n> > Sent: Friday, August 10, 2012 7:33 PM\n> > To: 'Shawn Pearce'\n> > Cc: 'git@vger.kernel.org'; 'rsbecker@nexbridge.com'\n> > Subject: RE: Porting git to HP NonStop\n> >\n> > > From: Shawn Pearce [mailto:spearce@spearce.org]\n> > > Sent: Friday, August 10, 2012 6:28 PM\n> > > To: Joachim Schmitz\n> > > Cc: git@vger.kernel.org; rsbecker@nexbridge.com\n> > > Subject: Re: Porting git to HP NonStop\n> > >\n> > > On Fri, Aug 10, 2012 at 8:04 AM, Joachim Schmitz\n> > > <jojo@schmitz-digital.de>\n> > > wrote:\n> <snip>\n> > > >> - HP NonStop doesn't have stat.st_?time.nsec, there are several\n> > > >> places\n> > > > what an\n> > > >> \"#ifdef USE_NSEC\" is missing, I can provide a diff if needed\n> > > >> (offending\n> > > >> files: builtin/fetch-pack.c and read-cache.c).\n> > >\n> > > I think this would be appreciated by anyone else that has a similar\n> > > problem where the platform lacks nsec.\n> >\n> > Will do.\n> \n> OK, here we go:\n> \n> /usr/local/bin/diff -EBbu ./builtin/fetch-pack.c.orig\n./builtin/fetch-pack.c\n<snip>\n\nSorry, this is not needed if I just set NO_NSEC, so just forget about it\n(and thanks to Junio for telling be)\n\n> /usr/local/bin/diff -EBbu ./git-compat-util.h.orig ./git-compat-util.h\n> --- ./git-compat-util.h.orig    2012-07-30 15:50:38 -0500\n> +++ ./git-compat-util.h 2012-08-10 09:59:56 -0500\n> @@ -74,7 +74,8 @@\n>  # define _XOPEN_SOURCE 500\n>  # endif\n>  #elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__)\n> && \\\n> -      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__)\n> +      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) &&\n\\\n> +      !defined(__TANDEM)\n>  #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD\n> needs 600 for S_ISLNK() */  #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L\n> needs this */  #endif @@ -98,6 +99,11 @@  #include <stdlib.h>  #include\n> <stdarg.h>  #include <string.h>\n> +#ifdef __TANDEM\n> +# include <strings.h> /* for strcasecmp() */\n> +  typedef long int intptr_t;\n> +  typedef unsigned long int uintptr_t;\n> +#endif\n>  #include <errno.h>\n>  #include <limits.h>\n>  #include <sys/param.h>\n\nThis one still stands though, unless someone can come up with a better idea?\n\nBye, Jojo\n"},{"id":"196974","messageId":"7vipcl8qu2.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"000f01cd79eb$2a0b6e00$7e224a00$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-14T14:56:37Z","receivedAt":"2012-08-14T14:56:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n\n>> /usr/local/bin/diff -EBbu ./git-compat-util.h.orig ./git-compat-util.h\n>> --- ./git-compat-util.h.orig    2012-07-30 15:50:38 -0500\n>> +++ ./git-compat-util.h 2012-08-10 09:59:56 -0500\n>> @@ -74,7 +74,8 @@\n>>  # define _XOPEN_SOURCE 500\n>>  # endif\n>>  #elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__)\n>> && \\\n>> -      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__)\n>> +      !defined(_M_UNIX) && !defined(__sgi) && !defined(__DragonFly__) &&\n> \\\n>> +      !defined(__TANDEM)\n>>  #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD\n>> needs 600 for S_ISLNK() */  #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L\n>> needs this */  #endif @@ -98,6 +99,11 @@  #include <stdlib.h>  #include\n>> <stdarg.h>  #include <string.h>\n>> +#ifdef __TANDEM\n>> +# include <strings.h> /* for strcasecmp() */\n>> +  typedef long int intptr_t;\n>> +  typedef unsigned long int uintptr_t;\n>> +#endif\n>>  #include <errno.h>\n>>  #include <limits.h>\n>>  #include <sys/param.h>\n>\n> This one still stands though, unless someone can come up with a better idea?\n\nThis hunk looks unobtrusive and obviously will not impact other\nplatforms, which is good.\n"},{"id":"197279","messageId":"01a801cd7de8$b4c311a0$1e4934e0$@schmitz-digital.de","threadId":"31227","inReplyTo":"CAJo=hJsz3ooDAV-0S-BDknnbQPK9ASEYw8b7t7PyKEtJ5jgxQA@mail.gmail.com","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-19T08:57:47Z","receivedAt":"2012-08-19T08:57:47Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Shawn Pearce [mailto:spearce@spearce.org]\n> Sent: Friday, August 10, 2012 7:38 PM\n> To: Joachim Schmitz\n> Cc: git@vger.kernel.org; rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> On Fri, Aug 10, 2012 at 10:32 AM, Joachim Schmitz\n<jojo@schmitz-digital.de>\n> wrote:\n> >> then use `git init --bare` in a new directory to copy in the\n> >> templates,\n> > and see if\n> >> its the template copying code that is making an incorrect copy.\n> >\n> > \"git init --bare\" gives the same error. It isn't copying any of the\n> > subdirectories, only the file 'description'\n> \n> Time to start debugging copy_templates_1 in builtin/init-db.c. :-(\n\nFound the problem: our mkdir(dir,flags) fails with ENOENT when dir ends with\na '/'.\nNot sure whether this us a bug on out platform or just allowed by POSIX and\nas such a wrong assumption in git though?\n\n[shortly after]\nA bit of googleing revealed that there is a GNUlib solution for this, which\nclaims that at least NetBSD 1.5.2 has the same problem.\n(http://www.opensource.apple.com/source/gpatch/gpatch-2/patch/mkdir.c)\n\nAnd apparently this has been discussed on the git mailing list too, 2 years\nago:\nhttp://lists-archives.com/git/728359-git-s-use-of-mkdir-2.html, there's a\npatch too.\n\nFor now I've fixed it like this:\n/usr/local/bin/diff -EBbu ./builtin/init-db.c.orig ./builtin/init-db.c\n--- ./builtin/init-db.c.orig    2012-08-19 03:55:50 -0500\n+++ ./builtin/init-db.c 2012-08-19 03:39:57 -0500\n@@ -25,7 +25,16 @@\n\n static void safe_create_dir(const char *dir, int share)\n {\n+#ifdef __TANDEM /* our mkdir() can't cope with a trailing '/' */\n+       char mydir[PATH_MAX];\n+\n+       strcpy(mydir,dir);\n+       if (dir[strlen(dir)-1] == '/')\n+               mydir[strlen(dir)-1] = '\\0';\n+       if (mkdir(mydir, 0777) < 0) {\n+#else\n        if (mkdir(dir, 0777) < 0) {\n+#endif\n                if (errno != EEXIST) {\n                        perror(dir);\n                        exit(1);\n\n\n\nBye, Jojo \n"},{"id":"197291","messageId":"7v628epzia.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"01a801cd7de8$b4c311a0$1e4934e0$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-19T17:23:09Z","receivedAt":"2012-08-19T17:23:09Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n\n> Found the problem: our mkdir(dir,flags) fails with ENOENT when dir ends with\n> a '/'.\n> Not sure whether this us a bug on out platform or just allowed by POSIX and\n> as such a wrong assumption in git though?\n>\n> [shortly after]\n> A bit of googleing revealed that there is a GNUlib solution for this, which\n> claims that at least NetBSD 1.5.2 has the same problem.\n> (http://www.opensource.apple.com/source/gpatch/gpatch-2/patch/mkdir.c)\n>\n> And apparently this has been discussed on the git mailing list too, 2 years\n> ago:\n> http://lists-archives.com/git/728359-git-s-use-of-mkdir-2.html, there's a\n> patch too.\n\nGiven that newer BSDs have fixed libc to accept directory name with\na trailing slash, and that we use mkdir(2) in many places, I think\nthe right way to do so is still what I suggested in that old thread\nin the last paragraph of my message\n\n  http://thread.gmane.org/gmane.comp.version-control.git/155812/focus=155876\n\nThat is, have compat/tandem.c and define a replacement mkdir(2) in a\nway similar to how MinGW does so.\n\n> For now I've fixed it like this:\n> /usr/local/bin/diff -EBbu ./builtin/init-db.c.orig ./builtin/init-db.c\n> --- ./builtin/init-db.c.orig    2012-08-19 03:55:50 -0500\n> +++ ./builtin/init-db.c 2012-08-19 03:39:57 -0500\n> @@ -25,7 +25,16 @@\n>\n>  static void safe_create_dir(const char *dir, int share)\n>  {\n> +#ifdef __TANDEM /* our mkdir() can't cope with a trailing '/' */\n> +       char mydir[PATH_MAX];\n> +\n> +       strcpy(mydir,dir);\n> +       if (dir[strlen(dir)-1] == '/')\n> +               mydir[strlen(dir)-1] = '\\0';\n> +       if (mkdir(mydir, 0777) < 0) {\n> +#else\n>         if (mkdir(dir, 0777) < 0) {\n> +#endif\n\nMove that part inside #ifdef __TANDEM to define\n\n\tint tandem_mkdir(const char *dir, mode_t mode)\n        {\n\t\t...\n\t}\n\nin your new file compat/tandem.c, add\n\n\t#ifdef __TANDEM\n        #define mkdir(a,b) tandem_mkdir((a), (b))\n\t#endif\n\nto git-compat-util.h and then add compat/tandem.o to COMPAT_OBJS in\nthe top-level Makefile.\n\nThat way we do not have to keep an ugly platform specific ifdef in\nthe very generic codepath.\n\n>                 if (errno != EEXIST) {\n>                         perror(dir);\n>                         exit(1);\n>\n>\n>\n> Bye, Jojo \n"},{"id":"197331","messageId":"000601cd7ebd$a4ef5740$eece05c0$@schmitz-digital.de","threadId":"31227","inReplyTo":"7v628epzia.fsf@alter.siamese.dyndns.org","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-20T10:22:03Z","receivedAt":"2012-08-20T10:22:03Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Junio C Hamano [mailto:gitster@pobox.com]\n> Sent: Sunday, August 19, 2012 7:23 PM\n> To: Joachim Schmitz\n> Cc: 'Shawn Pearce'; git@vger.kernel.org; rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> \"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n> \n> > Found the problem: our mkdir(dir,flags) fails with ENOENT when dir\n> > ends with a '/'.\n> > Not sure whether this us a bug on out platform or just allowed by\n> > POSIX and as such a wrong assumption in git though?\n> >\n> > [shortly after]\n> > A bit of googleing revealed that there is a GNUlib solution for this,\n> > which claims that at least NetBSD 1.5.2 has the same problem.\n> > (http://www.opensource.apple.com/source/gpatch/gpatch-2/patch/mkdir.c)\n> >\n> > And apparently this has been discussed on the git mailing list too, 2\n> > years\n> > ago:\n> > http://lists-archives.com/git/728359-git-s-use-of-mkdir-2.html,\n> > there's a patch too.\n> \n> Given that newer BSDs have fixed libc to accept directory name with a\ntrailing\n> slash, and that we use mkdir(2) in many places, I think the right way to\ndo so is\n> still what I suggested in that old thread in the last paragraph of my\nmessage\n> \n>   http://thread.gmane.org/gmane.comp.version-\n> control.git/155812/focus=155876\n> \n> That is, have compat/tandem.c and define a replacement mkdir(2) in a way\n> similar to how MinGW does so.\n\nOK, I'll go for a compat/mkdir.c though.\nWe shouldn't call it tandem.c as Tandem, the Company, doesn't exist anymore\nand since more than a decade (bough by Compaq, then HP), only the __TANDEM\nsurvived in our compiler and headers/libraries. Could call it NonStop.c, but\nI don't really like that idea either, I'd rather keep it more generic, just\nin case someone else might need it too, or that issue someday gets fixed for\nNonStop.\n\n> > For now I've fixed it like this:\n> > /usr/local/bin/diff -EBbu ./builtin/init-db.c.orig ./builtin/init-db.c\n> > --- ./builtin/init-db.c.orig    2012-08-19 03:55:50 -0500\n> > +++ ./builtin/init-db.c 2012-08-19 03:39:57 -0500\n> > @@ -25,7 +25,16 @@\n> >\n> >  static void safe_create_dir(const char *dir, int share)  {\n> > +#ifdef __TANDEM /* our mkdir() can't cope with a trailing '/' */\n> > +       char mydir[PATH_MAX];\n> > +\n> > +       strcpy(mydir,dir);\n> > +       if (dir[strlen(dir)-1] == '/')\n> > +               mydir[strlen(dir)-1] = '\\0';\n> > +       if (mkdir(mydir, 0777) < 0) {\n> > +#else\n> >         if (mkdir(dir, 0777) < 0) {\n> > +#endif\n> \n> Move that part inside #ifdef __TANDEM to define\n> \n> \tint tandem_mkdir(const char *dir, mode_t mode)\n>         {\n> \t\t...\n> \t}\n\nI'll go for git_mkdir(), similar to other git wrappers, (like for mmap,\npread, fopen, snprintf, vsnprintf, qsort). Could call it gitmkdir() too\n(like for basename, setenv, mkdtemp, mkstemps, unsetenv, strcasestr,\nstrlcpy, strtoumax, strtoimax, strtok_r, hstrerror, memmem, strchrnul,\nmemcpy), Opinions?\nIt seems the ones without the \"_\" are for missing APIs and the ones with \"_\"\nto wrap existing APIs (not sure about mmap and pread)?\n\nHere it's current state:\n$ cat compat/mkdir.c\n#include \"../git-compat-util.h\"\n#undef mkdir\n\n/* for platforms that can't deal with a trailing '/' */\nint git_mkdir(const char *dir, mode_t mode)\n{\n        int retval;\n        char *tmp_dir = NULL;\n        size_t len = strlen(dir);\n\n        if (len && dir[len-1] == '/') {\n                if ((tmp_dir = strdup(dir)) == NULL)\n                        return -1;\n                tmp_dir[len-1] = '\\0';\n        }\n        else\n                tmp_dir = (char *)dir;\n\n        retval = mkdir(tmp_dir, mode);\n        if (tmp_dir != dir)\n                free(tmp_dir);\n\n        return retval;\n}\n$\n \nThere is room for improvement though: it only removes one trailing slash. By\nfar not as advanced and generic as GNUlib's mkdir wrapper, but should be\ngood enough for git's usage.\n\n> in your new file compat/tandem.c, add\n> \n> \t#ifdef __TANDEM\n>         #define mkdir(a,b) tandem_mkdir((a), (b))\n> \t#endif\n> \n> to git-compat-util.h\n\nAgain, git_mkdir, see above\n\n> and then add compat/tandem.o to COMPAT_OBJS in the\n> top-level Makefile.\n\nFor now I've added it to the (new) NOSTOP_KERNEL section. \n\nWe may want it to go along with some\nMKDIR_DISLIKES_TRAILING_SLASH or MKDIR_BOGUS_TRAILING_SLASH some such.\nOpinions, Ideas?\n\n> That way we do not have to keep an ugly platform specific ifdef in the\nvery\n> generic codepath.\n\nAgreed, it was my quick and dirty fix for it.\n\nBye, Jojo\n"},{"id":"197412","messageId":"7vy5l9lj6m.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"000601cd7ebd$a4ef5740$eece05c0$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-20T14:41:37Z","receivedAt":"2012-08-20T14:41:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n\n> OK, I'll go for a compat/mkdir.c though.\n\nNo.  See below.\n\n> We shouldn't call it tandem.c as Tandem, the Company, doesn't exist anymore\n> and since more than a decade (bough by Compaq, then HP), only the __TANDEM\n> survived in our compiler and headers/libraries. Could call it NonStop.c, but\n> I don't really like that idea either, I'd rather keep it more generic, just\n> in case someone else might need it too, or that issue someday gets fixed for\n> NonStop.\n\ncompat/hp_nonstop.c is also fine, but I think matching \"#ifdef __TANDEM\" is\nthe most sensible.\n\nAnd I wouldn't call it just \"mkdir\", as it is more likely than not\nthat we will find other incompatibilities that needs to be absorbed\nin the compat/ layer, and we can add it to compat/tandem.c, but not\nto compat/mkdir.c, as that will be another nonstop specific tweak. \nA separate file, compat/tandem/mkdir.c, is fine, though.\n\n> I'll go for git_mkdir(), similar to other git wrappers, (like for mmap,\n> pread, fopen, snprintf, vsnprintf, qsort).\n\nAgain, no.  Your breakage is that having underlying system mkdir\nthat does not understand trailing slash, which may not be specific\nto __TANDEM, but still is _not_ the only possible mode of breakage.\nSquatting on a generic \"git_mkdir()\" name makes it harder for other\npeople to name their compat mkdir functions to tweak for the\nbreakage on their platforms.  The examples you listed are all \"the\nplatform does not offer it, so we implement the whole thing\" kind,\nso it is in a different genre.\n"},{"id":"197413","messageId":"001801cd7eee$24f95a50$6eec0ef0$@schmitz-digital.de","threadId":"31227","inReplyTo":"7vy5l9lj6m.fsf@alter.siamese.dyndns.org","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-20T16:09:14Z","receivedAt":"2012-08-20T16:09:14Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Junio C Hamano [mailto:gitster@pobox.com]\n> Sent: Monday, August 20, 2012 4:42 PM\n> To: Joachim Schmitz\n> Cc: 'Shawn Pearce'; git@vger.kernel.org; rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> \"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n> \n> > OK, I'll go for a compat/mkdir.c though.\n> \n> No.  See below.\n> \n> > We shouldn't call it tandem.c as Tandem, the Company, doesn't exist\n> > anymore and since more than a decade (bough by Compaq, then HP), only\n> > the __TANDEM survived in our compiler and headers/libraries. Could\n> > call it NonStop.c, but I don't really like that idea either, I'd\n> > rather keep it more generic, just in case someone else might need it\n> > too, or that issue someday gets fixed for NonStop.\n> \n> compat/hp_nonstop.c is also fine, but I think matching \"#ifdef __TANDEM\"\nis\n> the most sensible.\n> \n> And I wouldn't call it just \"mkdir\", as it is more likely than not that we\nwill find\n> other incompatibilities that needs to be absorbed in the compat/ layer,\nand we\n> can add it to compat/tandem.c, but not to compat/mkdir.c, as that will be\n> another nonstop specific tweak.\n\nI haven't found any other to be needed. Well, poll, maybe, but with only\nminor tweaks for the win32 one works for me (and those tweaks are compatible\nwith win32\n\n> A separate file, compat/tandem/mkdir.c, is fine, though.\n> \n> > I'll go for git_mkdir(), similar to other git wrappers, (like for\n> > mmap, pread, fopen, snprintf, vsnprintf, qsort).\n> \n> Again, no.  Your breakage is that having underlying system mkdir that does\nnot\n> understand trailing slash, which may not be specific to __TANDEM, but\nstill is\n> _not_ the only possible mode of breakage.\n\nWell, it is the only one GNUlib's mkdir caters for and I'd regard that an\nauthoritative source...\n\n> Squatting on a generic \"git_mkdir()\" name makes it harder for other people\nto\n> name their compat mkdir functions to tweak for the breakage on their\n> platforms.  The examples you listed are all \"the platform does not offer\nit, so\n> we implement the whole thing\" kind, so it is in a different genre.\n\nNope, git_fopen() definitly is a wrapper for fopen(), as is git_vsnprintf()\nfor vsnprintf().\n\nBye, Jojo\n"},{"id":"197422","messageId":"7v4nnxld24.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"001801cd7eee$24f95a50$6eec0ef0$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-20T16:53:55Z","receivedAt":"2012-08-20T16:53:55Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n\n> I haven't found any other to be needed. Well, poll, maybe, but with only\n> minor tweaks for the win32 one works for me (and those tweaks are compatible\n> with win32\n>\n>> A separate file, compat/tandem/mkdir.c, is fine, though.\n\nIf you wouldn't have dozens of them, so compat/tandem/mkdir.c is not\nsuitable; compat/tandem.c would be good, then.\n\n>> > I'll go for git_mkdir(), similar to other git wrappers, (like for\n>> > mmap, pread, fopen, snprintf, vsnprintf, qsort).\n>> \n>> Again, no.  Your breakage is that having underlying system mkdir that does\n> not\n>> understand trailing slash, which may not be specific to __TANDEM, but\n> still is\n>> _not_ the only possible mode of breakage.\n>\n> Well, it is the only one GNUlib's mkdir caters for and I'd regard that an\n> authoritative source...\n\nI suspect that you may be misunderstanding what compat/ is about, so\nlet's try again.\n\nPlatform difference in mkdir may not be limited to \"on this\nplatform, the underlying one supplied by the system does not like\npath ending with a slash\".\n\nWhat I am saying is that it is unacceptable to call something that\ncaters to that specific kind of difference from what the codebase\nexpects with a generic name such as \"git_mkdir()\".  Look at mingw's\nreplacement.  The platform difference over there is that the one\nfrom the system does not take mode parameter.  Imagine that one\nwas already called \"git_mkdir()\".  Now we have two different kind of\ndifferences, and one has more officially-looking \"git_mkdir()\" name;\nyours cannot take it---what would you do in that case?  Neither kind\nof difference is more officially sanctioned difference; don't call\nyours any more official/generic than necessary.\n\nYour wrapper is not limited to tandem, but is applicable to ancient\nBSDs, so it is fine to call it as compat_mkdir_wo_trailing_slash(),\nso that it can be shared among platforms whose mkdir do not want to\nsee trailing slashes.  If you are going that route, the function\nshould live in its own file (without any other wrapper), and not be\nnamed after specific platform (should be named after the specific\ndifference from what we expect, instead).  I am perfectly fine with\nthat approach as well.\n\n>> Squatting on a generic \"git_mkdir()\" name makes it harder for other people\n> to\n>> name their compat mkdir functions to tweak for the breakage on their\n>> platforms.  The examples you listed are all \"the platform does not offer\n> it, so\n>> we implement the whole thing\" kind, so it is in a different genre.\n>\n> Nope, git_fopen() definitly is a wrapper for fopen(), as is git_vsnprintf()\n> for vsnprintf().\n\nI was talking more about mmap() and pread().\n\nFor the two you mentioned, ideally they should have been named after\nthe specific breakages they cover (fopen that does not error out on\ndirectories is primarily AIX thing IIRC, and snprintf returns bogus\nresult are shared between HPUX and Windows), but over these years we\nhaven't seen any other kind of differences from various platforms, so\nthe need to rename them away is very low.\n\nOn the other hand, we already know there are at least two kinds of\nplatform mkdir() that need different compat/ layer support, so\ncalling one \"git_mkdir()\" to cover one particular kind of difference\ndoes not make any sense.\n\nBesides, an earlier mistake is not a valid excuse to add new\nmistakes.\n"},{"id":"197591","messageId":"002a01cd8083$69fb9960$3df2cc20$@schmitz-digital.de","threadId":"31227","inReplyTo":"7v4nnxld24.fsf@alter.siamese.dyndns.org","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T16:30:15Z","receivedAt":"2012-08-22T16:30:15Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Junio C Hamano [mailto:gitster@pobox.com]\n> Sent: Monday, August 20, 2012 6:54 PM\n> To: Joachim Schmitz\n> Cc: 'Shawn Pearce'; git@vger.kernel.org; rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> \"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n> \n> > I haven't found any other to be needed. Well, poll, maybe, but with\n> > only minor tweaks for the win32 one works for me (and those tweaks are\n> > compatible with win32\n> >\n> >> A separate file, compat/tandem/mkdir.c, is fine, though.\n> \n> If you wouldn't have dozens of them, so compat/tandem/mkdir.c is not\nsuitable;\n> compat/tandem.c would be good, then.\n> \n> >> > I'll go for git_mkdir(), similar to other git wrappers, (like for\n> >> > mmap, pread, fopen, snprintf, vsnprintf, qsort).\n> >>\n> >> Again, no.  Your breakage is that having underlying system mkdir that\n> >> does\n> > not\n> >> understand trailing slash, which may not be specific to __TANDEM, but\n> > still is\n> >> _not_ the only possible mode of breakage.\n\nTrue.\n\n> > Well, it is the only one GNUlib's mkdir caters for and I'd regard that\n> > an authoritative source...\n> \n> I suspect that you may be misunderstanding what compat/ is about\n\nI don't think so, it server the same purpose for git as gnulib does for\nothers.\n\n>, so let's try again.\n> Platform difference in mkdir may not be limited to \"on this platform, the\n> underlying one supplied by the system does not like path ending with a\nslash\".\n> \n> What I am saying is that it is unacceptable to call something that caters\nto that\n> specific kind of difference from what the codebase expects with a generic\n> name such as \"git_mkdir()\".  Look at mingw's replacement.  The platform\n> difference over there is that the one from the system does not take mode\n> parameter.  Imagine that one was already called \"git_mkdir()\".  Now we\nhave\n> two different kind of differences, and one has more officially-looking\n> \"git_mkdir()\" name; yours cannot take it---what would you do in that case?\n> Neither kind of difference is more officially sanctioned difference; don't\ncall\n> yours any more official/generic than necessary.\n\nGnulib's rpl_mkdir caters for 3 possible problems, the WIN32 one which mkdir\ntaking only one argument, the trailing slash one discussed here (victims\nbeing at least NetBSD 1.5.2 and current HP NonStop) and a trailing dot one\n(that allegedly Cygwin 1.5 suffered from).\n\nAs far as I can see git will not suffer from the latter, but even if, at\nthat time a git_mkdir() could be expanded to cater for this to, just like\ngnulib's one does, there it is an additional section inside their\nrpl_mkdir().\nAnd the WIN32 one is already being taken care of in compat/mingw.h. However,\nthis could as easily get integrated into \na git_mkdir(), just like in gnulib.\n\n> Your wrapper is not limited to tandem, but is applicable to ancient BSDs,\nso it is\n> fine to call it as compat_mkdir_wo_trailing_slash(), so that it can be\nshared\n> among platforms whose mkdir do not want to see trailing slashes.  If you\nare\n> going that route, the function should live in its own file (without any\nother\n> wrapper), and not be named after specific platform (should be named after\nthe\n> specific difference from what we expect, instead).  I am perfectly fine\nwith that\n> approach as well.\n> \n> >> Squatting on a generic \"git_mkdir()\" name makes it harder for other\n> >> people\n> > to\n> >> name their compat mkdir functions to tweak for the breakage on their\n> >> platforms.  The examples you listed are all \"the platform does not\n> >> offer\n> > it, so\n> >> we implement the whole thing\" kind, so it is in a different genre.\n> >\n> > Nope, git_fopen() definitly is a wrapper for fopen(), as is\n> > git_vsnprintf() for vsnprintf().\n> \n> I was talking more about mmap() and pread().\n> \n> For the two you mentioned, ideally they should have been named after the\n> specific breakages they cover (fopen that does not error out on\ndirectories is\n> primarily AIX thing IIRC, and snprintf returns bogus result are shared\nbetween\n> HPUX and Windows), but over these years we haven't seen any other kind of\n> differences from various platforms, so the need to rename them away is\nvery\n> low.\n> \n> On the other hand, we already know there are at least two kinds of\nplatform\n> mkdir() that need different compat/ layer support, so calling one\n\"git_mkdir()\"\n> to cover one particular kind of difference does not make any sense.\n> \n> Besides, an earlier mistake is not a valid excuse to add new mistakes.\n\nOK, so how about this:\n/usr/local/bin/diff -EBbu ./compat/mkdir.c.orig ./compat/mkdir.c\n--- ./compat/mkdir.c.orig       2012-08-21 05:02:11 -0500\n+++ ./compat/mkdir.c    2012-08-21 05:02:11 -0500\n@@ -0,0 +1,24 @@\n+#include \"../git-compat-util.h\"\n+#undef mkdir\n+\n+/* for platforms that can't deal with a trailing '/' */\n+int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)\n+{\n+       int retval;\n+       char *tmp_dir = NULL;\n+       size_t len = strlen(dir);\n+\n+       if (len && dir[len-1] == '/') {\n+               if ((tmp_dir = strdup(dir)) == NULL)\n+                       return -1;\n+               tmp_dir[len-1] = '\\0';\n+       }\n+       else\n+               tmp_dir = (char *)dir;\n+\n+       retval = mkdir(tmp_dir, mode);\n+       if (tmp_dir != dir)\n+               free(tmp_dir);\n+\n+       return retval;\n+}\n\nBTW: I've just today reported that mkdir bug to HP NonStop development.\nLet's see how fast they fix it and whether at all, but I'd be pretty\nsurprised if that happened earlier than 6 months from now.\n\nBye, Jojo\n"},{"id":"197597","messageId":"CA+sFfMdnixrUekh40Sde05tkap7Oj19=5D6J6aYVVD1krqPZkw@mail.gmail.com","threadId":"31227","inReplyTo":"002a01cd8083$69fb9960$3df2cc20$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2012-08-22T17:00:42Z","receivedAt":"2012-08-22T17:00:42Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"On Wed, Aug 22, 2012 at 9:30 AM, Joachim Schmitz\n<jojo@schmitz-digital.de> wrote:\n\n> OK, so how about this:\n> /usr/local/bin/diff -EBbu ./compat/mkdir.c.orig ./compat/mkdir.c\n> --- ./compat/mkdir.c.orig       2012-08-21 05:02:11 -0500\n> +++ ./compat/mkdir.c    2012-08-21 05:02:11 -0500\n> @@ -0,0 +1,24 @@\n> +#include \"../git-compat-util.h\"\n> +#undef mkdir\n> +\n> +/* for platforms that can't deal with a trailing '/' */\n> +int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)\n> +{\n> +       int retval;\n> +       char *tmp_dir = NULL;\n> +       size_t len = strlen(dir);\n> +\n> +       if (len && dir[len-1] == '/') {\n> +               if ((tmp_dir = strdup(dir)) == NULL)\n> +                       return -1;\n> +               tmp_dir[len-1] = '\\0';\n> +       }\n> +       else\n> +               tmp_dir = (char *)dir;\n> +\n> +       retval = mkdir(tmp_dir, mode);\n> +       if (tmp_dir != dir)\n> +               free(tmp_dir);\n> +\n> +       return retval;\n> +}\n\nWhy not rearrange this so that you assign to dir the value of tmp_dir\nand then just pass dir to mkdir.  Then you can avoid the recast of dir\nto (char*) in the else branch.  Later, just call free(tmp_dir).  Also,\nwe have xstrndup.  So I think the body of your function can become\nsomething like:\n\n   if (len && dir[len-1] == '/')\n       dir = tmp_dir = xstrndup(dir, len-1);\n\n   retval = mkdir(dir, mode);\n   free(tmp_dir);\n\n-Brandon\n"},{"id":"197599","messageId":"CA+sFfMfzpYaqRc7A0sZykA8PZ3LKahYVi9XASwCRGCEQO5PrrA@mail.gmail.com","threadId":"31227","inReplyTo":"CA+sFfMdnixrUekh40Sde05tkap7Oj19=5D6J6aYVVD1krqPZkw@mail.gmail.com","subject":"Re: Porting git to HP NonStop","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2012-08-22T17:13:22Z","receivedAt":"2012-08-22T17:13:22Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"On Wed, Aug 22, 2012 at 10:00 AM, Brandon Casey <drafnel@gmail.com> wrote:\n> Also, we have xstrndup.  So I think the body of your function can become\n> something like:\n>\n>    if (len && dir[len-1] == '/')\n>        dir = tmp_dir = xstrndup(dir, len-1);\n>\n>    retval = mkdir(dir, mode);\n>    free(tmp_dir);\n\nActually, xmemdupz could be used in place of xstrndup since we've\nalready called strlen.\n\n-Brandon\n"},{"id":"197600","messageId":"002f01cd808a$2e027e90$8a077bb0$@schmitz-digital.de","threadId":"31227","inReplyTo":"CA+sFfMdnixrUekh40Sde05tkap7Oj19=5D6J6aYVVD1krqPZkw@mail.gmail.com","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T17:18:41Z","receivedAt":"2012-08-22T17:18:41Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Brandon Casey [mailto:drafnel@gmail.com]\n> Sent: Wednesday, August 22, 2012 7:01 PM\n> To: Joachim Schmitz\n> Cc: Junio C Hamano; Shawn Pearce; git@vger.kernel.org;\n> rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> On Wed, Aug 22, 2012 at 9:30 AM, Joachim Schmitz <jojo@schmitz-digital.de>\n> wrote:\n> \n> > OK, so how about this:\n> > /usr/local/bin/diff -EBbu ./compat/mkdir.c.orig ./compat/mkdir.c\n> > --- ./compat/mkdir.c.orig       2012-08-21 05:02:11 -0500\n> > +++ ./compat/mkdir.c    2012-08-21 05:02:11 -0500\n> > @@ -0,0 +1,24 @@\n> > +#include \"../git-compat-util.h\"\n> > +#undef mkdir\n> > +\n> > +/* for platforms that can't deal with a trailing '/' */ int\n> > +compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode) {\n> > +       int retval;\n> > +       char *tmp_dir = NULL;\n> > +       size_t len = strlen(dir);\n> > +\n> > +       if (len && dir[len-1] == '/') {\n> > +               if ((tmp_dir = strdup(dir)) == NULL)\n> > +                       return -1;\n> > +               tmp_dir[len-1] = '\\0';\n> > +       }\n> > +       else\n> > +               tmp_dir = (char *)dir;\n> > +\n> > +       retval = mkdir(tmp_dir, mode);\n> > +       if (tmp_dir != dir)\n> > +               free(tmp_dir);\n> > +\n> > +       return retval;\n> > +}\n> \n> Why not rearrange this so that you assign to dir the value of tmp_dir and then\n> just pass dir to mkdir.  Then you can avoid the recast of dir to (char*) in the\n> else branch.  Later, just call free(tmp_dir).  Also, we have xstrndup.  So I think\n> the body of your function can become something like:\n> \n>    if (len && dir[len-1] == '/')\n>        dir = tmp_dir = xstrndup(dir, len-1);\n\nxstndup() can't fail?\n \n>    retval = mkdir(dir, mode);\n>    free(tmp_dir);\n> \n> -Brandon\n\nBye, Jojo\n"},{"id":"197603","messageId":"CA+sFfMd5zzfZVrGJSMkr2ga8kTg6Tiun=HBdHkg6rV-stjDT8Q@mail.gmail.com","threadId":"31227","inReplyTo":"002f01cd808a$2e027e90$8a077bb0$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2012-08-22T17:23:09Z","receivedAt":"2012-08-22T17:23:09Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"On Wed, Aug 22, 2012 at 10:18 AM, Joachim Schmitz\n<jojo@schmitz-digital.de> wrote:\n>> From: Brandon Casey [mailto:drafnel@gmail.com]\n>> Sent: Wednesday, August 22, 2012 7:01 PM\n>> To: Joachim Schmitz\n>> Cc: Junio C Hamano; Shawn Pearce; git@vger.kernel.org;\n>> rsbecker@nexbridge.com\n>> Subject: Re: Porting git to HP NonStop\n>>\n>> On Wed, Aug 22, 2012 at 9:30 AM, Joachim Schmitz <jojo@schmitz-digital.de>\n>> wrote:\n>>\n>> > OK, so how about this:\n>> > /usr/local/bin/diff -EBbu ./compat/mkdir.c.orig ./compat/mkdir.c\n>> > --- ./compat/mkdir.c.orig       2012-08-21 05:02:11 -0500\n>> > +++ ./compat/mkdir.c    2012-08-21 05:02:11 -0500\n>> > @@ -0,0 +1,24 @@\n>> > +#include \"../git-compat-util.h\"\n>> > +#undef mkdir\n>> > +\n>> > +/* for platforms that can't deal with a trailing '/' */ int\n>> > +compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode) {\n>> > +       int retval;\n>> > +       char *tmp_dir = NULL;\n>> > +       size_t len = strlen(dir);\n>> > +\n>> > +       if (len && dir[len-1] == '/') {\n>> > +               if ((tmp_dir = strdup(dir)) == NULL)\n>> > +                       return -1;\n>> > +               tmp_dir[len-1] = '\\0';\n>> > +       }\n>> > +       else\n>> > +               tmp_dir = (char *)dir;\n>> > +\n>> > +       retval = mkdir(tmp_dir, mode);\n>> > +       if (tmp_dir != dir)\n>> > +               free(tmp_dir);\n>> > +\n>> > +       return retval;\n>> > +}\n>>\n>> Why not rearrange this so that you assign to dir the value of tmp_dir and then\n>> just pass dir to mkdir.  Then you can avoid the recast of dir to (char*) in the\n>> else branch.  Later, just call free(tmp_dir).  Also, we have xstrndup.  So I think\n>> the body of your function can become something like:\n>>\n>>    if (len && dir[len-1] == '/')\n>>        dir = tmp_dir = xstrndup(dir, len-1);\n>\n> xstndup() can't fail?\n\nCorrect.  It will either succeed or die.  It will also try to free up\nsome memory used by git if possible.\n\n-Brandon\n"},{"id":"197606","messageId":"7vvcga96n9.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"CA+sFfMdnixrUekh40Sde05tkap7Oj19=5D6J6aYVVD1krqPZkw@mail.gmail.com","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-22T17:30:02Z","receivedAt":"2012-08-22T17:30:02Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <drafnel@gmail.com> writes:\n\n> On Wed, Aug 22, 2012 at 9:30 AM, Joachim Schmitz\n> <jojo@schmitz-digital.de> wrote:\n>\n>> OK, so how about this:\n>> /usr/local/bin/diff -EBbu ./compat/mkdir.c.orig ./compat/mkdir.c\n>> --- ./compat/mkdir.c.orig       2012-08-21 05:02:11 -0500\n>> +++ ./compat/mkdir.c    2012-08-21 05:02:11 -0500\n>> @@ -0,0 +1,24 @@\n>> +#include \"../git-compat-util.h\"\n>> +#undef mkdir\n>> +\n>> +/* for platforms that can't deal with a trailing '/' */\n>> +int compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)\n>> +{\n>> +       int retval;\n>> +       char *tmp_dir = NULL;\n>> +       size_t len = strlen(dir);\n>> + ...\n> Why not rearrange this so that you assign to dir the value of tmp_dir\n> and then just pass dir to mkdir.  Then you can avoid the recast of dir\n> to (char*) in the else branch.  Later, just call free(tmp_dir).  Also,\n> we have xstrndup.  So I think the body of your function can become\n> something like:\n>\n>    if (len && dir[len-1] == '/')\n>        dir = tmp_dir = xstrndup(dir, len-1);\n>\n>    retval = mkdir(dir, mode);\n>    free(tmp_dir);\n\nNice.  And we have xmemdupz() would be even better as you\nfollowed-up.\n\nThanks.\n"},{"id":"197607","messageId":"003101cd808b$db381e70$91a85b50$@schmitz-digital.de","threadId":"31227","inReplyTo":"CA+sFfMd5zzfZVrGJSMkr2ga8kTg6Tiun=HBdHkg6rV-stjDT8Q@mail.gmail.com","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T17:30:42Z","receivedAt":"2012-08-22T17:30:42Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Brandon Casey [mailto:drafnel@gmail.com]\n> Sent: Wednesday, August 22, 2012 7:23 PM\n> To: Joachim Schmitz\n> Cc: Junio C Hamano; Shawn Pearce; git@vger.kernel.org;\n> rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> On Wed, Aug 22, 2012 at 10:18 AM, Joachim Schmitz <jojo@schmitz-digital.de>\n> wrote:\n> >> From: Brandon Casey [mailto:drafnel@gmail.com]\n> >> Sent: Wednesday, August 22, 2012 7:01 PM\n> >> To: Joachim Schmitz\n> >> Cc: Junio C Hamano; Shawn Pearce; git@vger.kernel.org;\n> >> rsbecker@nexbridge.com\n> >> Subject: Re: Porting git to HP NonStop\n> >>\n> >> On Wed, Aug 22, 2012 at 9:30 AM, Joachim Schmitz\n> >> <jojo@schmitz-digital.de>\n> >> wrote:\n> >>\n> >> > OK, so how about this:\n> >> > /usr/local/bin/diff -EBbu ./compat/mkdir.c.orig ./compat/mkdir.c\n> >> > --- ./compat/mkdir.c.orig       2012-08-21 05:02:11 -0500\n> >> > +++ ./compat/mkdir.c    2012-08-21 05:02:11 -0500\n> >> > @@ -0,0 +1,24 @@\n> >> > +#include \"../git-compat-util.h\"\n> >> > +#undef mkdir\n> >> > +\n> >> > +/* for platforms that can't deal with a trailing '/' */ int\n> >> > +compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode) {\n> >> > +       int retval;\n> >> > +       char *tmp_dir = NULL;\n> >> > +       size_t len = strlen(dir);\n> >> > +\n> >> > +       if (len && dir[len-1] == '/') {\n> >> > +               if ((tmp_dir = strdup(dir)) == NULL)\n> >> > +                       return -1;\n> >> > +               tmp_dir[len-1] = '\\0';\n> >> > +       }\n> >> > +       else\n> >> > +               tmp_dir = (char *)dir;\n> >> > +\n> >> > +       retval = mkdir(tmp_dir, mode);\n> >> > +       if (tmp_dir != dir)\n> >> > +               free(tmp_dir);\n> >> > +\n> >> > +       return retval;\n> >> > +}\n> >>\n> >> Why not rearrange this so that you assign to dir the value of tmp_dir\n> >> and then just pass dir to mkdir.  Then you can avoid the recast of\n> >> dir to (char*) in the else branch.  Later, just call free(tmp_dir).\n> >> Also, we have xstrndup.  So I think the body of your function can become\n> something like:\n> >>\n> >>    if (len && dir[len-1] == '/')\n> >>        dir = tmp_dir = xstrndup(dir, len-1);\n> >\n> > xstndup() can't fail?\n> \n> Correct.  It will either succeed or die.  It will also try to free up some memory\n> used by git if possible.\n\nOK. So let's use that then.\n\nBye, Jojo\n"},{"id":"197610","messageId":"503519B3.1020403@kdbg.org","threadId":"31227","inReplyTo":"CA+sFfMdnixrUekh40Sde05tkap7Oj19=5D6J6aYVVD1krqPZkw@mail.gmail.com","subject":"Re: Porting git to HP NonStop","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-08-22T17:41:07Z","receivedAt":"2012-08-22T17:41:07Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 22.08.2012 19:00, schrieb Brandon Casey:\n>  So I think the body of [compat_mkdir] can become\n> something like:\n> \n>    if (len && dir[len-1] == '/')\n>        dir = tmp_dir = xstrndup(dir, len-1);\n\nDon't use x* wrappers in the compat layer, at least not those that\nallocate memory: They behave unpredictably due to try_to_free_routine\nand may lead to recursive invocations.\n\n> \n>    retval = mkdir(dir, mode);\n>    free(tmp_dir);\n\n-- Hannes\n"},{"id":"197617","messageId":"003d01cd8090$214ca710$63e5f530$@schmitz-digital.de","threadId":"31227","inReplyTo":"7vvcga96n9.fsf@alter.siamese.dyndns.org","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T18:01:17Z","receivedAt":"2012-08-22T18:01:17Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> -----Original Message-----\n> From: Junio C Hamano [mailto:gitster@pobox.com]\n> Sent: Wednesday, August 22, 2012 7:30 PM\n> To: Brandon Casey\n> Cc: Joachim Schmitz; Shawn Pearce; git@vger.kernel.org;\n> rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> Brandon Casey <drafnel@gmail.com> writes:\n> \n> > On Wed, Aug 22, 2012 at 9:30 AM, Joachim Schmitz\n> > <jojo@schmitz-digital.de> wrote:\n> >\n> >> OK, so how about this:\n> >> /usr/local/bin/diff -EBbu ./compat/mkdir.c.orig ./compat/mkdir.c\n> >> --- ./compat/mkdir.c.orig       2012-08-21 05:02:11 -0500\n> >> +++ ./compat/mkdir.c    2012-08-21 05:02:11 -0500\n> >> @@ -0,0 +1,24 @@\n> >> +#include \"../git-compat-util.h\"\n> >> +#undef mkdir\n> >> +\n> >> +/* for platforms that can't deal with a trailing '/' */ int\n> >> +compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode) {\n> >> +       int retval;\n> >> +       char *tmp_dir = NULL;\n> >> +       size_t len = strlen(dir);\n> >> + ...\n> > Why not rearrange this so that you assign to dir the value of tmp_dir\n> > and then just pass dir to mkdir.  Then you can avoid the recast of dir\n> > to (char*) in the else branch.  Later, just call free(tmp_dir).  Also,\n> > we have xstrndup.  So I think the body of your function can become\n> > something like:\n> >\n> >    if (len && dir[len-1] == '/')\n> >        dir = tmp_dir = xstrndup(dir, len-1);\n> >\n> >    retval = mkdir(dir, mode);\n> >    free(tmp_dir);\n> \n> Nice.  And we have xmemdupz() would be even better as you followed-up.\n\nHow's that one used?\n\nBye, Jojo\n"},{"id":"197618","messageId":"003e01cd8090$55126fd0$ff374f70$@schmitz-digital.de","threadId":"31227","inReplyTo":"503519B3.1020403@kdbg.org","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T18:02:43Z","receivedAt":"2012-08-22T18:02:43Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"\n\n> -----Original Message-----\n> From: Johannes Sixt [mailto:j6t@kdbg.org]\n> Sent: Wednesday, August 22, 2012 7:41 PM\n> To: Brandon Casey\n> Cc: Joachim Schmitz; Junio C Hamano; Shawn Pearce; git@vger.kernel.org;\n> rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> Am 22.08.2012 19:00, schrieb Brandon Casey:\n> >  So I think the body of [compat_mkdir] can become something like:\n> >\n> >    if (len && dir[len-1] == '/')\n> >        dir = tmp_dir = xstrndup(dir, len-1);\n> \n> Don't use x* wrappers in the compat layer, at least not those that allocate\n> memory: They behave unpredictably due to try_to_free_routine and may lead\n> to recursive invocations.\n\nI was just following orders ;-)\nWhat about the other proposal, xmemdupz? Same story I guess?\n\nBye, Jojo\n"},{"id":"197621","messageId":"50352053.609@kdbg.org","threadId":"31227","inReplyTo":"003e01cd8090$55126fd0$ff374f70$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Johannes Sixt","fromEmail":"j6t@kdbg.org","sentAt":"2012-08-22T18:09:23Z","receivedAt":"2012-08-22T18:09:23Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 22.08.2012 20:02, schrieb Joachim Schmitz:\n>> From: Johannes Sixt [mailto:j6t@kdbg.org]\n>> Don't use x* wrappers in the compat layer, at least not those that allocate\n>> memory: They behave unpredictably due to try_to_free_routine and may lead\n>> to recursive invocations.\n> \n> I was just following orders ;-)\n> What about the other proposal, xmemdupz? Same story I guess?\n\nxmemdupz calls xmalloc, so, yes, same story.\n\n-- Hannes\n"},{"id":"197622","messageId":"CA+sFfMedWVAgqvHS67V6L=ROjdN6M3p3pYTUDk98xgozX4djEw@mail.gmail.com","threadId":"31227","inReplyTo":"503519B3.1020403@kdbg.org","subject":"Re: Porting git to HP NonStop","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2012-08-22T18:09:56Z","receivedAt":"2012-08-22T18:09:56Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"On Wed, Aug 22, 2012 at 10:41 AM, Johannes Sixt <j6t@kdbg.org> wrote:\n> Am 22.08.2012 19:00, schrieb Brandon Casey:\n>>  So I think the body of [compat_mkdir] can become\n>> something like:\n>>\n>>    if (len && dir[len-1] == '/')\n>>        dir = tmp_dir = xstrndup(dir, len-1);\n>\n> Don't use x* wrappers in the compat layer, at least not those that\n> allocate memory: They behave unpredictably due to try_to_free_routine\n> and may lead to recursive invocations.\n\nI thought that rule only applied to die handlers.  i.e. don't use the\nx* wrappers to allocate memory in a die handler like\ncompat/win32/syslog.c.  At least that's what I wrote in 040a6551 when\nyou pointed out this issue back then.\n\nAdmittedly, it could get pretty sticky trying to trace the die\nhandlers to ensure they don't invoke your new compat/ function.  So,\nyeah, adopting this rule of not using x* wrappers that allocate memory\nin compat/ generally seems like a good idea.\n\nShould we also try to detect recursive invocation of die and friends?\nIn theory recursion could be triggered by any die handler that makes\nuse of a code path that calls an x* wrapper that allocates memory,\ncouldn't it?\n\n-Brandon\n"},{"id":"197624","messageId":"004001cd8092$7f9e6540$7edb2fc0$@schmitz-digital.de","threadId":"31227","inReplyTo":"50352053.609@kdbg.org","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T18:18:14Z","receivedAt":"2012-08-22T18:18:14Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> -----Original Message-----\n> From: Johannes Sixt [mailto:j6t@kdbg.org]\n> Sent: Wednesday, August 22, 2012 8:09 PM\n> To: Joachim Schmitz\n> Cc: 'Brandon Casey'; 'Junio C Hamano'; 'Shawn Pearce'; git@vger.kernel.org;\n> rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> Am 22.08.2012 20:02, schrieb Joachim Schmitz:\n> >> From: Johannes Sixt [mailto:j6t@kdbg.org] Don't use x* wrappers in\n> >> the compat layer, at least not those that allocate\n> >> memory: They behave unpredictably due to try_to_free_routine and may\n> >> lead to recursive invocations.\n> >\n> > I was just following orders ;-)\n> > What about the other proposal, xmemdupz? Same story I guess?\n> \n> xmemdupz calls xmalloc, so, yes, same story.\n\nSo back to my original patch, using strdup, check the return value, etc.\n\nBye, Jojo\n"},{"id":"197625","messageId":"CA+sFfMdNmT5+sVdiRsWyBYNUwF+nkPcAiBswGsTjp3Yr4yZLUQ@mail.gmail.com","threadId":"31227","inReplyTo":"CA+sFfMedWVAgqvHS67V6L=ROjdN6M3p3pYTUDk98xgozX4djEw@mail.gmail.com","subject":"Re: Porting git to HP NonStop","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2012-08-22T18:24:34Z","receivedAt":"2012-08-22T18:24:34Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"On Wed, Aug 22, 2012 at 11:09 AM, Brandon Casey <drafnel@gmail.com> wrote:\n> On Wed, Aug 22, 2012 at 10:41 AM, Johannes Sixt <j6t@kdbg.org> wrote:\n\n>> Don't use x* wrappers in the compat layer, at least not those that\n>> allocate memory: They behave unpredictably due to try_to_free_routine\n>> and may lead to recursive invocations.\n>\n> I thought that rule only applied to die handlers.  i.e. don't use the\n> x* wrappers to allocate memory in a die handler like\n> compat/win32/syslog.c.  At least that's what I wrote in 040a6551 when\n> you pointed out this issue back then.\n>\n> Admittedly, it could get pretty sticky trying to trace the die\n> handlers to ensure they don't invoke your new compat/ function.  So,\n> yeah, adopting this rule of not using x* wrappers that allocate memory\n> in compat/ generally seems like a good idea.\n>\n> Should we also try to detect recursive invocation of die and friends?\n> In theory recursion could be triggered by any die handler that makes\n> use of a code path that calls an x* wrapper that allocates memory,\n> couldn't it?\n\nPerhaps something like:\n\ndiff --git a/usage.c b/usage.c\nindex a2a6678..2d0ff35 100644\n--- a/usage.c\n+++ b/usage.c\n@@ -80,8 +80,15 @@ void NORETURN usage(const char *err)\n\n void NORETURN die(const char *err, ...)\n {\n+       static int dying;\n        va_list params;\n\n+       if (dying) {\n+               fputs(\"fatal: recursion detected in die handler\\n\", stderr);\n+               exit(128);\n+       }\n+       dying = 1;\n+\n        va_start(params, err);\n        die_routine(err, params);\n        va_end(params);\n@@ -89,11 +96,18 @@ void NORETURN die(const char *err, ...)\n\n void NORETURN die_errno(const char *fmt, ...)\n {\n+       static int dying;\n        va_list params;\n        char fmt_with_err[1024];\n        char str_error[256], *err;\n        int i, j;\n\n+       if (dying) {\n+               fputs(\"fatal: recursion detected in die handler\\n\", stderr);\n+               exit(128);\n+       }\n+       dying = 1;\n+\n        err = strerror(errno);\n        for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {\n                if ((str_error[j++] = err[i++]) != '%')\n\n-Brandon\n"},{"id":"197626","messageId":"7v393e943x.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"003d01cd8090$214ca710$63e5f530$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-22T18:24:50Z","receivedAt":"2012-08-22T18:24:50Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n\n>> Nice.  And we have xmemdupz() would be even better as you followed-up.\n>\n> How's that one used?\n\nI forgot that we frown upon use of any x<allocate>() wrapper in the\ncompat/ layer as J6t mentioned.\n\nSo probably something along these lines...\n\n\tint retval;\n\tchar *dir_to_free = NULL;\n\tsize_t len = strlen(dir);\n\n        if (len && dir[len - 1] == '/') {\n\t\tdir_to_free = malloc(len);\n                if (!dir_to_free) {\n\t\t\tfprintf(stderr, \"malloc failed!\\n\");\n\t\t\texit(1);\n\t\t}\n                memcpy(dir_to_free, dir, len - 1);\n                dir_to_free[len - 1] = '\\0';\n                dir = dir_to_free;\n\t}                \n\tretval = mkdir(dir, mode);\n\tfree(dir_to_free);\n        return retval;\n\nIt might be possible to for the error path to get away with\nsomething like:\n\n\tif (!dir_to_free)\n\t\treturn -1;\n\nif we know the callers are prepared to see mkdir() failing with\nENOMEM, but that is not very likely.\n"},{"id":"197627","messageId":"7vy5l67pgj.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"CA+sFfMedWVAgqvHS67V6L=ROjdN6M3p3pYTUDk98xgozX4djEw@mail.gmail.com","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-22T18:26:36Z","receivedAt":"2012-08-22T18:26:36Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <drafnel@gmail.com> writes:\n\n> On Wed, Aug 22, 2012 at 10:41 AM, Johannes Sixt <j6t@kdbg.org> wrote:\n>> Am 22.08.2012 19:00, schrieb Brandon Casey:\n>>>  So I think the body of [compat_mkdir] can become\n>>> something like:\n>>>\n>>>    if (len && dir[len-1] == '/')\n>>>        dir = tmp_dir = xstrndup(dir, len-1);\n>>\n>> Don't use x* wrappers in the compat layer, at least not those that\n>> allocate memory: They behave unpredictably due to try_to_free_routine\n>> and may lead to recursive invocations.\n>\n> I thought that rule only applied to die handlers.  i.e. don't use the\n> x* wrappers to allocate memory in a die handler like\n> compat/win32/syslog.c.  At least that's what I wrote in 040a6551 when\n> you pointed out this issue back then.\n>\n> Admittedly, it could get pretty sticky trying to trace the die\n> handlers to ensure they don't invoke your new compat/ function.  So,\n> yeah, adopting this rule of not using x* wrappers that allocate memory\n> in compat/ generally seems like a good idea.\n>\n> Should we also try to detect recursive invocation of die and friends?\n\n> In theory recursion could be triggered by any die handler that makes\n> use of a code path that calls an x* wrapper that allocates memory,\n> couldn't it?\n\nCorrect, but at that point we will end up dying anyway, so...\n"},{"id":"197629","messageId":"7vtxvu7p5s.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"CA+sFfMdNmT5+sVdiRsWyBYNUwF+nkPcAiBswGsTjp3Yr4yZLUQ@mail.gmail.com","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-22T18:33:03Z","receivedAt":"2012-08-22T18:33:03Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Brandon Casey <drafnel@gmail.com> writes:\n\n> Perhaps something like:\n>\n> diff --git a/usage.c b/usage.c\n> index a2a6678..2d0ff35 100644\n> --- a/usage.c\n> +++ b/usage.c\n> @@ -80,8 +80,15 @@ void NORETURN usage(const char *err)\n>\n>  void NORETURN die(const char *err, ...)\n>  {\n> +       static int dying;\n>         va_list params;\n>\n> +       if (dying) {\n> +               fputs(\"fatal: recursion detected in die handler\\n\", stderr);\n> +               exit(128);\n> +       }\n> +       dying = 1;\n> +\n>         va_start(params, err);\n>         die_routine(err, params);\n>         va_end(params);\n> @@ -89,11 +96,18 @@ void NORETURN die(const char *err, ...)\n>\n>  void NORETURN die_errno(const char *fmt, ...)\n>  {\n> +       static int dying;\n>         va_list params;\n>         char fmt_with_err[1024];\n>         char str_error[256], *err;\n>         int i, j;\n>\n> +       if (dying) {\n> +               fputs(\"fatal: recursion detected in die handler\\n\", stderr);\n> +               exit(128);\n> +       }\n> +       dying = 1;\n> +\n>         err = strerror(errno);\n>         for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {\n>                 if ((str_error[j++] = err[i++]) != '%')\n\nWith two function-scope static, you can go like this:\n\ndie()\n-> die_routine()\n   -> xsomething()\n      -> die_errno()\n        -> die_routine()\n           -> xsomethingelse()\n              -> die() or die_errno()\n\nNot that we probably care too deeply about, as at least we won't\ninfinitely recurse and die out of stack space.\n"},{"id":"197630","messageId":"CA+sFfMdL=h=aoX7mCWfXJ+QvDLH7gvzWWo9HMXKSaTv+ykx-8w@mail.gmail.com","threadId":"31227","inReplyTo":"7vtxvu7p5s.fsf@alter.siamese.dyndns.org","subject":"Re: Porting git to HP NonStop","fromName":"Brandon Casey","fromEmail":"drafnel@gmail.com","sentAt":"2012-08-22T18:38:59Z","receivedAt":"2012-08-22T18:38:59Z","isPatch":false,"sender":{"key":"drafnel@gmail.com","avatar":"https://avatars.githubusercontent.com/u/921167?v=4"},"body":"On Wed, Aug 22, 2012 at 11:33 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Brandon Casey <drafnel@gmail.com> writes:\n>\n>> Perhaps something like:\n>>\n>> diff --git a/usage.c b/usage.c\n>> index a2a6678..2d0ff35 100644\n>> --- a/usage.c\n>> +++ b/usage.c\n>> @@ -80,8 +80,15 @@ void NORETURN usage(const char *err)\n>>\n>>  void NORETURN die(const char *err, ...)\n>>  {\n>> +       static int dying;\n>>         va_list params;\n>>\n>> +       if (dying) {\n>> +               fputs(\"fatal: recursion detected in die handler\\n\", stderr);\n>> +               exit(128);\n>> +       }\n>> +       dying = 1;\n>> +\n>>         va_start(params, err);\n>>         die_routine(err, params);\n>>         va_end(params);\n>> @@ -89,11 +96,18 @@ void NORETURN die(const char *err, ...)\n>>\n>>  void NORETURN die_errno(const char *fmt, ...)\n>>  {\n>> +       static int dying;\n>>         va_list params;\n>>         char fmt_with_err[1024];\n>>         char str_error[256], *err;\n>>         int i, j;\n>>\n>> +       if (dying) {\n>> +               fputs(\"fatal: recursion detected in die handler\\n\", stderr);\n>> +               exit(128);\n>> +       }\n>> +       dying = 1;\n>> +\n>>         err = strerror(errno);\n>>         for (i = j = 0; err[i] && j < sizeof(str_error) - 1; ) {\n>>                 if ((str_error[j++] = err[i++]) != '%')\n>\n> With two function-scope static, you can go like this:\n>\n> die()\n> -> die_routine()\n>    -> xsomething()\n>       -> die_errno()\n>         -> die_routine()\n>            -> xsomethingelse()\n>               -> die() or die_errno()\n>\n> Not that we probably care too deeply about, as at least we won't\n> infinitely recurse and die out of stack space.\n\nYeah, I noticed that, but didn't think it was important or likely.\nBut there's no reason not to make \"dying\" a global.\n\n-Brandon\n"},{"id":"197632","messageId":"004201cd8097$4ef04a80$ecd0df80$@schmitz-digital.de","threadId":"31227","inReplyTo":"7v393e943x.fsf@alter.siamese.dyndns.org","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T18:52:39Z","receivedAt":"2012-08-22T18:52:39Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Junio C Hamano [mailto:gitster@pobox.com]\n> Sent: Wednesday, August 22, 2012 8:25 PM\n> To: Joachim Schmitz\n> Cc: 'Brandon Casey'; 'Shawn Pearce'; git@vger.kernel.org;\n> rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> \"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n> \n> >> Nice.  And we have xmemdupz() would be even better as you followed-up.\n> >\n> > How's that one used?\n> \n> I forgot that we frown upon use of any x<allocate>() wrapper in the\ncompat/\n> layer as J6t mentioned.\n> \n> So probably something along these lines...\n> \n> \tint retval;\n> \tchar *dir_to_free = NULL;\n> \tsize_t len = strlen(dir);\n> \n>         if (len && dir[len - 1] == '/') {\n> \t\tdir_to_free = malloc(len);\n>                 if (!dir_to_free) {\n> \t\t\tfprintf(stderr, \"malloc failed!\\n\");\n> \t\t\texit(1);\n> \t\t}\n>                 memcpy(dir_to_free, dir, len - 1);\n>                 dir_to_free[len - 1] = '\\0';\n>                 dir = dir_to_free;\n> \t}\n> \tretval = mkdir(dir, mode);\n> \tfree(dir_to_free);\n>         return retval;\n\nSo why not just strdup? I stole the idea from gnulib...\n\nint\nrpl_mkdir (char const *dir, mode_t mode maybe_unused)\n{\n  int ret_val;\n  char *tmp_dir;\n  size_t len = strlen (dir);\n\n  if (len && dir[len - 1] == '/')\n    {\n      tmp_dir = strdup (dir);\n      if (!tmp_dir)\n        {\n          /* Rather than rely on strdup-posix, we set errno ourselves.  */\n          errno = ENOMEM;\n          return -1;\n        }\n      strip_trailing_slashes (tmp_dir);\n    }\n  else\n    {\n      tmp_dir = (char *) dir;\n    }\n\n\nThey strip more than one trailing slash, but for git's purpose I believed\nthis to be too much overhead. Also the errno stuff doesn't seem to be really\nneeded IMHO. Same for the following code\n\n#if FUNC_MKDIR_DOT_BUG\n  /* Additionally, cygwin 1.5 mistakenly creates a directory \"d/./\".  */\n  {\n    char *last = last_component (tmp_dir);\n    if (*last == '.' && (last[1] == '\\0'\n                         || (last[1] == '.' && last[2] == '\\0')))\n      {\n        struct stat st;\n        if (stat (tmp_dir, &st) == 0)\n          errno = EEXIST;\n        return -1;\n      }\n  }\n#endif /* FUNC_MKDIR_DOT_BUG */\n\nThen it goes on like mine:\n\n  ret_val = mkdir (tmp_dir, mode);\n\n  if (tmp_dir != dir)\n    free (tmp_dir);\n\n  return ret_val;\n}\n\nCompare:\n$ cat compat/mkdir.c\n#include \"../git-compat-util.h\"\n#undef mkdir\n\n/* for platforms that can't deal with a trailing '/' */\nint compat_mkdir_wo_trailing_slash(const char *dir, mode_t mode)\n{\n        int retval;\n        char *tmp_dir = NULL;\n        size_t len = strlen(dir);\n\n        if (len && dir[len-1] == '/') {\n                if ((tmp_dir = strdup(dir)) == NULL)\n                        return -1;\n                tmp_dir[len-1] = '\\0';\n        }\n        else\n                tmp_dir = (char *)dir;\n\n        retval = mkdir(tmp_dir, mode);\n        if (tmp_dir != dir)\n                free(tmp_dir);\n\n        return retval;\n}\n\nBye, Jojo\n"},{"id":"197656","messageId":"004401cd80a3$4b0cff60$e126fe20$@schmitz-digital.de","threadId":"31227","inReplyTo":"CA+sFfMdL=h=aoX7mCWfXJ+QvDLH7gvzWWo9HMXKSaTv+ykx-8w@mail.gmail.com","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T20:18:28Z","receivedAt":"2012-08-22T20:18:28Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"Hi folks\n\nThere another API missing on HP NonStop and that is setitimer(), used in progress.c and build/log.c\nI do have a homebrewed implementation, on top of alarm(), it goes like this:\n\n#include \"../git-compat-util.h\"\n#undef getitimer\n#undef setitimer\n\n\nint\ngit_getitimer(int which, struct itimerval *value)\n{\n        int ret = 0;\n\n        switch (which) {\n                case ITIMER_REAL:\n                        value->it_value.tv_usec = 0;\n                        value->it_value.tv_sec = alarm(0);\n                        ret = 0; /* if alarm() fails we get a SIGLIMIT */\n                        break;\n                case ITIMER_VIRTUAL: /* FALLTHRU */\n                case ITIMER_PROF: errno = ENOTSUP; ret = -1; break;\n                default: errno = EINVAL; ret = -1;\n        }\n        return ret;\n}\n\nint\ngit_setitimer(int which, const struct itimerval *value,\n                        struct itimerval *ovalue)\n{\n        int ret = 0;\n\n        if (!value\n                || value->it_value.tv_usec < 0\n                || value->it_value.tv_usec > 1000000\n                || value->it_value.tv_sec < 0) {\n                errno = EINVAL;\n                return -1;\n        }\n\n        else if (ovalue)\n                if (!git_getitimer(which, ovalue))\n                        return -1; /* errno set in git_getitimer() */\n\n        else\n        switch (which) {\n                case ITIMER_REAL:\n                        alarm(value->it_value.tv_sec +\n                                (value->it_value.tv_usec > 0) ? 1 : 0);\n                        ret = 0; /* if alarm() fails we get a SIGLIMIT */\n                        break;\n                case ITIMER_VIRTUAL: /* FALLTHRU */\n                case ITIMER_PROF: errno = ENOTSUP; ret = -1; break;\n                default: errno = EINVAL; ret = -1;\n        }\n\n        return ret;\n}\n\n\nWorth being added to compat/, e.g. as setitimer.c, or, as itimer.c (as a by-product, it has getitimer() too)?\n\nBye, Jojo\n"},{"id":"197657","messageId":"7v628a7iu5.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"004401cd80a3$4b0cff60$e126fe20$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-22T20:49:38Z","receivedAt":"2012-08-22T20:49:38Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n\n> Hi folks\n>\n> There another API missing on HP NonStop and that is setitimer(), used in progress.c and build/log.c\n> I do have a homebrewed implementation, on top of alarm(), it goes like this:\n>\n> #include \"../git-compat-util.h\"\n> #undef getitimer\n> #undef setitimer\n>\n>\n> int\n> git_getitimer(int which, struct itimerval *value)\n\nSee Documentation/CodingGuidelines for style nits.\n\n> {\n>         int ret = 0;\n>\n>         switch (which) {\n>                 case ITIMER_REAL:\n>                         value->it_value.tv_usec = 0;\n>                         value->it_value.tv_sec = alarm(0);\n>                         ret = 0; /* if alarm() fails we get a SIGLIMIT */\n>                         break;\n>                 case ITIMER_VIRTUAL: /* FALLTHRU */\n>                 case ITIMER_PROF: errno = ENOTSUP; ret = -1; break;\n>                 default: errno = EINVAL; ret = -1;\n>         }\n>         return ret;\n> }\n>\n> int\n> git_setitimer(int which, const struct itimerval *value,\n>                         struct itimerval *ovalue)\n> {\n>         int ret = 0;\n>\n>         if (!value\n>                 || value->it_value.tv_usec < 0\n>                 || value->it_value.tv_usec > 1000000\n>                 || value->it_value.tv_sec < 0) {\n>                 errno = EINVAL;\n>                 return -1;\n>         }\n>\n>         else if (ovalue)\n>                 if (!git_getitimer(which, ovalue))\n>                         return -1; /* errno set in git_getitimer() */\n>\n>         else\n>         switch (which) {\n>                 case ITIMER_REAL:\n>                         alarm(value->it_value.tv_sec +\n>                                 (value->it_value.tv_usec > 0) ? 1 : 0);\n>                         ret = 0; /* if alarm() fails we get a SIGLIMIT */\n>                         break;\n>                 case ITIMER_VIRTUAL: /* FALLTHRU */\n>                 case ITIMER_PROF: errno = ENOTSUP; ret = -1; break;\n>                 default: errno = EINVAL; ret = -1;\n>         }\n>\n>         return ret;\n> }\n>\n>\n> Worth being added to compat/, e.g. as setitimer.c, or, as itimer.c\n> (as a by-product, it has getitimer() too)?\n\nIf it helps your port, compat/itimer.c sounds like a good place.\nDoesn't it need a new header file to introduce structures and\nconstants, too?\n"},{"id":"197661","messageId":"004501cd80a9$d01ecc00$705c6400$@schmitz-digital.de","threadId":"31227","inReplyTo":"7v628a7iu5.fsf@alter.siamese.dyndns.org","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T21:05:08Z","receivedAt":"2012-08-22T21:05:08Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"> From: Junio C Hamano [mailto:gitster@pobox.com]\n> Sent: Wednesday, August 22, 2012 10:50 PM\n> To: Joachim Schmitz\n> Cc: git@vger.kernel.org; rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> \"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n> \n> > Hi folks\n> >\n> > There another API missing on HP NonStop and that is setitimer(), used\n> > in progress.c and build/log.c I do have a homebrewed implementation, on\ntop\n> of alarm(), it goes like this:\n> >\n> > #include \"../git-compat-util.h\"\n> > #undef getitimer\n> > #undef setitimer\n> >\n> >\n> > int\n> > git_getitimer(int which, struct itimerval *value)\n> \n> See Documentation/CodingGuidelines for style nits.\n\nWill do and adjust code accordingly. Here I was more concerned about content\nthough ;-)\n\n...\n> > Worth being added to compat/, e.g. as setitimer.c, or, as itimer.c (as\n> > a by-product, it has getitimer() too)?\n> \n> If it helps your port, compat/itimer.c sounds like a good place.\n> Doesn't it need a new header file to introduce structures and constants,\ntoo?\n\nYou mean the ITIMER_* and struct itimerval, right?\nOn NonStop these are available in <sys/time.h>, so here's no need to add\nthem.\n\nBye, Jojo\n"},{"id":"197663","messageId":"7vobm2637y.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"004501cd80a9$d01ecc00$705c6400$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-22T21:12:17Z","receivedAt":"2012-08-22T21:12:17Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n\n>> If it helps your port, compat/itimer.c sounds like a good place.\n>> Doesn't it need a new header file to introduce structures and constants,\n> too?\n>\n> You mean the ITIMER_* and struct itimerval, right?\n> On NonStop these are available in <sys/time.h>, so here's no need to add\n> them.\n\nAt least you would need a header to declare these two functions and\nmake them visible so that the remainder of the codebase will not\nhave to know about git_setitimer(), no?  Or does your header files\non NonStop declare setitimer() but does not implement it?\n\nAs your proposed name is not compat/tandem.c but more generic\nsounding compat/itimer.c, we would have to plan for systems other\nthan NonStop, so we may later have to introduce makefile variables\nto ask that header file to declare the structure and define the\nconstants that are missing from such a system.  While you are\nporting to NonStop, you may not have to define/declare them, but\nknowing that these files are the place to later do so is part of the\nplanning.\n"},{"id":"197665","messageId":"005201cd80ac$4cd414b0$e67c3e10$@schmitz-digital.de","threadId":"31227","inReplyTo":"7vobm2637y.fsf@alter.siamese.dyndns.org","subject":"RE: Porting git to HP NonStop","fromName":"Joachim Schmitz","fromEmail":"jojo@schmitz-digital.de","sentAt":"2012-08-22T21:22:56Z","receivedAt":"2012-08-22T21:22:56Z","isPatch":false,"sender":{"key":"jojo@schmitz-digital.de","avatar":"https://avatars.githubusercontent.com/u/1786669?v=4"},"body":"\n\n> -----Original Message-----\n> From: Junio C Hamano [mailto:gitster@pobox.com]\n> Sent: Wednesday, August 22, 2012 11:12 PM\n> To: Joachim Schmitz\n> Cc: git@vger.kernel.org; rsbecker@nexbridge.com\n> Subject: Re: Porting git to HP NonStop\n> \n> \"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n> \n> >> If it helps your port, compat/itimer.c sounds like a good place.\n> >> Doesn't it need a new header file to introduce structures and\n> >> constants,\n> > too?\n> >\n> > You mean the ITIMER_* and struct itimerval, right?\n> > On NonStop these are available in <sys/time.h>, so here's no need to\n> > add them.\n> \n> At least you would need a header to declare these two functions and make\n> them visible so that the remainder of the codebase will not have to know\nabout\n> git_setitimer(), no?  Or does your header files on NonStop declare\nsetitimer()\n> but does not implement it?\n\nNo it doesn't, at least not if a form visible to a compiler...\n\n> As your proposed name is not compat/tandem.c but more generic sounding\n> compat/itimer.c, we would have to plan for systems other than NonStop, so\nwe\n> may later have to introduce makefile variables to ask that header file to\n> declare the structure and define the constants that are missing from such\na\n> system.  While you are porting to NonStop, you may not have to\ndefine/declare\n> them, but knowing that these files are the place to later do so is part of\nthe\n> planning.\n\nI thought of having the function decclaration in git-compat-util.h, just\nlike for eg. setenv, gitmkdtemp, etc.\n\nBye, Jojo\n"},{"id":"197668","messageId":"7vharu6196.fsf@alter.siamese.dyndns.org","threadId":"31227","inReplyTo":"005201cd80ac$4cd414b0$e67c3e10$@schmitz-digital.de","subject":"Re: Porting git to HP NonStop","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-08-22T21:54:45Z","receivedAt":"2012-08-22T21:54:45Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Joachim Schmitz\" <jojo@schmitz-digital.de> writes:\n\n> I thought of having the function decclaration in git-compat-util.h, just\n> like for eg. setenv, gitmkdtemp, etc.\n\nYeah, that's also fine, especially if you do not have to declare\nstructures and constants.\n\nOnce you start having to declare other things in order to declare\nthe function missing on the system, it won't be like setenv where a\npair of #ifdef NO_SETENV/#endif just surrounds a single line.  At\nthat point, a separate header file to hold them together would\nbecome easier to read.  It's a judgement call; we'll see how it\nturns out (we do not have to get everything right in our first\nattempt).\n"}]}