🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #3997

[PATCH v7 0/6] notes: start passing the repository through notes.[ch]

#3997
From: Okhuomon Ajayi
Date: Fri, 27 Nov 2026 22:04
95 lines
15590 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:
 - 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, and the KEY_INDEX
   and SUBTREE_SHA1_PREFIXCMP macros in load_subtree() still derive their
   byte offset from the_hash_algo, so they need to move together with
   those helpers before a notes tree can mix hash algorithms.
 - 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.

Changes since v6:
 - Reword the reading patch's (3/6) log message, per review: describe the
   notes_tree_or_default() helper that an earlier patch introduced more
   directly, and mark the get_note() -> note_tree_find() call chain as an
   example.

Changes since v5:
 - Rewrite the reading patch's log message to give the wider picture
   first (the '.repo' member, the NULL-tree contract, and the entry
   points vs. the leaf helpers) rather than listing functions, per
   review.
 - Fix the helper patch's log message to call the function init_notes()
   at that step; the rename to notes_tree_init() lands in the next patch.
 - Note the KEY_INDEX and SUBTREE_SHA1_PREFIXCMP macros under 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 v6:
1:  1d17c6b7db = 1:  1d17c6b7db notes: add notes_tree_or_default()
2:  124381fdcc = 2:  124381fdcc notes: store the repository in struct notes_tree
3:  93afb08fb9 ! 3:  0dfe9934ce notes: use the tree's repository when reading notes
    @@ Commit message
         There is a catch in the notes API's NULL contract. Passing NULL in
         place of a notes tree is allowed and means "use the default notes
         tree", so a 't' handed around a call chain may be NULL and 't->repo'
    -    cannot be dereferenced blindly. The high-level entry points cope with
    -    this: add_note(), remove_note() and get_note() replace a NULL 't'
    -    with the default notes tree via notes_tree_or_default() on entry, so
    -    afterwards 't->repo' is safe. The internal format_note() does the
    -    same swap and initializes the tree if needed. The leaf helpers
    +    cannot be dereferenced blindly. A previous commit introduced a
    +    notes_tree_or_default() helper to cope with this, and ensured all the
    +    high-level entry points (except copy_note(), see below), as well as
    +    the internal format_note(), call this helper. The leaf helpers
         note_tree_find(), add_non_note() and load_subtree() do not check for
         NULL themselves; they rely on being reached only through those entry
    -    points (get_note() -> note_tree_find(), and note_tree_search() lazily
    -    unpacking a subtree through load_subtree(), still after the tree has
    -    been resolved).
    +    points (for example get_note() -> note_tree_find(), and
    +    note_tree_search() lazily unpacking a subtree through load_subtree(),
    +    still after the tree has been resolved).
     
         Given those guarantees, read objects and hash algorithms from t->repo
         instead of the_repository in note_tree_find(), add_non_note(),
4:  1cea119abf = 4:  494e142cf8 notes: use the tree's repository when writing and pruning
5:  1d2ecbe2a5 = 5:  2e38f08ca5 notes: pass the repository to the ref glob helpers
6:  8b59b9ba01 = 6:  30e785c788 notes: pass the repository to the combine_notes callbacks
-- 
2.56.0
Technical Details
Message-ID: <20261127220445.45639-1-okhuomonajayi54@gmail.com>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76548-linux-kernel-git=dewy.ru
References: <20261126213306.87466-1-okhuomonajayi54@gmail.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder2.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!git+bounces-76548-linux-kernel-git=dewy.ru
From: okhuomonajayi54@gmail.com (Okhuomon Ajayi)
Newsgroups: linux.kernel.git
Subject: [PATCH v7 0/6] notes: start passing the repository through notes.[ch]
Date: Fri, 27 Nov 2026 23:04:39 +0100
Organization: Usenet Network
Message-ID: <20261127220445.45639-1-okhuomonajayi54@gmail.com>
References: <20261126213306.87466-1-okhuomonajayi54@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="828785"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:mE6kSY5NVu4ZDLkHHhSbgkA6aTw= sha256:NqvRKmi2tBQdS8DFz6iDJZxxQrQ7XNFttIqhAw7YMHU= sha1:FaPDZ3RMOyLU01M5E7sI3VtIdz4= sha256:JRDASZpNUC03SCzrXi9ToEQiMUwWl/CcW9fxCEwSJdg=
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 585B6125F69; Sat, 28 Nov 2026 01:05:23 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -1.949
X-Spam-Status: No, score=-1.949 tagged_above=-9999 required=6.31 tests=[DCC_CHECK=1.1, DCC_REPUT_70_89=0.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 RuAtNPJOIVpS; Sat, 28 Nov 2026 01:05:16 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=git+bounces-76548-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 sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id 1DBFE125F66; Sat, 28 Nov 2026 01:05:07 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 48A492DF22; Fri, 27 Nov 2026 22:05:04 +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=1795817103; b=LhG0fsyyUHZjyydAzIotLMLQRARfX6Xg7OSKKqhnhgV4HX5q72Sbbzyx8/X9ncWqGp3q NPKLuvF1izqio7R9Q1hPWrOZ2sXlJuMOVyXPmQFqoESht7yUJ3s1O8DkuBcLAuxjjiJwf cFpfw3m0/LnhwTmWmsZ6k+5Hwlk0qTzr9CzJTQorh4mtMQ3PHSxhDIPK2hgG5CojIEXVD DYslxEKH6FyaFa0b5ZxgwCDKXWofvmcOIdkPYWSv04QLOkPpHliJk89XFu1i9LsKWzTbR vRU9/a4Yg8S0JidSP99AUP0emQv4VNojYIGtBP0wBdBeLos/szLKXkxeT/0zyiqpk3A==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795817103; 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=aWA6rugWTa1Abbj6YG4x9LNpOTs7X/JHD40B7NJ2RYY=; b=YpuaM5NVM68+8ufV5Cy2rLbgRQ/GGGa8RnbIAlJj6mBnSUFCZpFCBSYctaywbFKCulpv Jog5hUyUsgwZVftFEYWNzshSXVmADeN3s+NO9oAdunN9nPABv8s3vRIpsi+Z4fbu5kkIl ZKriMsV/xSb2JOGs76MysR89Rl1tExzi4dck19mwiC+rcciayrteTdDhvTp7TigyyNU7B Q+XMYeVZvjvkP21T9/tqm1m6Adoo8JN29Yki/9tIQ1GfWSYcxtpjPPWvXhcFqBldL0B7e L3GDHkAPmhJtYt9VWGFjQ2D0pH/avfViM4mULn5nu6MvbTwcL/xsfmyJh1HDJlvyd1Q==
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="icK/g5Iz"; 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 63C58606A32C; Fri, 27 Nov 2026 22:05:03 +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=icK/g5Iz
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795817102; b=K97VH4TEYcW3MJcYEpG+7oTzCAdMfFtJvVtOeTUHUjhTYJwfDBjREND4+jKhGqL4kdh2 20+64LPhQiss8NwhDlu79gbdQWPJlFMKAd/FLEWQxwLSXnniIfrgycKvKPTZrCl5ykk5Q 3+e19mONNiI/mLK9y1zEJ84wdsMW5Eq27oGEbQtmMssmvpnWoxtRtarTm+DGVjwHJ46dn PdjTk7/uYs+L0ki0zJHepoUumF5U7jnN3OwacNccavEawU1kCHfuckaxUly/Le0Q+GVEG LJAt8DqLVSaCXC6qha6YmltlwUsn5udYkbLXKQP3R85YprXh7GHTYMzqdQk1dPVQYBw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795817102; 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=aWA6rugWTa1Abbj6YG4x9LNpOTs7X/JHD40B7NJ2RYY=; b=1P/X1M6lyxWEbGeuyCji9egeZSh8WMFh3272FLEzOPF7g6+22T678q+POX/su0I2oJ+H XNbqme2nzkGLYyvqhYUjXvoJeRHvs6iu6KOuzorxnM5QLbkH1t/uZJLi2Os0+otfMRHKZ 90w97FHWT28/Y65VdDc/8Nlzq/uqo740xrSRik8Vn2/+1Kv0QjaesYMHNj0c5nA7Zs0pr WulEIFrZdg3vi1z6YTGgnQM5TmtUkgl36aO6v5qN+c2879sWmHmDmg48wwLQ6dywLY/9K C0sBbQLQcIEtW8D873TqjbzGO2nklujZVlhOjQu3f0L7pc4nF1OC0iUjo2Sq1a/o8bg==
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="icK/g5Iz"; arc=none smtp.remote-ip=209.85.221.51
X-Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 300D6606A323 for <git@vger.kernel.org>; Fri, 27 Nov 2026 22:05:02 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 300D6606A323
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-wr1-f51.google.com with SMTP id ffacd0b85a97d-48dfc0421d9so7776247f8f.1 for <git@vger.kernel.org>; Fri, 27 Nov 2026 14:05:01 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795817100; x=1796421900; 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=aWA6rugWTa1Abbj6YG4x9LNpOTs7X/JHD40B7NJ2RYY=; b=icK/g5IzXiS80Y1kf1QwAuAkZMnX6SomjKcMJ8Fag7luGXgcy5MV5mmUybsnH05WzV Tk/amVtfbS/5yYAZgm43MhEkegJpPRRmcYo9Ful21UiHDfok4uR5ivRckJGwSnjJ7EQw 7pecY8DUeghuPbOD4UySXTzaaWDDCA3groHld25PZdKW1ikLB4zWGwUf23l8glNACCnn jJzYs6XgH6552qcr32VZa6ujD8S57TRnkMvXX83pFN3ya+JUMCYNKHSki+SKnCmlj9wv cEGPqXVq5Gapgnez+/omeQUTPDgJmoWjCu+YNEsaXPmVObYXmy+TG83GQM8yfMxnrHsZ vgGA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795817100; x=1796421900; 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=aWA6rugWTa1Abbj6YG4x9LNpOTs7X/JHD40B7NJ2RYY=; b=xrKNfLmVjlLMqG2WjatM8R9NFERw+dBsW67SMoHRc6U3hbPPQs6Zq0q33AA6+D/iFa jXDxWy2k1SRHSYqDSttVH690WjRGOiFndGugO5MEg4vcnvI2/RZih5xgpL2NOsMJ6Frr 1vLtDQtG6b/TCi10gOo/WEMrfnUnOZ4HaeDu+47voixq6f2G5G/cd7C5aBDetSN2D6ft 7IZKELiTW7wRe/XG42Mau6Kci34r8Uei89qKTTPNSzoi8rcYMylEHWhUu91CLDkD6vJs 0ZCgUxWmBHQMJper1qjDdwB99SOePKdBMVNn3NwKJKJcKapcM+TW1XmEM4d32VfmcF1V klSw==
X-Gm-Message-State: APuU4Z8NH8GoYpSz19rOQIT55KGfBM+cyiOvY56czriZZJLSlgJnACn5 opP88YmQgmL6Pz8E3mfl59w4DGczAqWtYmjSvPUMlv/1I05ioczGKeXGjrcu0DyVKH8=
X-Gm-Gg: AZFdTZc6cKMSYunHsdfEbGUL/aszkmzD2ZU3wp3a9ICZZTWPqUbzoq6q7sI45u6ndsd sLi73vvi147IMGKaE2kUJaEnkRKh91P7MLfLX8zFFWnY813T+P9FFUayUBv/jTJSBd3VgVj4BX1 ZrTn/4N7FPEOqSn5mvhlUYVdczpmp4Ka7Al9S45G/GSgQBmNPPx6jijljdNgB/y5ZnhAG3/j/ZZ c/WVYPeF2UFhhUaWZ4b9CxQ89ZNcWcLVcwwBJxdzbfXLEdlUMASQR/YBTuvf5dIZi/gNH/qzJf/ rOtLtnRpgr1FlsJgE3zjyVeOFiDT5q6YYw5fMI0WDUcmg3AgOtBIBkWm8GfiUJhcFUP6dE0oI4v S5YHyHCsIcLtxwCVhQj/WhfozcDyG8FhNY1TKSnJYmjq8pYlArhfBpxWUO35zFRP6it9k6S+mtL Zlm5oDAB7c51ioxvyKa96YFGV+7mMRPQHL+1rpnn9382J9TL0YQo8CcfbKQIYCnqCpgJGwd1lal mXcFwZFmbZzdw/ZgAuPlQdnlJQsZISEYbTzu4CtN+6khTXxYQzNEYpAtO0kSXXQ9XIT/hLJ4wQv 6v45JU2scB3QTzhn9cnE77V7kenuHT3Lb9Ula2fL/naZDEhWXHqcFcXDjMyk2bRargxKEEHD5tp C1Yy2sBQNmHfZHxvJhTw3wikwTFsAoOZuYtuD/ZAa1USxUV9F86vssQ+rJX+EbZwO8VdeZeAQ61 tE6JSZ9DfHjkQJW4QSNCE6D//k9Jfx2g==
X-Received: by 2002:a05:6000:4b15:b0:48d:df08:307c with SMTP id ffacd0b85a97d-4abb8ac0d92mr44673843f8f.44.1795817100287; Fri, 27 Nov 2026 14:05:00 -0800 (PST)
X-Received: from localhost.localdomain ([104.28.251.98]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab658e2d1bsm51467422f8f.8.2026.11.27.14.04.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 27 Nov 2026 14:04:59 -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: <20261126213306.87466-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