git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [Outreachy PATCH v2 1/2] notes-utils: use the passed repository for notes refs

From
Karthik Nayak <karthik.188@gmail.com>
Date
Nov 3, 2026, 09:45 UTC
Message-ID
<CAOLa=ZSPHDWAUmqUev9PRdEB03cUW=NWrbXHjRyma6yUmV7Yng@mail.gmail.com>
In-Reply-To
<20261103084930.15532-2-okhuomonajayi54@gmail.com>
Okhuomon Ajayi <okhuomonajayi54@gmail.com> writes:
Show 5 quoted lines
> create_notes_commit() and commit_notes() receive a repository,
> but read and update the notes ref in the_repository.
>
> Use the repository they are given.
>
Nit: It would also be nice to talk about why this is the same repository
and if its safe to do this swap.

Sometimes it's also useful to look at the history and argue about why it is the way it is.

For this file, all `the_repository` usages were removed first in 1d18d7581c (notes-utils.c: remove the_repository references, 2019-01-12), then it was added back in 2e5c4758b7 (cocci: apply rules to rewrite callers of "refs" interfaces, 2024-05-07). So seems like the latter was an automated addition of `the_repository`.

Show 18 quoted lines
> Keep USE_THE_REPOSITORY_VARIABLE because
> init_copy_notes_for_rewrite() still uses the_repository.
>
> Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
> ---
>  notes-utils.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/notes-utils.c b/notes-utils.c
> index 5c1c75d5b8..d4606bc576 100644
> --- a/notes-utils.c
> +++ b/notes-utils.c
> @@ -26,7 +26,7 @@ void create_notes_commit(struct repository *r,
>  	if (!parents) {
>  		/* Deduce parent commit from t->ref */
>  		struct object_id parent_oid;
> -		if (!refs_read_ref(get_main_ref_store(the_repository), t->ref, &parent_oid)) {
> +		if (!refs_read_ref(get_main_ref_store(r), t->ref, &parent_oid)) {

Here, the repository we read the reference from and the commit from should be the same. So r == the_repository.

Show 12 quoted lines
>  			struct commit *parent = lookup_commit(r, &parent_oid);
>  			if (repo_parse_commit(r, parent))
>  				die("Failed to find/parse commit %s", t->ref);
> @@ -61,7 +61,7 @@ void commit_notes(struct repository *r, struct notes_tree *t, const char *msg)
>
>  	create_notes_commit(r, t, NULL, buf.buf, buf.len, &commit_oid);
>  	strbuf_insertstr(&buf, 0, "notes: ");
> -	refs_update_ref(get_main_ref_store(the_repository), buf.buf,
> +	refs_update_ref(get_main_ref_store(r), buf.buf,
>  			t->update_ref, &commit_oid, NULL, 0,
>  			UPDATE_REFS_DIE_ON_ERR);
>
Similar here.
> --
> 2.56.0
The patch looks good.
Previous: Okhuomon AjayiNext: Junio C Hamano
Message 6 of 10 in “notes-utils: use the passed repository for notes refs”
  1. notes-utils: use the passed repository for notes refsOkhuomon Ajayi, Oct 31, 2026
  2. Patrick SteinhardtNov 2, 2026
  3. Okhuomon AjayiNov 2, 2026
  4. 0/2 notes-utils: stop using the_repositoryOkhuomon Ajayi, Nov 3, 2026
  5. 1/2 notes-utils: use the passed repository for notes refsOkhuomon Ajayi, Nov 3, 2026
  6. Karthik NayakNov 3, 2026
  7. Junio C HamanoNov 3, 2026
  8. 2/2 notes-utils: pass the repository to init_copy_notes_for_rewrite()Okhuomon Ajayi, Nov 3, 2026
  9. Karthik NayakNov 3, 2026
  10. Patrick SteinhardtNov 3, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.