{"thread":{"id":"65993","subject":"[PATCH 0/5] tempfile: stop using the_repository","startedAt":"2026-07-14T18:00:08Z","lastAt":"2026-07-21T22:03:26Z","messageCount":15,"participants":["René Scharfe","Junio C Hamano","Patrick Steinhardt"],"isPatch":true,"patchVersion":1,"patchTotal":5},"messages":[{"id":"548139","messageId":"20260714175956.54601-1-l.s.r@web.de","threadId":"65993","inReplyTo":null,"subject":"[PATCH 0/5] tempfile: stop using the_repository","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-07-14T17:59:51Z","receivedAt":"2026-07-14T18:00:08Z","isPatch":true,"body":"create_tempfile_mode() and create_tempfile() use the_repository\ninternally to call adjust_shared_perm().  Expose that dependency and\npush it out to their callers.\n\nPatch 5 is a bonus; it converts lockfile users that already work with\nother repositories.\n\n  tempfile: add repo_create_tempfile{,_mode}()\n  refs/packed: use repo_create_tempfile()\n  lockfile: add repo_hold_lock_file_for_update{,_timeout}{,_mode}()\n  tempfile: stop using the_repository\n  use repo_hold_lock_file_for_update{,_mode,_timeout}() with custom repos\n\n apply.c                   | 10 ++++++----\n builtin/difftool.c        |  2 +-\n builtin/gc.c              |  2 +-\n builtin/history.c         |  2 +-\n builtin/sparse-checkout.c |  3 ++-\n bundle.c                  |  4 ++--\n commit-graph.c            |  9 +++++----\n config.c                  |  4 ++--\n lockfile.c                | 30 ++++++++++++++++++++++--------\n lockfile.h                | 31 +++++++++++++++++++++++++++++++\n loose.c                   |  6 ++++--\n midx-write.c              |  7 ++++---\n odb/source-files.c        |  3 ++-\n refs/files-backend.c      | 10 ++++++----\n refs/packed-backend.c     |  9 ++++-----\n refs/packed-backend.h     |  2 +-\n repack-midx.c             |  3 ++-\n repository.c              |  2 +-\n rerere.c                  |  6 +++---\n tempfile.c                |  7 +++----\n tempfile.h                | 10 +++++++---\n 21 files changed, 110 insertions(+), 52 deletions(-)\n\n-- \n2.55.0\n\n"},{"id":"548140","messageId":"20260714175956.54601-2-l.s.r@web.de","threadId":"65993","inReplyTo":"20260714175956.54601-1-l.s.r@web.de","subject":"[PATCH 1/5] tempfile: add repo_create_tempfile{,_mode}()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-07-14T17:59:52Z","receivedAt":"2026-07-14T18:00:08Z","isPatch":true,"body":"Add variants of create_tempfile_mode() that handle arbitrary\nrepositories.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n tempfile.c |  8 +++++++-\n tempfile.h | 11 +++++++++++\n 2 files changed, 18 insertions(+), 1 deletion(-)\n\ndiff --git a/tempfile.c b/tempfile.c\nindex f0fdf58279..3132eb4371 100644\n--- a/tempfile.c\n+++ b/tempfile.c\n@@ -135,6 +135,12 @@ static void deactivate_tempfile(struct tempfile *tempfile)\n \n /* Make sure errno contains a meaningful value on error */\n struct tempfile *create_tempfile_mode(const char *path, int mode)\n+{\n+\treturn repo_create_tempfile_mode(the_repository, path, mode);\n+}\n+\n+struct tempfile *repo_create_tempfile_mode(struct repository *r,\n+\t\t\t\t\t   const char *path, int mode)\n {\n \tstruct tempfile *tempfile = new_tempfile();\n \n@@ -150,7 +156,7 @@ struct tempfile *create_tempfile_mode(const char *path, int mode)\n \t\treturn NULL;\n \t}\n \tactivate_tempfile(tempfile);\n-\tif (adjust_shared_perm(the_repository, tempfile->filename.buf)) {\n+\tif (adjust_shared_perm(r, tempfile->filename.buf)) {\n \t\tint save_errno = errno;\n \t\terror(\"cannot fix permission bits on %s\", tempfile->filename.buf);\n \t\tdelete_tempfile(&tempfile);\ndiff --git a/tempfile.h b/tempfile.h\nindex 2227a095fd..2d17e4dad3 100644\n--- a/tempfile.h\n+++ b/tempfile.h\n@@ -4,6 +4,8 @@\n #include \"list.h\"\n #include \"strbuf.h\"\n \n+struct repository;\n+\n /*\n  * Handle temporary files.\n  *\n@@ -94,11 +96,20 @@ struct tempfile {\n  */\n struct tempfile *create_tempfile_mode(const char *path, int mode);\n \n+struct tempfile *repo_create_tempfile_mode(struct repository *r,\n+\t\t\t\t\t   const char *path, int mode);\n+\n static inline struct tempfile *create_tempfile(const char *path)\n {\n \treturn create_tempfile_mode(path, 0666);\n }\n \n+static inline struct tempfile *repo_create_tempfile(struct repository *r,\n+\t\t\t\t\t\t    const char *path)\n+{\n+\treturn repo_create_tempfile_mode(r, path, 0666);\n+}\n+\n /*\n  * Register an existing file as a tempfile, meaning that it will be\n  * deleted when the program exits. The tempfile is considered closed,\n-- \n2.55.0\n\n"},{"id":"548141","messageId":"20260714175956.54601-3-l.s.r@web.de","threadId":"65993","inReplyTo":"20260714175956.54601-1-l.s.r@web.de","subject":"[PATCH 2/5] refs/packed: use repo_create_tempfile()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-07-14T17:59:53Z","receivedAt":"2026-07-14T18:00:08Z","isPatch":true,"body":"Apply the config setting core.sharedRepository from the ref store base\nrepository at hand instead of from the_repository.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n refs/packed-backend.c | 2 +-\n 1 file changed, 1 insertion(+), 1 deletion(-)\n\ndiff --git a/refs/packed-backend.c b/refs/packed-backend.c\nindex 499cb55dfa..7e65d9580e 100644\n--- a/refs/packed-backend.c\n+++ b/refs/packed-backend.c\n@@ -1393,7 +1393,7 @@ static enum ref_transaction_error write_with_updates(struct packed_ref_store *re\n \tpacked_refs_path = get_locked_file_path(&refs->lock);\n \tstrbuf_addf(&sb, \"%s.new\", packed_refs_path);\n \tfree(packed_refs_path);\n-\trefs->tempfile = create_tempfile(sb.buf);\n+\trefs->tempfile = repo_create_tempfile(refs->base.repo, sb.buf);\n \tif (!refs->tempfile) {\n \t\tstrbuf_addf(err, \"unable to create file %s: %s\",\n \t\t\t    sb.buf, strerror(errno));\n-- \n2.55.0\n\n"},{"id":"548143","messageId":"20260714175956.54601-4-l.s.r@web.de","threadId":"65993","inReplyTo":"20260714175956.54601-1-l.s.r@web.de","subject":"[PATCH 3/5] lockfile: add repo_hold_lock_file_for_update{,_timeout}{,_mode}()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-07-14T17:59:54Z","receivedAt":"2026-07-14T18:00:08Z","isPatch":true,"body":"Add variants of hold_lock_file_for_update_timeout_mode() that handle\narbitrary repositories.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n lockfile.c | 30 ++++++++++++++++++++++--------\n lockfile.h | 31 +++++++++++++++++++++++++++++++\n 2 files changed, 53 insertions(+), 8 deletions(-)\n\ndiff --git a/lockfile.c b/lockfile.c\nindex 7add2f136a..100f603771 100644\n--- a/lockfile.c\n+++ b/lockfile.c\n@@ -2,11 +2,14 @@\n  * Copyright (c) 2005, Junio C Hamano\n  */\n \n+#define USE_THE_REPOSITORY_VARIABLE\n+\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"gettext.h\"\n #include \"lockfile.h\"\n #include \"parse.h\"\n+#include \"repository.h\"\n #include \"strbuf.h\"\n #include \"wrapper.h\"\n \n@@ -162,8 +165,8 @@ static int read_lock_pid(const char *pid_path, uintmax_t *pid_out)\n }\n \n /* Make sure errno contains a meaningful value on error */\n-static int lock_file(struct lock_file *lk, const char *path, int flags,\n-\t\t     int mode)\n+static int lock_file(struct repository *r, struct lock_file *lk,\n+\t\t     const char *path, int flags, int mode)\n {\n \tstruct strbuf base_path = STRBUF_INIT;\n \tstruct strbuf lock_path = STRBUF_INIT;\n@@ -176,7 +179,7 @@ static int lock_file(struct lock_file *lk, const char *path, int flags,\n \tget_lock_path(&lock_path, base_path.buf);\n \tget_pid_path(&pid_path, base_path.buf);\n \n-\tlk->tempfile = create_tempfile_mode(lock_path.buf, mode);\n+\tlk->tempfile = repo_create_tempfile_mode(r, lock_path.buf, mode);\n \tif (lk->tempfile)\n \t\tlk->pid_tempfile = create_lock_pid_file(pid_path.buf, mode);\n \n@@ -200,8 +203,9 @@ static int lock_file(struct lock_file *lk, const char *path, int flags,\n  * timeout_ms milliseconds. If timeout_ms is 0, try locking the file\n  * exactly once. If timeout_ms is -1, try indefinitely.\n  */\n-static int lock_file_timeout(struct lock_file *lk, const char *path,\n-\t\t\t     int flags, long timeout_ms, int mode)\n+static int lock_file_timeout(struct repository *r, struct lock_file *lk,\n+\t\t\t     const char *path, int flags, long timeout_ms,\n+\t\t\t     int mode)\n {\n \tint n = 1;\n \tint multiplier = 1;\n@@ -209,7 +213,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n \tstatic int random_initialized = 0;\n \n \tif (timeout_ms == 0)\n-\t\treturn lock_file(lk, path, flags, mode);\n+\t\treturn lock_file(r, lk, path, flags, mode);\n \n \tif (!random_initialized) {\n \t\tsrand((unsigned int)getpid());\n@@ -223,7 +227,7 @@ static int lock_file_timeout(struct lock_file *lk, const char *path,\n \t\tlong backoff_ms, wait_ms;\n \t\tint fd;\n \n-\t\tfd = lock_file(lk, path, flags, mode);\n+\t\tfd = lock_file(r, lk, path, flags, mode);\n \n \t\tif (fd >= 0)\n \t\t\treturn fd; /* success */\n@@ -308,7 +312,17 @@ int hold_lock_file_for_update_timeout_mode(struct lock_file *lk,\n \t\t\t\t\t   const char *path, int flags,\n \t\t\t\t\t   long timeout_ms, int mode)\n {\n-\tint fd = lock_file_timeout(lk, path, flags, timeout_ms, mode);\n+\treturn repo_hold_lock_file_for_update_timeout_mode(the_repository,\n+\t\t\t\t\t\t\t   lk, path, flags,\n+\t\t\t\t\t\t\t   timeout_ms, mode);\n+}\n+\n+int repo_hold_lock_file_for_update_timeout_mode(struct repository *r,\n+\t\t\t\t\t\tstruct lock_file *lk,\n+\t\t\t\t\t\tconst char *path, int flags,\n+\t\t\t\t\t\tlong timeout_ms, int mode)\n+{\n+\tint fd = lock_file_timeout(r, lk, path, flags, timeout_ms, mode);\n \tif (fd < 0) {\n \t\tif (flags & LOCK_DIE_ON_ERROR)\n \t\t\tunable_to_lock_die(path, errno);\ndiff --git a/lockfile.h b/lockfile.h\nindex e7233f28de..1667612674 100644\n--- a/lockfile.h\n+++ b/lockfile.h\n@@ -189,6 +189,11 @@ int hold_lock_file_for_update_timeout_mode(\n \tstruct lock_file *lk, const char *path,\n \tint flags, long timeout_ms, int mode);\n \n+int repo_hold_lock_file_for_update_timeout_mode(struct repository *r,\n+\t\t\t\t\t\tstruct lock_file *lk,\n+\t\t\t\t\t\tconst char *path, int flags,\n+\t\t\t\t\t\tlong timeout_ms, int mode);\n+\n static inline int hold_lock_file_for_update_timeout(\n \tstruct lock_file *lk, const char *path,\n \tint flags, long timeout_ms)\n@@ -197,6 +202,16 @@ static inline int hold_lock_file_for_update_timeout(\n \t\t\t\t\t\t      timeout_ms, 0666);\n }\n \n+static inline int repo_hold_lock_file_for_update_timeout(struct repository *r,\n+\t\t\t\t\t\t\t struct lock_file *lk,\n+\t\t\t\t\t\t\t const char *path,\n+\t\t\t\t\t\t\t int flags,\n+\t\t\t\t\t\t\t long timeout_ms)\n+{\n+\treturn repo_hold_lock_file_for_update_timeout_mode(r, lk, path, flags,\n+\t\t\t\t\t\t\t   timeout_ms, 0666);\n+}\n+\n /*\n  * Attempt to create a lockfile for the file at `path` and return a\n  * file descriptor for writing to it, or -1 on error. The flags\n@@ -208,6 +223,13 @@ static inline int hold_lock_file_for_update(\n \treturn hold_lock_file_for_update_timeout(lk, path, flags, 0);\n }\n \n+static inline int repo_hold_lock_file_for_update(struct repository *r,\n+\t\t\t\t\t\t struct lock_file *lk,\n+\t\t\t\t\t\t const char *path, int flags)\n+{\n+\treturn repo_hold_lock_file_for_update_timeout(r, lk, path, flags, 0);\n+}\n+\n static inline int hold_lock_file_for_update_mode(\n \tstruct lock_file *lk, const char *path,\n \tint flags, int mode)\n@@ -215,6 +237,15 @@ static inline int hold_lock_file_for_update_mode(\n \treturn hold_lock_file_for_update_timeout_mode(lk, path, flags, 0, mode);\n }\n \n+static inline int repo_hold_lock_file_for_update_mode(struct repository *r,\n+\t\t\t\t\t\t      struct lock_file *lk,\n+\t\t\t\t\t\t      const char *path,\n+\t\t\t\t\t\t      int flags, int mode)\n+{\n+\treturn repo_hold_lock_file_for_update_timeout_mode(r, lk, path, flags,\n+\t\t\t\t\t\t\t   0, mode);\n+}\n+\n /*\n  * Return a nonzero value iff `lk` is currently locked.\n  */\n-- \n2.55.0\n\n"},{"id":"548142","messageId":"20260714175956.54601-5-l.s.r@web.de","threadId":"65993","inReplyTo":"20260714175956.54601-1-l.s.r@web.de","subject":"[PATCH 4/5] tempfile: stop using the_repository","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-07-14T17:59:55Z","receivedAt":"2026-07-14T18:00:09Z","isPatch":true,"body":"Remove the compatibility wrappers create_tempfile_mode() and\ncreate_tempfile() that have become unused.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n tempfile.c | 7 -------\n tempfile.h | 7 -------\n 2 files changed, 14 deletions(-)\n\ndiff --git a/tempfile.c b/tempfile.c\nindex 3132eb4371..dc9ca4e645 100644\n--- a/tempfile.c\n+++ b/tempfile.c\n@@ -42,8 +42,6 @@\n  * file created by its parent.\n  */\n \n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"abspath.h\"\n #include \"path.h\"\n@@ -134,11 +132,6 @@ static void deactivate_tempfile(struct tempfile *tempfile)\n }\n \n /* Make sure errno contains a meaningful value on error */\n-struct tempfile *create_tempfile_mode(const char *path, int mode)\n-{\n-\treturn repo_create_tempfile_mode(the_repository, path, mode);\n-}\n-\n struct tempfile *repo_create_tempfile_mode(struct repository *r,\n \t\t\t\t\t   const char *path, int mode)\n {\ndiff --git a/tempfile.h b/tempfile.h\nindex 2d17e4dad3..f571f3c609 100644\n--- a/tempfile.h\n+++ b/tempfile.h\n@@ -94,16 +94,9 @@ struct tempfile {\n  * `core.sharedRepository`, so it is not guaranteed to have the given\n  * mode.\n  */\n-struct tempfile *create_tempfile_mode(const char *path, int mode);\n-\n struct tempfile *repo_create_tempfile_mode(struct repository *r,\n \t\t\t\t\t   const char *path, int mode);\n \n-static inline struct tempfile *create_tempfile(const char *path)\n-{\n-\treturn create_tempfile_mode(path, 0666);\n-}\n-\n static inline struct tempfile *repo_create_tempfile(struct repository *r,\n \t\t\t\t\t\t    const char *path)\n {\n-- \n2.55.0\n\n"},{"id":"548144","messageId":"20260714175956.54601-6-l.s.r@web.de","threadId":"65993","inReplyTo":"20260714175956.54601-1-l.s.r@web.de","subject":"[PATCH 5/5] use repo_hold_lock_file_for_update{,_mode,_timeout}() with custom repos","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-07-14T17:59:56Z","receivedAt":"2026-07-14T18:00:09Z","isPatch":true,"body":"Apply the config setting core.sharedRepository from the repository at\nhand instead of from the_repository.\n\nSigned-off-by: René Scharfe <l.s.r@web.de>\n---\n apply.c                   | 10 ++++++----\n builtin/difftool.c        |  2 +-\n builtin/gc.c              |  2 +-\n builtin/history.c         |  2 +-\n builtin/sparse-checkout.c |  3 ++-\n bundle.c                  |  4 ++--\n commit-graph.c            |  9 +++++----\n config.c                  |  4 ++--\n loose.c                   |  6 ++++--\n midx-write.c              |  7 ++++---\n odb/source-files.c        |  3 ++-\n refs/files-backend.c      | 10 ++++++----\n refs/packed-backend.c     |  7 +++----\n refs/packed-backend.h     |  2 +-\n repack-midx.c             |  3 ++-\n repository.c              |  2 +-\n rerere.c                  |  6 +++---\n 17 files changed, 46 insertions(+), 36 deletions(-)\n\ndiff --git a/apply.c b/apply.c\nindex 5e54453f79..ac1bfc7f85 100644\n--- a/apply.c\n+++ b/apply.c\n@@ -4287,7 +4287,8 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)\n \t\t}\n \t}\n \n-\thold_lock_file_for_update(&lock, state->fake_ancestor, LOCK_DIE_ON_ERROR);\n+\trepo_hold_lock_file_for_update(state->repo, &lock, state->fake_ancestor,\n+\t\t\t\t       LOCK_DIE_ON_ERROR);\n \tres = write_locked_index(&result, &lock, COMMIT_LOCK);\n \tdiscard_index(&result);\n \n@@ -4945,9 +4946,10 @@ static int apply_patch(struct apply_state *state,\n \tstate->update_index = (state->check_index || state->ita_only) && state->apply;\n \tif (state->update_index && !is_lock_file_locked(&state->lock_file)) {\n \t\tif (state->index_file)\n-\t\t\thold_lock_file_for_update(&state->lock_file,\n-\t\t\t\t\t\t  state->index_file,\n-\t\t\t\t\t\t  LOCK_DIE_ON_ERROR);\n+\t\t\trepo_hold_lock_file_for_update(state->repo,\n+\t\t\t\t\t\t       &state->lock_file,\n+\t\t\t\t\t\t       state->index_file,\n+\t\t\t\t\t\t       LOCK_DIE_ON_ERROR);\n \t\telse\n \t\t\trepo_hold_locked_index(state->repo, &state->lock_file,\n \t\t\t\t\t       LOCK_DIE_ON_ERROR);\ndiff --git a/builtin/difftool.c b/builtin/difftool.c\nindex 26778f8515..99c01c92ef 100644\n--- a/builtin/difftool.c\n+++ b/builtin/difftool.c\n@@ -636,7 +636,7 @@ static int run_dir_diff(struct repository *repo,\n \t\t\tstruct lock_file lock = LOCK_INIT;\n \t\t\tstrbuf_reset(&buf);\n \t\t\tstrbuf_addf(&buf, \"%s/wtindex\", tmpdir.buf);\n-\t\t\tif (hold_lock_file_for_update(&lock, buf.buf, 0) < 0 ||\n+\t\t\tif (repo_hold_lock_file_for_update(repo, &lock, buf.buf, 0) < 0 ||\n \t\t\t    write_locked_index(&wtindex, &lock, COMMIT_LOCK)) {\n \t\t\t\tret = error(\"could not write %s\", buf.buf);\n \t\t\t\tgoto finish;\ndiff --git a/builtin/gc.c b/builtin/gc.c\nindex d32af422af..7153a49aca 100644\n--- a/builtin/gc.c\n+++ b/builtin/gc.c\n@@ -1790,7 +1790,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,\n \tstruct repository *r = the_repository;\n \tchar *lock_path = xstrfmt(\"%s/maintenance\", r->objects->sources->path);\n \n-\tif (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {\n+\tif (repo_hold_lock_file_for_update(r, &lk, lock_path, LOCK_NO_DEREF) < 0) {\n \t\t/*\n \t\t * Another maintenance command is running.\n \t\t *\ndiff --git a/builtin/history.c b/builtin/history.c\nindex fd83de8265..7e5177bc0a 100644\n--- a/builtin/history.c\n+++ b/builtin/history.c\n@@ -764,7 +764,7 @@ static int write_ondisk_index(struct repository *repo,\n \n \tprime_cache_tree(repo, &index, tree);\n \n-\tif (hold_lock_file_for_update(&lock, path, 0) < 0) {\n+\tif (repo_hold_lock_file_for_update(repo, &lock, path, 0) < 0) {\n \t\tret = error_errno(_(\"unable to acquire index lock\"));\n \t\tgoto out;\n \t}\ndiff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c\nindex 0863d0fb46..cb4a037b77 100644\n--- a/builtin/sparse-checkout.c\n+++ b/builtin/sparse-checkout.c\n@@ -341,7 +341,8 @@ static int write_patterns_and_update(struct repository *repo,\n \tif (safe_create_leading_directories(repo, sparse_filename))\n \t\tdie(_(\"failed to create directory for sparse-checkout file\"));\n \n-\thold_lock_file_for_update(&lk, sparse_filename, LOCK_DIE_ON_ERROR);\n+\trepo_hold_lock_file_for_update(repo, &lk, sparse_filename,\n+\t\t\t\t       LOCK_DIE_ON_ERROR);\n \n \tresult = update_working_directory(repo, pl);\n \tif (result) {\ndiff --git a/bundle.c b/bundle.c\nindex fd2db2c837..b64716f252 100644\n--- a/bundle.c\n+++ b/bundle.c\n@@ -519,8 +519,8 @@ int create_bundle(struct repository *r, const char *path,\n \tif (bundle_to_stdout)\n \t\tbundle_fd = 1;\n \telse\n-\t\tbundle_fd = hold_lock_file_for_update(&lock, path,\n-\t\t\t\t\t\t      LOCK_DIE_ON_ERROR);\n+\t\tbundle_fd = repo_hold_lock_file_for_update(r, &lock, path,\n+\t\t\t\t\t\t\t   LOCK_DIE_ON_ERROR);\n \n \tif (version == -1)\n \t\tversion = min_version;\ndiff --git a/commit-graph.c b/commit-graph.c\nindex c6d9c5c740..1b073b367a 100644\n--- a/commit-graph.c\n+++ b/commit-graph.c\n@@ -2122,8 +2122,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \tif (ctx->split) {\n \t\tchar *lock_name = get_commit_graph_chain_filename(ctx->odb_source);\n \n-\t\thold_lock_file_for_update_mode(&lk, lock_name,\n-\t\t\t\t\t       LOCK_DIE_ON_ERROR, 0444);\n+\t\trepo_hold_lock_file_for_update_mode(ctx->r, &lk, lock_name,\n+\t\t\t\t\t\t    LOCK_DIE_ON_ERROR, 0444);\n \t\tfree(lock_name);\n \n \t\tgraph_layer = mks_tempfile_m(ctx->graph_name, 0444);\n@@ -2141,8 +2141,9 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)\n \t\tf = hashfd(ctx->r->hash_algo,\n \t\t\t   get_tempfile_fd(graph_layer), get_tempfile_path(graph_layer));\n \t} else {\n-\t\thold_lock_file_for_update_mode(&lk, ctx->graph_name,\n-\t\t\t\t\t       LOCK_DIE_ON_ERROR, 0444);\n+\t\trepo_hold_lock_file_for_update_mode(ctx->r, &lk,\n+\t\t\t\t\t\t    ctx->graph_name,\n+\t\t\t\t\t\t    LOCK_DIE_ON_ERROR, 0444);\n \t\tf = hashfd(ctx->r->hash_algo,\n \t\t\t   get_lock_file_fd(&lk), get_lock_file_path(&lk));\n \t}\ndiff --git a/config.c b/config.c\nindex 6a0de86e3a..d29425ab8e 100644\n--- a/config.c\n+++ b/config.c\n@@ -3034,7 +3034,7 @@ int repo_config_set_multivar_in_file_gently(struct repository *r,\n \t * The lock serves a purpose in addition to locking: the new\n \t * contents of .git/config will be written into it.\n \t */\n-\tfd = hold_lock_file_for_update(&lock, config_filename, 0);\n+\tfd = repo_hold_lock_file_for_update(r, &lock, config_filename, 0);\n \tif (fd < 0) {\n \t\terror_errno(_(\"could not lock config file %s\"), config_filename);\n \t\tret = CONFIG_NO_LOCK;\n@@ -3379,7 +3379,7 @@ static int repo_config_copy_or_rename_section_in_file(\n \tif (!config_filename)\n \t\tconfig_filename = filename_buf = repo_git_path(r, \"config\");\n \n-\tout_fd = hold_lock_file_for_update(&lock, config_filename, 0);\n+\tout_fd = repo_hold_lock_file_for_update(r, &lock, config_filename, 0);\n \tif (out_fd < 0) {\n \t\tret = error(_(\"could not lock config file %s\"), config_filename);\n \t\tgoto out;\ndiff --git a/loose.c b/loose.c\nindex 0b626c1b85..a79cafd38a 100644\n--- a/loose.c\n+++ b/loose.c\n@@ -138,7 +138,8 @@ int repo_write_loose_object_map(struct repository *repo)\n \t\treturn 0;\n \n \trepo_common_path_replace(repo, &path, \"objects/loose-object-idx\");\n-\tfd = hold_lock_file_for_update_timeout(&lock, path.buf, LOCK_DIE_ON_ERROR, -1);\n+\tfd = repo_hold_lock_file_for_update_timeout(repo, &lock, path.buf,\n+\t\t\t\t\t\t    LOCK_DIE_ON_ERROR, -1);\n \titer = kh_begin(map);\n \tif (write_in_full(fd, loose_object_header, strlen(loose_object_header)) < 0)\n \t\tgoto errout;\n@@ -180,7 +181,8 @@ static int write_one_object(struct odb_source_loose *loose,\n \tstruct strbuf buf = STRBUF_INIT, path = STRBUF_INIT;\n \n \tstrbuf_addf(&path, \"%s/loose-object-idx\", loose->base.path);\n-\thold_lock_file_for_update_timeout(&lock, path.buf, LOCK_DIE_ON_ERROR, -1);\n+\trepo_hold_lock_file_for_update_timeout(loose->base.odb->repo, &lock,\n+\t\t\t\t\t       path.buf, LOCK_DIE_ON_ERROR, -1);\n \n \tfd = open(path.buf, O_WRONLY | O_CREAT | O_APPEND, 0666);\n \tif (fd < 0)\ndiff --git a/midx-write.c b/midx-write.c\nindex 8c1837f6df..580724d21a 100644\n--- a/midx-write.c\n+++ b/midx-write.c\n@@ -1627,8 +1627,8 @@ static int write_midx_internal(struct write_midx_opts *opts)\n \t\t\tstruct strbuf lock_name = STRBUF_INIT;\n \n \t\t\tget_midx_chain_filename(opts->source, &lock_name);\n-\t\t\thold_lock_file_for_update(&lk, lock_name.buf,\n-\t\t\t\t\t\t  LOCK_DIE_ON_ERROR);\n+\t\t\trepo_hold_lock_file_for_update(r, &lk, lock_name.buf,\n+\t\t\t\t\t\t       LOCK_DIE_ON_ERROR);\n \t\t\tstrbuf_release(&lock_name);\n \t\t}\n \n@@ -1647,7 +1647,8 @@ static int write_midx_internal(struct write_midx_opts *opts)\n \t\tf = hashfd(r->hash_algo, get_tempfile_fd(incr),\n \t\t\t   get_tempfile_path(incr));\n \t} else {\n-\t\thold_lock_file_for_update(&lk, midx_name.buf, LOCK_DIE_ON_ERROR);\n+\t\trepo_hold_lock_file_for_update(r, &lk, midx_name.buf,\n+\t\t\t\t\t       LOCK_DIE_ON_ERROR);\n \t\tf = hashfd(r->hash_algo, get_lock_file_fd(&lk),\n \t\t\t   get_lock_file_path(&lk));\n \t}\ndiff --git a/odb/source-files.c b/odb/source-files.c\nindex 6c8e935c75..db83a9745c 100644\n--- a/odb/source-files.c\n+++ b/odb/source-files.c\n@@ -218,7 +218,8 @@ static int odb_source_files_write_alternate(struct odb_source *source,\n \tint found = 0;\n \tint ret;\n \n-\thold_lock_file_for_update(&lock, path, LOCK_DIE_ON_ERROR);\n+\trepo_hold_lock_file_for_update(source->odb->repo, &lock, path,\n+\t\t\t\t       LOCK_DIE_ON_ERROR);\n \tout = fdopen_lock_file(&lock, \"w\");\n \tif (!out) {\n \t\tret = error_errno(_(\"unable to fdopen alternates lockfile\"));\ndiff --git a/refs/files-backend.c b/refs/files-backend.c\nindex 3df56c25c8..1953610c03 100644\n--- a/refs/files-backend.c\n+++ b/refs/files-backend.c\n@@ -842,7 +842,7 @@ static enum ref_transaction_error lock_raw_ref(struct files_ref_store *refs,\n \t\tgoto error_return;\n \t}\n \n-\tif (hold_lock_file_for_update_timeout(\n+\tif (repo_hold_lock_file_for_update_timeout(refs->base.repo,\n \t\t\t    &lock->lk, ref_file.buf, LOCK_NO_DEREF,\n \t\t\t    get_files_ref_lock_timeout_ms(transaction->ref_store->repo)) < 0) {\n \t\tint myerr = errno;\n@@ -1250,8 +1250,8 @@ struct create_reflock_cb {\n static int create_reflock(const char *path, void *cb)\n {\n \tstruct create_reflock_cb *data = cb;\n-\treturn hold_lock_file_for_update_timeout(\n-\t\t\tdata->lk, path, LOCK_NO_DEREF,\n+\treturn repo_hold_lock_file_for_update_timeout(\n+\t\t\tdata->repo, data->lk, path, LOCK_NO_DEREF,\n \t\t\tget_files_ref_lock_timeout_ms(data->repo)) < 0 ? -1 : 0;\n }\n \n@@ -3581,7 +3581,9 @@ static int files_reflog_expire(struct ref_store *ref_store,\n \t\t * work we need, including cleaning up if the program\n \t\t * exits unexpectedly.\n \t\t */\n-\t\tif (hold_lock_file_for_update(&reflog_lock, log_file, 0) < 0) {\n+\t\tif (repo_hold_lock_file_for_update(ref_store->repo,\n+\t\t\t\t\t\t   &reflog_lock, log_file,\n+\t\t\t\t\t\t   0) < 0) {\n \t\t\tstruct strbuf err = STRBUF_INIT;\n \t\t\tunable_to_lock_message(log_file, errno, &err);\n \t\t\terror(\"%s\", err.buf);\ndiff --git a/refs/packed-backend.c b/refs/packed-backend.c\nindex 7e65d9580e..0cfef881be 100644\n--- a/refs/packed-backend.c\n+++ b/refs/packed-backend.c\n@@ -1246,10 +1246,9 @@ int packed_refs_lock(struct ref_store *ref_store, int flags, struct strbuf *err)\n \t * don't write new content to it, but rather to a separate\n \t * tempfile.\n \t */\n-\tif (hold_lock_file_for_update_timeout(\n-\t\t\t    &refs->lock,\n-\t\t\t    refs->path,\n-\t\t\t    flags, timeout_value) < 0) {\n+\tif (repo_hold_lock_file_for_update_timeout(ref_store->repo, &refs->lock,\n+\t\t\t\t\t\t   refs->path, flags,\n+\t\t\t\t\t\t   timeout_value) < 0) {\n \t\tunable_to_lock_message(refs->path, errno, err);\n \t\treturn -1;\n \t}\ndiff --git a/refs/packed-backend.h b/refs/packed-backend.h\nindex 1db48e801d..8a7b323825 100644\n--- a/refs/packed-backend.h\n+++ b/refs/packed-backend.h\n@@ -21,7 +21,7 @@ struct ref_store *packed_ref_store_init(struct repository *repo,\n \n /*\n  * Lock the packed-refs file for writing. Flags is passed to\n- * hold_lock_file_for_update(). Return 0 on success. On errors, write\n+ * repo_hold_lock_file_for_update(). Return 0 on success. On errors, write\n  * an error message to `err` and return a nonzero value.\n  */\n int packed_refs_lock(struct ref_store *ref_store, int flags, struct strbuf *err);\ndiff --git a/repack-midx.c b/repack-midx.c\nindex 7c7c3620e5..64c7f8d0f4 100644\n--- a/repack-midx.c\n+++ b/repack-midx.c\n@@ -954,7 +954,8 @@ static int write_midx_incremental(struct repack_write_midx_opts *opts)\n \t\t\t\t\t    lock_name.buf))\n \t\tdie_errno(_(\"unable to create leading directories of %s\"),\n \t\t\t  lock_name.buf);\n-\thold_lock_file_for_update(&lf, lock_name.buf, LOCK_DIE_ON_ERROR);\n+\trepo_hold_lock_file_for_update(opts->existing->repo, &lf, lock_name.buf,\n+\t\t\t\t       LOCK_DIE_ON_ERROR);\n \n \tif (!fdopen_lock_file(&lf, \"w\")) {\n \t\tret = error_errno(_(\"unable to open multi-pack-index chain file\"));\ndiff --git a/repository.c b/repository.c\nindex 73d80bcffd..11fbc69781 100644\n--- a/repository.c\n+++ b/repository.c\n@@ -472,5 +472,5 @@ int repo_hold_locked_index(struct repository *repo,\n {\n \tif (!repo->index_file)\n \t\tBUG(\"the repo hasn't been setup\");\n-\treturn hold_lock_file_for_update(lf, repo->index_file, flags);\n+\treturn repo_hold_lock_file_for_update(repo, lf, repo->index_file, flags);\n }\ndiff --git a/rerere.c b/rerere.c\nindex 8232542585..2d1e99ec11 100644\n--- a/rerere.c\n+++ b/rerere.c\n@@ -911,9 +911,9 @@ int setup_rerere(struct repository *r, struct string_list *merge_rr, int flags)\n \tif (flags & RERERE_READONLY)\n \t\tfd = 0;\n \telse\n-\t\tfd = hold_lock_file_for_update(&write_lock,\n-\t\t\t\t\t       git_path_merge_rr(r),\n-\t\t\t\t\t       LOCK_DIE_ON_ERROR);\n+\t\tfd = repo_hold_lock_file_for_update(r, &write_lock,\n+\t\t\t\t\t\t    git_path_merge_rr(r),\n+\t\t\t\t\t\t    LOCK_DIE_ON_ERROR);\n \tread_rr(r, merge_rr);\n \treturn fd;\n }\n-- \n2.55.0\n\n"},{"id":"548165","messageId":"xmqq8q7ds3ld.fsf@gitster.g","threadId":"65993","inReplyTo":"20260714175956.54601-1-l.s.r@web.de","subject":"Re: [PATCH 0/5] tempfile: stop using the_repository","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-07-14T20:45:02Z","receivedAt":"2026-07-14T20:45:07Z","isPatch":true,"body":"René Scharfe <l.s.r@web.de> writes:\n\n> create_tempfile_mode() and create_tempfile() use the_repository\n> internally to call adjust_shared_perm().  Expose that dependency and\n> push it out to their callers.\n>\n> Patch 5 is a bonus; it converts lockfile users that already work with\n> other repositories.\n>\n>   tempfile: add repo_create_tempfile{,_mode}()\n>   refs/packed: use repo_create_tempfile()\n>   lockfile: add repo_hold_lock_file_for_update{,_timeout}{,_mode}()\n>   tempfile: stop using the_repository\n>   use repo_hold_lock_file_for_update{,_mode,_timeout}() with custom repos\n\n\n\nWill queue.  If I have a chance I may revisit the topic a bit\ndeeper, but nothing stood out as glaringly wrong to my cursory\nreading so far.\n\nThanks.\n\n>\n>  apply.c                   | 10 ++++++----\n>  builtin/difftool.c        |  2 +-\n>  builtin/gc.c              |  2 +-\n>  builtin/history.c         |  2 +-\n>  builtin/sparse-checkout.c |  3 ++-\n>  bundle.c                  |  4 ++--\n>  commit-graph.c            |  9 +++++----\n>  config.c                  |  4 ++--\n>  lockfile.c                | 30 ++++++++++++++++++++++--------\n>  lockfile.h                | 31 +++++++++++++++++++++++++++++++\n>  loose.c                   |  6 ++++--\n>  midx-write.c              |  7 ++++---\n>  odb/source-files.c        |  3 ++-\n>  refs/files-backend.c      | 10 ++++++----\n>  refs/packed-backend.c     |  9 ++++-----\n>  refs/packed-backend.h     |  2 +-\n>  repack-midx.c             |  3 ++-\n>  repository.c              |  2 +-\n>  rerere.c                  |  6 +++---\n>  tempfile.c                |  7 +++----\n>  tempfile.h                | 10 +++++++---\n>  21 files changed, 110 insertions(+), 52 deletions(-)\n"},{"id":"548252","messageId":"aldYK5rWcU7auJeG@pks.im","threadId":"65993","inReplyTo":"20260714175956.54601-1-l.s.r@web.de","subject":"Re: [PATCH 0/5] tempfile: stop using the_repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-07-15T09:51:39Z","receivedAt":"2026-07-15T09:51:47Z","isPatch":true,"body":"On Tue, Jul 14, 2026 at 07:59:51PM +0200, René Scharfe wrote:\n> create_tempfile_mode() and create_tempfile() use the_repository\n> internally to call adjust_shared_perm().  Expose that dependency and\n> push it out to their callers.\n\nYay! I was just starting to have a look at this area yesterday because\nthe implicit dependency got in my way. Happy to see that you tackle it\n:)\n\nPatrick\n"},{"id":"548253","messageId":"aldYTuMvN-8EMvYK@pks.im","threadId":"65993","inReplyTo":"20260714175956.54601-2-l.s.r@web.de","subject":"Re: [PATCH 1/5] tempfile: add repo_create_tempfile{,_mode}()","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-07-15T09:52:14Z","receivedAt":"2026-07-15T09:52:20Z","isPatch":true,"body":"On Tue, Jul 14, 2026 at 07:59:52PM +0200, René Scharfe wrote:\n> Add variants of create_tempfile_mode() that handle arbitrary\n> repositories.\n\nOne thing I was wondering is whether it really makes sense to pass in a\nfull repository. All we require it for is `adjust_shared_perm()`, and it\nfeels quite extreme to require a full-blown repository.\n\nAn alternative would be to let callers pass in the setting by\nthemselves, but that would likely lead to lots of duplicated code. So\nmaybe this is a good first step, and we could eventually create another\nAPI where users can pass in the configuration instead of a repository if\nwe ever gain callers that don't have a repository available.\n\n> diff --git a/tempfile.c b/tempfile.c\n> index f0fdf58279..3132eb4371 100644\n> --- a/tempfile.c\n> +++ b/tempfile.c\n> @@ -135,6 +135,12 @@ static void deactivate_tempfile(struct tempfile *tempfile)\n>  \n>  /* Make sure errno contains a meaningful value on error */\n>  struct tempfile *create_tempfile_mode(const char *path, int mode)\n> +{\n> +\treturn repo_create_tempfile_mode(the_repository, path, mode);\n> +}\n\nNit: We could've easily created this as an inline function in\n\"tempfile.h\". But I expect that we'll get mostly rid of this function in\nsubssubsequent patches, so it probably doesn't matter too much.\n\nPatrick\n"},{"id":"548254","messageId":"aldYVPyMl40-Myp0@pks.im","threadId":"65993","inReplyTo":"20260714175956.54601-5-l.s.r@web.de","subject":"Re: [PATCH 4/5] tempfile: stop using the_repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-07-15T09:52:20Z","receivedAt":"2026-07-15T09:52:25Z","isPatch":true,"body":"On Tue, Jul 14, 2026 at 07:59:55PM +0200, René Scharfe wrote:\n> Remove the compatibility wrappers create_tempfile_mode() and\n> create_tempfile() that have become unused.\n\nAh, so we do get rid of it. Nice. We might tease in the preceding commit\nmessage that we'll get rid of it in a subsequent patch.\n\nPatrick\n"},{"id":"548258","messageId":"aldYW4TPUqgDMRcf@pks.im","threadId":"65993","inReplyTo":"20260714175956.54601-6-l.s.r@web.de","subject":"Re: [PATCH 5/5] use repo_hold_lock_file_for_update{,_mode,_timeout}() with custom repos","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-07-15T09:52:27Z","receivedAt":"2026-07-15T09:52:31Z","isPatch":true,"body":"On Tue, Jul 14, 2026 at 07:59:56PM +0200, René Scharfe wrote:\n> Apply the config setting core.sharedRepository from the repository at\n> hand instead of from the_repository.\n\nWe only do this for a subset of callsites, apparently. How did you\nselect which subsystems to convert and which not to? To make this\nexplicit: I don't mind a partial migration, but I think the commit\nmessage should briefly explain the reasoning behind it.\n\nAlso, as you don't get rid of the old functions that still implicitly\ndepend on `the_repository`, I think we should have an additional commit\non top that guards all functions that have this implicit dependency with\n`USE_THE_REPOSITORY_VARIABLE`. This ensures that we cannot accidentally\ncall such functions from other subsystems that already got rid of the\nglobal dependency.\n\nThanks!\n\nPatrick\n"},{"id":"548273","messageId":"a84437e9-6a7d-41b9-b638-30c81eecd672@web.de","threadId":"65993","inReplyTo":"aldYTuMvN-8EMvYK@pks.im","subject":"Re: [PATCH 1/5] tempfile: add repo_create_tempfile{,_mode}()","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-07-15T11:25:22Z","receivedAt":"2026-07-15T11:25:30Z","isPatch":true,"body":"On 7/15/26 11:52 AM, Patrick Steinhardt wrote:\n> On Tue, Jul 14, 2026 at 07:59:52PM +0200, René Scharfe wrote:\n>> Add variants of create_tempfile_mode() that handle arbitrary\n>> repositories.\n> \n> One thing I was wondering is whether it really makes sense to pass in a\n> full repository. All we require it for is `adjust_shared_perm()`, and it\n> feels quite extreme to require a full-blown repository.\n> \n> An alternative would be to let callers pass in the setting by\n> themselves, but that would likely lead to lots of duplicated code. So\n> maybe this is a good first step, and we could eventually create another\n> API where users can pass in the configuration instead of a repository if\n> we ever gain callers that don't have a repository available.\nHad the same thought.  I think it's because create_tempfile() sounds\nquite generic, but is actually for creating temporary files within a\nrepository, not just anywhere or just for the duration of the creating\nprocess, so shared access matters (if enabled).\n\nI didn't find a case where a caller would not have at least\nthe_repository to pass in, so while a repo-less adjust_shared_perm()\nor create_tempfile() might seem cleaner, we probably won't need it in\npractice.  We'll find out..\n\nRené\n\n"},{"id":"548567","messageId":"3c0a8031-7082-422a-b474-938418682b60@web.de","threadId":"65993","inReplyTo":"aldYW4TPUqgDMRcf@pks.im","subject":"Re: [PATCH 5/5] use repo_hold_lock_file_for_update{,_mode,_timeout}() with custom repos","fromName":"René Scharfe","fromEmail":"l.s.r@web.de","sentAt":"2026-07-18T06:35:37Z","receivedAt":"2026-07-18T06:35:45Z","isPatch":true,"body":"On 7/15/26 11:52 AM, Patrick Steinhardt wrote:\n> On Tue, Jul 14, 2026 at 07:59:56PM +0200, René Scharfe wrote:\n>> Apply the config setting core.sharedRepository from the repository at\n>> hand instead of from the_repository.\n> \n> We only do this for a subset of callsites, apparently. How did you\n> select which subsystems to convert and which not to? To make this\n> explicit: I don't mind a partial migration, but I think the commit\n> message should briefly explain the reasoning behind it.\n\nAll those that have a repository reference other than the_repository.\n\n> Also, as you don't get rid of the old functions that still implicitly\n> depend on `the_repository`, I think we should have an additional commit\n> on top that guards all functions that have this implicit dependency with\n> `USE_THE_REPOSITORY_VARIABLE`. This ensures that we cannot accidentally\n> call such functions from other subsystems that already got rid of the\n> global dependency.\nProbably, but the lockfile conversions deserve their own patch series.\nPatch 5 is only included here because it was easy to write.  We can drop\nit and leave the low-hanging fruit on the tree if that's preferable.\n\nRené\n\n\n"},{"id":"548629","messageId":"xmqqmrvmn6a5.fsf@gitster.g","threadId":"65993","inReplyTo":"3c0a8031-7082-422a-b474-938418682b60@web.de","subject":"Re: [PATCH 5/5] use repo_hold_lock_file_for_update{,_mode,_timeout}() with custom repos","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-07-19T19:11:46Z","receivedAt":"2026-07-19T19:11:49Z","isPatch":true,"body":"René Scharfe <l.s.r@web.de> writes:\n\n> On 7/15/26 11:52 AM, Patrick Steinhardt wrote:\n>> On Tue, Jul 14, 2026 at 07:59:56PM +0200, René Scharfe wrote:\n>>> Apply the config setting core.sharedRepository from the repository at\n>>> hand instead of from the_repository.\n>> \n>> We only do this for a subset of callsites, apparently. How did you\n>> select which subsystems to convert and which not to? To make this\n>> explicit: I don't mind a partial migration, but I think the commit\n>> message should briefly explain the reasoning behind it.\n>\n> All those that have a repository reference other than the_repository.\n>\n>> Also, as you don't get rid of the old functions that still implicitly\n>> depend on `the_repository`, I think we should have an additional commit\n>> on top that guards all functions that have this implicit dependency with\n>> `USE_THE_REPOSITORY_VARIABLE`. This ensures that we cannot accidentally\n>> call such functions from other subsystems that already got rid of the\n>> global dependency.\n>\n> Probably, but the lockfile conversions deserve their own patch series.\n> Patch 5 is only included here because it was easy to write.  We can drop\n> it and leave the low-hanging fruit on the tree if that's preferable.\n\nI am personally indifferent as to what we do immediately in this\nseries, as long as we all agree on the longer-term direction.  It\nseems we are in agreement on providing additional safety in the\nmedium term?\n\nThanks.\n"},{"id":"548746","messageId":"al_spOloKmeCp0oe@pks.im","threadId":"65993","inReplyTo":"xmqqmrvmn6a5.fsf@gitster.g","subject":"Re: [PATCH 5/5] use repo_hold_lock_file_for_update{,_mode,_timeout}() with custom repos","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-07-21T22:03:16Z","receivedAt":"2026-07-21T22:03:26Z","isPatch":true,"body":"On Sun, Jul 19, 2026 at 12:11:46PM -0700, Junio C Hamano wrote:\n> René Scharfe <l.s.r@web.de> writes:\n> \n> > On 7/15/26 11:52 AM, Patrick Steinhardt wrote:\n> >> On Tue, Jul 14, 2026 at 07:59:56PM +0200, René Scharfe wrote:\n> >>> Apply the config setting core.sharedRepository from the repository at\n> >>> hand instead of from the_repository.\n> >> \n> >> We only do this for a subset of callsites, apparently. How did you\n> >> select which subsystems to convert and which not to? To make this\n> >> explicit: I don't mind a partial migration, but I think the commit\n> >> message should briefly explain the reasoning behind it.\n> >\n> > All those that have a repository reference other than the_repository.\n> >\n> >> Also, as you don't get rid of the old functions that still implicitly\n> >> depend on `the_repository`, I think we should have an additional commit\n> >> on top that guards all functions that have this implicit dependency with\n> >> `USE_THE_REPOSITORY_VARIABLE`. This ensures that we cannot accidentally\n> >> call such functions from other subsystems that already got rid of the\n> >> global dependency.\n> >\n> > Probably, but the lockfile conversions deserve their own patch series.\n> > Patch 5 is only included here because it was easy to write.  We can drop\n> > it and leave the low-hanging fruit on the tree if that's preferable.\n> \n> I am personally indifferent as to what we do immediately in this\n> series, as long as we all agree on the longer-term direction.  It\n> seems we are in agreement on providing additional safety in the\n> medium term?\n\nIt would be an easy thing to guard existing interfaces that depend on\n`the_repository` behind `USE_THE_REPOSITORY_VARIABLE`. But the patch\nseries is already a strict improvement over the status quo, so I don't\nmind if we merge it as-is and defer that to a later point.\n\nThanks!\n\nPatrick\n"}]}