From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=103.168.172.147 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796249857; b=dLCSn9RwZdAAxmzc1ilVh6kcJVuDo1k5bfhVm3zJw+moIo0tSN2ExxCMbfmznCmrkU9c tnE07lPyGcMq9mxgq8Beiduxn9TD6AUaLsaEWFhTH5OOFRtcklqj/LKVihNctWbQ/FRri gRRdx3cDjscegMe8hGDHXx7PIt2lq6TZ34MaihzNIGQP7XcAVaufQO3wYmYPG2ZmSimt2 NUgxuX4XTHd1pP8mZy7ZDCoW0kuwJ5nwAdTnHUZrXz1WsrM8sFQ5uWy/lFwfDoOSSfUNZ I9FARbWkaEhf8rX7ZQfdryjWqJ9XH438eanmpbfx7pKgILLbegLbRhYjpLkYqeupyOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796249857; 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=ylla9tFtUg8yR0GsnZM5ilMipulpUxmxUzaVMbE+Ul4=; b=e9vIvwkRH4knAmBmDTFMDAgPFd+xu1w71ThYeDyJPw/HBOdz2Zluno0gFaTJml9q5OfJ X07/5Saxf6H+s7B1LWkAm1xW0OvM+Xr/B5YB1bBrieJGRwB6JJMpx0i4pAbttWY6GdGuK 7ApRTMSVcHsfOFzOPifu7RlHia9Me6EzyQVICBbZcOxWTJSPXdwf8oLnmWPNfcEcNKxLN utlclbUa2jpdDX2dCh17mMDtpPSEfjkwhUmYUuzMGTh9JHtO3m2yzhH6U1LW/hGGjDiSx +4BAt7lHQa8Z3gqTieygGkwPzh5uLrfEcTcKheBxj1RLKZWhy2AJcH6rwJyHWLK9roA== 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="EmMs9/wk"; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=5o9Z2Mjd; arc=none smtp.remote-ip=103.168.172.147 Received: from fout-a4-smtp.messagingengine.com (fout-a4-smtp.messagingengine.com [103.168.172.147]) (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 491E2606A32C for ; Wed, 2 Dec 2026 22:17:37 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 491E2606A32C 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=EmMs9/wk; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=5o9Z2Mjd Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfout.phl.internal (Postfix) with ESMTP id 78290EC0308 for ; Wed, 2 Dec 2026 17:17:36 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Wed, 02 Dec 2026 17:17:36 -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=1796249856; x=1796336256; bh=ylla9tFtUg8yR0GsnZM5ilMipulpUxmxUzaVMbE+Ul4=; b= EmMs9/wkmmMt8haene6XbWPBuyDMzPRgQuYbT/xRmVYO2cFFF4u5K/QxzsOhon+u 1zP8aGz4JK9OrlGxjo8GKwfP9vzqp95UMpAZScfaei3LjullOqdkbjobp7QYDmUP e0zA7uLS58UlsFwSKAz/4v1UiQrXdIDTwNjzMntzEiMSyC0yrR8OVVfbqHNQV7Bb 4/A1A9T+nL1yYjvEkdBiwppL0F6juU6KbXOmGfOavRgVkgH13xXFJEr+ZzkilA0/ EYqbdKQkUfnGGM/cBpmzAoG7AIxQDkK9exG4fe2nTYL3e/HkmGfeZer9vMEoMa16 Iben1bfqHXlqQG+otKt92w== 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=1796249856; x= 1796336256; bh=ylla9tFtUg8yR0GsnZM5ilMipulpUxmxUzaVMbE+Ul4=; b=5 o9Z2MjdbmKqBljqX++hTjpC4GR3sL+b/m/E0jSCk5rHK+rYguHCGXzTRH4X1fOqI 9qkLah3/OsHbeGfcOO5nYIRfo2yVtP/BUzfp4Q/paThLfreVSvIG1yOnHSfkHssP yE49Fd8wwnHQhFD6okTPBhzr09cqj9fwfrG2FGO8amZYt3MdkNfFXYhIXiQFTqqS 8DZcmT3PnxPmHrOsGmxqXe5tQuCAsnKUaMu3RONIuPto+k12ZgvLpsZojf/a1SxG f0FKX/s9fAj57DgLdLU5eHCWxKktGWYqRtg+jXk54eOpY5S/iAncy1PrJPcEUmtg 0z+O2BXgfT4UlMkiDxbTA== 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=1796249856; d=fastmail.com; mf=PGtyaXN0b2ZmZXJoYXVnc2Jha2tAZmFzdG1haWwuY29tPg==; rt=PGdpdEB2Z2VyLmtlcm5lbC5vcmc+; s=fm3:rsa-sha256:HL2GITnddgmeMzvSGJMvEVv7bhZNdcs3lLRvWt2k/SxyddO 79y2eiqz3PpJ/v7HVH0aHJ013Q+FhZtpmB644/yQHAPONuFdsDLmQTGDZTl81JjQ eGZGd9TgkOmQoEOT5jzkAQqhY2uJWF8xdTKIMQDWsXW27HyzzL3D4n782U0OvpIq CYoutgd/TLLkq2pkeURhu2SJlGs5C350LfuH6Gl854eeCI1lInqQDhBj085JQcUW WDs8jR+nbhBXBKdSm7zETIvq1wpebbv9TURnzygq8EDkpDPrJ/Pcgz8H5Y5untag E2pGUe80APA/Odj+728BsxG7WDlK1XvC/gQPetg==; 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:oWzaB6WqS31laeTYh591/y7p5GTRdY9IQ69uEJhplC4=:6JZrcvc1MGMa/mZC8k8lth/UJX6slqAyg2zg6DhVH3w=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTG27Ml/YuSbYnCd5JfQbPXRQsveRIRnRksGK3W/LMKAsg7tBv5xwlO8/KksamYNW/ iaaKP3oAF70H25kF13D9XP9asC4mTz66qiN2ekbjQni/1V5SKngH7OykbafzvIp2k1txrV iU2Qlk79MVlt+UQ40uFaD+dCjKdzm8vWS7hBPA8UKTNOHj3RAEHslasbvU5RgbvhkgQLon 2fsSERldBhZsD1m3LtSz8q4M0mwlkdxCA2aPR53P7NphBgvwxbeWt1QfUWXhL5S8eJlG0z 0aeceOPhfOEXVtZ3+b7l6rUjx5k2E3z8PEH7ivaFghW5xw/Qlr2Sizzk3XlIm8tlPD6Cn/ 1r6AkN9xQwT0icxoHrTmO6UHaJhkZZO1No/yQ40Js4IdnU4+2JcMMWvlbt5dah+PbYx7jT 4bcyAjZDnyWGmA1k41dXp7bizdTCeWebNw+57LVenNQTjzNiZLH/yMqYZ3K0xWNaqBPPdW O/408QO8BLFWbeu3TK5GSu4AFOgXn08iqn7wnUcSLf4SQ7F0UHNv7OxwHQjxp2U3kG79Kc fKOp9S34DqV7hICwFAlwm0PBkpPaKD/YuiPA6f6z2S+FH7tzZRvy8zNoRTQw7WsTsFHGsm YEW6STD720HhThHBdXGIGLvd8t5eKHr8Y+jeVW5PtjoICJKg3GLQx4EMmr5g X-ME-Proxy: Feedback-ID: i8b11424c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 2 Dec 2026 17:17:35 -0500 (EST) From: kristofferhaugsbakk@fastmail.com To: git@vger.kernel.org Cc: Kristoffer Haugsbakk Subject: [PATCH 11/12] doc: diff-tree: add Examples section and mention --stdin Date: Wed, 2 Dec 2026 23:14:19 +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 We added option -Z a few commits ago.[1] This option can be used by any command that uses revision.c:handle_revision_opt(...), but I had in mind git-diff-tree(1) in particular. That is because 'git diff-tree --stdin' outputs each record (commit or diff or both) immediately after it is processed. That is unlike git-rev-list(1)/git-show(1)/git-log(1) which wait until stdin is closed to and then outputs everything. † 1: commit “revision: learn -Z (NUL termination)” And this behavior is useful for feeding commit IDs, getting back some output, acting on it, and then feeding the next commit ID. This is facilitated by using -z so that you know a record is done after you read it. However, this does not work well for the default separator case; the delimiter is added *between* records, an in turn you have to give the Nth commit in order to get the NUL delimiter for the N-1 commit. Also, the last commit is not terminated. However, with the new -Z option you can pretty-print commits on demand just like 'git format-rev --stdin-mode=revs': git cat-file --batch-command='%(objectname)' | git diff-tree --no-patch --format= --always -Z --stdin And you also get log-tree.c formatted output (e.g. 'Notes:' in --format=medium) just like commands like git-log(1). And you can do the same for diffs, or combine commits and diffs with --format= --patch. Signed-off-by: Kristoffer Haugsbakk --- Documentation/git-diff-tree.adoc | 40 ++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Documentation/git-diff-tree.adoc b/Documentation/git-diff-tree.adoc index 084be99e7cf..b73cf4d268d 100644 --- a/Documentation/git-diff-tree.adoc +++ b/Documentation/git-diff-tree.adoc @@ -25,6 +25,8 @@ This command outputs a line with the commit ID when applicable. Use Note that 'git diff-tree' can use the tree encapsulated in a commit object. +See the "EXAMPLES" section at the end for a few examples. + OPTIONS ------- include::diff-options.adoc[] @@ -129,6 +131,44 @@ include::pretty-formats.adoc[] include::diff-format.adoc[] +EXAMPLES +-------- + +The default behavior is to show the commit ID and then the raw diff (see +`--raw`): + +---- +$ git diff-tree HEAD +00645eb9f4e515533cdf67376d481ffb4a796bcc +:040000 040000 ac1844364599b5671e9e4da68eab0817cab2ac2d b39de8e87a84787fb7bc2b38e015540e6d336eae M Documentation +---- + +But you can use this command to show normal diffs (`--patch`) and commit +messages as well. You can for example get the same output as `git log` +with: + +---- +$ git rev-list HEAD | +git diff-tree --no-patch --stdin --always --format=medium +---- + +The above is of course longer to type and uses two processes instead +of two. But this longer form with `--stdin` is more flexible than `git +log --stdin`. That is because the linkgit:git-log[1] form only outputs +anything after you close standard in (stdin). Meanwhile, `git diff-tree +--stdin ...` outputs each commit or diff (or both) immediately. This +means that you can use `-Z` to feed the commit, handle the output, and +then continue with the next commit. The above can be tweaked to for +example show the diff as well with `--patch`. + +---- +$ git diff-tree --no-patch --stdin --always --format= -Z + [rev-list options] +---- + +The command `git diff-tree --stdin --patch` can be used together with +linkgit:git-patch-id[1] to create a map from commit IDs to pach IDs. + GIT --- Part of the linkgit:git[1] suite -- 2.56.1.5.g155936fbb2a