{"thread":{"id":"10401","subject":"[PATCH] Define compat version of mkdtemp for systems lacking it","startedAt":"2007-10-21T05:30:15Z","lastAt":"2007-10-21T22:03:49Z","messageCount":2,"participants":["Shawn O. Pearce","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"56748","messageId":"20071021053015.GA31995@spearce.org","threadId":"10401","inReplyTo":null,"subject":"[PATCH] Define compat version of mkdtemp for systems lacking it","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2007-10-21T05:30:15Z","receivedAt":"2007-10-21T05:30:15Z","isPatch":true,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Solaris 9 doesn't have mkdtemp() so we need to emulate it for the\nrsync transport implementation.  Since Solaris 9 is lacking this\nfunction we can also reasonably assume it is not available on\nSolaris 8 either.  The new Makfile definition NO_MKDTEMP can be\nset to enable the git compat version.\n\nSigned-off-by: Shawn O. Pearce <spearce@spearce.org>\n---\n\n On top of 'next' so that the db/fetch-pack series will actually\n build on Solaris 9.\n\n Makefile          |    8 ++++++++\n compat/mkdtemp.c  |    8 ++++++++\n git-compat-util.h |    5 +++++\n 3 files changed, 21 insertions(+), 0 deletions(-)\n create mode 100644 compat/mkdtemp.c\n\ndiff --git a/Makefile b/Makefile\nindex bb4873d..6287418 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -38,6 +38,8 @@ all::\n #\n # Define NO_SETENV if you don't have setenv in the C library.\n #\n+# Define NO_MKDTEMP if you don't have mkdtemp in the C library.\n+#\n # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.\n # Enable it on Windows.  By default, symrefs are still used.\n #\n@@ -414,12 +416,14 @@ ifeq ($(uname_S),SunOS)\n \t\tNEEDS_LIBICONV = YesPlease\n \t\tNO_UNSETENV = YesPlease\n \t\tNO_SETENV = YesPlease\n+\t\tNO_MKDTEMP = YesPlease\n \t\tNO_C99_FORMAT = YesPlease\n \t\tNO_STRTOUMAX = YesPlease\n \tendif\n \tifeq ($(uname_R),5.9)\n \t\tNO_UNSETENV = YesPlease\n \t\tNO_SETENV = YesPlease\n+\t\tNO_MKDTEMP = YesPlease\n \t\tNO_C99_FORMAT = YesPlease\n \t\tNO_STRTOUMAX = YesPlease\n \tendif\n@@ -610,6 +614,10 @@ ifdef NO_SETENV\n \tCOMPAT_CFLAGS += -DNO_SETENV\n \tCOMPAT_OBJS += compat/setenv.o\n endif\n+ifdef NO_MKDTEMP\n+\tCOMPAT_CFLAGS += -DNO_MKDTEMP\n+\tCOMPAT_OBJS += compat/mkdtemp.o\n+endif\n ifdef NO_UNSETENV\n \tCOMPAT_CFLAGS += -DNO_UNSETENV\n \tCOMPAT_OBJS += compat/unsetenv.o\ndiff --git a/compat/mkdtemp.c b/compat/mkdtemp.c\nnew file mode 100644\nindex 0000000..34d4b49\n--- /dev/null\n+++ b/compat/mkdtemp.c\n@@ -0,0 +1,8 @@\n+#include \"../git-compat-util.h\"\n+\n+char *gitmkdtemp(char *template)\n+{\n+\tif (!mktemp(template) || mkdir(template, 0700))\n+\t\treturn NULL;\n+\treturn template;\n+}\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex f23d934..474f1d1 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -147,6 +147,11 @@ extern ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);\n extern int gitsetenv(const char *, const char *, int);\n #endif\n \n+#ifdef NO_MKDTEMP\n+#define mkdtemp gitmkdtemp\n+extern char *gitmkdtemp(char *);\n+#endif\n+\n #ifdef NO_UNSETENV\n #define unsetenv gitunsetenv\n extern void gitunsetenv(const char *);\n-- \n1.5.3.4.1270.g2fe543\n"},{"id":"56784","messageId":"Pine.LNX.4.64.0710212303200.25221@racer.site","threadId":"10401","inReplyTo":"20071021053015.GA31995@spearce.org","subject":"Re: [PATCH] Define compat version of mkdtemp for systems lacking it","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-10-21T22:03:49Z","receivedAt":"2007-10-21T22:03:49Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sun, 21 Oct 2007, Shawn O. Pearce wrote:\n\n> Solaris 9 doesn't have mkdtemp() so we need to emulate it for the\n> rsync transport implementation.\n\nThanks.  I've been meaning to do it for msysGit, but I never came around \nto do it...\n\nCiao,\nDscho\n"}]}