{"thread":{"id":"19496","subject":"Re: [PATCH] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF","startedAt":"2009-05-25T10:36:06Z","lastAt":"2009-05-25T10:36:06Z","messageCount":1,"participants":["David Aguilar"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"114651","messageId":"20090525103604.GB13411@gmail.com","threadId":"19496","inReplyTo":"1243226693-72293-1-git-send-email-davvid@gmail.com","subject":"Re: [PATCH] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-05-25T10:36:06Z","receivedAt":"2009-05-25T10:36:06Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Sun, May 24, 2009 at 09:44:53PM -0700, David Aguilar wrote:\n> diff --git a/path.c b/path.c\n> index 8a0a674..c2a0fb6 100644\n> --- a/path.c\n> +++ b/path.c\n> @@ -140,6 +140,24 @@ int git_mkstemp(char *path, size_t len, const char *template)\n>  }\n>  \n>  \n> +/* git_mkstemp() - create tmp file with suffix honoring TMPDIR variable */\n> +int git_mkstemps(char *path, size_t len, const char *template, int suffix_len)\n> +{\n> +\tconst char *tmp;\n> +\tsize_t n;\n> +\n> +\ttmp = getenv(\"TMPDIR\");\n> +\tif (!tmp)\n> +\t\ttmp = \"/tmp\";\n> +\tn = snprintf(path, len, \"%s/%s\", tmp, template);\n> +\tif (len <= n) {\n> +\t\terrno = ENAMETOOLONG;\n> +\t\treturn -1;\n> +\t}\n> +\treturn mkstemps(path, suffix_len);\n> +}\n\n\nLured by a mac.  I came home and I tried it on linux:\n\npath.c:157: warning: implicit declaration of function\n‘mkstemps’\n\nGah.\nDarn you OS X and your non-portable 4.4 BSD extensions.\nSorry about that.\n\nThe original patch could do without the strbuf_detach\nand free(), too.  Being tricked by an OS X manpage like\nthat is quite unpleasant.\n\nmkstemp() won't do since it doesn't work with suffixes\n(the templates must end with \"XXXX\").  I'm sure there has to\nbe another way, but I just can't think of it right now.\n\nIt seemed so easy at the time.\nSigh...\n\n-- \n\n\tDavid\n"}]}