{"thread":{"id":"19519","subject":"[PATCH 1/2] compat: add a mkstemps() compatibility function","startedAt":"2009-05-27T03:19:23Z","lastAt":"2009-05-27T08:20:55Z","messageCount":8,"participants":["David Aguilar","Johannes Sixt","Jakub Narebski"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"114756","messageId":"1243394364-13772-1-git-send-email-davvid@gmail.com","threadId":"19519","inReplyTo":null,"subject":"[PATCH 1/2] compat: add a mkstemps() compatibility function","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-05-27T03:19:23Z","receivedAt":"2009-05-27T03:19:23Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"mkstemps() is a BSD extension so provide an implementation\nfor cross-platform use.\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n\nThis mkstemps() implementation is adapted from libiberty's\nGPLv2+ mkstemps.c.\n\n Makefile          |   19 +++++++++++++\n compat/mkstemps.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n git-compat-util.h |    5 +++\n 3 files changed, 102 insertions(+), 0 deletions(-)\n create mode 100644 compat/mkstemps.c\n\ndiff --git a/Makefile b/Makefile\nindex eaae45d..a70b5f0 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -52,6 +52,8 @@ all::\n #\n # Define NO_MKDTEMP if you don't have mkdtemp in the C library.\n #\n+# Define NO_MKSTEMPS if you don't have mkstemps in the C library.\n+#\n # Define NO_SYS_SELECT_H if you don't have sys/select.h.\n #\n # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link.\n@@ -636,10 +638,12 @@ EXTLIBS =\n \n ifeq ($(uname_S),Linux)\n \tNO_STRLCPY = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tTHREADED_DELTA_SEARCH = YesPlease\n endif\n ifeq ($(uname_S),GNU/kFreeBSD)\n \tNO_STRLCPY = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tTHREADED_DELTA_SEARCH = YesPlease\n endif\n ifeq ($(uname_S),UnixWare)\n@@ -651,6 +655,7 @@ ifeq ($(uname_S),UnixWare)\n \tSHELL_PATH = /usr/local/bin/bash\n \tNO_IPV6 = YesPlease\n \tNO_HSTRERROR = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tBASIC_CFLAGS += -Kthread\n \tBASIC_CFLAGS += -I/usr/local/include\n \tBASIC_LDFLAGS += -L/usr/local/lib\n@@ -674,6 +679,7 @@ ifeq ($(uname_S),SCO_SV)\n \tSHELL_PATH = /usr/bin/bash\n \tNO_IPV6 = YesPlease\n \tNO_HSTRERROR = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tBASIC_CFLAGS += -I/usr/local/include\n \tBASIC_LDFLAGS += -L/usr/local/lib\n \tNO_STRCASESTR = YesPlease\n@@ -702,6 +708,7 @@ ifeq ($(uname_S),SunOS)\n \tNO_MEMMEM = YesPlease\n \tNO_HSTRERROR = YesPlease\n \tNO_MKDTEMP = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tOLD_ICONV = UnfortunatelyYes\n \tifeq ($(uname_R),5.8)\n \t\tNO_UNSETENV = YesPlease\n@@ -724,6 +731,7 @@ ifeq ($(uname_O),Cygwin)\n \tNO_D_INO_IN_DIRENT = YesPlease\n \tNO_STRCASESTR = YesPlease\n \tNO_MEMMEM = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tNO_SYMLINK_HEAD = YesPlease\n \tNEEDS_LIBICONV = YesPlease\n \tNO_FAST_WORKING_DIRECTORY = UnfortunatelyYes\n@@ -767,11 +775,13 @@ ifeq ($(uname_S),NetBSD)\n \tBASIC_LDFLAGS += -L/usr/pkg/lib $(CC_LD_DYNPATH)/usr/pkg/lib\n \tTHREADED_DELTA_SEARCH = YesPlease\n \tUSE_ST_TIMESPEC = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n endif\n ifeq ($(uname_S),AIX)\n \tNO_STRCASESTR=YesPlease\n \tNO_MEMMEM = YesPlease\n \tNO_MKDTEMP = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tNO_STRLCPY = YesPlease\n \tNO_NSEC = YesPlease\n \tFREAD_READS_DIRECTORIES = UnfortunatelyYes\n@@ -787,12 +797,14 @@ endif\n ifeq ($(uname_S),GNU)\n \t# GNU/Hurd\n \tNO_STRLCPY=YesPlease\n+\tNO_MKSTEMPS = YesPlease\n endif\n ifeq ($(uname_S),IRIX64)\n \tNO_IPV6=YesPlease\n \tNO_SETENV=YesPlease\n \tNO_STRCASESTR=YesPlease\n \tNO_MEMMEM = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tNO_STRLCPY = YesPlease\n \tNO_SOCKADDR_STORAGE=YesPlease\n \tSHELL_PATH=/usr/gnu/bin/bash\n@@ -805,6 +817,7 @@ ifeq ($(uname_S),HP-UX)\n \tNO_SETENV=YesPlease\n \tNO_STRCASESTR=YesPlease\n \tNO_MEMMEM = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tNO_STRLCPY = YesPlease\n \tNO_MKDTEMP = YesPlease\n \tNO_UNSETENV = YesPlease\n@@ -834,6 +847,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n \tNO_C99_FORMAT = YesPlease\n \tNO_STRTOUMAX = YesPlease\n \tNO_MKDTEMP = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n \tSNPRINTF_RETURNS_BOGUS = YesPlease\n \tNO_SVN_TESTS = YesPlease\n \tNO_PERL_MAKEMAKER = YesPlease\n@@ -853,6 +867,7 @@ ifneq (,$(findstring MINGW,$(uname_S)))\n endif\n ifneq (,$(findstring arm,$(uname_M)))\n \tARM_SHA1 = YesPlease\n+\tNO_MKSTEMPS = YesPlease\n endif\n \n -include config.mak.autogen\n@@ -1011,6 +1026,10 @@ ifdef NO_MKDTEMP\n \tCOMPAT_CFLAGS += -DNO_MKDTEMP\n \tCOMPAT_OBJS += compat/mkdtemp.o\n endif\n+ifdef NO_MKSTEMPS\n+\tCOMPAT_CFLAGS += -DNO_MKSTEMPS\n+\tCOMPAT_OBJS += compat/mkstemps.o\n+endif\n ifdef NO_UNSETENV\n \tCOMPAT_CFLAGS += -DNO_UNSETENV\n \tCOMPAT_OBJS += compat/unsetenv.o\ndiff --git a/compat/mkstemps.c b/compat/mkstemps.c\nnew file mode 100644\nindex 0000000..10f9ed6\n--- /dev/null\n+++ b/compat/mkstemps.c\n@@ -0,0 +1,78 @@\n+#include <string.h>\n+#include <errno.h>\n+#include <stdio.h>\n+#include <fcntl.h>\n+#include <inttypes.h>\n+#include <unistd.h>\n+#include <sys/time.h>\n+#include <sys/types.h>\n+\n+#ifndef TMP_MAX\n+#define TMP_MAX 16384\n+#endif\n+\n+#ifndef O_BINARY\n+#define O_BINARY 0\n+#endif\n+\n+/* Adapted from libiberty's mkstemp.c. */\n+int gitmkstemps(char *pattern, int suffix_len)\n+{\n+\tstatic const char letters[] =\n+\t\t\"abcdefghijklmnopqrstuvwxyz\"\n+\t\t\"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n+\t\t\"0123456789\";\n+\tstatic const int num_letters = 62;\n+\tuint64_t value;\n+\tstruct timeval tv;\n+\tchar *template;\n+\tsize_t len;\n+\tint fd, count;\n+\n+\tlen = strlen(pattern);\n+\n+\tif (len < 6 + suffix_len) {\n+\t\terrno = EINVAL;\n+\t\treturn -1;\n+\t}\n+\n+\tif (strncmp(&pattern[len - 6 - suffix_len], \"XXXXXX\", 6)) {\n+\t\terrno = EINVAL;\n+\t\treturn -1;\n+\t}\n+\n+\t/* Replace pattern's XXXXXX characters with randomness.\n+\t * Try TMP_MAX different filenames.\n+\t */\n+\tgettimeofday(&tv, NULL);\n+\tvalue = ((size_t)(tv.tv_usec << 16)) ^ tv.tv_sec ^ getpid();\n+\ttemplate = &pattern[len - 6 - suffix_len];\n+\tfor (count = 0; count < TMP_MAX; ++count) {\n+\t\tuint64_t v = value;\n+\t\t/* Fill in the random bits. */\n+\t\ttemplate[0] = letters[v % num_letters]; v/= num_letters;\n+\t\ttemplate[1] = letters[v % num_letters]; v/= num_letters;\n+\t\ttemplate[2] = letters[v % num_letters]; v/= num_letters;\n+\t\ttemplate[3] = letters[v % num_letters]; v/= num_letters;\n+\t\ttemplate[4] = letters[v % num_letters]; v/= num_letters;\n+\t\ttemplate[5] = letters[v % num_letters]; v/= num_letters;\n+\n+\t\tfd = open(pattern, O_BINARY|O_CREAT|O_EXCL|O_RDWR, 0600);\n+\t\tif (fd > 0)\n+\t\t\treturn fd;\n+\t\t/* Fatal error (EPERM, ENOSPC etc).\n+\t\t * It doesn't make sense to loop.\n+\t\t */\n+\t\tif (errno != EEXIST)\n+\t\t\tbreak;\n+\t\t/* This is a random value.  It is only necessary that\n+\t\t * the next TMP_MAX values generated by adding 7777 to\n+\t\t * VALUE are different with (module 2^32).\n+\t\t */\n+\t\tvalue += 7777;\n+\t}\n+\t/* We return the null string if we can't find a unique file name.  */\n+\tpattern[0] = '\\0';\n+\terrno = EINVAL;\n+\treturn -1;\n+}\ndiff --git a/git-compat-util.h b/git-compat-util.h\nindex c7cf2d5..f7217ad 100644\n--- a/git-compat-util.h\n+++ b/git-compat-util.h\n@@ -232,6 +232,11 @@ extern int gitsetenv(const char *, const char *, int);\n extern char *gitmkdtemp(char *);\n #endif\n \n+#ifdef NO_MKSTEMPS\n+#define mkstemps gitmkstemps\n+extern int gitmkstemps(char *, int);\n+#endif\n+\n #ifdef NO_UNSETENV\n #define unsetenv gitunsetenv\n extern void gitunsetenv(const char *);\n-- \n1.6.3.1.169.g33fd\n"},{"id":"114757","messageId":"1243394364-13772-2-git-send-email-davvid@gmail.com","threadId":"19519","inReplyTo":"1243394364-13772-1-git-send-email-davvid@gmail.com","subject":"[PATCH 2/2] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-05-27T03:19:24Z","receivedAt":"2009-05-27T03:19:24Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"Naturally, prep_temp_blob() did not care about filenames.\nAs a result, scripts that use GIT_EXTERNAL_DIFF ended up\nwith filenames such as \".diff_XXXXXX\".\n\nThis specializes the GIT_EXTERNAL_DIFF code to generate\nuser-friendly filenames when creating temporary files.\n\nDiffing \"name.ext\" now generates \"XXXXXX_name.ext\".\n\nSigned-off-by: David Aguilar <davvid@gmail.com>\n---\n cache.h                  |    2 ++\n diff.c                   |   40 ++++++++++++++++++++++++++++++++--------\n path.c                   |   19 +++++++++++++++++++\n t/t4020-diff-external.sh |   18 ++++++++++++++++++\n 4 files changed, 71 insertions(+), 8 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex b8503ad..871c984 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -614,6 +614,8 @@ extern int is_empty_blob_sha1(const unsigned char *sha1);\n \n int git_mkstemp(char *path, size_t n, const char *template);\n \n+int git_mkstemps(char *path, size_t n, const char *template, int suffix_len);\n+\n /*\n  * NOTE NOTE NOTE!!\n  *\ndiff --git a/diff.c b/diff.c\nindex dcfbcb0..23c52f5 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -13,6 +13,7 @@\n #include \"utf8.h\"\n #include \"userdiff.h\"\n #include \"sigchain.h\"\n+#include <libgen.h>\n \n #ifdef NO_FAST_WORKING_DIRECTORY\n #define FAST_WORKING_DIRECTORY 0\n@@ -1960,12 +1961,31 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,\n \t\t\t   void *blob,\n \t\t\t   unsigned long size,\n \t\t\t   const unsigned char *sha1,\n-\t\t\t   int mode)\n+\t\t\t   int mode,\n+\t\t\t   int pretty_filename)\n {\n \tint fd;\n \tstruct strbuf buf = STRBUF_INIT;\n \n-\tfd = git_mkstemp(temp->tmp_path, PATH_MAX, \".diff_XXXXXX\");\n+\tif (pretty_filename) {\n+\t\t/* Generate \"XXXXXX_filename\" */\n+\t\tstruct strbuf pretty_name = STRBUF_INIT;\n+\t\tchar *pathdup = xstrdup(path);\n+\t\tchar *base = basename(pathdup);\n+\t\tint suffix_len = strlen(base) + 1;\n+\n+\t\tstrbuf_addstr(&pretty_name, \"XXXXXX_\");\n+\t\tstrbuf_addstr(&pretty_name, base);\n+\n+\t\tfd = git_mkstemps(temp->tmp_path, PATH_MAX,\n+\t\t\tpretty_name.buf, suffix_len);\n+\n+\t\tfree(pathdup);\n+\t\tstrbuf_release(&pretty_name);\n+\t}\n+\telse {\n+\t\tfd = git_mkstemp(temp->tmp_path, PATH_MAX, \".diff_XXXXXX\");\n+\t}\n \tif (fd < 0)\n \t\tdie(\"unable to create temp-file: %s\", strerror(errno));\n \tif (convert_to_working_tree(path,\n@@ -1984,7 +2004,8 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,\n }\n \n static struct diff_tempfile *prepare_temp_file(const char *name,\n-\t\tstruct diff_filespec *one)\n+\t\tstruct diff_filespec *one,\n+\t\tint pretty_filename)\n {\n \tstruct diff_tempfile *temp = claim_diff_tempfile();\n \n@@ -2021,7 +2042,8 @@ static struct diff_tempfile *prepare_temp_file(const char *name,\n \t\t\t\t       (one->sha1_valid ?\n \t\t\t\t\tone->sha1 : null_sha1),\n \t\t\t\t       (one->sha1_valid ?\n-\t\t\t\t\tone->mode : S_IFLNK));\n+\t\t\t\t\tone->mode : S_IFLNK),\n+\t\t\t\t       pretty_filename);\n \t\t\tstrbuf_release(&sb);\n \t\t}\n \t\telse {\n@@ -2045,7 +2067,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,\n \t\tif (diff_populate_filespec(one, 0))\n \t\t\tdie(\"cannot read data blob for %s\", one->path);\n \t\tprep_temp_blob(name, temp, one->data, one->size,\n-\t\t\t       one->sha1, one->mode);\n+\t\t\t       one->sha1, one->mode, pretty_filename);\n \t}\n \treturn temp;\n }\n@@ -2071,8 +2093,9 @@ static void run_external_diff(const char *pgm,\n \tif (one && two) {\n \t\tstruct diff_tempfile *temp_one, *temp_two;\n \t\tconst char *othername = (other ? other : name);\n-\t\ttemp_one = prepare_temp_file(name, one);\n-\t\ttemp_two = prepare_temp_file(othername, two);\n+\t\tint pretty_filename = 1;\n+\t\ttemp_one = prepare_temp_file(name, one, pretty_filename);\n+\t\ttemp_two = prepare_temp_file(othername, two, pretty_filename);\n \t\t*arg++ = pgm;\n \t\t*arg++ = name;\n \t\t*arg++ = temp_one->name;\n@@ -3574,8 +3597,9 @@ static char *run_textconv(const char *pgm, struct diff_filespec *spec,\n \tconst char **arg = argv;\n \tstruct child_process child;\n \tstruct strbuf buf = STRBUF_INIT;\n+\tint pretty_filename = 0;\n \n-\ttemp = prepare_temp_file(spec->path, spec);\n+\ttemp = prepare_temp_file(spec->path, spec, pretty_filename);\n \t*arg++ = pgm;\n \t*arg++ = temp->name;\n \t*arg = NULL;\ndiff --git a/path.c b/path.c\nindex 8a0a674..090b490 100644\n--- a/path.c\n+++ b/path.c\n@@ -140,6 +140,25 @@ int git_mkstemp(char *path, size_t len, const char *template)\n }\n \n \n+\n+/* git_mkstemps() - 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+\n int validate_headref(const char *path)\n {\n \tstruct stat st;\ndiff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh\nindex 0720001..602d932 100755\n--- a/t/t4020-diff-external.sh\n+++ b/t/t4020-diff-external.sh\n@@ -136,6 +136,24 @@ test_expect_success 'GIT_EXTERNAL_DIFF with more than one changed files' '\n \tGIT_EXTERNAL_DIFF=echo git diff\n '\n \n+test_expect_success 'GIT_EXTERNAL_DIFF generates pretty paths with no ext' '\n+\ttouch filenoext &&\n+\tgit add filenoext &&\n+\techo no extension > filenoext &&\n+\tGIT_EXTERNAL_DIFF=echo git diff filenoext | grep _filenoext &&\n+\tgit update-index --force-remove filenoext &&\n+\trm filenoext\n+'\n+\n+test_expect_success 'GIT_EXTERNAL_DIFF generates pretty paths with ext' '\n+\ttouch file.ext &&\n+\tgit add file.ext &&\n+\techo with extension > file.ext &&\n+\tGIT_EXTERNAL_DIFF=echo git diff file.ext | grep ......_file\\.ext &&\n+\tgit update-index --force-remove file.ext &&\n+\trm file.ext\n+'\n+\n echo \"#!$SHELL_PATH\" >fake-diff.sh\n cat >> fake-diff.sh <<\\EOF\n cat $2 >> crlfed.txt\n-- \n1.6.3.1.169.g33fd\n"},{"id":"114766","messageId":"20090527051737.GA2986@gmail.com","threadId":"19519","inReplyTo":"1243394364-13772-2-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 2/2] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-05-27T05:17:38Z","receivedAt":"2009-05-27T05:17:38Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Tue, May 26, 2009 at 08:19:24PM -0700, David Aguilar wrote:\n> --- a/t/t4020-diff-external.sh\n> +++ b/t/t4020-diff-external.sh\n> @@ -136,6 +136,24 @@ test_expect_success 'GIT_EXTERNAL_DIFF with more than one changed files' '\n>  \tGIT_EXTERNAL_DIFF=echo git diff\n>  '\n\nSorry for including both tests here.\nI forgot to remove the first test when we changed the naming\nconvention to 6X_name and not special-casing filenames with\ndots in them.\n\nI guess I'll resend w/out it.  I'll wait until wednesday\nevening before resending to see if anyone spots any other\nfixups.\n\n\nThe rationale for the original naming convention was that it\nwas arguably easier for users to spot what file they're\nworking on when playing games with dot.\n\ncompare:\n\na) !!!!!!_Makefile\n\nb) Makefile_!!!!!!\n\nand:\n\na) !!!!!!_diff.c\n\nb) diff.!!!!!!.c\n\n\nIn both examples you already know what filename you're talking\nabout before scanning past any other information.\n\n.gitignore would look like .!!!!!!.gitignore, which isn't too\nbad either.\n\nAnyways, not looking to bikeshed, so I'll wait to here what\nothers have to say and continue.  The patch is fine as-is too\nsans the first test.\n\n\n> +test_expect_success 'GIT_EXTERNAL_DIFF generates pretty paths with no ext' '\n> +\ttouch filenoext &&\n> +\tgit add filenoext &&\n> +\techo no extension > filenoext &&\n> +\tGIT_EXTERNAL_DIFF=echo git diff filenoext | grep _filenoext &&\n> +\tgit update-index --force-remove filenoext &&\n> +\trm filenoext\n> +'\n> +\n> +test_expect_success 'GIT_EXTERNAL_DIFF generates pretty paths with ext' '\n> +\ttouch file.ext &&\n> +\tgit add file.ext &&\n> +\techo with extension > file.ext &&\n> +\tGIT_EXTERNAL_DIFF=echo git diff file.ext | grep ......_file\\.ext &&\n> +\tgit update-index --force-remove file.ext &&\n> +\trm file.ext\n> +'\n> +\n>  echo \"#!$SHELL_PATH\" >fake-diff.sh\n>  cat >> fake-diff.sh <<\\EOF\n>  cat $2 >> crlfed.txt\n> -- \n> 1.6.3.1.169.g33fd\n> \n\n-- \n\n\tDavid\n"},{"id":"114771","messageId":"4A1CDF11.4080507@viscovery.net","threadId":"19519","inReplyTo":"1243394364-13772-2-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 2/2] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-05-27T06:34:57Z","receivedAt":"2009-05-27T06:34:57Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"David Aguilar schrieb:\n> +#include <libgen.h>\n\nWe don't have libgen.h on Windows :-( (at least not with my aging gcc\n3.something). Would you please open-code the call to basename()?\n\n-- Hannes\n"},{"id":"114772","messageId":"20090527063735.GB2986@gmail.com","threadId":"19519","inReplyTo":"4A1CDF11.4080507@viscovery.net","subject":"Re: [PATCH 2/2] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-05-27T06:37:36Z","receivedAt":"2009-05-27T06:37:36Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Wed, May 27, 2009 at 08:34:57AM +0200, Johannes Sixt wrote:\n> David Aguilar schrieb:\n> > +#include <libgen.h>\n> \n> We don't have libgen.h on Windows :-( (at least not with my aging gcc\n> 3.something). Would you please open-code the call to basename()?\n> \n> -- Hannes\n> \n\nThanks for catching that.\nI'll roll that into the next version.\n\n-- \n\n\tDavid\n"},{"id":"114773","messageId":"20090527070221.GC2986@gmail.com","threadId":"19519","inReplyTo":"4A1CDF11.4080507@viscovery.net","subject":"Re: [PATCH 2/2] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2009-05-27T07:02:22Z","receivedAt":"2009-05-27T07:02:22Z","isPatch":true,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Wed, May 27, 2009 at 08:34:57AM +0200, Johannes Sixt wrote:\n> David Aguilar schrieb:\n> > +#include <libgen.h>\n> \n> We don't have libgen.h on Windows :-( (at least not with my aging gcc\n> 3.something). Would you please open-code the call to basename()?\n> \n> -- Hannes\n> \n\nI don't know much about Windows.\nDo we need to check for \\ in addition to /?\n\n-- \n\n\tDavid\n"},{"id":"114774","messageId":"4A1CE853.9080305@viscovery.net","threadId":"19519","inReplyTo":"20090527070221.GC2986@gmail.com","subject":"Re: [PATCH 2/2] diff: generate prettier filenames when using GIT_EXTERNAL_DIFF","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2009-05-27T07:14:27Z","receivedAt":"2009-05-27T07:14:27Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"David Aguilar schrieb:\n> On Wed, May 27, 2009 at 08:34:57AM +0200, Johannes Sixt wrote:\n>> David Aguilar schrieb:\n>>> +#include <libgen.h>\n>> We don't have libgen.h on Windows :-( (at least not with my aging gcc\n>> 3.something). Would you please open-code the call to basename()?\n> \n> I don't know much about Windows.\n> Do we need to check for \\ in addition to /?\n\nIf the paths have been taken from the index or have passed through\nget_pathspec or prefix_filename, then it is sufficient to check for '/'.\nOtherwise, use is_dir_sep() (note it is a macro: don't call it like\nis_dir_sep(*c++)).\n\n-- Hannes\n"},{"id":"114782","messageId":"m33aarc5yc.fsf@localhost.localdomain","threadId":"19519","inReplyTo":"1243394364-13772-1-git-send-email-davvid@gmail.com","subject":"Re: [PATCH 1/2] compat: add a mkstemps() compatibility function","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-05-27T08:20:55Z","receivedAt":"2009-05-27T08:20:55Z","isPatch":true,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"David Aguilar <davvid@gmail.com> writes:\n\n> mkstemps() is a BSD extension so provide an implementation\n> for cross-platform use.\n> \n> Signed-off-by: David Aguilar <davvid@gmail.com>\n> ---\n> \n> This mkstemps() implementation is adapted from libiberty's\n> GPLv2+ mkstemps.c.\n> \n>  Makefile          |   19 +++++++++++++\n>  compat/mkstemps.c |   78 +++++++++++++++++++++++++++++++++++++++++++++++++++++\n>  git-compat-util.h |    5 +++\n>  3 files changed, 102 insertions(+), 0 deletions(-)\n>  create mode 100644 compat/mkstemps.c\n\nCould you squash this in?  I see that configure.ac is a bit outdated,\nbut we shouldn't make it even more so...\n\n---\n config.mak.in |    1 +\n configure.ac  |    6 ++++++\n 2 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/config.mak.in b/config.mak.in\nindex 7cce0c1..b6619af 100644\n--- a/config.mak.in\n+++ b/config.mak.in\n@@ -46,6 +46,7 @@ NO_STRTOUMAX=@NO_STRTOUMAX@\n NO_SETENV=@NO_SETENV@\n NO_UNSETENV=@NO_UNSETENV@\n NO_MKDTEMP=@NO_MKDTEMP@\n+NO_MKSTEMPS=@NO_MKSTEMPS@\n NO_ICONV=@NO_ICONV@\n OLD_ICONV=@OLD_ICONV@\n NO_DEFLATE_BOUND=@NO_DEFLATE_BOUND@\ndiff --git a/configure.ac b/configure.ac\nindex 4e728bc..2ddf498 100644\n--- a/configure.ac\n+++ b/configure.ac\n@@ -677,6 +677,12 @@ GIT_CHECK_FUNC(mkdtemp,\n [NO_MKDTEMP=YesPlease])\n AC_SUBST(NO_MKDTEMP)\n #\n+# Define NO_MKSTEMPS if you don't have mkstemps in the C library.\n+GIT_CHECK_FUNC(mkstemps,\n+[NO_MKSTEMPS=],\n+[NO_MKSTEMPS=YesPlease])\n+AC_SUBST(NO_MKSTEMPS)\n+#\n # Define NO_MMAP if you want to avoid mmap.\n #\n # Define NO_ICONV if your libc does not properly support iconv.\n-- \n1.6.3.1\n"}]}