diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-03-20 22:09:39 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-03-20 22:09:39 -0700 |
commit | a8e04ddf6e3fc444469e6f0f2f4690c04c0290ab (patch) | |
tree | 6a00db96c1ac88e318bb379413743a95fe88076f /wrapper.c | |
parent | c3786c8472093ec01b73a71a56f405932044a67e (diff) | |
parent | 6cf6bb3e47ac2f667fa0b27a4222e903ff6fb77c (diff) | |
download | git-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.c | 32 |
1 files changed, 28 insertions, 4 deletions
@@ -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; } |