{"thread":{"id":"66725","subject":"[Outreachy PATCH] notes-utils: use the passed repository for notes refs","startedAt":"2026-10-31T10:45:26Z","lastAt":"2026-11-03T18:01:44Z","messageCount":10,"participants":["Okhuomon Ajayi","Patrick Steinhardt","Karthik Nayak","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"557009","messageId":"20261031104526.46711-1-okhuomonajayi54@gmail.com","threadId":"66725","inReplyTo":null,"subject":"[Outreachy PATCH] notes-utils: use the passed repository for notes refs","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-10-31T10:45:26Z","receivedAt":"2026-10-31T10:45:26Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"create_notes_commit() and commit_notes() receive a repository,\nbut read and update the notes ref in the_repository.\n\nUse the repository they are given.\n\nKeep USE_THE_REPOSITORY_VARIABLE because\ninit_copy_notes_for_rewrite() still uses the_repository.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n notes-utils.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 5c1c75d5b8..d4606bc576 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -26,7 +26,7 @@ void create_notes_commit(struct repository *r,\n \tif (!parents) {\n \t\t/* Deduce parent commit from t->ref */\n \t\tstruct object_id parent_oid;\n-\t\tif (!refs_read_ref(get_main_ref_store(the_repository), t->ref, &parent_oid)) {\n+\t\tif (!refs_read_ref(get_main_ref_store(r), t->ref, &parent_oid)) {\n \t\t\tstruct commit *parent = lookup_commit(r, &parent_oid);\n \t\t\tif (repo_parse_commit(r, parent))\n \t\t\t\tdie(\"Failed to find/parse commit %s\", t->ref);\n@@ -61,7 +61,7 @@ void commit_notes(struct repository *r, struct notes_tree *t, const char *msg)\n \n \tcreate_notes_commit(r, t, NULL, buf.buf, buf.len, &commit_oid);\n \tstrbuf_insertstr(&buf, 0, \"notes: \");\n-\trefs_update_ref(get_main_ref_store(the_repository), buf.buf,\n+\trefs_update_ref(get_main_ref_store(r), buf.buf,\n \t\t\tt->update_ref, &commit_oid, NULL, 0,\n \t\t\tUPDATE_REFS_DIE_ON_ERR);\n \n\nbase-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n-- \n2.56.0\n\n\n"},{"id":"557144","messageId":"auhtiZ86trLamccS@pks.im","threadId":"66725","inReplyTo":"20261031104526.46711-1-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH] notes-utils: use the passed repository for notes refs","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-02T11:01:38Z","receivedAt":"2026-11-02T11:01:38Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Sat, Oct 31, 2026 at 11:45:26AM +0100, Okhuomon Ajayi wrote:\n> create_notes_commit() and commit_notes() receive a repository,\n> but read and update the notes ref in the_repository.\n> \n> Use the repository they are given.\n> \n> Keep USE_THE_REPOSITORY_VARIABLE because\n> init_copy_notes_for_rewrite() still uses the_repository.\n\nI don't quite understand patches like this. They are _so_ close to\ngetting rid of `USE_THE_REPOSITORY_VARIABLE`, but then they just skip on\nthe final change that would make them work. I've already asked about\nthis on one of your preceding patches.\n\nAlso, could you maybe reduce the frequency a bit with which you send new\ntopics? There's a ton of in-flight patch series by you in this vicinity,\nand it gets a bit overwhelming. May I ask you to maybe batch related\npatches into bigger series (maybe 5-10 commits) so that the reviewer can\nfocus on way fewer patch series overall, and then have less series in\nflight at the same point in time?\n\nThanks!\n\nPatrick\n\n"},{"id":"557148","messageId":"CAFpMFfCkMNvFWOUsDJgRkhadd=jZX=ByavgsiYiCCuAsxiFNFA@mail.gmail.com","threadId":"66725","inReplyTo":"auhtiZ86trLamccS@pks.im","subject":"Re: [Outreachy PATCH] notes-utils: use the passed repository for notes refs","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-11-02T11:10:37Z","receivedAt":"2026-11-02T11:10:37Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"On Mon, Nov 2, 2026 at 12:01 PM Patrick Steinhardt <ps@pks.im> wrote:\n> I don't quite understand patches like this. They are _so_ close to\n> getting rid of `USE_THE_REPOSITORY_VARIABLE`, but then they just skip on\n> the final change that would make them work. I've already asked about\n> this on one of your preceding patches.\n\nThanks, Patrick. You're right, I should have gone the full way here\nafter your comment on bundle-uri.\n\nI'll send a v2 that also passes the repository to\ninit_copy_notes_for_rewrite() and updates its callers, so that\nnotes-utils.c can drop USE_THE_REPOSITORY_VARIABLE.\n\n> Also, could you maybe reduce the frequency a bit with which you send new\n> topics? There's a ton of in-flight patch series by you in this vicinity,\n> and it gets a bit overwhelming. May I ask you to maybe batch related\n> patches into bigger series (maybe 5-10 commits) so that the reviewer can\n> focus on way fewer patch series overall, and then have less series in\n> flight at the same point in time?\n\nSorry about that. I'll stop sending new topics for now, and batch\nrelated conversions into one series from now on.\n\nThanks,\nOkhuomon\n\nOn Mon, Nov 2, 2026 at 12:01 PM Patrick Steinhardt <ps@pks.im> wrote:\n>\n> On Sat, Oct 31, 2026 at 11:45:26AM +0100, Okhuomon Ajayi wrote:\n> > create_notes_commit() and commit_notes() receive a repository,\n> > but read and update the notes ref in the_repository.\n> >\n> > Use the repository they are given.\n> >\n> > Keep USE_THE_REPOSITORY_VARIABLE because\n> > init_copy_notes_for_rewrite() still uses the_repository.\n>\n> I don't quite understand patches like this. They are _so_ close to\n> getting rid of `USE_THE_REPOSITORY_VARIABLE`, but then they just skip on\n> the final change that would make them work. I've already asked about\n> this on one of your preceding patches.\n>\n> Also, could you maybe reduce the frequency a bit with which you send new\n> topics? There's a ton of in-flight patch series by you in this vicinity,\n> and it gets a bit overwhelming. May I ask you to maybe batch related\n> patches into bigger series (maybe 5-10 commits) so that the reviewer can\n> focus on way fewer patch series overall, and then have less series in\n> flight at the same point in time?\n>\n> Thanks!\n>\n> Patrick\n\n"},{"id":"557277","messageId":"20261103084930.15532-1-okhuomonajayi54@gmail.com","threadId":"66725","inReplyTo":"20261031104526.46711-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v2 0/2] notes-utils: stop using the_repository","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-11-03T08:49:28Z","receivedAt":"2026-11-03T08:49:28Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"This series removes the_repository from notes-utils.c.\n\nChanges since v1:\n- Add patch 2, which passes a repository to\n  init_copy_notes_for_rewrite() and drops USE_THE_REPOSITORY_VARIABLE\n  from notes-utils.c, as Patrick suggested. v1 stopped one step short\n  of that.\n\nThe callers in builtin/am.c and builtin/notes.c pass the_repository,\nas those files still use it everywhere. copy() in builtin/notes.c\ndoes receive a repo that could be passed down instead, if that is\npreferred.\n\nThanks, Patrick, for the review.\n\nOkhuomon Ajayi (2):\n  notes-utils: use the passed repository for notes refs\n  notes-utils: pass the repository to init_copy_notes_for_rewrite()\n\n builtin/am.c    |  2 +-\n builtin/notes.c |  2 +-\n notes-utils.c   | 11 +++++------\n notes-utils.h   |  3 ++-\n sequencer.c     |  2 +-\n 5 files changed, 10 insertions(+), 10 deletions(-)\n\n\nbase-commit: 50fe5cc63f9cd6e89b87a2c9ccf96a444f4cfdb7\n-- \n2.56.0\n\n\n"},{"id":"557278","messageId":"20261103084930.15532-2-okhuomonajayi54@gmail.com","threadId":"66725","inReplyTo":"20261103084930.15532-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v2 1/2] notes-utils: use the passed repository for notes refs","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-11-03T08:49:29Z","receivedAt":"2026-11-03T08:49:29Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"create_notes_commit() and commit_notes() receive a repository,\nbut read and update the notes ref in the_repository.\n\nUse the repository they are given.\n\nKeep USE_THE_REPOSITORY_VARIABLE because\ninit_copy_notes_for_rewrite() still uses the_repository.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n notes-utils.c | 4 ++--\n 1 file changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/notes-utils.c b/notes-utils.c\nindex 5c1c75d5b8..d4606bc576 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -26,7 +26,7 @@ void create_notes_commit(struct repository *r,\n \tif (!parents) {\n \t\t/* Deduce parent commit from t->ref */\n \t\tstruct object_id parent_oid;\n-\t\tif (!refs_read_ref(get_main_ref_store(the_repository), t->ref, &parent_oid)) {\n+\t\tif (!refs_read_ref(get_main_ref_store(r), t->ref, &parent_oid)) {\n \t\t\tstruct commit *parent = lookup_commit(r, &parent_oid);\n \t\t\tif (repo_parse_commit(r, parent))\n \t\t\t\tdie(\"Failed to find/parse commit %s\", t->ref);\n@@ -61,7 +61,7 @@ void commit_notes(struct repository *r, struct notes_tree *t, const char *msg)\n \n \tcreate_notes_commit(r, t, NULL, buf.buf, buf.len, &commit_oid);\n \tstrbuf_insertstr(&buf, 0, \"notes: \");\n-\trefs_update_ref(get_main_ref_store(the_repository), buf.buf,\n+\trefs_update_ref(get_main_ref_store(r), buf.buf,\n \t\t\tt->update_ref, &commit_oid, NULL, 0,\n \t\t\tUPDATE_REFS_DIE_ON_ERR);\n \n-- \n2.56.0\n\n\n"},{"id":"557279","messageId":"20261103084930.15532-3-okhuomonajayi54@gmail.com","threadId":"66725","inReplyTo":"20261103084930.15532-1-okhuomonajayi54@gmail.com","subject":"[Outreachy PATCH v2 2/2] notes-utils: pass the repository to init_copy_notes_for_rewrite()","fromName":"Okhuomon Ajayi","fromEmail":"okhuomonajayi54@gmail.com","sentAt":"2026-11-03T08:49:30Z","receivedAt":"2026-11-03T08:49:30Z","isPatch":true,"sender":{"key":"okhuomonajayi54@gmail.com","avatar":null},"body":"init_copy_notes_for_rewrite() reads the notes.rewrite* config from\nthe_repository, as it is not given a repository. This is the last\nuse of the_repository in notes-utils.c.\n\nAdd a repository parameter to it. commit_post_rewrite() in sequencer.c\nalready has one and passes it on. The callers in builtin/am.c and\nbuiltin/notes.c still use the_repository, so pass that for now.\n\nDrop USE_THE_REPOSITORY_VARIABLE, as notes-utils.c no longer uses\nthe_repository.\n\nSigned-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n---\n builtin/am.c    | 2 +-\n builtin/notes.c | 2 +-\n notes-utils.c   | 7 +++----\n notes-utils.h   | 3 ++-\n sequencer.c     | 2 +-\n 5 files changed, 8 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/am.c b/builtin/am.c\nindex e9623b8307..daa4b601b6 100644\n--- a/builtin/am.c\n+++ b/builtin/am.c\n@@ -536,7 +536,7 @@ static int copy_notes_for_rebase(const struct am_state *state)\n \n \tassert(state->rebasing);\n \n-\tc = init_copy_notes_for_rewrite(\"rebase\");\n+\tc = init_copy_notes_for_rewrite(the_repository, \"rebase\");\n \tif (!c)\n \t\treturn 0;\n \ndiff --git a/builtin/notes.c b/builtin/notes.c\nindex 9f1f0ec840..20f7bb8377 100644\n--- a/builtin/notes.c\n+++ b/builtin/notes.c\n@@ -366,7 +366,7 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)\n \tconst char *msg = \"Notes added by 'git notes copy'\";\n \n \tif (rewrite_cmd) {\n-\t\tc = init_copy_notes_for_rewrite(rewrite_cmd);\n+\t\tc = init_copy_notes_for_rewrite(the_repository, rewrite_cmd);\n \t\tif (!c)\n \t\t\treturn 0;\n \t} else {\ndiff --git a/notes-utils.c b/notes-utils.c\nindex d4606bc576..3a3b84f79c 100644\n--- a/notes-utils.c\n+++ b/notes-utils.c\n@@ -1,5 +1,3 @@\n-#define USE_THE_REPOSITORY_VARIABLE\n-\n #include \"git-compat-util.h\"\n #include \"config.h\"\n #include \"commit.h\"\n@@ -134,7 +132,8 @@ static int notes_rewrite_config(const char *k, const char *v,\n }\n \n \n-struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)\n+struct notes_rewrite_cfg *init_copy_notes_for_rewrite(struct repository *r,\n+\t\t\t\t\t\t      const char *cmd)\n {\n \tstruct notes_rewrite_cfg *c = xmalloc(sizeof(struct notes_rewrite_cfg));\n \tconst char *rewrite_mode_env = getenv(GIT_NOTES_REWRITE_MODE_ENVIRONMENT);\n@@ -162,7 +161,7 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)\n \t\tc->refs_from_env = 1;\n \t\tstring_list_add_refs_from_colon_sep(c->refs, rewrite_refs_env);\n \t}\n-\trepo_config(the_repository, notes_rewrite_config, c);\n+\trepo_config(r, notes_rewrite_config, c);\n \tif (!c->enabled || !c->refs->nr) {\n \t\tstring_list_clear(c->refs, 0);\n \t\tfree(c->refs);\ndiff --git a/notes-utils.h b/notes-utils.h\nindex c54b1fe141..ef3c0f6732 100644\n--- a/notes-utils.h\n+++ b/notes-utils.h\n@@ -45,7 +45,8 @@ struct notes_rewrite_cfg {\n };\n \n int parse_notes_merge_strategy(const char *v, enum notes_merge_strategy *s);\n-struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd);\n+struct notes_rewrite_cfg *init_copy_notes_for_rewrite(struct repository *r,\n+\t\t\t\t\t\t      const char *cmd);\n int copy_note_for_rewrite(struct notes_rewrite_cfg *c,\n \t\t\t  const struct object_id *from_obj, const struct object_id *to_obj);\n void finish_copy_notes_for_rewrite(struct repository *r,\ndiff --git a/sequencer.c b/sequencer.c\nindex 508ec71792..a40243c56b 100644\n--- a/sequencer.c\n+++ b/sequencer.c\n@@ -1366,7 +1366,7 @@ void commit_post_rewrite(struct repository *r,\n {\n \tstruct notes_rewrite_cfg *cfg;\n \n-\tcfg = init_copy_notes_for_rewrite(\"amend\");\n+\tcfg = init_copy_notes_for_rewrite(r, \"amend\");\n \tif (cfg) {\n \t\t/* we are amending, so old_head is not NULL */\n \t\tcopy_note_for_rewrite(cfg, &old_head->object.oid, new_head);\n-- \n2.56.0\n\n\n"},{"id":"557281","messageId":"CAOLa=ZSPHDWAUmqUev9PRdEB03cUW=NWrbXHjRyma6yUmV7Yng@mail.gmail.com","threadId":"66725","inReplyTo":"20261103084930.15532-2-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH v2 1/2] notes-utils: use the passed repository for notes refs","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-11-03T09:45:18Z","receivedAt":"2026-11-03T09:45:18Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:\n\n> create_notes_commit() and commit_notes() receive a repository,\n> but read and update the notes ref in the_repository.\n>\n> Use the repository they are given.\n>\n\nNit: It would also be nice to talk about why this is the same repository\nand if its safe to do this swap.\n\nSometimes it's also useful to look at the history and argue about why it\nis the way it is.\n\nFor this file, all `the_repository` usages were removed first in\n1d18d7581c (notes-utils.c: remove the_repository references,\n2019-01-12), then it was added back in 2e5c4758b7 (cocci: apply rules to\nrewrite callers of \"refs\" interfaces, 2024-05-07). So seems like the\nlatter was an automated addition of `the_repository`.\n\n> Keep USE_THE_REPOSITORY_VARIABLE because\n> init_copy_notes_for_rewrite() still uses the_repository.\n>\n> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>\n> ---\n>  notes-utils.c | 4 ++--\n>  1 file changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/notes-utils.c b/notes-utils.c\n> index 5c1c75d5b8..d4606bc576 100644\n> --- a/notes-utils.c\n> +++ b/notes-utils.c\n> @@ -26,7 +26,7 @@ void create_notes_commit(struct repository *r,\n>  \tif (!parents) {\n>  \t\t/* Deduce parent commit from t->ref */\n>  \t\tstruct object_id parent_oid;\n> -\t\tif (!refs_read_ref(get_main_ref_store(the_repository), t->ref, &parent_oid)) {\n> +\t\tif (!refs_read_ref(get_main_ref_store(r), t->ref, &parent_oid)) {\n\nHere, the repository we read the reference from and the commit from\nshould be the same. So r == the_repository.\n\n>  \t\t\tstruct commit *parent = lookup_commit(r, &parent_oid);\n>  \t\t\tif (repo_parse_commit(r, parent))\n>  \t\t\t\tdie(\"Failed to find/parse commit %s\", t->ref);\n> @@ -61,7 +61,7 @@ void commit_notes(struct repository *r, struct notes_tree *t, const char *msg)\n>\n>  \tcreate_notes_commit(r, t, NULL, buf.buf, buf.len, &commit_oid);\n>  \tstrbuf_insertstr(&buf, 0, \"notes: \");\n> -\trefs_update_ref(get_main_ref_store(the_repository), buf.buf,\n> +\trefs_update_ref(get_main_ref_store(r), buf.buf,\n>  \t\t\tt->update_ref, &commit_oid, NULL, 0,\n>  \t\t\tUPDATE_REFS_DIE_ON_ERR);\n>\n\nSimilar here.\n\n> --\n> 2.56.0\n\nThe patch looks good.\n"},{"id":"557282","messageId":"CAOLa=ZTAEVcKj-Y5QCGsAFAMUSh665E1fmQrEnuuufTLLbn3Wg@mail.gmail.com","threadId":"66725","inReplyTo":"20261103084930.15532-1-okhuomonajayi54@gmail.com","subject":"Re: [Outreachy PATCH v2 0/2] notes-utils: stop using the_repository","fromName":"Karthik Nayak","fromEmail":"karthik.188@gmail.com","sentAt":"2026-11-03T09:48:01Z","receivedAt":"2026-11-03T09:48:01Z","isPatch":true,"sender":{"key":"karthik.188@gmail.com","avatar":"https://avatars.githubusercontent.com/u/1786334?v=4"},"body":"Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:\n\n> This series removes the_repository from notes-utils.c.\n>\n> Changes since v1:\n> - Add patch 2, which passes a repository to\n>   init_copy_notes_for_rewrite() and drops USE_THE_REPOSITORY_VARIABLE\n>   from notes-utils.c, as Patrick suggested. v1 stopped one step short\n>   of that.\n>\n> The callers in builtin/am.c and builtin/notes.c pass the_repository,\n> as those files still use it everywhere. copy() in builtin/notes.c\n> does receive a repo that could be passed down instead, if that is\n> preferred.\n>\n> Thanks, Patrick, for the review.\n>\n\nOverall the patches look good to me.\n\n[snip]\n"},{"id":"557291","messageId":"aum29zvhcsj41yHz@pks.im","threadId":"66725","inReplyTo":"CAOLa=ZTAEVcKj-Y5QCGsAFAMUSh665E1fmQrEnuuufTLLbn3Wg@mail.gmail.com","subject":"Re: [Outreachy PATCH v2 0/2] notes-utils: stop using the_repository","fromName":"Patrick Steinhardt","fromEmail":"ps@pks.im","sentAt":"2026-11-03T10:27:03Z","receivedAt":"2026-11-03T10:27:03Z","isPatch":true,"sender":{"key":"ps@pks.im","avatar":"https://avatars.githubusercontent.com/u/4056630?v=4"},"body":"On Tue, Nov 03, 2026 at 03:48:01AM -0600, Karthik Nayak wrote:\n> Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:\n> \n> > This series removes the_repository from notes-utils.c.\n> >\n> > Changes since v1:\n> > - Add patch 2, which passes a repository to\n> >   init_copy_notes_for_rewrite() and drops USE_THE_REPOSITORY_VARIABLE\n> >   from notes-utils.c, as Patrick suggested. v1 stopped one step short\n> >   of that.\n> >\n> > The callers in builtin/am.c and builtin/notes.c pass the_repository,\n> > as those files still use it everywhere. copy() in builtin/notes.c\n> > does receive a repo that could be passed down instead, if that is\n> > preferred.\n> >\n> > Thanks, Patrick, for the review.\n> >\n> \n> Overall the patches look good to me.\n\nAgreed, the patches look good to me, too.\n\nPatrick\n\n"},{"id":"557346","messageId":"xmqqjymt94l3.fsf@gitster.g","threadId":"66725","inReplyTo":"CAOLa=ZSPHDWAUmqUev9PRdEB03cUW=NWrbXHjRyma6yUmV7Yng@mail.gmail.com","subject":"Re: [Outreachy PATCH v2 1/2] notes-utils: use the passed repository for notes refs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2026-11-03T18:01:44Z","receivedAt":"2026-11-03T18:01:44Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Karthik Nayak <karthik.188@gmail.com> writes:\n\n> Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:\n>\n>> Keep USE_THE_REPOSITORY_VARIABLE because\n>> init_copy_notes_for_rewrite() still uses the_repository.\n\nUnfortunately, this is a highly misleading comment to leave here.\n\nThe next person would be misled into thinking that it would be just\na matter of giving a \"struct repository *r\" argument to that\nfunction to lift the USE_THE_REPOSITORY_VARIABLE declaration from\nthere.\n\nLooking at what <notes-utils.h> exports, the file has quite some way\nto go to be free from the_repository.\n\n * create_notes_commit() takes \"struct repository *\" to pretend as\n   if it can work with any repository, but the first function it\n   calls is write_notes_tree() that eventually calls into\n   odb_write_object() with hardcoded the_repository->objects.\n\n * commit_notes() calls the above create_notes_commit() and shares\n   the same problem.\n\n * init_copy_notes_for_rewrite(), in addition to having its own\n   reference to the_repository, calls load_notes_trees() that makes\n   calls to init_notes() that works only on the_repository.\n\n * copy_note_for_rewrite() calls copy_note() which calls add_note(),\n   which eventually calls into load_subtree() that can only work\n   with the_repository.\n\nIn short, I think adding \"struct repository *\" to anything in\n<notes-utils.h> is not yet a productive exercise at this point,\nbefore cleaning up what is in the underlying things exported from\n<notes.h>.\n\nThis is a tangent but there are precedents to mark the functions\nthat still work only on the_repository or the_hash_algo:\n\n    $ git grep 'ifdef *USE_THE' \\*.h\n    environment.h:# ifdef USE_THE_REPOSITORY_VARIABLE\n    hash.h:#ifdef USE_THE_REPOSITORY_VARIABLE\n    hex.h:#ifdef USE_THE_REPOSITORY_VARIABLE\n    path.h:# ifdef USE_THE_REPOSITORY_VARIABLE\n    repository.h:#ifdef USE_THE_REPOSITORY_VARIABLE\n\nPerhaps we need similar protection to forbid use of these functions\nthat still assume the_repository is available in this file?\n\n notes-utils.h | 4 ++++\n 1 file changed, 4 insertions(+)\n\ndiff --git c/notes-utils.h w/notes-utils.h\nindex c54b1fe141..1503991cf6 100644\n--- c/notes-utils.h\n+++ w/notes-utils.h\n@@ -7,6 +7,9 @@ struct commit_list;\n struct object_id;\n struct repository;\n \n+/* most of the things in notes.h still only work with the_repository */\n+# ifdef USE_THE_REPOSITORY_VARIABLE\n+\n /*\n  * Create new notes commit from the given notes tree\n  *\n@@ -52,4 +55,5 @@ void finish_copy_notes_for_rewrite(struct repository *r,\n \t\t\t\t   struct notes_rewrite_cfg *c,\n \t\t\t\t   const char *msg);\n \n+# endif\n #endif\n\n"}]}