diff options
author | Junio C Hamano <gitster@pobox.com> | 2011-02-09 16:41:16 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2011-02-09 16:41:16 -0800 |
commit | 70ec8687a66eb7d3b273d9a7996fab309d2b0974 (patch) | |
tree | 0399e03a1c664f6b02ed36b080eca5b3ac00196d /wrapper.c | |
parent | 06938a37dca9bb19784c1bd41e90c99a7c8f8e5e (diff) | |
parent | 6cf6bb3e47ac2f667fa0b27a4222e903ff6fb77c (diff) | |
download | git-70ec8687a66eb7d3b273d9a7996fab309d2b0974.tar.gz |
Merge branch 'ae/better-template-failure-report'
* 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; } |