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

Re: [PATCH 2/4] compat: use git_mkdtemp()

From
Jeff King <peff@peff.net>
Date
Dec 6, 2025, 02:11 UTC
Message-ID
<20251206021122.GC1714099@coredump.intra.peff.net>
In-Reply-To
<aebd0ffe-7914-4731-8f79-830bd3b5a147@web.de>
On Fri, Dec 05, 2025 at 01:11:40PM +0100, René Scharfe wrote:
Show 11 quoted lines
> > This one is a conditionally-compiled wrapper for NO_MKDTEMP. But since
> > we always have git_mkdtemp() available (as of your first patch), can't
> > we just point at it directly with the macro?
> 
> A worthwhile cleanup if we stop at this point, but complicated by
> targeting three build systems, the CMake build being broken on macOS and
> me only knowing how to fake NO_MKDEMP for make, leaving half the build
> space untestable for me.
> [...]
> At the very least this cleanup should be done in a separated patch, as
> it's harder than it looks.

OK, I am convinced that it is not entirely trivial and can go in a separate patch. :) Mostly I was surprised that you would not have followed through on an obvious cleanup opportunity. It just turned out harder than I expected.

> Right.  Dropping this dependency and then deep cleaning the compat code
> is attractive and mostly sidesteps the build system complications.
> That's for a later series.
Yup. Sounds reasonable.
> Ultimately you'd prefer banning mkdtemp(3) instead of automatically
> redirecting to git_mkdtemp(), though, no?

I'm OK either way. Whatever we end up doing for mkstemp(), I think we should match here.

I do like being explicit that we are using our own wrapper and not the system function. But I wonder if it might make complications in third-party code like clar, which calls mkdtemp(). If we don't have a compat macro we'll have to patch the sources that we import into t/unit-tests/clar.

So maybe that is an argument that we should leave the "#define mkdtemp" in place.

-Peff
Previous: René ScharfeNext: Junio C Hamano
Message 8 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.