X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=wrapper.c;h=4c147d6c48c000bab636fad3edc2fe7da6670948;hb=c27e559da5b26faa31858fe6dc5492d4f605b867;hp=79635f2e1628a1ac25d62ca502c9ee4d0a2b61d6;hpb=759e84f07fd0fba2f3466b11b74146173d42cb6b;p=git.git diff --git a/wrapper.c b/wrapper.c index 79635f2e1..4c147d6c4 100644 --- a/wrapper.c +++ b/wrapper.c @@ -198,10 +198,22 @@ FILE *xfdopen(int fd, const char *mode) int xmkstemp(char *template) { int fd; + char origtemplate[PATH_MAX]; + strlcpy(origtemplate, template, sizeof(origtemplate)); fd = mkstemp(template); - if (fd < 0) - die_errno("Unable to create temporary file"); + if (fd < 0) { + int saved_errno = errno; + const char *nonrelative_template; + + if (!template[0]) + template = origtemplate; + + nonrelative_template = make_nonrelative_path(template); + errno = saved_errno; + die_errno("Unable to create temporary file '%s'", + nonrelative_template); + } return fd; } @@ -321,10 +333,22 @@ int gitmkstemps(char *pattern, int suffix_len) int xmkstemp_mode(char *template, int mode) { int fd; + char origtemplate[PATH_MAX]; + strlcpy(origtemplate, template, sizeof(origtemplate)); fd = git_mkstemp_mode(template, mode); - if (fd < 0) - die_errno("Unable to create temporary file"); + if (fd < 0) { + int saved_errno = errno; + const char *nonrelative_template; + + if (!template[0]) + template = origtemplate; + + nonrelative_template = make_nonrelative_path(template); + errno = saved_errno; + die_errno("Unable to create temporary file '%s'", + nonrelative_template); + } return fd; }