# [Outreachy PATCH] fsmonitor: stop using the_repository

1 messages from 2026-10-31 to 2026-10-31. Participants: Okhuomon Ajayi.
Thread: https://gitlist.dev/t/66727

## Okhuomon Ajayi, 2026-10-31 11:14

Subject: [Outreachy PATCH] fsmonitor: stop using the_repository
Message-ID: <20261031111450.66192-1-okhuomonajayi54@gmail.com>
URL: https://gitlist.dev/e/20261031111450.66192-1-okhuomonajayi54%40gmail.com

```
refresh_fsmonitor() gets its repository from the index, but the
helpers it calls still use the_repository: fsmonitor_hook_version()
reads core.fsmonitorHookVersion, query_fsmonitor_hook() runs the
hook in the work tree, and fsmonitor_refresh_callback() checks
core.ignoreCase.

Pass the repository to fsmonitor_hook_version(), whose only caller
is refresh_fsmonitor(). query_fsmonitor_hook() already receives one,
and fsmonitor_refresh_callback() can use istate->repo.

Drop USE_THE_REPOSITORY_VARIABLE, as the file no longer uses
the_repository.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
 fsmonitor.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/fsmonitor.c b/fsmonitor.c
index 107767527e..ed3d36d3fe 100644
--- a/fsmonitor.c
+++ b/fsmonitor.c
@@ -1,4 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
@@ -39,11 +38,11 @@ static void fsmonitor_ewah_callback(size_t pos, void *is)
 	ce->ce_flags &= ~CE_FSMONITOR_VALID;
 }
 
-static int fsmonitor_hook_version(void)
+static int fsmonitor_hook_version(struct repository *r)
 {
 	int hook_version;
 
-	if (repo_config_get_int(the_repository, "core.fsmonitorhookversion", &hook_version))
+	if (repo_config_get_int(r, "core.fsmonitorhookversion", &hook_version))
 		return -1;
 
 	if (hook_version == HOOK_INTERFACE_VERSION1 ||
@@ -171,7 +170,7 @@ static int query_fsmonitor_hook(struct repository *r,
 	strvec_pushf(&cp.args, "%d", version);
 	strvec_pushf(&cp.args, "%s", last_update);
 	cp.use_shell = 1;
-	cp.dir = repo_get_work_tree(the_repository);
+	cp.dir = repo_get_work_tree(r);
 
 	trace2_region_enter("fsm_hook", "query", NULL);
 
@@ -453,7 +452,7 @@ static void fsmonitor_refresh_callback(struct index_state *istate, char *name)
 	 * case-insensitive file system, try again using the name-hash
 	 * and dir-name-hash.
 	 */
-	if (!nr_in_cone && repo_ignore_case(the_repository)) {
+	if (!nr_in_cone && repo_ignore_case(istate->repo)) {
 		nr_in_cone = handle_using_name_hash_icase(istate, name);
 		if (!nr_in_cone)
 			nr_in_cone = handle_using_dir_name_hash_icase(
@@ -573,7 +572,7 @@ void refresh_fsmonitor(struct index_state *istate)
 
 	assert(fsm_mode == FSMONITOR_MODE_HOOK);
 
-	hook_version = fsmonitor_hook_version();
+	hook_version = fsmonitor_hook_version(r);
 
 	/*
 	 * This could be racy so save the date/time now and query_fsmonitor_hook

base-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7
-- 
2.56.0



```
