wrapper: simplify xmkstemp()

Call xmkstemp_mode() instead of duplicating its error handling code. This switches the implementation from the system's mkstemp(3) to our own git_mkstemp_mode(), which works just as well. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Nov 17, 2025 at 20:42 UTC f18aa68861538e93421699aa366d6691a85258b6
1 file changed +1 -18
wrapper.c
+1 -18
@@ -421,24 +421,7 @@ FILE *fopen_or_warn(const char *path, const char *mode)
421
422 int xmkstemp(char *filename_template)
423 {
424 - int fd;
425 - char origtemplate[PATH_MAX];
426 - strlcpy(origtemplate, filename_template, sizeof(origtemplate));
427 -
428 - fd = mkstemp(filename_template);
429 - if (fd < 0) {
430 - int saved_errno = errno;
431 - const char *nonrelative_template;
432 -
433 - if (strlen(filename_template) != strlen(origtemplate))
434 - filename_template = origtemplate;
435 -
436 - nonrelative_template = absolute_path(filename_template);
437 - errno = saved_errno;
438 - die_errno("Unable to create temporary file '%s'",
439 - nonrelative_template);
440 - }
441 - return fd;
424 + return xmkstemp_mode(filename_template, 0600);
425 }
426
427 /* Adapted from libiberty's mkstemp.c. */