]> git.ipfire.org Git - thirdparty/git.git/commit
builtin: introduce diff-pairs command
authorJustin Tobler <jltobler@gmail.com>
Fri, 28 Feb 2025 21:33:45 +0000 (15:33 -0600)
committerJunio C Hamano <gitster@pobox.com>
Mon, 3 Mar 2025 16:17:47 +0000 (08:17 -0800)
commit5bd10b2adcf3a080169574dd08c5529de81eecb1
tree6a1f6162d7a8e9a16043683c77ba1954bb9d88d9
parentc8a8e04099a99d6eafbe6e9bb1db3b50996836f8
builtin: introduce diff-pairs command

Through git-diff(1), a single diff can be generated from a pair of blob
revisions directly. Unfortunately, there is not a mechanism to compute
batches of specific file pair diffs in a single process. Such a feature
is particularly useful on the server-side where diffing between a large
set of changes is not feasible all at once due to timeout concerns.

To facilitate this, introduce git-diff-pairs(1) which acts as a backend
passing its NUL-terminated raw diff format input from stdin through diff
machinery to produce various forms of output such as patch or raw.

The raw format was originally designed as an interchange format and
represents the contents of the diff_queued_diff list making it possible
to break the diff pipeline into separate stages. For example,
git-diff-tree(1) can be used as a frontend to compute file pairs to
queue and feed its raw output to git-diff-pairs(1) to compute patches.
With this, batches of diffs can be progressively generated without
having to recompute renames or retrieve object context. Something like
the following:

git diff-tree -r -z -M $old $new |
git diff-pairs -p -z

should generate the same output as `git diff-tree -p -M`. Furthermore,
each line of raw diff formatted input can also be individually fed to a
separate git-diff-pairs(1) process and still produce the same output.

Based-on-patch-by: Jeff King <peff@peff.net>
Signed-off-by: Justin Tobler <jltobler@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
.gitignore
Documentation/git-diff-pairs.adoc [new file with mode: 0644]
Documentation/meson.build
Makefile
builtin.h
builtin/diff-pairs.c [new file with mode: 0644]
command-list.txt
git.c
meson.build
t/meson.build
t/t4070-diff-pairs.sh [new file with mode: 0755]