From: Okhuomon Ajayi Date: Tue, 03 Nov 2026 08:49:30 GMT Subject: [Outreachy PATCH v2 2/2] notes-utils: pass the repository to init_copy_notes_for_rewrite() Message-ID: <20261103084930.15532-3-okhuomonajayi54@gmail.com> In-Reply-To: <20261103084930.15532-1-okhuomonajayi54@gmail.com> init_copy_notes_for_rewrite() reads the notes.rewrite* config from the_repository, as it is not given a repository. This is the last use of the_repository in notes-utils.c. Add a repository parameter to it. commit_post_rewrite() in sequencer.c already has one and passes it on. The callers in builtin/am.c and builtin/notes.c still use the_repository, so pass that for now. Drop USE_THE_REPOSITORY_VARIABLE, as notes-utils.c no longer uses the_repository. Signed-off-by: Okhuomon Ajayi --- builtin/am.c | 2 +- builtin/notes.c | 2 +- notes-utils.c | 7 +++---- notes-utils.h | 3 ++- sequencer.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/builtin/am.c b/builtin/am.c index e9623b8307..daa4b601b6 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -536,7 +536,7 @@ static int copy_notes_for_rebase(const struct am_state *state) assert(state->rebasing); - c = init_copy_notes_for_rewrite("rebase"); + c = init_copy_notes_for_rewrite(the_repository, "rebase"); if (!c) return 0; diff --git a/builtin/notes.c b/builtin/notes.c index 9f1f0ec840..20f7bb8377 100644 --- a/builtin/notes.c +++ b/builtin/notes.c @@ -366,7 +366,7 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd) const char *msg = "Notes added by 'git notes copy'"; if (rewrite_cmd) { - c = init_copy_notes_for_rewrite(rewrite_cmd); + c = init_copy_notes_for_rewrite(the_repository, rewrite_cmd); if (!c) return 0; } else { diff --git a/notes-utils.c b/notes-utils.c index d4606bc576..3a3b84f79c 100644 --- a/notes-utils.c +++ b/notes-utils.c @@ -1,5 +1,3 @@ -#define USE_THE_REPOSITORY_VARIABLE - #include "git-compat-util.h" #include "config.h" #include "commit.h" @@ -134,7 +132,8 @@ static int notes_rewrite_config(const char *k, const char *v, } -struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd) +struct notes_rewrite_cfg *init_copy_notes_for_rewrite(struct repository *r, + const char *cmd) { struct notes_rewrite_cfg *c = xmalloc(sizeof(struct notes_rewrite_cfg)); const char *rewrite_mode_env = getenv(GIT_NOTES_REWRITE_MODE_ENVIRONMENT); @@ -162,7 +161,7 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd) c->refs_from_env = 1; string_list_add_refs_from_colon_sep(c->refs, rewrite_refs_env); } - repo_config(the_repository, notes_rewrite_config, c); + repo_config(r, notes_rewrite_config, c); if (!c->enabled || !c->refs->nr) { string_list_clear(c->refs, 0); free(c->refs); diff --git a/notes-utils.h b/notes-utils.h index c54b1fe141..ef3c0f6732 100644 --- a/notes-utils.h +++ b/notes-utils.h @@ -45,7 +45,8 @@ struct notes_rewrite_cfg { }; int parse_notes_merge_strategy(const char *v, enum notes_merge_strategy *s); -struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd); +struct notes_rewrite_cfg *init_copy_notes_for_rewrite(struct repository *r, + const char *cmd); int copy_note_for_rewrite(struct notes_rewrite_cfg *c, const struct object_id *from_obj, const struct object_id *to_obj); void finish_copy_notes_for_rewrite(struct repository *r, diff --git a/sequencer.c b/sequencer.c index 508ec71792..a40243c56b 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1366,7 +1366,7 @@ void commit_post_rewrite(struct repository *r, { struct notes_rewrite_cfg *cfg; - cfg = init_copy_notes_for_rewrite("amend"); + cfg = init_copy_notes_for_rewrite(r, "amend"); if (cfg) { /* we are amending, so old_head is not NULL */ copy_note_for_rewrite(cfg, &old_head->object.oid, new_head); -- 2.56.0