All of lore.kernel.org
 help / color / mirror / Atom feed
From: "René Scharfe" <l.s.r@web.de>
To: git@vger.kernel.org
Subject: [PATCH 1/5] tempfile: add repo_create_tempfile{,_mode}()
Date: Tue, 14 Jul 2026 19:59:52 +0200	[thread overview]
Message-ID: <20260714175956.54601-2-l.s.r@web.de> (raw)
In-Reply-To: <20260714175956.54601-1-l.s.r@web.de>

Add variants of create_tempfile_mode() that handle arbitrary
repositories.

Signed-off-by: René Scharfe <l.s.r@web.de>
---
 tempfile.c |  8 +++++++-
 tempfile.h | 11 +++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/tempfile.c b/tempfile.c
index f0fdf58279..3132eb4371 100644
--- a/tempfile.c
+++ b/tempfile.c
@@ -135,6 +135,12 @@ static void deactivate_tempfile(struct tempfile *tempfile)
 
 /* Make sure errno contains a meaningful value on error */
 struct tempfile *create_tempfile_mode(const char *path, int mode)
+{
+	return repo_create_tempfile_mode(the_repository, path, mode);
+}
+
+struct tempfile *repo_create_tempfile_mode(struct repository *r,
+					   const char *path, int mode)
 {
 	struct tempfile *tempfile = new_tempfile();
 
@@ -150,7 +156,7 @@ struct tempfile *create_tempfile_mode(const char *path, int mode)
 		return NULL;
 	}
 	activate_tempfile(tempfile);
-	if (adjust_shared_perm(the_repository, tempfile->filename.buf)) {
+	if (adjust_shared_perm(r, tempfile->filename.buf)) {
 		int save_errno = errno;
 		error("cannot fix permission bits on %s", tempfile->filename.buf);
 		delete_tempfile(&tempfile);
diff --git a/tempfile.h b/tempfile.h
index 2227a095fd..2d17e4dad3 100644
--- a/tempfile.h
+++ b/tempfile.h
@@ -4,6 +4,8 @@
 #include "list.h"
 #include "strbuf.h"
 
+struct repository;
+
 /*
  * Handle temporary files.
  *
@@ -94,11 +96,20 @@ struct tempfile {
  */
 struct tempfile *create_tempfile_mode(const char *path, int mode);
 
+struct tempfile *repo_create_tempfile_mode(struct repository *r,
+					   const char *path, int mode);
+
 static inline struct tempfile *create_tempfile(const char *path)
 {
 	return create_tempfile_mode(path, 0666);
 }
 
+static inline struct tempfile *repo_create_tempfile(struct repository *r,
+						    const char *path)
+{
+	return repo_create_tempfile_mode(r, path, 0666);
+}
+
 /*
  * Register an existing file as a tempfile, meaning that it will be
  * deleted when the program exits. The tempfile is considered closed,
-- 
2.55.0


  reply	other threads:[~2026-07-14 18:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 17:59 [PATCH 0/5] tempfile: stop using the_repository René Scharfe
2026-07-14 17:59 ` René Scharfe [this message]
2026-07-14 17:59 ` [PATCH 2/5] refs/packed: use repo_create_tempfile() René Scharfe
2026-07-14 17:59 ` [PATCH 3/5] lockfile: add repo_hold_lock_file_for_update{,_timeout}{,_mode}() René Scharfe
2026-07-14 17:59 ` [PATCH 4/5] tempfile: stop using the_repository René Scharfe
2026-07-14 17:59 ` [PATCH 5/5] use repo_hold_lock_file_for_update{,_mode,_timeout}() with custom repos René Scharfe
2026-07-14 20:45 ` [PATCH 0/5] tempfile: stop using the_repository Junio C Hamano

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=20260714175956.54601-2-l.s.r@web.de \
    --to=l.s.r@web.de \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.