{"thread":{"id":"66727","subject":"[Outreachy PATCH] fsmonitor: stop using the_repository","startedAt":"2026-10-31T11:14:50Z","lastAt":"2026-10-31T11:14:50Z","messageCount":1,"participants":["Okhuomon Ajayi"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"557015","messageId":"20261031111450.66192-1-okhuomonajayi54@gmail.com","threadId":"66727","inReplyTo":null,"subject":"[Outreachy PATCH] fsmonitor: stop using the_repository","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-31T11:14:50Z","receivedAt":"2026-10-31T11:14:50Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"refresh_fsmonitor() gets its repository from the index, but the\nhelpers it calls still use the_repository: fsmonitor_hook_version()\nreads core.fsmonitorHookVersion, query_fsmonitor_hook() runs the\nhook in the work tree, and fsmonitor_refresh_callback() checks\ncore.ignoreCase.\n\nPass the repository to fsmonitor_hook_version(), whose only caller\nis refresh_fsmonitor(). query_fsmonitor_hook() already receives one,\nand fsmonitor_refresh_callback() can use istate->repo.\n\nDrop USE_THE_REPOSITORY_VARIABLE, as the file no longer uses\nthe_repository.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n fsmonitor.c | 11 +++++------\n 1 file changed, 5 insertions(+), 6 deletions(-)\n\ndiff --git a/fsmonitor.c b/fsmonitor.c\nindex 107767527e..ed3d36d3fe 100644\n--- a/fsmonitor.c\n+++ b/fsmonitor.c\n@@ -1,4 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n #define DISABLE_SIGN_COMPARE_WARNINGS\n \n #include \"git-compat-util.h\"\n@@ -39,11 +38,11 @@ static void fsmonitor_ewah_callback(size_t pos, void *is)\n \tce->ce_flags &= ~CE_FSMONITOR_VALID;\n }\n \n-static int fsmonitor_hook_version(void)\n+static int fsmonitor_hook_version(struct repository *r)\n {\n \tint hook_version;\n \n-\tif (repo_config_get_int(the_repository, \"core.fsmonitorhookversion\", &hook_version))\n+\tif (repo_config_get_int(r, \"core.fsmonitorhookversion\", &hook_version))\n \t\treturn -1;\n \n \tif (hook_version == HOOK_INTERFACE_VERSION1 ||\n@@ -171,7 +170,7 @@ static int query_fsmonitor_hook(struct repository *r,\n \tstrvec_pushf(&cp.args, \"%d\", version);\n \tstrvec_pushf(&cp.args, \"%s\", last_update);\n \tcp.use_shell = 1;\n-\tcp.dir = repo_get_work_tree(the_repository);\n+\tcp.dir = repo_get_work_tree(r);\n \n \ttrace2_region_enter(\"fsm_hook\", \"query\", NULL);\n \n@@ -453,7 +452,7 @@ static void fsmonitor_refresh_callback(struct index_state *istate, char *name)\n \t * case-insensitive file system, try again using the name-hash\n \t * and dir-name-hash.\n \t */\n-\tif (!nr_in_cone && repo_ignore_case(the_repository)) {\n+\tif (!nr_in_cone && repo_ignore_case(istate->repo)) {\n \t\tnr_in_cone = handle_using_name_hash_icase(istate, name);\n \t\tif (!nr_in_cone)\n \t\t\tnr_in_cone = handle_using_dir_name_hash_icase(\n@@ -573,7 +572,7 @@ void refresh_fsmonitor(struct index_state *istate)\n \n \tassert(fsm_mode == FSMONITOR_MODE_HOOK);\n \n-\thook_version = fsmonitor_hook_version();\n+\thook_version = fsmonitor_hook_version(r);\n \n \t/*\n \t * This could be racy so save the date/time now and query_fsmonitor_hook\n\nbase-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n-- \n2.56.0\n\n\n"}]}