From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <l.s.r@web.de>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 1/4] wrapper: add git_mkdtemp()
Date: Sat, 06 Dec 2025 08:05:38 +0900 [thread overview]
Message-ID: <xmqqikek7cn1.fsf@gitster.g> (raw)
In-Reply-To: <65c997a7-e480-4617-a761-fc9dc8a7b20d@web.de> ("René Scharfe"'s message of "Wed, 3 Dec 2025 11:51:48 +0100")
René Scharfe <l.s.r@web.de> writes:
> -int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
> +static int git_mkdstemps_mode(char *pattern, int suffix_len, int mode, bool dir)
This is a file-scope static, so as long as it is understood by those
who futz with things in this file well, there is no need to go extra
mile to avoid confusion, but the meaning of the returned value from
this function is vastly different depending on the value of "dir".
It used to be that you can subject it to write(2), but obviously
that is not relevant when you called mkdir(2) here.
> {
> static const char letters[] =
> "abcdefghijklmnopqrstuvwxyz"
> @@ -471,7 +471,10 @@ int git_mkstemps_mode(char *pattern, int suffix_len, int mode)
> v /= num_letters;
> }
>
> - fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
> + if (dir)
> + fd = mkdir(pattern, mode);
OK. The caller calls this helper with 0700 (S_IRWXU), so that's
probably OK. If we can make this into two helper functions with
distinct function signatures that share the majority of logic, it
would have been much nicer, but short of introducing a callback
function I do not think of a good way, so I'll let it pass.
> + else
> + fd = open(pattern, O_CREAT | O_EXCL | O_RDWR, mode);
> if (fd >= 0)
> return fd;
next prev parent reply other threads:[~2025-12-05 23:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-03 10:45 [PATCH 0/4] ban mktemp(3) René Scharfe
2025-12-03 10:51 ` [PATCH 1/4] wrapper: add git_mkdtemp() René Scharfe
2025-12-04 11:51 ` Chris Torek
2025-12-05 23:05 ` Junio C Hamano [this message]
2025-12-03 10:52 ` [PATCH 2/4] compat: use git_mkdtemp() René Scharfe
2025-12-03 16:11 ` Jeff King
2025-12-05 12:11 ` René Scharfe
2025-12-06 2:11 ` Jeff King
2025-12-05 23:05 ` Junio C Hamano
2025-12-03 10:52 ` [PATCH 3/4] compat: remove mingw_mktemp() René Scharfe
2025-12-03 10:53 ` [PATCH 4/4] banned.h: ban mktemp(3) René Scharfe
2025-12-03 16:12 ` Jeff King
2025-12-06 13:21 ` [PATCH v2 0/5] " René Scharfe
2025-12-06 13:27 ` [PATCH v2 1/5] wrapper: add git_mkdtemp() René Scharfe
2025-12-06 13:27 ` [PATCH v2 2/5] compat: use git_mkdtemp() René Scharfe
2025-12-06 13:28 ` [PATCH v2 3/5] compat: remove mingw_mktemp() René Scharfe
2025-12-06 13:29 ` [PATCH v2 4/5] banned.h: ban mktemp(3) René Scharfe
2025-12-06 13:35 ` [PATCH v2 5/5] compat: remove gitmkdtemp() René Scharfe
2025-12-08 20:33 ` [PATCH v2 0/5] ban mktemp(3) Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqikek7cn1.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=l.s.r@web.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).