* [Outreachy PATCH 1/6] notes: store the repository in struct notes_tree
2026-11-05 20:33 ` [Outreachy PATCH 0/6] notes: use the repository stored in the notes tree Okhuomon Ajayi
@ 2026-11-05 20:33 ` Okhuomon Ajayi
2026-11-09 9:18 ` Patrick Steinhardt
2026-11-05 20:33 ` [Outreachy PATCH 2/6] notes: use the tree's repository when reading notes Okhuomon Ajayi
` (4 subsequent siblings)
5 siblings, 1 reply; 25+ messages in thread
From: Okhuomon Ajayi @ 2026-11-05 20:33 UTC (permalink / raw)
To: git
Cc: christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, ps, gitster, karthik.188
A notes tree is always read from one repository, but the tree
does not record which one. Later code has to fall back to
the_repository.
Store the repository on the tree. init_notes() and
load_notes_trees() take it as their first argument, and
init_notes() saves it in t->repo. notes_cache_init() passes
the repository it was given. Other callers pass
the_repository for now.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
builtin/notes.c | 8 +++++---
notes-cache.c | 3 ++-
notes-utils.c | 3 ++-
notes.c | 26 +++++++++++++++-----------
notes.h | 9 ++++++---
5 files changed, 30 insertions(+), 19 deletions(-)
diff --git a/builtin/notes.c b/builtin/notes.c
index 9f1f0ec840..7e7dff6672 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -370,7 +370,8 @@ static int notes_copy_from_stdin(int force, const char *rewrite_cmd)
if (!c)
return 0;
} else {
- init_notes(NULL, NULL, NULL, NOTES_INIT_WRITABLE);
+ init_notes(the_repository, NULL, NULL, NULL,
+ NOTES_INIT_WRITABLE);
t = &default_notes_tree;
}
@@ -420,7 +421,7 @@ static struct notes_tree *init_notes_check(const char *subcommand,
{
struct notes_tree *t;
const char *ref;
- init_notes(NULL, NULL, NULL, flags);
+ init_notes(the_repository, NULL, NULL, NULL, flags);
t = &default_notes_tree;
ref = (flags & NOTES_INIT_WRITABLE) ? t->update_ref : t->ref;
@@ -841,7 +842,8 @@ static int merge_commit(struct notes_merge_options *o)
else
oidclr(&parent_oid, the_repository->hash_algo);
- init_notes(&t, "NOTES_MERGE_PARTIAL", combine_notes_overwrite, 0);
+ init_notes(the_repository, &t, "NOTES_MERGE_PARTIAL",
+ combine_notes_overwrite, 0);
o->local_ref = local_ref_to_free =
refs_resolve_refdup(get_main_ref_store(the_repository),
diff --git a/notes-cache.c b/notes-cache.c
index 74cef802bd..7c35ebe64b 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -50,7 +50,8 @@ void notes_cache_init(struct repository *r, struct notes_cache *c,
strbuf_addf(&ref, "refs/notes/%s", name);
if (!notes_cache_match_validity(r, ref.buf, validity))
flags |= NOTES_INIT_EMPTY;
- init_notes(&c->tree, ref.buf, combine_notes_overwrite, flags);
+ init_notes(r, &c->tree, ref.buf,
+ combine_notes_overwrite, flags);
strbuf_release(&ref);
}
diff --git a/notes-utils.c b/notes-utils.c
index 5c1c75d5b8..404e9a5eea 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -169,7 +169,8 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)
free(c);
return NULL;
}
- c->trees = load_notes_trees(c->refs, NOTES_INIT_WRITABLE);
+ c->trees = load_notes_trees(the_repository, c->refs,
+ NOTES_INIT_WRITABLE);
string_list_clear(c->refs, 0);
free(c->refs);
return c;
diff --git a/notes.c b/notes.c
index ec9c2cb150..4ab3d45d7c 100644
--- a/notes.c
+++ b/notes.c
@@ -1012,8 +1012,9 @@ char *default_notes_ref(struct repository *repo)
return notes_ref;
}
-void init_notes(struct notes_tree *t, const char *notes_ref,
- combine_notes_fn combine_notes, int flags)
+void init_notes(struct repository *r, struct notes_tree *t,
+ const char *notes_ref, combine_notes_fn combine_notes,
+ int flags)
{
struct object_id oid, object_oid;
unsigned short mode;
@@ -1025,7 +1026,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
assert(!t->initialized);
if (!notes_ref)
- notes_ref = to_free = default_notes_ref(the_repository);
+ notes_ref = to_free = default_notes_ref(r);
update_ref_namespace(NAMESPACE_NOTES, xstrdup(notes_ref));
if (!combine_notes)
@@ -1034,6 +1035,7 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
t->root = (struct int_node *) xcalloc(1, sizeof(struct int_node));
t->first_non_note = NULL;
t->prev_non_note = NULL;
+ t->repo = r;
t->ref = xstrdup(notes_ref);
t->update_ref = (flags & NOTES_INIT_WRITABLE) ? t->ref : NULL;
t->combine_notes = combine_notes;
@@ -1041,15 +1043,15 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
t->dirty = 0;
if (flags & NOTES_INIT_EMPTY ||
- repo_get_oid_treeish(the_repository, notes_ref, &object_oid))
+ repo_get_oid_treeish(r, notes_ref, &object_oid))
goto out;
- if (flags & NOTES_INIT_WRITABLE && refs_read_ref(get_main_ref_store(the_repository), notes_ref, &object_oid))
+ if (flags & NOTES_INIT_WRITABLE && refs_read_ref(get_main_ref_store(r), notes_ref, &object_oid))
die("Cannot use notes ref %s", notes_ref);
- if (get_tree_entry(the_repository, &object_oid, "", &oid, &mode))
+ if (get_tree_entry(r, &object_oid, "", &oid, &mode))
die("Failed to read notes tree referenced by %s (%s)",
notes_ref, oid_to_hex(&object_oid));
- oidclr(&root_tree.key_oid, the_repository->hash_algo);
+ oidclr(&root_tree.key_oid, r->hash_algo);
oidcpy(&root_tree.val_oid, &oid);
load_subtree(t, &root_tree, t->root, 0);
@@ -1057,7 +1059,8 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
free(to_free);
}
-struct notes_tree **load_notes_trees(struct string_list *refs, int flags)
+struct notes_tree **load_notes_trees(struct repository *r,
+ struct string_list *refs, int flags)
{
struct string_list_item *item;
int counter = 0;
@@ -1065,7 +1068,7 @@ struct notes_tree **load_notes_trees(struct string_list *refs, int flags)
ALLOC_ARRAY(trees, refs->nr + 1);
for_each_string_list_item(item, refs) {
struct notes_tree *t = xcalloc(1, sizeof(struct notes_tree));
- init_notes(t, item->string, combine_notes_ignore, flags);
+ init_notes(r, t, item->string, combine_notes_ignore, flags);
trees[counter++] = t;
}
trees[counter] = NULL;
@@ -1136,7 +1139,8 @@ void load_display_notes(struct display_notes_opt *opt)
item->string);
}
- display_notes_trees = load_notes_trees(&display_notes_refs, 0);
+ display_notes_trees = load_notes_trees(the_repository,
+ &display_notes_refs, 0);
string_list_clear(&display_notes_refs, 0);
}
@@ -1290,7 +1294,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid
if (!t)
t = &default_notes_tree;
if (!t->initialized)
- init_notes(t, NULL, NULL, 0);
+ init_notes(the_repository, t, NULL, NULL, 0);
oid = get_note(t, object_oid);
if (!oid)
diff --git a/notes.h b/notes.h
index 6dc6d7b265..0f50020816 100644
--- a/notes.h
+++ b/notes.h
@@ -50,6 +50,7 @@ int combine_notes_cat_sort_uniq(struct object_id *cur_oid,
* simultaneously.
*/
extern struct notes_tree {
+ struct repository *repo;
struct int_node *root;
struct non_note *first_non_note, *prev_non_note;
char *ref;
@@ -107,8 +108,9 @@ char *default_notes_ref(struct repository *repo);
* Precondition: The notes_tree structure is zeroed (this can be achieved with
* memset(t, 0, sizeof(struct notes_tree)))
*/
-void init_notes(struct notes_tree *t, const char *notes_ref,
- combine_notes_fn combine_notes, int flags);
+void init_notes(struct repository *r, struct notes_tree *t,
+ const char *notes_ref, combine_notes_fn combine_notes,
+ int flags);
/*
* Add the given note object to the given notes_tree structure
@@ -319,7 +321,8 @@ void format_display_notes(const struct object_id *object_oid,
* Load the notes tree from each ref listed in 'refs'. The output is
* an array of notes_tree*, terminated by a NULL.
*/
-struct notes_tree **load_notes_trees(struct string_list *refs, int flags);
+struct notes_tree **load_notes_trees(struct repository *r,
+ struct string_list *refs, int flags);
/*
* Add all refs that match 'glob' to the 'list'.
--
2.56.0
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [Outreachy PATCH 1/6] notes: store the repository in struct notes_tree
2026-11-05 20:33 ` [Outreachy PATCH 1/6] notes: store the repository in struct notes_tree Okhuomon Ajayi
@ 2026-11-09 9:18 ` Patrick Steinhardt
2026-11-09 10:27 ` Okhuomon Ajayi
0 siblings, 1 reply; 25+ messages in thread
From: Patrick Steinhardt @ 2026-11-09 9:18 UTC (permalink / raw)
To: Okhuomon Ajayi
Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, gitster, karthik.188
On Thu, Nov 05, 2026 at 09:33:39PM +0100, Okhuomon Ajayi wrote:
> diff --git a/notes.c b/notes.c
> index ec9c2cb150..4ab3d45d7c 100644
> --- a/notes.c
> +++ b/notes.c
> @@ -1012,8 +1012,9 @@ char *default_notes_ref(struct repository *repo)
> return notes_ref;
> }
>
> -void init_notes(struct notes_tree *t, const char *notes_ref,
> - combine_notes_fn combine_notes, int flags)
> +void init_notes(struct repository *r, struct notes_tree *t,
> + const char *notes_ref, combine_notes_fn combine_notes,
> + int flags)
> {
> struct object_id oid, object_oid;
> unsigned short mode;
I think this function should continue to receive `struct notes_tree` as
first parameter, as this is the subsystem it belongs to. While at it,
and as we already have to adjust all callers anyway, we might rename the
function to `notes_tree_init()`.
> @@ -1057,7 +1059,8 @@ void init_notes(struct notes_tree *t, const char *notes_ref,
> free(to_free);
> }
>
> -struct notes_tree **load_notes_trees(struct string_list *refs, int flags)
> +struct notes_tree **load_notes_trees(struct repository *r,
> + struct string_list *refs, int flags)
> {
> struct string_list_item *item;
> int counter = 0;
Okay, here the arguments make sense. We could likewise rename to
`notes_tree_load()` though.
> diff --git a/notes.h b/notes.h
> index 6dc6d7b265..0f50020816 100644
> --- a/notes.h
> +++ b/notes.h
> @@ -50,6 +50,7 @@ int combine_notes_cat_sort_uniq(struct object_id *cur_oid,
> * simultaneously.
> */
> extern struct notes_tree {
> + struct repository *repo;
> struct int_node *root;
> struct non_note *first_non_note, *prev_non_note;
> char *ref;
Oof, this interface is cursed, it really should be refactored to not
have implicit global state. Arguably, this default notes tree should be
either dropped, or it should be stored as part of a repository.
Anyway, as far as I can see we always initialize this default notes tree
via `init_notes()`. So it's cursed, but I think it should at least be
correct.
Patrick
^ permalink raw reply [flat|nested] 25+ messages in thread* Re: [Outreachy PATCH 1/6] notes: store the repository in struct notes_tree
2026-11-09 9:18 ` Patrick Steinhardt
@ 2026-11-09 10:27 ` Okhuomon Ajayi
0 siblings, 0 replies; 25+ messages in thread
From: Okhuomon Ajayi @ 2026-11-09 10:27 UTC (permalink / raw)
To: Patrick Steinhardt
Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, gitster, karthik.188
Patrick Steinhardt <ps@pks.im> writes:
> I think this function should continue to receive `struct notes_tree` as
> first parameter, as this is the subsystem it belongs to. While at it,
> and as we already have to adjust all callers anyway, we might rename the
> function to `notes_tree_init()`.
I put the repository first because most functions take it as their
first argument, but you're right that this one belongs to the notes
tree. I'll put the tree first and rename it to notes_tree_init().
> Okay, here the arguments make sense. We could likewise rename to
> `notes_tree_load()` though.
I'll rename it to notes_tree_load() too.
> Oof, this interface is cursed, it really should be refactored to not
> have implicit global state. Arguably, this default notes tree should be
> either dropped, or it should be stored as part of a repository.
Agreed. It is the same global I mentioned in my reply to 5/6.
Thanks,
Okhuomon
^ permalink raw reply [flat|nested] 25+ messages in thread
* [Outreachy PATCH 2/6] notes: use the tree's repository when reading notes
2026-11-05 20:33 ` [Outreachy PATCH 0/6] notes: use the repository stored in the notes tree Okhuomon Ajayi
2026-11-05 20:33 ` [Outreachy PATCH 1/6] notes: store the repository in struct notes_tree Okhuomon Ajayi
@ 2026-11-05 20:33 ` Okhuomon Ajayi
2026-11-05 20:33 ` [Outreachy PATCH 3/6] notes: use the tree's repository when writing and pruning Okhuomon Ajayi
` (3 subsequent siblings)
5 siblings, 0 replies; 25+ messages in thread
From: Okhuomon Ajayi @ 2026-11-05 20:33 UTC (permalink / raw)
To: git
Cc: christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, ps, gitster, karthik.188
note_tree_find(), add_non_note(), load_subtree(), remove_note()
and format_note() already have the notes tree, but still read
objects and hash algorithms from the_repository.
Read them from t->repo, the repository stored on the tree.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
notes.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/notes.c b/notes.c
index 4ab3d45d7c..5c2e8815f8 100644
--- a/notes.c
+++ b/notes.c
@@ -153,7 +153,7 @@ static struct leaf_node *note_tree_find(struct notes_tree *t,
void **p = note_tree_search(t, &tree, &n, key_sha1);
if (GET_PTR_TYPE(*p) == PTR_TYPE_NOTE) {
struct leaf_node *l = (struct leaf_node *) CLR_PTR_TYPE(*p);
- if (hasheq(key_sha1, l->key_oid.hash, the_repository->hash_algo))
+ if (hasheq(key_sha1, l->key_oid.hash, t->repo->hash_algo))
return l;
}
return NULL;
@@ -357,7 +357,7 @@ static void add_non_note(struct notes_tree *t, char *path,
n->next = NULL;
n->path = path;
n->mode = mode;
- oidread(&n->oid, sha1, the_repository->hash_algo);
+ oidread(&n->oid, sha1, t->repo->hash_algo);
t->prev_non_note = n;
if (!t->first_non_note) {
@@ -402,9 +402,9 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
void *buf;
struct tree_desc desc;
struct name_entry entry;
- const unsigned hashsz = the_hash_algo->rawsz;
+ const unsigned hashsz = t->repo->hash_algo->rawsz;
- buf = fill_tree_descriptor(the_repository, &desc, &subtree->val_oid);
+ buf = fill_tree_descriptor(t->repo, &desc, &subtree->val_oid);
if (!buf)
die("Could not read %s for notes-index",
oid_to_hex(&subtree->val_oid));
@@ -462,8 +462,8 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
CALLOC_ARRAY(l, 1);
oidcpy(&l->key_oid, &object_oid);
oidcpy(&l->val_oid, &entry.oid);
- oid_set_algo(&l->key_oid, the_hash_algo);
- oid_set_algo(&l->val_oid, the_hash_algo);
+ oid_set_algo(&l->key_oid, t->repo->hash_algo);
+ oid_set_algo(&l->val_oid, t->repo->hash_algo);
if (note_tree_insert(t, node, n, l, type,
combine_notes_concatenate))
die("Failed to load %s %s into notes tree "
@@ -493,7 +493,7 @@ static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,
strbuf_addch(&non_note_path, '/');
}
strbuf_addstr(&non_note_path, entry.path);
- oid_set_algo(&entry.oid, the_hash_algo);
+ oid_set_algo(&entry.oid, t->repo->hash_algo);
add_non_note(t, strbuf_detach(&non_note_path, NULL),
entry.mode, entry.oid.hash);
}
@@ -1168,8 +1168,8 @@ int remove_note(struct notes_tree *t, const unsigned char *object_sha1)
if (!t)
t = &default_notes_tree;
assert(t->initialized);
- oidread(&l.key_oid, object_sha1, the_repository->hash_algo);
- oidclr(&l.val_oid, the_repository->hash_algo);
+ oidread(&l.key_oid, object_sha1, t->repo->hash_algo);
+ oidclr(&l.val_oid, t->repo->hash_algo);
note_tree_remove(t, t->root, 0, &l);
if (is_null_oid(&l.val_oid)) /* no note was removed */
return 1;
@@ -1300,7 +1300,7 @@ static void format_note(struct notes_tree *t, const struct object_id *object_oid
if (!oid)
return;
- if (!(msg = odb_read_object(the_repository->objects, oid, &type, &msglen)) ||
+ if (!(msg = odb_read_object(t->repo->objects, oid, &type, &msglen)) ||
type != OBJ_BLOB) {
free(msg);
return;
--
2.56.0
^ permalink raw reply related [flat|nested] 25+ messages in thread* [Outreachy PATCH 3/6] notes: use the tree's repository when writing and pruning
2026-11-05 20:33 ` [Outreachy PATCH 0/6] notes: use the repository stored in the notes tree Okhuomon Ajayi
2026-11-05 20:33 ` [Outreachy PATCH 1/6] notes: store the repository in struct notes_tree Okhuomon Ajayi
2026-11-05 20:33 ` [Outreachy PATCH 2/6] notes: use the tree's repository when reading notes Okhuomon Ajayi
@ 2026-11-05 20:33 ` Okhuomon Ajayi
2026-11-05 20:33 ` [Outreachy PATCH 4/6] notes: pass the repository to the ref glob helpers Okhuomon Ajayi
` (2 subsequent siblings)
5 siblings, 0 replies; 25+ messages in thread
From: Okhuomon Ajayi @ 2026-11-05 20:33 UTC (permalink / raw)
To: git
Cc: christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, ps, gitster, karthik.188
write_notes_tree() writes the notes tree into the_repository,
and prune_notes() looks for missing objects there too. Both
already have the notes tree.
Write through t->repo. tree_write_stack_finish_subtree() takes
the repository, passed down from the tree. prune_notes() hands
the repository to its callback in a small struct.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
notes.c | 59 ++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 35 insertions(+), 24 deletions(-)
diff --git a/notes.c b/notes.c
index 5c2e8815f8..c83bcc29ad 100644
--- a/notes.c
+++ b/notes.c
@@ -673,16 +673,17 @@ static void tree_write_stack_init_subtree(struct tree_write_stack *tws,
tws->path[1] = path[1];
}
-static int tree_write_stack_finish_subtree(struct tree_write_stack *tws)
+static int tree_write_stack_finish_subtree(struct repository *r,
+ struct tree_write_stack *tws)
{
int ret;
struct tree_write_stack *n = tws->next;
struct object_id s;
if (n) {
- ret = tree_write_stack_finish_subtree(n);
+ ret = tree_write_stack_finish_subtree(r, n);
if (ret)
return ret;
- ret = odb_write_object(the_repository->objects, n->buf.buf,
+ ret = odb_write_object(r->objects, n->buf.buf,
n->buf.len, OBJ_TREE, &s);
if (ret)
return ret;
@@ -695,9 +696,10 @@ static int tree_write_stack_finish_subtree(struct tree_write_stack *tws)
return 0;
}
-static int write_each_note_helper(struct tree_write_stack *tws,
- const char *path, unsigned int mode,
- const struct object_id *oid)
+static int write_each_note_helper(struct repository *r,
+ struct tree_write_stack *tws,
+ const char *path, unsigned int mode,
+ const struct object_id *oid)
{
size_t path_len = strlen(path);
unsigned int n = 0;
@@ -711,7 +713,7 @@ static int write_each_note_helper(struct tree_write_stack *tws,
}
/* tws point to last matching tree_write_stack entry */
- ret = tree_write_stack_finish_subtree(tws);
+ ret = tree_write_stack_finish_subtree(r, tws);
if (ret)
return ret;
@@ -733,6 +735,7 @@ static int write_each_note_helper(struct tree_write_stack *tws,
}
struct write_each_note_data {
+ struct repository *repo;
struct tree_write_stack *root;
struct non_note **nn_list;
struct non_note *nn_prev;
@@ -748,8 +751,8 @@ static int write_each_non_note_until(const char *note_path,
if (note_path && cmp == 0)
; /* do nothing, prefer note to non-note */
else {
- ret = write_each_note_helper(d->root, n->path, n->mode,
- &n->oid);
+ ret = write_each_note_helper(d->repo, d->root, n->path,
+ n->mode, &n->oid);
if (ret)
return ret;
}
@@ -779,7 +782,8 @@ static int write_each_note(const struct object_id *object_oid UNUSED,
/* Weave non-note entries into note entries */
return write_each_non_note_until(note_path, d) ||
- write_each_note_helper(d->root, note_path, mode, note_oid);
+ write_each_note_helper(d->repo, d->root, note_path, mode,
+ note_oid);
}
struct note_delete_list {
@@ -787,23 +791,28 @@ struct note_delete_list {
const unsigned char *sha1;
};
+struct prune_notes_data {
+ struct repository *repo;
+ struct note_delete_list *list;
+};
+
static int prune_notes_helper(const struct object_id *object_oid,
const struct object_id *note_oid UNUSED,
char *note_path UNUSED,
void *cb_data)
{
- struct note_delete_list **l = (struct note_delete_list **) cb_data;
+ struct prune_notes_data *d = cb_data;
struct note_delete_list *n;
- if (odb_has_object(the_repository->objects, object_oid,
+ if (odb_has_object(d->repo->objects, object_oid,
ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
return 0; /* nothing to do for this note */
/* failed to find object => prune this note */
n = (struct note_delete_list *) xmalloc(sizeof(*n));
- n->next = *l;
+ n->next = d->list;
n->sha1 = object_oid->hash;
- *l = n;
+ d->list = n;
return 0;
}
@@ -1213,6 +1222,7 @@ int write_notes_tree(struct notes_tree *t, struct object_id *result)
root.next = NULL; /* last forward entry in list is grounded */
strbuf_init(&root.buf, 256 * (32 + the_hash_algo->hexsz)); /* assume 256 entries */
root.path[0] = root.path[1] = '\0';
+ cb_data.repo = t->repo;
cb_data.root = &root;
cb_data.nn_list = &(t->first_non_note);
cb_data.nn_prev = NULL;
@@ -1222,8 +1232,8 @@ int write_notes_tree(struct notes_tree *t, struct object_id *result)
FOR_EACH_NOTE_YIELD_SUBTREES;
ret = for_each_note(t, flags, write_each_note, &cb_data) ||
write_each_non_note_until(NULL, &cb_data) ||
- tree_write_stack_finish_subtree(&root) ||
- odb_write_object(the_repository->objects, root.buf.buf,
+ tree_write_stack_finish_subtree(t->repo, &root) ||
+ odb_write_object(t->repo->objects, root.buf.buf,
root.buf.len, OBJ_TREE, result);
strbuf_release(&root.buf);
return ret;
@@ -1231,25 +1241,26 @@ int write_notes_tree(struct notes_tree *t, struct object_id *result)
void prune_notes(struct notes_tree *t, int flags)
{
- struct note_delete_list *l = NULL;
+ struct prune_notes_data d = { 0 };
if (!t)
t = &default_notes_tree;
assert(t->initialized);
- for_each_note(t, 0, prune_notes_helper, &l);
+ d.repo = t->repo;
+ for_each_note(t, 0, prune_notes_helper, &d);
- while (l) {
+ while (d.list) {
struct note_delete_list *next;
if (flags & NOTES_PRUNE_VERBOSE)
- printf("%s\n", hash_to_hex(l->sha1));
+ printf("%s\n", hash_to_hex(d.list->sha1));
if (!(flags & NOTES_PRUNE_DRYRUN))
- remove_note(t, l->sha1);
+ remove_note(t, d.list->sha1);
- next = l->next;
- free(l);
- l = next;
+ next = d.list->next;
+ free(d.list);
+ d.list = next;
}
}
--
2.56.0
^ permalink raw reply related [flat|nested] 25+ messages in thread* [Outreachy PATCH 4/6] notes: pass the repository to the ref glob helpers
2026-11-05 20:33 ` [Outreachy PATCH 0/6] notes: use the repository stored in the notes tree Okhuomon Ajayi
` (2 preceding siblings ...)
2026-11-05 20:33 ` [Outreachy PATCH 3/6] notes: use the tree's repository when writing and pruning Okhuomon Ajayi
@ 2026-11-05 20:33 ` Okhuomon Ajayi
2026-11-05 20:33 ` [Outreachy PATCH 5/6] notes: pass the repository to the combine_notes callbacks Okhuomon Ajayi
2026-11-05 20:33 ` [Outreachy PATCH 6/6] notes-utils: use the given repository Okhuomon Ajayi
5 siblings, 0 replies; 25+ messages in thread
From: Okhuomon Ajayi @ 2026-11-05 20:33 UTC (permalink / raw)
To: git
Cc: christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, ps, gitster, karthik.188
string_list_add_refs_by_glob() and
string_list_add_refs_from_colon_sep() walk refs in
the_repository. The caller already knows which repository
that is.
Take the repository as their first argument. Callers pass
the_repository for now.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
notes-utils.c | 6 ++++--
notes.c | 21 +++++++++++++--------
notes.h | 6 ++++--
3 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/notes-utils.c b/notes-utils.c
index 404e9a5eea..70c619269e 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -123,7 +123,8 @@ static int notes_rewrite_config(const char *k, const char *v,
/* note that a refs/ prefix is implied in the
* underlying for_each_glob_ref */
if (starts_with(v, "refs/notes/"))
- string_list_add_refs_by_glob(c->refs, v);
+ string_list_add_refs_by_glob(the_repository,
+ c->refs, v);
else
warning(_("Refusing to rewrite notes in %s"
" (outside of refs/notes/)"), v);
@@ -160,7 +161,8 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)
}
if (rewrite_refs_env) {
c->refs_from_env = 1;
- string_list_add_refs_from_colon_sep(c->refs, rewrite_refs_env);
+ string_list_add_refs_from_colon_sep(the_repository, c->refs,
+ rewrite_refs_env);
}
repo_config(the_repository, notes_rewrite_config, c);
if (!c->enabled || !c->refs->nr) {
diff --git a/notes.c b/notes.c
index c83bcc29ad..cff63a4410 100644
--- a/notes.c
+++ b/notes.c
@@ -958,25 +958,27 @@ static int string_list_add_one_ref(const struct reference *ref, void *cb)
/*
* The list argument must have strdup_strings set on it.
*/
-void string_list_add_refs_by_glob(struct string_list *list, const char *glob)
+void string_list_add_refs_by_glob(struct repository *r,
+ struct string_list *list, const char *glob)
{
assert(list->strdup_strings);
if (has_glob_specials(glob)) {
struct refs_for_each_ref_options opts = {
.pattern = glob,
};
- refs_for_each_ref_ext(get_main_ref_store(the_repository),
+ refs_for_each_ref_ext(get_main_ref_store(r),
string_list_add_one_ref, list, &opts);
} else {
struct object_id oid;
- if (repo_get_oid(the_repository, glob, &oid))
+ if (repo_get_oid(r, glob, &oid))
warning("notes ref %s is invalid", glob);
if (!unsorted_string_list_has_string(list, glob))
string_list_append(list, glob);
}
}
-void string_list_add_refs_from_colon_sep(struct string_list *list,
+void string_list_add_refs_from_colon_sep(struct repository *r,
+ struct string_list *list,
const char *globs)
{
struct string_list split = STRING_LIST_INIT_NODUP;
@@ -987,7 +989,7 @@ void string_list_add_refs_from_colon_sep(struct string_list *list,
STRING_LIST_SPLIT_NONEMPTY);
for (i = 0; i < split.nr; i++)
- string_list_add_refs_by_glob(list, split.items[i].string);
+ string_list_add_refs_by_glob(r, list, split.items[i].string);
string_list_clear(&split, 0);
free(globs_copy);
@@ -1002,7 +1004,8 @@ static int notes_display_config(const char *k, const char *v,
if (*load_refs && !strcmp(k, "notes.displayref")) {
if (!v)
return config_error_nonbool(k);
- string_list_add_refs_by_glob(&display_notes_refs, v);
+ string_list_add_refs_by_glob(the_repository,
+ &display_notes_refs, v);
}
return 0;
@@ -1132,7 +1135,8 @@ void load_display_notes(struct display_notes_opt *opt)
string_list_append_nodup(&display_notes_refs, default_notes_ref(the_repository));
display_ref_env = getenv(GIT_NOTES_DISPLAY_REF_ENVIRONMENT);
if (display_ref_env) {
- string_list_add_refs_from_colon_sep(&display_notes_refs,
+ string_list_add_refs_from_colon_sep(the_repository,
+ &display_notes_refs,
display_ref_env);
load_config_refs = 0;
} else
@@ -1144,7 +1148,8 @@ void load_display_notes(struct display_notes_opt *opt)
if (opt) {
struct string_list_item *item;
for_each_string_list_item(item, &opt->extra_notes_refs)
- string_list_add_refs_by_glob(&display_notes_refs,
+ string_list_add_refs_by_glob(the_repository,
+ &display_notes_refs,
item->string);
}
diff --git a/notes.h b/notes.h
index 0f50020816..b571ecede4 100644
--- a/notes.h
+++ b/notes.h
@@ -327,14 +327,16 @@ struct notes_tree **load_notes_trees(struct repository *r,
/*
* Add all refs that match 'glob' to the 'list'.
*/
-void string_list_add_refs_by_glob(struct string_list *list, const char *glob);
+void string_list_add_refs_by_glob(struct repository *r,
+ struct string_list *list, const char *glob);
/*
* Add all refs from a colon-separated glob list 'globs' to the end of
* 'list'. Empty components are ignored. This helper is used to
* parse GIT_NOTES_DISPLAY_REF style environment variables.
*/
-void string_list_add_refs_from_colon_sep(struct string_list *list,
+void string_list_add_refs_from_colon_sep(struct repository *r,
+ struct string_list *list,
const char *globs);
/* Expand inplace a note ref like "foo" or "notes/foo" into "refs/notes/foo" */
--
2.56.0
^ permalink raw reply related [flat|nested] 25+ messages in thread* [Outreachy PATCH 5/6] notes: pass the repository to the combine_notes callbacks
2026-11-05 20:33 ` [Outreachy PATCH 0/6] notes: use the repository stored in the notes tree Okhuomon Ajayi
` (3 preceding siblings ...)
2026-11-05 20:33 ` [Outreachy PATCH 4/6] notes: pass the repository to the ref glob helpers Okhuomon Ajayi
@ 2026-11-05 20:33 ` Okhuomon Ajayi
2026-11-09 9:18 ` Patrick Steinhardt
2026-11-05 20:33 ` [Outreachy PATCH 6/6] notes-utils: use the given repository Okhuomon Ajayi
5 siblings, 1 reply; 25+ messages in thread
From: Okhuomon Ajayi @ 2026-11-05 20:33 UTC (permalink / raw)
To: git
Cc: christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, ps, gitster, karthik.188
combine_notes_concatenate() and combine_notes_cat_sort_uniq() read
and write note blobs in the_repository, even when the notes tree
belongs to another repository. The callbacks are only called from
note_tree_insert(), which has the tree.
Pass the tree's repository to all combine_notes callbacks. Also make
copy_note() use the tree's hash algorithm for its null object ID.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
notes.c | 34 ++++++++++++++++++++--------------
notes.h | 23 ++++++++++++++---------
2 files changed, 34 insertions(+), 23 deletions(-)
diff --git a/notes.c b/notes.c
index cff63a4410..d675562bf6 100644
--- a/notes.c
+++ b/notes.c
@@ -279,7 +279,7 @@ static int note_tree_insert(struct notes_tree *t, struct int_node *tree,
return 0;
}
- ret = combine_notes(&l->val_oid,
+ ret = combine_notes(t->repo, &l->val_oid,
&entry->val_oid);
if (!ret && is_null_oid(&l->val_oid))
note_tree_remove(t, tree, n, entry);
@@ -816,7 +816,8 @@ static int prune_notes_helper(const struct object_id *object_oid,
return 0;
}
-int combine_notes_concatenate(struct object_id *cur_oid,
+int combine_notes_concatenate(struct repository *r,
+ struct object_id *cur_oid,
const struct object_id *new_oid)
{
char *cur_msg = NULL, *new_msg = NULL, *buf;
@@ -827,14 +828,14 @@ int combine_notes_concatenate(struct object_id *cur_oid,
/* read in both note blob objects */
if (!is_null_oid(new_oid))
- new_msg = odb_read_object(the_repository->objects, new_oid,
+ new_msg = odb_read_object(r->objects, new_oid,
&new_type, &new_len);
if (!new_msg || !new_len || new_type != OBJ_BLOB) {
free(new_msg);
return 0;
}
if (!is_null_oid(cur_oid))
- cur_msg = odb_read_object(the_repository->objects, cur_oid,
+ cur_msg = odb_read_object(r->objects, cur_oid,
&cur_type, &cur_len);
if (!cur_msg || !cur_len || cur_type != OBJ_BLOB) {
free(cur_msg);
@@ -858,20 +859,22 @@ int combine_notes_concatenate(struct object_id *cur_oid,
free(new_msg);
/* create a new blob object from buf */
- ret = odb_write_object(the_repository->objects, buf,
+ ret = odb_write_object(r->objects, buf,
buf_len, OBJ_BLOB, cur_oid);
free(buf);
return ret;
}
-int combine_notes_overwrite(struct object_id *cur_oid,
+int combine_notes_overwrite(struct repository *r UNUSED,
+ struct object_id *cur_oid,
const struct object_id *new_oid)
{
oidcpy(cur_oid, new_oid);
return 0;
}
-int combine_notes_ignore(struct object_id *cur_oid UNUSED,
+int combine_notes_ignore(struct repository *r UNUSED,
+ struct object_id *cur_oid UNUSED,
const struct object_id *new_oid UNUSED)
{
return 0;
@@ -881,7 +884,8 @@ int combine_notes_ignore(struct object_id *cur_oid UNUSED,
* Add the lines from the named object to list, with trailing
* newlines removed.
*/
-static int string_list_add_note_lines(struct string_list *list,
+static int string_list_add_note_lines(struct repository *r,
+ struct string_list *list,
const struct object_id *oid)
{
char *data;
@@ -892,7 +896,7 @@ static int string_list_add_note_lines(struct string_list *list,
return 0;
/* read_sha1_file NUL-terminates */
- data = odb_read_object(the_repository->objects, oid, &t, &len);
+ data = odb_read_object(r->objects, oid, &t, &len);
if (t != OBJ_BLOB || !data || !len) {
free(data);
return t != OBJ_BLOB || !data;
@@ -918,7 +922,8 @@ static int string_list_join_lines_helper(struct string_list_item *item,
return 0;
}
-int combine_notes_cat_sort_uniq(struct object_id *cur_oid,
+int combine_notes_cat_sort_uniq(struct repository *r,
+ struct object_id *cur_oid,
const struct object_id *new_oid)
{
struct string_list sort_uniq_list = STRING_LIST_INIT_DUP;
@@ -926,9 +931,9 @@ int combine_notes_cat_sort_uniq(struct object_id *cur_oid,
int ret = 1;
/* read both note blob objects into unique_lines */
- if (string_list_add_note_lines(&sort_uniq_list, cur_oid))
+ if (string_list_add_note_lines(r, &sort_uniq_list, cur_oid))
goto out;
- if (string_list_add_note_lines(&sort_uniq_list, new_oid))
+ if (string_list_add_note_lines(r, &sort_uniq_list, new_oid))
goto out;
string_list_remove_empty_items(&sort_uniq_list, 0);
string_list_sort_u(&sort_uniq_list, 0);
@@ -938,7 +943,7 @@ int combine_notes_cat_sort_uniq(struct object_id *cur_oid,
string_list_join_lines_helper, &buf))
goto out;
- ret = odb_write_object(the_repository->objects, buf.buf,
+ ret = odb_write_object(r->objects, buf.buf,
buf.len, OBJ_BLOB, cur_oid);
out:
@@ -1382,7 +1387,8 @@ int copy_note(struct notes_tree *t,
if (note)
return add_note(t, to_obj, note, combine_notes);
else if (existing_note)
- return add_note(t, to_obj, null_oid(the_hash_algo), combine_notes);
+ return add_note(t, to_obj, null_oid(t->repo->hash_algo),
+ combine_notes);
return 0;
}
diff --git a/notes.h b/notes.h
index b571ecede4..6d6f6068d8 100644
--- a/notes.h
+++ b/notes.h
@@ -13,10 +13,10 @@ struct strbuf;
* When adding a new note annotating the same object as an existing note, it is
* up to the caller to decide how to combine the two notes. The decision is
* made by passing in a function of the following form. The function accepts
- * two object_ids -- of the existing note and the new note, respectively. The
- * function then combines the notes in whatever way it sees fit, and writes the
- * resulting oid into the first argument (cur_oid). A non-zero return
- * value indicates failure.
+ * the repository the notes live in and two object_ids -- of the existing
+ * note and the new note, respectively. The function then combines the notes
+ * in whatever way it sees fit, and writes the resulting oid into cur_oid.
+ * A non-zero return value indicates failure.
*
* The two given object_ids shall both be non-NULL and different from each
* other. Either of them (but not both) may be == null_oid, which indicates an
@@ -27,17 +27,22 @@ struct strbuf;
* combine_notes_concatenate(), which appends the contents of the new note to
* the contents of the existing note.
*/
-typedef int (*combine_notes_fn)(struct object_id *cur_oid,
+typedef int (*combine_notes_fn)(struct repository *r,
+ struct object_id *cur_oid,
const struct object_id *new_oid);
/* Common notes combinators */
-int combine_notes_concatenate(struct object_id *cur_oid,
+int combine_notes_concatenate(struct repository *r,
+ struct object_id *cur_oid,
const struct object_id *new_oid);
-int combine_notes_overwrite(struct object_id *cur_oid,
+int combine_notes_overwrite(struct repository *r,
+ struct object_id *cur_oid,
const struct object_id *new_oid);
-int combine_notes_ignore(struct object_id *cur_oid,
+int combine_notes_ignore(struct repository *r,
+ struct object_id *cur_oid,
const struct object_id *new_oid);
-int combine_notes_cat_sort_uniq(struct object_id *cur_oid,
+int combine_notes_cat_sort_uniq(struct repository *r,
+ struct object_id *cur_oid,
const struct object_id *new_oid);
/*
--
2.56.0
^ permalink raw reply related [flat|nested] 25+ messages in thread* Re: [Outreachy PATCH 5/6] notes: pass the repository to the combine_notes callbacks
2026-11-05 20:33 ` [Outreachy PATCH 5/6] notes: pass the repository to the combine_notes callbacks Okhuomon Ajayi
@ 2026-11-09 9:18 ` Patrick Steinhardt
2026-11-09 10:11 ` Okhuomon Ajayi
0 siblings, 1 reply; 25+ messages in thread
From: Patrick Steinhardt @ 2026-11-09 9:18 UTC (permalink / raw)
To: Okhuomon Ajayi
Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, gitster, karthik.188
On Thu, Nov 05, 2026 at 09:33:43PM +0100, Okhuomon Ajayi wrote:
> combine_notes_concatenate() and combine_notes_cat_sort_uniq() read
> and write note blobs in the_repository, even when the notes tree
> belongs to another repository. The callbacks are only called from
> note_tree_insert(), which has the tree.
>
> Pass the tree's repository to all combine_notes callbacks. Also make
> copy_note() use the tree's hash algorithm for its null object ID.
Hmm. I was hoping that at the end of this series we'd also get rid of
`USE_THE_REPOSITORY_VARIABLE` in "notes.c". Any reason why you decided
to not go all the way?
Patrick
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [Outreachy PATCH 5/6] notes: pass the repository to the combine_notes callbacks
2026-11-09 9:18 ` Patrick Steinhardt
@ 2026-11-09 10:11 ` Okhuomon Ajayi
0 siblings, 0 replies; 25+ messages in thread
From: Okhuomon Ajayi @ 2026-11-09 10:11 UTC (permalink / raw)
To: Patrick Steinhardt
Cc: git, christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, gitster, karthik.188
Patrick Steinhardt <ps@pks.im> writes:
> Hmm. I was hoping that at the end of this series we'd also get rid of
> `USE_THE_REPOSITORY_VARIABLE` in "notes.c". Any reason why you decided
> to not go all the way?
I limited the series to code that already has a notes tree. The
rest needs more than that, the display notes code keeps its state
in globals, and log, format-patch, diff-tree and format-rev are
given a repository but do not pass it on. format_note() falls
back to the global default_notes_tree, where I wasn't sure which
direction to take, and expand_loose_notes_ref() only takes a
strbuf. The hash-size helpers are simpler, I just left them on
the global.
Thanks,
Okhuomon
^ permalink raw reply [flat|nested] 25+ messages in thread
* [Outreachy PATCH 6/6] notes-utils: use the given repository
2026-11-05 20:33 ` [Outreachy PATCH 0/6] notes: use the repository stored in the notes tree Okhuomon Ajayi
` (4 preceding siblings ...)
2026-11-05 20:33 ` [Outreachy PATCH 5/6] notes: pass the repository to the combine_notes callbacks Okhuomon Ajayi
@ 2026-11-05 20:33 ` Okhuomon Ajayi
5 siblings, 0 replies; 25+ messages in thread
From: Okhuomon Ajayi @ 2026-11-05 20:33 UTC (permalink / raw)
To: git
Cc: christian.couder, usmanakinyemi202, siddharthasthana31,
kaartic.sivaraam, ps, gitster, karthik.188
create_notes_commit() and commit_notes() take a repository, but
still read and update the notes ref in the_repository.
init_copy_notes_for_rewrite() does not take a repository at all:
it reads config and loads notes trees from the_repository.
Pass the repository through. The config callback keeps it on
struct notes_rewrite_cfg. The sequencer passes its repository;
am and notes pass the_repository for now. notes-utils.c no
longer uses the_repository, so drop USE_THE_REPOSITORY_VARIABLE.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
builtin/am.c | 2 +-
builtin/notes.c | 2 +-
notes-utils.c | 21 ++++++++++-----------
notes-utils.h | 4 +++-
sequencer.c | 2 +-
5 files changed, 16 insertions(+), 15 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 7e7dff6672..a32af68928 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 70c619269e..7e9262411d 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"
@@ -26,7 +24,8 @@ 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)) {
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 +60,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);
@@ -123,8 +122,7 @@ static int notes_rewrite_config(const char *k, const char *v,
/* note that a refs/ prefix is implied in the
* underlying for_each_glob_ref */
if (starts_with(v, "refs/notes/"))
- string_list_add_refs_by_glob(the_repository,
- c->refs, v);
+ string_list_add_refs_by_glob(c->repo, c->refs, v);
else
warning(_("Refusing to rewrite notes in %s"
" (outside of refs/notes/)"), v);
@@ -135,11 +133,13 @@ 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);
const char *rewrite_refs_env = getenv(GIT_NOTES_REWRITE_REF_ENVIRONMENT);
+ c->repo = r;
c->cmd = cmd;
c->enabled = 1;
c->combine = combine_notes_concatenate;
@@ -161,18 +161,17 @@ struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)
}
if (rewrite_refs_env) {
c->refs_from_env = 1;
- string_list_add_refs_from_colon_sep(the_repository, c->refs,
+ string_list_add_refs_from_colon_sep(r, 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);
free(c);
return NULL;
}
- c->trees = load_notes_trees(the_repository, c->refs,
- NOTES_INIT_WRITABLE);
+ c->trees = load_notes_trees(r, c->refs, NOTES_INIT_WRITABLE);
string_list_clear(c->refs, 0);
free(c->refs);
return c;
diff --git a/notes-utils.h b/notes-utils.h
index c54b1fe141..14dd16f0ea 100644
--- a/notes-utils.h
+++ b/notes-utils.h
@@ -35,6 +35,7 @@ enum notes_merge_strategy {
};
struct notes_rewrite_cfg {
+ struct repository *repo;
struct notes_tree **trees;
const char *cmd;
int enabled;
@@ -45,7 +46,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
^ permalink raw reply related [flat|nested] 25+ messages in thread