@@ -198,10 +198,22 @@ FILE *xfdopen(int fd, const char *mode)
198198int xmkstemp (char * template )
199199{
200200 int fd ;
201+ char origtemplate [PATH_MAX ];
202+ strlcpy (origtemplate , template , sizeof (origtemplate ));
201203
202204 fd = mkstemp (template );
203- if (fd < 0 )
204- die_errno ("Unable to create temporary file" );
205+ if (fd < 0 ) {
206+ int saved_errno = errno ;
207+ const char * nonrelative_template ;
208+
209+ if (!template [0 ])
210+ template = origtemplate ;
211+
212+ nonrelative_template = make_nonrelative_path (template );
213+ errno = saved_errno ;
214+ die_errno ("Unable to create temporary file '%s'" ,
215+ nonrelative_template );
216+ }
205217 return fd ;
206218}
207219
@@ -321,10 +333,22 @@ int gitmkstemps(char *pattern, int suffix_len)
321333int xmkstemp_mode (char * template , int mode )
322334{
323335 int fd ;
336+ char origtemplate [PATH_MAX ];
337+ strlcpy (origtemplate , template , sizeof (origtemplate ));
324338
325339 fd = git_mkstemp_mode (template , mode );
326- if (fd < 0 )
327- die_errno ("Unable to create temporary file" );
340+ if (fd < 0 ) {
341+ int saved_errno = errno ;
342+ const char * nonrelative_template ;
343+
344+ if (!template [0 ])
345+ template = origtemplate ;
346+
347+ nonrelative_template = make_nonrelative_path (template );
348+ errno = saved_errno ;
349+ die_errno ("Unable to create temporary file '%s'" ,
350+ nonrelative_template );
351+ }
328352 return fd ;
329353}
330354
0 commit comments