From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.154 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796249667; b=BC+4BWa0fcFOzjcl/IxXGqXXAMjsDwBiCprSVwZ561C7sY+GU77wsleSQDxQ5uOLL/3V JcZDXAvCOibre4MeH/rJNszm4fT6amqNPtUIvl7qKorMJMhIVC73sh/YqN5SgvXVqWaUg MI3pRGl8m1OZ1clOvBBmNEOLlTzqP5Ojy2sVeAyU05i5g0akK1hX1n1WynpdaoO1GyTcb wp6a9GW/dKmip0EQNR56T2dndCA9CzOzu0KWPOmSk68k9ocIVTPL3PBzol0jMpUpIYnLB GUT0Kmpw0iY+O0fMo10ConY8FlLQT+gRptba06pdOk96V5pgdfnkDzUx4QCauBlSlqQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796249667; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Type:Content-Transfer-Encoding; bh=oIhJBjuq0lDDq9GVpfA4Y8IKAwrfzENDlbziOO6lvdA=; b=Q7s3zd6/tgVo88HED/imlevqOuGiHhViS5afJ1J6S4xSXqHDiSLS3r538m2oxNsMLvhi +Am+dWFnxLWNoxUNCtysTWr08tIilDAT1Zq6tdf1JvM5kSjCjz+ur+QMmCY/n3kIb/cwX nSRCT25iQOxctKiIQSFkg8U1FUyEB6xI7jY0QRW4e0BFIMRZ4Om80wKsHk3vy7M9jr4wM gFrdAfmvYhMMNHGrCiW4echv9ekbDRlOArHtXnH7FjJM2Dy81Kkny0WoBnKK1u3+13gKV tnafXn6JgeH++Rbxrt85iSYFLRYWYrXV+gIPAY4kBBCQyyopBC80F0RWAAJy8LYXtcQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=fastmail.com; spf=pass smtp.mailfrom=fastmail.com; dkim=pass header.d=fastmail.com header.i=@fastmail.com header.a=rsa-sha256 header.s=fm3 header.b=AOzKJkkr; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=RWhClsBw; arc=none smtp.remote-ip=103.168.172.154 Received: from fhigh-a3-smtp.messagingengine.com (fhigh-a3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6B673606A32C for ; Wed, 2 Dec 2026 22:14:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 6B673606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=fastmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fastmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=fastmail.com header.i=@fastmail.com header.a=rsa-sha256 header.s=fm3 header.b=AOzKJkkr; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=RWhClsBw Received: from phl-compute-01.internal (phl-compute-01.internal [10.202.2.41]) by mailfhigh.phl.internal (Postfix) with ESMTP id 6A588140011E for ; Wed, 2 Dec 2026 17:14:25 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-01.internal (MEProxy); Wed, 02 Dec 2026 17:14:25 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:message-id:mime-version:reply-to :subject:subject:to:to; s=fm3; t=1796249665; x=1796336065; bh=oI hJBjuq0lDDq9GVpfA4Y8IKAwrfzENDlbziOO6lvdA=; b=AOzKJkkr1pLeCz6GbJ mGzLUSFy4BfI1uYWfXWhRIZ6ldh3zawWflT2xxXPxkAsJIuB36fJBF3I9+NZq5fJ A/RRO08W0x/jrXINCzk/JqHSYfoPY0y/2KBJN5SQ1e9yCv7gs/2d0xjdfAezpEui Xhz+GsNSTAgpZ8wsxbhEAat33HqMb3I73ybiPVYLnpS6Ar3SqpvoZnx8ssjgLhB1 kD1nnzc+ekuR9saMjN5lZkOMwuRRolqXI522CCjRfiiG00/uPCuLu3Hp+sQZA7RS sA/VoL4H9xamYr0jKgqPkJNGY59poM57AZweS564Hvr5aD1FbLB5gNZ0pskdaCNc b/NA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:message-id:mime-version:reply-to:subject :subject:to:to:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1796249665; x=1796336065; bh=oIhJBjuq0lDDq9GVpfA4Y8IKAwrf zENDlbziOO6lvdA=; b=RWhClsBwbsMWqfP6mKXpvsrvxYxI8wjXDTB8JiTYEi64 l4XVXYWfgbXQtIGQY89EcB5xIVVNcU+bJRN1Ic2Xp1H240j4o4JB7nl7fNk1bUWJ PRH0dN8U+UmSuJ1dlhi4cKocMMi5mvxAp0jWpdYIxa3yEtJqcyw8RzYA+qlbVFJ+ ejqJ55nZPmCnj76QGQajyvMHySJH8dBWnAzKXMMCpEHm8XAorz4CNusphOPCh8MK 9XwbeECnj91Kd7jXn4DDjYi3PmrIqozZh8WDyBTWnxbS6UEysgqsc/vmJJE5+ZpX 2801j/kGrxRX5AUbrJSYZMbCVf/mIMIrpNL/wBdtpw== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=fastmail.com a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1796249665; d=fastmail.com; mf=PGtyaXN0b2ZmZXJoYXVnc2Jha2tAZmFzdG1haWwuY29tPg==; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:EJuYmNj6HuUkA+pYUcOjPP2lWfGXF2NFntkCDQ+c/J/ifHt Y9ZIPoJX/BXI2kC975f6R6nBlkj+yDa1AtpX37vi0em1Ewobwbc/LuBz/G4ZhGhc XBctGCVwU8z939XWokZdZaVVtVmf3uqZLJbx62x8qE45Rf27Qv+EOJZDtLA1GuJ0 jZcOwdqNw6LPBfXOJ42zAVOHMDbMXS0lY6qltAjV/QNPe4rOPlLQT0TcLDGvfsVs +zrFGlEOv4c31Zafcpnmt/y19sdG4Ur+vPpHFXCYvUZ1suLIwk6MRCyA5+/EOsyM Iki/jOBDo/7+ZwjgFra6KZBf1ywG8uz5EU5hpbA==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=10; hn=cc,content-transfer-encoding,content-type,date,feedback-id, from,message-id,mime-version,subject,to; Message-Instance: m=1; h=sha256:eU4r+ZkR4u90gJKlYoCTpXn1q2ouVQ3WHFzbUj5tyJY=:PKI5ZD+nsLuOpMagq2NKWKUtLx/6BIP5O8f369P/8ms=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTEO9xEA/BEO0TuE8EK9nI4XTtRAtRjpD9gQkhzcE7oUU0Uk8MiDwBnjK92JypXXpk ETyYK7i3gzWbkXOtZ5JnmJNg+sPOeQ/7Znk7vf0CtOWEslmnUEaIAV9XZjgtsICjZzzOkz fgpGFjdsqfvencjU3b6PY8Edi66kzX/5yJpCBunGoxOoMVJV4j42FMxD88LcSfN6aTsEpb K+sh2hh3jrX2Ofzhel84OB7XqgSGXXxHQmB+Kk0BG30+w22tyP3nW1ccrqob0a3RYKfnnb uO5VbXPfZV7DliOxyxwNtH/blcRb1X3Y2sgoP9bWNk/UONRbIF9AnfannBrqLaJz8PvdJ4 l2xSz+sT3SHwsscYNSTC2ePgzycanCduhRbIWcMmFbv15xC8sUMN4EhzZ/y492BQEywN/T 9RfPHiayHxQkONsryuyffL2gsxjTc9YXdZu8ABzVRX+nH6ZRfmXfDIHw5To2p1isEkhZkU I/7u7WjcGxQn2n6CW20i9BZc3XtJbJcLAXRj6WD8oFz5vdDjZaBRNdySet1p5Qduv7ANTX 1TjpUBVrgKUWX4DJ4z63CVrANElUo6y+WbnMETagAlpD8FPTlzxXndqK/85dDx4HyV0O0l Wxax9WqvHQQwsbS1t1vU9jpk6nPYcKaSfOWgtHU39FXeMgm3/V+VoBnbdZ9Q X-ME-Proxy: Feedback-ID: i8b11424c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 2 Dec 2026 17:14:24 -0500 (EST) From: kristofferhaugsbakk@fastmail.com To: git@vger.kernel.org Cc: Kristoffer Haugsbakk Subject: [PATCH 00/12] revision: learn -Z for NUL termination Date: Wed, 2 Dec 2026 23:14:08 +0100 Message-ID: X-Mailer: git-send-email 2.56.1.5.g155936fbb2a X-Mailing-List: git@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Kristoffer Haugsbakk Topic name: kh/revision-nul-termination Topic summary: Commands in the git-rev-list(1) family support NUL delimiting commits. NUL delimiting is handy when you want to process each commit at a time (cf. just run through all via a pipeline). But this NUL delimit support lacks in ergonomics, is fragile, and inconsistent. Introduce `-Z` which NUL terminates commits and is decoupled from the NUL handling internal to diffs. This started when I wanted to replace git-format-rev(1) with simply using git-diff-tree(1) with some options that I would have never guessed. But I found some problems:[1] But I was wrong again. git-diff-tree(1) supports NUL for pretty printing (`-v`). I was only looking at one single output. But with “separator” delimiters (either newline or NUL) there is no delimiter for one single record (output). That’s why it didn’t show up for me. (thanks `cat -A`) But the separator behavior is a problem. Because when consuming input piecemeal (like reading from a shell coproc) you need a terminator. But the `log-tree.c` functionality very diligently keeps itself to using separators: 1. You feed one commit: you get the output with no delimiter 2. You feed another one: now there are two output records so a delimiter is needed. *Then* a separator is printed right before the record 3. Repeat 4. Of course the final record will not have a delimiter at the end I experimented with forcing terminator behavior but it seems that git-diff-tree(1) is just unwilling. This patch series adds `-Z`: • NUL delimiter • Termination. This is needed when you want to read each record and act on it. Reading up until NUL avoids deadlock risks.[2] • Cf. separator which does not add a delimiter after the final record • Also, every separator is emitted “lazily”, at the start of the *next* record • The standard logic chooses separator if no custom format and terminator for custom format. (You can also get separator with a custom format with `--pretty=format:`.) So you effectively cannot get termination with the built-in formats. • Both the commit message as well as the commit acts as a record. Or just the diff, of course (git-diff-tree(1)) • Things like `git log --format=%s --patch -z` terminate after the commit subject, then the diff, then the commit subject, termination, and repeat. This is inconsistent with plain `git log -z` (default format), which delimits the commit message and diff as a single unit (record) (see abd4e222 (Fix "git log -z" behaviour, 2007-02-07) • Decoupled from the `-z` diff behavior, which adds internal NUL to the non-patch diff formats like `--name-only` and `--raw` • But you can pass `-Z -z` and get both This is a new `revision.c:handle_revision_opt` option, but the utility is focused around git-diff-tree(1). Also no backticks in the commit messages.[4] And less code-quoting overall. 🔗 1: https://lore.kernel.org/git/238e5652-e95b-4d44-a900-e16aa6ab81f0@app.fastmail.com/ † 2: I learned this while working on git-format-rev(1)[3] 🔗 3: https://lore.kernel.org/git/e8bb57a2-8eff-4f72-96ca-72d8880901e0@gmail.com/ 🔗 4: https://lore.kernel.org/git/xmqq33sme4u5.fsf@gitster.g/ [01/12] t4205: use correct 'setup' keyword [02/12] t4205: add test coverage for NUL separator and --patch [03/12] t4205: test blank line between commit and diff explicitly [04/12] t4013-diff-various.sh: test --stdin -z --patch [05/12] log-tree: terminate cmt+diff when -z --patch [06/12] t4205: test --diff-merges [07/12] revision: learn -Z for NUL termination [08/12] revision: split out termination character [09/12] diff-tree: flush each diff when --stdin [10/12] doc: diff-tree: tell about --no-commit-id in Description [11/12] doc: diff-tree: add Examples section and mention --stdin [12/12] doc: rev-list: complete diff-tree by mentioning --always Documentation/git-diff-tree.adoc | 43 ++++++++++ Documentation/git-rev-list.adoc | 3 + Documentation/rev-list-options.adoc | 12 +++ builtin/diff-tree.c | 4 + log-tree.c | 35 ++++++-- log-tree.h | 5 ++ pretty.c | 8 +- revision.c | 7 ++ revision.h | 7 ++ t/t4013-diff-various.sh | 72 ++++++++++++++++ t/t4205-log-pretty-formats.sh | 127 +++++++++++++++++++++++++++- 11 files changed, 312 insertions(+), 11 deletions(-) base-commit: 1891de46f79dc444a47db1c87bd0c8c76b5463f2 -- 2.56.1.5.g155936fbb2a