From: kristofferhaugsbakk@fastmail.com
To: git@vger.kernel.org
Cc: Kristoffer Haugsbakk <code@khaugsbakk.name>
Subject: [PATCH 09/12] diff-tree: flush each diff when --stdin
Date: Wed, 2 Dec 2026 23:14:17 +0100 [thread overview]
Message-ID: <flush_diff_--stdin.df8@m5gid.xyz> (raw)
In-Reply-To: <CV_diff-tree_NUL_termination.def@m5gid.xyz>
From: Kristoffer Haugsbakk <code@khaugsbakk.name>
'git diff-tree --stdin' handles both commits and diffs. The commit case
is handled by log-tree.c:log_tree_commit. That method calls
maybe_flush_or_die(...). That means that with e.g.:
git diff-tree --stdin --patch -Z
We can feed a commit to the commit and read it back in a loop without
riskig deadlocks.
The diff case, on the other hand, calls log-tree.c:
log_tree_diff_flush(...). That function does not call the
IO flush function.[1]
Let’s call the IO flush function so that we are guaranteed to read back
a diff after each input immediately, just like with commits.
† 1: The “flush” in the name is because it calls diff.c:diff_flush
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
builtin/diff-tree.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index c7734f7be63..d516c496521 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -11,6 +11,7 @@
#include "revision.h"
#include "tmp-objdir.h"
#include "tree.h"
+#include "write-or-die.h"
static struct rev_info log_tree_opt;
@@ -60,6 +61,8 @@ static int stdin_diff_trees(struct tree *tree1, const char *p)
"", &log_tree_opt.diffopt);
log_tree_diff_flush(&log_tree_opt);
log_tree_nul_terminate(&log_tree_opt);
+ maybe_flush_or_die(log_tree_opt.diffopt.file, "stdout");
+
return 0;
}
--
2.56.1.5.g155936fbb2a
next prev parent reply other threads:[~2026-12-02 22:17 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 22:14 [PATCH 00/12] revision: learn -Z for NUL termination kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 01/12] t4205: use correct 'setup' keyword kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 02/12] t4205: add test coverage for NUL separator and --patch kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 03/12] t4205: test blank line between commit and diff explicitly kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 04/12] t4013-diff-various.sh: test --stdin -z --patch kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 05/12] log-tree: terminate cmt+diff when " kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 06/12] t4205: test --diff-merges kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 07/12] revision: learn -Z for NUL termination kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 08/12] revision: split out termination character kristofferhaugsbakk
2026-12-02 22:14 ` kristofferhaugsbakk [this message]
2026-12-02 22:14 ` [PATCH 10/12] doc: diff-tree: tell about --no-commit-id in Description kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 11/12] doc: diff-tree: add Examples section and mention --stdin kristofferhaugsbakk
2026-12-02 22:14 ` [PATCH 12/12] doc: rev-list: complete diff-tree by mentioning --always kristofferhaugsbakk
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=flush_diff_--stdin.df8@m5gid.xyz \
--to=kristofferhaugsbakk@fastmail.com \
--cc=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
/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