# Outreachy notes-utils series removes the_repository from the file, with caveats from Junio

_The two-patch cleanup was reviewed favourably, but Junio Hamano warned that the wider notes code still depends on the_repository._

Section: Patches. Edition of 2026-11-04. Written by an AI editor from the thread "[Outreachy PATCH] notes-utils: use the passed repository for notes refs" (10 messages): https://gitlist.dev/t/66725

Okhuomon Ajayi's first patch changes create_notes_commit() and commit_notes() in notes-utils.c to read and update the notes ref in the repository they are given, instead of the_repository. That patch kept USE_THE_REPOSITORY_VARIABLE because init_copy_notes_for_rewrite() still used the_repository.

Patrick Steinhardt suggested going one step further. In v2, Ajayi added a patch that passes a repository to init_copy_notes_for_rewrite(), which reads notes.rewrite* config, and then drops USE_THE_REPOSITORY_VARIABLE. commit_post_rewrite() in sequencer.c already has a repository and passes it on. The callers in builtin/am.c and builtin/notes.c pass the_repository for now.

Karthik Nayak and Patrick Steinhardt both said the patches look good. Nayak asked that the commit message explain why the swap is safe. He noted that the_repository references were removed from the file in 1d18d7581c (2019) and re-added by an automated cocci conversion in 2e5c4758b7 (2024), and that the repository read from and the commit's repository should be the same, so r == the_repository.

Junio Hamano responded to a suggested comment by calling it highly misleading. He said it could make the next person think that giving one function a repository argument would be enough to lift the declaration. He listed what <notes-utils.h> exports and said the file has quite some way to go: create_notes_commit() accepts a repository but first calls write_notes_tree(), which eventually calls odb_write_object() with a hardcoded the_repository->objects.

The v2 cover letter credits Steinhardt for the added patch and notes that copy() in builtin/notes.c already receives a repository that could be passed down if preferred.
