From: "Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: gitster@pobox.com, peff@peff.net, newren@gmail.com,
Derrick Stolee <stolee@gmail.com>,
Derrick Stolee <stolee@gmail.com>
Subject: [PATCH 5/6] json-writer: include strbuf-safe.h
Date: Fri, 18 Sep 2026 13:02:19 +0000 [thread overview]
Message-ID: <6e654dcbac2ac1b6c4d5311e64ce516d0bded0fb.1789736540.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.2230.git.1789736540.gitgitgadget@gmail.com>
From: Derrick Stolee <stolee@gmail.com>
We will use json-writer.c as our first 'safe' API, after removing some
unsafe methods that reach die(), especially the strbuf API. However, the
fact that json-writer.h includes strbuf.h causes someheadaches here.
Normally, we would only declare 'struct strbuf;' as a way to anonymously
define a struct and have implementations include the full header as needed.
However, 'struct json_writer' needs the full struct info and
JSON_WRITER_INIT needs access to STRBUF_INIT.
Thankfully, both are included in strbuf-safe.h, so we can have the header
include the safe API and move an include of strbuf.h to json-writer.c.
However, this has some implications to the trace2 API that includes
json-writer.h and implicitly depends on that includes of strbuf.h. Have
those files include strbuf.h directly to compensate.
Signed-off-by: Derrick Stolee <stolee@gmail.com>
---
json-writer.c | 1 +
json-writer.h | 2 +-
trace2/tr2_tgt_event.c | 1 +
trace2/tr2_tgt_perf.c | 1 +
4 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/json-writer.c b/json-writer.c
index 34577dc25f..e7fc5775da 100644
--- a/json-writer.c
+++ b/json-writer.c
@@ -2,6 +2,7 @@
#include "git-compat-util.h"
#include "json-writer.h"
+#include "strbuf.h"
void jw_init(struct json_writer *jw)
{
diff --git a/json-writer.h b/json-writer.h
index 8f845d4d29..fa8cf02253 100644
--- a/json-writer.h
+++ b/json-writer.h
@@ -70,7 +70,7 @@
* of the given strings.
*/
-#include "strbuf.h"
+#include "strbuf-safe.h"
struct json_writer
{
diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
index 36a746cc10..b25fa0fb30 100644
--- a/trace2/tr2_tgt_event.c
+++ b/trace2/tr2_tgt_event.c
@@ -5,6 +5,7 @@
#include "json-writer.h"
#include "repository.h"
#include "run-command.h"
+#include "strbuf.h"
#include "version.h"
#include "trace2/tr2_dst.h"
#include "trace2/tr2_tbuf.h"
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
index 96a5bc7f10..5554081c3c 100644
--- a/trace2/tr2_tgt_perf.c
+++ b/trace2/tr2_tgt_perf.c
@@ -7,6 +7,7 @@
#include "quote.h"
#include "version.h"
#include "json-writer.h"
+#include "strbuf.h"
#include "trace2/tr2_dst.h"
#include "trace2/tr2_sid.h"
#include "trace2/tr2_sysenv.h"
--
gitgitgadget
next prev parent reply other threads:[~2026-09-18 13:02 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 13:02 [PATCH 0/6] [RFC] Create a 'safe' strbuf API Derrick Stolee via GitGitGadget
2026-09-18 13:02 ` [PATCH 1/6] strbuf: add header for 'safe' API Derrick Stolee via GitGitGadget
2026-09-21 21:18 ` Junio C Hamano
2026-09-23 19:25 ` Mark C. Chu-Carroll
2026-09-23 20:14 ` Junio C Hamano
2026-09-18 13:02 ` [PATCH 2/6] wrapper: initialize GIT_ALLOC_LIMIT proactively Derrick Stolee via GitGitGadget
2026-09-18 13:02 ` [PATCH 3/6] wrapper: create safe_memory_limit_check() Derrick Stolee via GitGitGadget
2026-09-21 21:24 ` Junio C Hamano
2026-09-18 13:02 ` [PATCH 4/6] strbuf-safe: add sstrbuf_grow() Derrick Stolee via GitGitGadget
2026-09-21 21:29 ` Junio C Hamano
2026-09-18 13:02 ` Derrick Stolee via GitGitGadget [this message]
2026-09-18 13:02 ` [PATCH 6/6] strbuf-safe: add init and release methods Derrick Stolee via GitGitGadget
2026-09-21 21:44 ` Junio C Hamano
2026-09-21 22:34 ` Junio C Hamano
2026-09-19 15:23 ` [PATCH 0/6] [RFC] Create a 'safe' strbuf API Phillip Wood
2026-09-23 19:46 ` Jeff King
2026-10-06 14:33 ` Derrick Stolee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e654dcbac2ac1b6c4d5311e64ce516d0bded0fb.1789736540.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=newren@gmail.com \
--cc=peff@peff.net \
--cc=stolee@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox