git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 5/5] compat: remove gitmkdtemp()

From
René Scharfe <l.s.r@web.de>
Date
Dec 6, 2025, 13:35 UTC
Message-ID
<b0ed5848-ab28-4255-9933-b1d15ac9e13c@web.de>
In-Reply-To
<64e62623-b911-4ddd-a481-05191853c0a6@web.de>

gitmkdtemp() has become a trivial wrapper around git_mkdtemp(). Remove this now unnecessary layer of indirection.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
Only tested with make.
 Makefile                            | 1 -
 compat/mkdtemp.c                    | 6 ------
 compat/posix.h                      | 3 +--
 contrib/buildsystems/CMakeLists.txt | 4 ----
 meson.build                         | 2 +-
 5 files changed, 2 insertions(+), 14 deletions(-)
 delete mode 100644 compat/mkdtemp.c
diff --git a/Makefile b/Makefile
index 237b56fc9d..8226aed443 100644
--- a/Makefile
+++ b/Makefile
@@ -1919,7 +1919,6 @@ ifdef NO_SETENV
 endif
 ifdef NO_MKDTEMP
 	COMPAT_CFLAGS += -DNO_MKDTEMP
-	COMPAT_OBJS += compat/mkdtemp.o
 endif
 ifdef MKDIR_WO_TRAILING_SLASH
 	COMPAT_CFLAGS += -DMKDIR_WO_TRAILING_SLASH
diff --git a/compat/mkdtemp.c b/compat/mkdtemp.c
deleted file mode 100644
index fcdd4e01e1..0000000000
--- a/compat/mkdtemp.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "../git-compat-util.h"
-
-char *gitmkdtemp(char *template)
-{
-	return git_mkdtemp(template);
-}
diff --git a/compat/posix.h b/compat/posix.h
index 067a00f33b..245386fa4a 100644
--- a/compat/posix.h
+++ b/compat/posix.h
@@ -329,8 +329,7 @@ int gitsetenv(const char *, const char *, int);
 #endif
 
 #ifdef NO_MKDTEMP
-#define mkdtemp gitmkdtemp
-char *gitmkdtemp(char *);
+#define mkdtemp git_mkdtemp
 #endif
 
 #ifdef NO_UNSETENV
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 479163ab5c..28877feb9d 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -411,10 +411,6 @@ if(NOT HAVE_SETENV)
 	list(APPEND compat_SOURCES compat/setenv.c)
 endif()
 
-if(NOT HAVE_MKDTEMP)
-	list(APPEND compat_SOURCES compat/mkdtemp.c)
-endif()
-
 if(NOT HAVE_PREAD)
 	list(APPEND compat_SOURCES compat/pread.c)
 endif()
diff --git a/meson.build b/meson.build
index f1b3615659..24c656681c 100644
--- a/meson.build
+++ b/meson.build
@@ -1401,7 +1401,7 @@ checkfuncs = {
   'strlcpy' : ['strlcpy.c'],
   'strtoull' : [],
   'setenv' : ['setenv.c'],
-  'mkdtemp' : ['mkdtemp.c'],
+  'mkdtemp' : [],
   'initgroups' : [],
   'strtoumax' : ['strtoumax.c', 'strtoimax.c'],
   'pread' : ['pread.c'],
-- 
2.52.0
Previous: René ScharfeNext: Jeff King
Message 18 of 19 in “ban mktemp(3)”
  1. 0/4 ban mktemp(3)René Scharfe, Dec 3, 2025
  2. 1/4 wrapper: add git_mkdtemp()René Scharfe, Dec 3, 2025
  3. Chris TorekDec 4, 2025
  4. Junio C HamanoDec 5, 2025
  5. 2/4 compat: use git_mkdtemp()René Scharfe, Dec 3, 2025
  6. Jeff KingDec 3, 2025
  7. René ScharfeDec 5, 2025
  8. Jeff KingDec 6, 2025
  9. Junio C HamanoDec 5, 2025
  10. 3/4 compat: remove mingw_mktemp()René Scharfe, Dec 3, 2025
  11. 4/4 banned.h: ban mktemp(3)René Scharfe, Dec 3, 2025
  12. Jeff KingDec 3, 2025
  13. 0/5 ban mktemp(3)René Scharfe, Dec 6, 2025
  14. 1/5 wrapper: add git_mkdtemp()René Scharfe, Dec 6, 2025
  15. 2/5 compat: use git_mkdtemp()René Scharfe, Dec 6, 2025
  16. 3/5 compat: remove mingw_mktemp()René Scharfe, Dec 6, 2025
  17. 4/5 banned.h: ban mktemp(3)René Scharfe, Dec 6, 2025
  18. 5/5 compat: remove gitmkdtemp()René Scharfe, Dec 6, 2025
  19. Jeff KingDec 8, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.