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=1796249805; b=2NyjBnwxhP/EJpowpD3jROOj19bAbAvoSmUv4TVhr0UgPyj2alVVjG6N36ogn+ERRSxJ nJ36p/OIX/WxVnEj13dnC02Mt8wyJv++YF0jfwg0w5K97xb+ewiij34qBtDhXXbbAg1oc 8EbpI5OuCOX1F/ixrfCrIPkRncirKh4zhq2shcIPMMn7u2lzSW6hoappGk1sEQKK+4DfD BbX02n+Y5Zz1KMY8Q9VJfaB7WiV7SHm4twDLkV/BBZOvryfDM/jxIoapjzaUnmhAFN1Tm 33pPaXDb4ehEGV/E55sMHAeHeLfaSMl+RYriPaZx3Rr+DAB8baMrkKrv0pT0A4+zl1Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796249805; 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:In-Reply-To: References:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=7QPFek1BW8A40BMj+WVdcTjsBGDBMRaH4y0yAoyM+Os=; b=MLzajKX0jjjjcuOzqHdr8jVD/ycrUkuQbkn+hsIZdV6PeWsv5R/zUXeIQaO0fQ1jP5HL hfzSKV4WgMTj1bi//RLDqJS2j+qKMyEnDD3VQCPa00/hB8QQ9M/v18ehVb2/dv1SyA1Fk kAIASxeS+O7EYiczTrgJlRnY90vcO1EH67CSwnlKs/YtQFbYthvg821RyieXb7MebdGKF R/0OophtC3iEw+nV+fc76qcWiZ97oHBb7VFFNNuz85bSG/HkNw9OvGzhPO/MW0jySMYk1 eipu6B0Z3xD8q8udwIhRrcK8RRaU9gN4+qaE3hErEY6kJJGsisJQ75P5GeVF50H3hlA== 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=YctDfQuG; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=HFdsWJdj; 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)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2CDA7606A339 for ; Wed, 2 Dec 2026 22:16:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2CDA7606A339 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=YctDfQuG; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=HFdsWJdj Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.phl.internal (Postfix) with ESMTP id 5FD2E140011E for ; Wed, 2 Dec 2026 17:16:44 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Wed, 02 Dec 2026 17:16:44 -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:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1796249804; x=1796336204; bh=7QPFek1BW8A40BMj+WVdcTjsBGDBMRaH4y0yAoyM+Os=; b= YctDfQuGEgLWle7o44hsNllTFXeDMHPCahdffvNjruiCDXmqRWbTn0dBi3Ob0+le ysXjP15DKP0MZibNRcBjNKnAIQhLdsuSB6+mxQ2J9w4Wm37PTu+bDKIdXd7iRWIK /j35AvFzIDiKDPxZYi381Cmp8Ceg+il1sYK0IKvw+fP5ANrPj/IyT7K4kR0lluYi ZkDCz6BEksWU2vTTSk58huIbPs/4yT7bc548cMioB7U5DsL0IH4MEUNkkYEMcBKs 0aY/IcwSWwHDN0pk4hpowoRwh3yZ4qiQajk3i2RZrBpoz+1YSRIAmXrwcqrQpqRu A/rBJWw8vhh95GZ5YbObbg== 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:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1796249804; x= 1796336204; bh=7QPFek1BW8A40BMj+WVdcTjsBGDBMRaH4y0yAoyM+Os=; b=H FdsWJdjr28yTlnrOycE16Vxj0oIsCLhkHuVsG/XdjWjnj65tnHQZ8xLhFpJoM1MS 0Mz0PAjjgJNE5jKeFBGtoy80N/OvXa6eThyP+4imAyZug6k8mwz7PJgh3IoQokKa eLJ9c2KBXUzMBT5xijX2BoA9rUopHN84drrswuWN8Xcf9SeADF5rOm1kOJaaf7XB E18/a2lVKeWDrEoIcLJtjX+QjBT3AgQduNJP+UnvPhOLTzmcAIEk/aoDV/vLYUJa rjAzuz0qcLh2orEEg4Ionuzl2hGlAOcc9GKhqgE6E006u5vzJAM9KdTOsiiLn8FW iwxRI196qql3/rerotM7Q== 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=1796249804; d=fastmail.com; mf=PGtyaXN0b2ZmZXJoYXVnc2Jha2tAZmFzdG1haWwuY29tPg==; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:A6iTNXj/XiBOI/DI+alIDCu0bjFbFhdbmbU/eABYeq4xtpn Rm3mjmOgjpTzXkfyxKF5GQyWhWJuTRCeOGcIEnakf30z4qWgcQ/cW5Hx9RuNZzKc Uuq6ICzZQ7HdxlkazHmNHh0irE7trwoescUAP+W8E6rr6Jeaq47IHG1kedet3/gp rb4+xuMTys/qLTXps+dxKnS8AuxSF51+DtyEQJT56fZvqXAX3ecLIh5YF6vVg0+a gRvfwlibtOwKxsrUYK/t8mgLxyblvbe/8suy34gKw898i79Tcm4pspS7S3ijD1S+ S87/DOpxbGW5f3Z07SCfxIoCSHZYGsIc0a4KK6Q==; 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=12; hn=cc,content-transfer-encoding,content-type,date,feedback-id, from,in-reply-to,message-id,mime-version,references,subject,to; Message-Instance: m=1; h=sha256:ItvZm1MHIgyTS9CPnL9U6BFSAKEDtRCqkDVwf4qBz3w=:zU1nkvRpu4kiyYdVLHMnQ3yQVuq5+s0fxwt7kgvLbDQ=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFdGC2aTRE+edtzaYLBlfGqn7EcboGyYkzh+OgeH7RZr6UPZmIKNDkBy/nhYkwXmd txIZc//ogOEJhcwo1ts9LDx5db7uFGkq/rYK1rw9tcO7t0hw2w7DPQpcLlNkRbGNS2Kq1W ROVdZ//SPC6Z22Dg+t3G9ZVfmGOoknPz+VQWYA1mEN0VK+KEminVuYhfHrluh0hW5iD878 N9ucLDPi+B81yAKIah1SV6etBE3P5cFahDaoXoNJtnW1ZomV7pxVy5TrzyYRDSpm9bgwAW svCTx4rr4FdIa6wbiKZ0OtYfgCoG85pH851JQWPx+CJg7UwpPrsbNiLLWmVoHMn3BZ9Uj+ tjN39+/RRJ4CTSrLdvtFWgVGXdp//qaEbAWJj6WmoztOGPzMo51z31FlIqDMuntqipbpKC hfgTtRNxbCbeHzl4ibpZK4B0pezR+OCeQjlcPkdBo1+NzTQukiCsdgiDavH09qCiwXe8qn 1He8Kq88qwGQ+BWYjMPnYoCvIANamhiziOEr5GwwgHzBg9Ospuw7LFtE3TJlSUzWabd6x8 +fa6dG54TmBuylGlGKEI54REbL1//GQ8sRoMpPs0s1jLaEtl3B7SupXg8Tau5TAm7hJVI0 0sEdOC2AGah6f+LjgY+BW6Qdz3waykL4pQ8UqdHFVWTKxCIpAnb34Qg5TuSA X-ME-Proxy: Feedback-ID: i8b11424c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 2 Dec 2026 17:16:43 -0500 (EST) From: kristofferhaugsbakk@fastmail.com To: git@vger.kernel.org Cc: Kristoffer Haugsbakk Subject: [PATCH 08/12] revision: split out termination character Date: Wed, 2 Dec 2026 23:14:16 +0100 Message-ID: X-Mailer: git-send-email 2.56.1.5.g155936fbb2a In-Reply-To: References: 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 log-tree.c uses struct diff_options.line_termination for the commit record termination. That means that options -z and -Z give you both NUL commit record delimiting as well as NUL in non-patch diff formats. The -z behavior has to stay that way for backwards compatibility. But with the new -Z option we have an opportunity to split out this behavior so that -Z only means delimiting commit records and does not affect diffs; if you want to NUL-terminate diffs as well you can use both -Z and -z. Let’s store 'delimiter' in struct rev_info and use that in log-tree.c. Let’s also add -z to handle_revision_opt(...) that acts like -z in diff.c for struct diffopt and also sets 'delimiter' appropriately. Signed-off-by: Kristoffer Haugsbakk --- Documentation/rev-list-options.adoc | 4 ++-- log-tree.c | 21 ++++++++++----------- revision.c | 5 ++++- revision.h | 2 ++ t/t4013-diff-various.sh | 13 +++++++++++++ 5 files changed, 31 insertions(+), 14 deletions(-) diff --git a/Documentation/rev-list-options.adoc b/Documentation/rev-list-options.adoc index a4bf96e7d0a..4ba410c5e06 100644 --- a/Documentation/rev-list-options.adoc +++ b/Documentation/rev-list-options.adoc @@ -405,8 +405,8 @@ Note that separator/terminator behavior is usually set when using `--pretty` or `--format`. These have no effect when this option is given. + -This implies `-z`, so diff output formats like `--raw` and `--numstat` -will also contain _NUL_ internally. +This does not imply `-z`, but `-z` can be passed as well in order to use +_NUL_ internally for diff formats like `--raw` and `--numstat`. History Simplification ~~~~~~~~~~~~~~~~~~~~~~ diff --git a/log-tree.c b/log-tree.c index 5dcee870be0..e9ea5620e9b 100644 --- a/log-tree.c +++ b/log-tree.c @@ -764,8 +764,7 @@ void show_log(struct rev_info *opt) putc('\n', opt->diffopt.file); graph_show_remainder(opt->graph); } - if (opt->use_terminator && - opt->diffopt.line_termination == '\0') { + if (opt->use_terminator && opt->delimiter == '\0') { /* * NUL termination means that we postpone the terminator. * But we do want a newline between the commit ID and @@ -774,7 +773,7 @@ void show_log(struct rev_info *opt) if (opt->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT) putc('\n', opt->diffopt.file); } else { - putc(opt->diffopt.line_termination, opt->diffopt.file); + putc(opt->delimiter, opt->diffopt.file); } return; } @@ -782,8 +781,8 @@ void show_log(struct rev_info *opt) /* * If use_terminator is set, we already handled any record termination * at the end of the last record. - * Otherwise, add a diffopt.line_termination character before all - * entries but the first. (IOW, as a separator between entries) + * Otherwise, add a ''delimiter' character before all entries + * but the first. (IOW, as a separator between entries) */ if (opt->shown_one && !opt->use_terminator) { /* @@ -798,10 +797,10 @@ void show_log(struct rev_info *opt) * never want the extra graph output before the entry * separator. */ - if (opt->diffopt.line_termination == '\n' && + if (opt->delimiter == '\n' && !opt->missing_newline) graph_show_padding(opt->graph); - putc(opt->diffopt.line_termination, opt->diffopt.file); + putc(opt->delimiter, opt->diffopt.file); } opt->shown_one = 1; @@ -931,8 +930,8 @@ void show_log(struct rev_info *opt) * Termination is postponed for NUL in case there is * diff output after the log message. */ - if (opt->diffopt.line_termination != '\0') - putc(opt->diffopt.line_termination, opt->diffopt.file); + if (opt->delimiter != '\0') + putc(opt->delimiter, opt->diffopt.file); } strbuf_release(&msgbuf); @@ -991,8 +990,8 @@ int log_tree_diff_flush(struct rev_info *opt) void log_tree_nul_terminate(struct rev_info *opt) { if (opt->use_terminator && - opt->diffopt.line_termination == '\0') - putc(opt->diffopt.line_termination, opt->diffopt.file); + opt->delimiter == '\0') + putc(opt->delimiter, opt->diffopt.file); } static int do_diff_combined(struct rev_info *opt, struct commit *commit) diff --git a/revision.c b/revision.c index 1d2a10267ca..e9c10c354e0 100644 --- a/revision.c +++ b/revision.c @@ -2755,10 +2755,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg if (revs->repo->fetch_if_missing) BUG("exclude_promisor_objects can only be used when fetch_if_missing is 0"); revs->exclude_promisor_objects = 1; + } else if (!strcmp(arg, "-z")) { + revs->delimiter = '\0'; + revs->diffopt.line_termination = '\0'; } else if (!strcmp(arg, "-Z")) { revs->want_terminator = 1; revs->use_terminator = 1; - revs->diffopt.line_termination = '\0'; + revs->delimiter = '\0'; } else { int opts = diff_opt_parse(&revs->diffopt, argv, argc, revs->prefix); if (!opts) diff --git a/revision.h b/revision.h index c6598ba6f22..337ba08e553 100644 --- a/revision.h +++ b/revision.h @@ -284,6 +284,7 @@ struct rev_info { force_in_body_from:1, encode_email_headers:1, include_header:1; + char delimiter; unsigned int disable_stdin:1; /* --show-linear-break */ unsigned int track_linear:1, @@ -444,6 +445,7 @@ struct rev_info { .max_parents = -1, \ .expand_tabs_in_log = -1, \ .commit_format = CMIT_FMT_DEFAULT, \ + .delimiter = '\n', \ .expand_tabs_in_log_default = 8, \ .rdiff_log_arg = STRVEC_INIT, \ .argv_to_free = STRVEC_INIT, \ diff --git a/t/t4013-diff-various.sh b/t/t4013-diff-various.sh index 207bd2df423..b6974b9b64d 100755 --- a/t/t4013-diff-various.sh +++ b/t/t4013-diff-various.sh @@ -649,6 +649,19 @@ test_expect_success 'diff-tree --stdin --patch -Z --always with one empty diff' test_cmp_bin expect actual ' +test_expect_success 'diff-tree --stdin -Z' ' + cat oid1 >expect && + echo >>expect && + git diff-tree main~2 main~1 >>expect && + printf "\0" >>expect && + cat oid2 >>expect && + echo >>expect && + git diff-tree main~3 main~2 >>expect && + printf "\0" >>expect && + git diff-tree --stdin -Z actual && + test_cmp_bin expect actual +' + test_expect_success 'show A B ... -- ' ' # side touches dir/sub, file0, and file3 # main^ touches dir/sub, and file1 -- 2.56.1.5.g155936fbb2a