summaryrefslogtreecommitdiff
path: root/wrapper.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2011-03-20 22:09:39 -0700
committerJunio C Hamano <gitster@pobox.com>2011-03-20 22:09:39 -0700
commita8e04ddf6e3fc444469e6f0f2f4690c04c0290ab (patch)
tree6a00db96c1ac88e318bb379413743a95fe88076f /wrapper.c
parentc3786c8472093ec01b73a71a56f405932044a67e (diff)
parent6cf6bb3e47ac2f667fa0b27a4222e903ff6fb77c (diff)
downloadgit-a8e04ddf6e3fc444469e6f0f2f4690c04c0290ab.tar.gz
Merge branch 'ae/better-template-failure-report' into maint
* ae/better-template-failure-report: Improve error messages when temporary file creation fails
Diffstat (limited to 'wrapper.c')
-rw-r--r--wrapper.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/wrapper.c b/wrapper.c
index 79635f2e16..4c147d6c48 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;
}