[PATCH v5 0/3] refs: reduce reliance on global state
- From
Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
- Date
- Apr 4, 2026, 13:58 UTC
- Message-ID
- <20260404135914.61195-1-shreyanshpaliwalcmsmn@gmail.com>
- In-Reply-To
- <20260403120938.1142533-1-shreyanshpaliwalcmsmn@gmail.com>
This series continues the effort to reduce reliance on the_repository global state by making repository context explicit across the refs subsystem. The patches focus on passing struct repository through various ref helpers and backends, and replacing uses of global state such as the_repository and the_hash_algo with the appropriate repository instance.
Patch 1/3: Updating get_files_ref_lock_timeout_ms() to take a repository and propagating it through files-backend, including callback paths.
Patch 2/3:Replacing uses of the_hash_algo in refs.c with the hash algorithm from the appropriate repository.
Patch 3/3:Removing remaining uses of the_repository in reftable-backend.c where a repository instance is already available.
Shreyansh Paliwal (3):
refs: add struct repository parameter in
get_files_ref_lock_timeout_ms()
refs: remove the_hash_algo global state
refs/reftable-backend: drop uses of the_repositoryrefs.c | 17 +++++++++-------- refs/files-backend.c | 19 +++++++++++++------ refs/refs-internal.h | 2 +- refs/reftable-backend.c | 6 +++--- 4 files changed, 26 insertions(+), 18 deletions(-)
--- Changes in v5: - made the commit message of patch 1/3 more explicit.
Changes in v4: - Dropped patches 1/5 and 5/5, as they require further refactoring and discussion. I will send them separately as a follow-up.
Changes in v3: - Fixed an import - better readability in patch 3/5
Changes in v2: - Made struct repository the first argument in function parameters.
Range-diff against v4:
1: 11c134b3f5 ! 1: 59c4662031 refs: add struct repository parameter in get_files_ref_lock_timeout_ms()
@@ Commit message
is used as a callback, introduce a small wrapper struct to pass both struct
lock_file and struct repository through the callback data. - This reduces reliance on the_repository global.
+ This reduces reliance on the_repository global, though the function
+ still uses static variables and is not yet fully repository-scoped.
+ This can be addressed in a follow-up change.Signed-off-by: Shreyansh Paliwal <shreyanshpaliwalcmsmn@gmail.com>
2: d144e879ad = 2: 9dd20df759 refs: remove the_hash_algo global state 3: 76c14eb320 = 3: 04c88f7ed4 refs/reftable-backend: drop uses of the_repository -- 2.53.0