Article View: linux.kernel.git
Article #3861[PATCH v5 0/6] notes: start passing the repository through notes.[ch]
From: Okhuomon Ajayi
Date: Wed, 25 Nov 2026 22:02
Date: Wed, 25 Nov 2026 22:02
156 lines
17758 bytes
17758 bytes
This is a preparatory series. It makes the code in notes.[c,h] and its
direct callers work on the repository stored in struct notes_tree instead
of the_repository. It deliberately does not convert the whole notes
subsystem yet; it does the bulk of the work in notes.[c,h] and leaves the
rest for future series.
What it does:
- adds notes_tree_or_default() for the shared NULL-tree check;
- stores the repository in struct notes_tree;
- uses the tree's repository when reading, writing and pruning notes;
- passes the repository to the ref glob helpers and the combine_notes
callbacks.
What is left for future series:
- notes.c: 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() still falls back to the global
default_notes_tree, and expand_loose_notes_ref() only takes a strbuf.
The hash-size helpers are also still on the global.
- notes-utils.[c,h]: still use the_repository. And the hash-size helpers
still on the global are reached from here, through create_notes_commit()
-> write_notes_tree(), so converting notes-utils is tied to converting
those helpers too.
- notes-merge.[c,h]: still work on the global repository.
- notes-cache.c: notes_cache_init() passes its repository through, but
notes_cache_match_validity(), notes_cache_write(), notes_cache_get()
and notes_cache_put() still use the_repository.
The previous round was labeled v2. It should have been v4, so this
reroll is v5.
Changes since v4:
- Add notes_tree_or_default() and use it for the repeated NULL-tree
check. copy_note() uses that helper for its new guard.
- Document 'r' and 'flags' above notes_tree_init().
- Explain in the reading patch why the converted helpers are safe
when the tree is NULL. copy_note() was the exception.
- List notes-cache.c with what is left for a future series.
Okhuomon Ajayi (6):
notes: add notes_tree_or_default()
notes: store the repository in struct notes_tree
notes: use the tree's repository when reading notes
notes: use the tree's repository when writing and pruning
notes: pass the repository to the ref glob helpers
notes: pass the repository to the combine_notes callbacks
builtin/notes.c | 8 +-
notes-cache.c | 3 +-
notes-utils.c | 9 ++-
notes.c | 205 +++++++++++++++++++++++++++---------------------
notes.h | 44 +++++++----
5 files changed, 159 insertions(+), 110 deletions(-)
Range-diff against v4:
-: ---------- > 1: c9891e887c notes: add notes_tree_or_default()
1: 5ad0f1bd62 ! 2: 831db4c68a notes: store the repository in struct notes_tree
@@ notes.h: extern struct notes_tree {
* This the first of the following to be defined:
* 1. The '--ref' option to 'git notes', if given
@@ notes.h: char *default_notes_ref(struct repository *repo);
+ *
+ * If you pass t == NULL, the default internal notes_tree will be initialized.
+ *
++ * 'r' is the repository that this notes_tree belongs to.
++ *
+ * The combine_notes function that is passed becomes the default combine_notes
+ * function for the given notes_tree. If NULL is passed, the default
+ * combine_notes function is combine_notes_concatenate().
+ *
++ * 'flags' is a combination of the NOTES_INIT_* flags above.
++ *
* Precondition: The notes_tree structure is zeroed (this can be achieved with
* memset(t, 0, sizeof(struct notes_tree)))
*/
2: 1018419720 ! 3: 82f6f6ea7c notes: use the tree's repository when reading notes
@@ Commit message
Read them from t->repo, the repository stored on the tree.
+ note_tree_find(), add_non_note() and load_subtree() do not check
+ for a NULL tree themselves. add_note(), remove_note() and
+ get_note() replace a NULL tree with the default notes tree and
+ assert that it is initialized before those helpers run.
+ format_note() does the same NULL swap, and initializes the tree
+ if it is not already. load_subtree() is also reached when a
+ lookup unpacks a subtree, which is still after that check.
+ copy_note() is the one public function that does not do this;
+ the next patch adds the guard.
+
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
## notes.c ##
@@ notes.c: static void load_subtree(struct notes_tree *t, struct leaf_node *subtre
entry.mode, entry.oid.hash);
}
@@ notes.c: int remove_note(struct notes_tree *t, const unsigned char *object_sha1)
- if (!t)
- t = &default_notes_tree;
- assert(t->initialized);
+ struct leaf_node l;
+
+ t = notes_tree_or_default(t);
- 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);
3: 67a2942c09 ! 4: b35eb50a45 notes: use the tree's repository when writing and pruning
@@ Commit message
copy_note() also writes through the tree, by calling add_note(),
so it uses the tree's hash algorithm for its null object ID.
+ It now takes a NULL tree the same way as the other entry points,
+ through notes_tree_or_default(), before reading the tree's
+ repository.
Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
@@ notes.c: int write_notes_tree(struct notes_tree *t, struct object_id *result)
- struct note_delete_list *l = NULL;
+ struct prune_notes_data d = { 0 };
- if (!t)
- t = &default_notes_tree;
- assert(t->initialized);
+ t = notes_tree_or_default(t);
- for_each_note(t, 0, prune_notes_helper, &l);
+ d.repo = t->repo;
@@ notes.c: int write_notes_tree(struct notes_tree *t, struct object_id *result)
}
}
+@@ notes.c: int copy_note(struct notes_tree *t,
+ const struct object_id *from_obj, const struct object_id *to_obj,
+ int force, combine_notes_fn combine_notes)
+ {
+- const struct object_id *note = get_note(t, from_obj);
+- const struct object_id *existing_note = get_note(t, to_obj);
++ const struct object_id *note;
++ const struct object_id *existing_note;
++
++ t = notes_tree_or_default(t);
++
++ note = get_note(t, from_obj);
++ existing_note = get_note(t, to_obj);
+
+ if (!force && existing_note)
+ return 1;
@@ notes.c: int copy_note(struct notes_tree *t,
if (note)
return add_note(t, to_obj, note, combine_notes);
4: 7ea6c0e5a2 = 5: dcda05343a notes: pass the repository to the ref glob helpers
5: ff8cf4d22a = 6: 69928b58f6 notes: pass the repository to the combine_notes callbacks
--
2.56.0
Technical Details
Message-ID:
<20261125220214.35881-1-okhuomonajayi54@gmail.com>Path:
mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76398-linux-kernel-git=dewy.ruReferences:
<20261124172146.18330-1-okhuomonajayi54@gmail.com>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-can.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-76398-linux-kernel-git=dewy.ru
From: okhuomonajayi54@gmail.com (Okhuomon Ajayi)
Newsgroups: linux.kernel.git
Subject: [PATCH v5 0/6] notes: start passing the repository through notes.[ch]
Date: Wed, 25 Nov 2026 23:02:08 +0100
Organization: Usenet Network
Message-ID: <20261125220214.35881-1-okhuomonajayi54@gmail.com>
References: <20261124172146.18330-1-okhuomonajayi54@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
logging-data="315092"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:0v3alLUlW204DcS/iRzcf/+JxwY= sha256:KGffVj9bSnpa01H0n8x2gQfrxgz1H6R6BF8LVz/Z8Nc=
sha1:9G6se3pbzDVudS3YHV8WQtzOtUI= sha256:tC6oLUUj9c309qcKK7dTf9lVPK3D1NKmGeEs7RgSePM=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id F2748125EA3; Thu, 26 Nov 2026 01:02:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -2.049
X-Spam-Status: No, score=-2.049 tagged_above=-9999 required=6.31
tests=[DCC_CHECK=1.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id 9az-YqCFwqDa;
Thu, 26 Nov 2026 01:02:45 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-76398-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 86C9C125E9E; Thu, 26 Nov 2026 01:02:36 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 180052D980; Wed, 25 Nov 2026 22:02:34 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1795644153;
b=KJqBUrwb18DpbgjMh+b+5v/LRkMGaggt7Lur9BvaWd3Y3T3HB6ePGFA93Tkt42jQ2yEi
TpX7jmK/T2FciNH+Z/nmAq4ZCDipOsLTqvnaAmd+8x/3T0mgVhksii0NYvXj3Bk6nEe7J
xcLeC8HYGPuTqVcZcZrdPY2TauiiTehRvENJ7DVMXrDS1Ql04fER2A9SDEDht+c56Y7K6
2c8jwnrwkknlXkF12epzSNG51NGGZh/NWbCSHOwrNQ7rVjIRaEZhgryLUXUUQ2Fe98F+l
4gELyi4Bym9MMrXPCA6qmBLCiH6elw95nvO6Ud0+jwb5OG0veFdXMV2NeSm1Z4oDmLg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795644153;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Gm-Message-State:X-Gm-Gg:X-Received:
Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:
References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Transfer-Encoding;
bh=QW3JKu4Ju6ecGBFAob3aGqdbz2w3ML2gPpvKS3+j6Wk=;
b=y5+H3eIX5pG2bBKOjhxaq6XQL//EgscPENjJFv5I/VUOb8mP7/s+vskUgCJ5bCVinWmb
Qvg970HQIS71qrD2FL39Ioh5J4oXMgCFnNxlyb9czW/YMCUD1elAOWkoPEPV/9t4Wt0yt
lz+LfcGIT0SpWY8/RBEqlpOvSBuC5ZwQzNzzPsMPEv+g7ow0sLffWt9iW4QBwk7KkJr2r
Eu0gLg0BIRMtWOzQqoy7qy2QLXT1Lfo0IaeW9J8cgmOw5BIs5Og8cncT55AzXcEovevYC
h2l/NsseHE4h3iOdiybSjhPgEQoDDlKc8/TWifQanCAiilrwYL4aypNDQVxvFwhBMOA==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Wf9vrA1S;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id CEB36606A327;
Wed, 25 Nov 2026 22:02:33 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Wf9vrA1S
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.218.45
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1795644153;
b=FgDD+Abb0TQAnjvAX+RstkkCGJjmxaZ6F6f1zuX0MbYhFi+0QNvJTAgnhkyyvZnixrIT
erp8dV/nL/02pY4m5gnhbZcaTkzq6RbiJ444wEnMNCSyv2t40G6pe469mC2m12QnLPik+
8PW2US/frLlfMW4Zys8duBFS06VCYdNi69lk7gdQSp3f2nIMzbaSuR3yx/g1DkJl4K3m8
EGXnrBzRM1OMpuZ7RQIPhAvVU7owvOvU7YiS0CBXqgKAAZIHihdL8y5z4+MS1CMCXfbsl
7YsmKUZ7gqw/S+zybX3dgSRacJ81XC5MJDrqyUpSGlsohKH1r3UdGKBGlCDrOn48fIg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1795644153;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Gm-Message-State:X-Gm-Gg:X-Received:Received:From:To:Cc:Subject:
Date:Message-ID:X-Mailer:In-Reply-To:References:MIME-Version:
Content-Transfer-Encoding;
bh=QW3JKu4Ju6ecGBFAob3aGqdbz2w3ML2gPpvKS3+j6Wk=;
b=iEnfscABk+eixbl3VSaoRUH9b1FG1kdPGKdYC1T0MSvOHKzjVfYk1/cOe7DJdYxtVsyW
CW9+VJS9zy1K68HxQutOGmQvtTAalOvMXTohIxAtpd2jUUBdzMmhzM1LYI0tli9q8pRjb
TtSNCrlulJJSZYDx3Qih9OFF45V5Z/CczNL0DL2DPtFlzuUGR/A9d6yFod7dwxHM9NS9l
uMumT0sCWwC3IbBxa4arQuq32PNig+ltt2iKbgJmFnQGlsLRW3nsuysE/PA69j7SkyQUR
wja3PLtWp9P64oEFtsy+p3eg2VNO6eLuAdFbs4k7aUXQnKpnM96VgmZ3CafXbLzX1KQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=Wf9vrA1S;
arc=none smtp.remote-ip=209.85.218.45
X-Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8A9CF606A339
for <git@vger.kernel.org>; Wed, 25 Nov 2026 22:02:32 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 8A9CF606A339
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ej1-f45.google.com with SMTP id a640c23a62f3a-c5126505cb3so821792466b.0
for <git@vger.kernel.org>; Wed, 25 Nov 2026 14:02:32 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20260707; t=1795644151; x=1796248951; darn=vger.kernel.org;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:from:to:cc:subject:date
:message-id:reply-to:content-type;
bh=QW3JKu4Ju6ecGBFAob3aGqdbz2w3ML2gPpvKS3+j6Wk=;
b=Wf9vrA1SSEb8JDIv4oWKuMoOYS7KcRLWyEKpl0fVNNRPrwWAZ8Jza6FjBC5VqlYtnk
MdRZcABuyQ4j4REg6p0O9D1ILMTKOGwmVUkbif6Ljjq6LFDphmnd/pF5QQOTc2x0iWCW
RaYUKykjZp8fJYhyf5hCbNP1l6X3LBQPWBQ6Vwi/5ev6bnrEvqs4blwrBBX6VfsL5LFF
4p3OFyHLbylMyAx8QF9UxRDsFFyU3rDPmRBLdfB6iy9kZ071iZ2s1B7L1UHKBTtLoiw2
H8kA45cXXwF5NMn3Xkdl8AqIxD8TquXYoKWDG5fSZ3y2px06307yolXvkqrw24RO0uMY
tSfw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1795644151; x=1796248951;
h=content-transfer-encoding:mime-version:references:in-reply-to
:message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from
:to:cc:subject:date:message-id:reply-to:content-type;
bh=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F
g0IAydn1Vm3OWeaE6/bPaBAF74DN99n8K0BDyC5/sD01TsIJv3omHxOzki9A+Oxd7S9xepJPOqu
kEjXIkzAZ5pbiI94eXyeszXDdhd4d0B/HsMVa0OORf3D8iD7d6zN65JVdB7ODUnmPPB7veSlyjh
US6vZybcUZLj4yASCCuFDLwnttU5wdh31SHitZYS3pre7kjSqTjPXx5E+eZarnSjlNV6w3TzkQe
ltCgaTJFuPuprYmfHFQF6GtGc7xHo2
X-Received: by 2002:a17:907:3f05:b0:c41:e0c0:e6b7 with SMTP id a640c23a62f3a-c513a99a69cmr1411445166b.12.1795644150684;
Wed, 25 Nov 2026 14:02:30 -0800 (PST)
X-Received: from localhost.localdomain ([104.28.251.99])
by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c513aec3c60sm676998366b.50.2026.11.25.14.02.26
(version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
Wed, 25 Nov 2026 14:02:29 -0800 (PST)
X-Cc: christian.couder@gmail.com,
ps@pks.im,
gitster@pobox.com,
usmanakinyemi202@gmail.com,
siddharthasthana31@gmail.com,
kaartic.sivaraam@gmail.com,
okhuomonajayi54@gmail.com
X-Mailer: git-send-email 2.56.0
X-In-Reply-To: <20261124172146.18330-1-okhuomonajayi54@gmail.com>
X-Mailing-List: git@vger.kernel.org
X-List-Post: <mailto:git@vger.kernel.org>
X-List-Help: <mailto:git+help@vger.kernel.org>
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:git+owner@vger.kernel.org>
X-Precedence: list