git/Documentation/config
Michael Montalbo 91c8989d4e diff: consult oid-only hunk providers via diff.<driver>.process
The provider chain so far holds the diff-hunks store in front of the
terminal builtin computation.  Open it to external processes: a pair on
a path whose driver configures diff.<driver>.process is answered by a
long-running process speaking a pkt-line protocol (following the filter
process protocol), registered at the head of the chain and consulted
before the store and before any blob is loaded.

The protocol starts with the smallest request that can carry an answer:
object names alone.  A request is the pathname and the pair's
old-oid/new-oid, with no content.  The process answers with hunk lines,
with a zero-hunk success that asserts the blobs equivalent (trailing
newlines included), or with status=need-content, on which the pair
falls through to the builtin answer.  This serves the two shapes that
need no content pushed to them: a cache keyed on the blob pair, and a
process that fetches the blobs itself (for example over "git cat-file
--batch").  A pair whose side is not a stored blob carries a NULL id;
the provider sends no request and passes it.  Because Git holds no
content for the exchange, the answer is used as sent: hunks are
validated for order, overlap, lockstep alignment, and magnitude, then
replayed without the normalization xdiff applies to diffs it computes
itself.  The magnitude bound is the blobs' sizes, read from the object
database without loading content: a blob of N bytes holds at most N
lines.

Because the process's answer is authoritative, it outranks the store,
and its head-of-chain position says so.  A pair the process answers
never reaches the store and is never recorded, so nothing it produces
enters the store, which holds the builtin answer only.  A request it
does not answer, whether need-content, a missing capability, or a
missing id, passes down the chain to the builtin answer, which is what
the store serves, so the store may serve such a pair and a warming run
may record it.  Entries recorded before a process was configured are
not purged; a pair the process answers ignores them, and "git diff-hunks
clear" discards them.

The provider gates itself per request.  The driver is looked up by the
old-side path, so a renamed file resolves to the same driver, and by
the repository-relative path, so a diff.relative run from a
subdirectory names the pair the same way.  Options the process is never
told about select no process: the whitespace-ignoring options, -I,
--anchored, and an algorithm forced by option or configuration (blame
routes its algorithm through xdl_opts, so --histogram is covered).  The
request gains its last field, the path; the consumers change only by
filling it, and neither names the process.

The provider's state is its repository's pool of running processes,
keyed by the configured command, so drivers sharing a command share a
process, a submodule speaks to its own, and releasing the provider
(from repo_clear()) stops them.  The pool owns a copy of each command
string, so an entry outlives a config re-read.  A command that fails
stays as an entry that is not retried: its request and every later one
pass, so the store may serve the path for the rest of the command.

A protocol error in a response never kills the command.  The response
is read through a packet reader gentle about framing, so an error takes
one path: a single warning, the process stopped and marked failed, and
the builtin diff for the rest of the command.  That covers garbage
bytes, a truncated response, an empty packet, a bare status, and an
unrecognized status.  Semantically invalid coordinates cost only their
pair: the response is drained, the pair is computed, and the process
stays alive.  A path the protocol cannot carry (an embedded newline, or
one too long for a packet) falls back per path rather than costing the
command its process.  The handshake keeps one fatal check: a process
that announces a capability Git did not request aborts the command, as
the long-running filter protocol does.

Consulting is allowed per command, following the allow_textconv
precedent.  "git diff", "git log" and "git show", and "git blame" set
allow_diff_process; the plumbing diff commands and the interactive-patch
machinery never set it, so scripted and staging output stays builtin.
The options adjust the flag:

- --no-ext-diff clears it and --ext-diff sets it;
- --diff-process and --no-diff-process set and clear it alone, leaving
  external diff drivers as they were;
- format-patch clears it unconditionally, so a generated patch applies
  for recipients without the process;
- range-diff passes --no-ext-diff to the "git log" it compares.

git blame and the summary formats consult the process.  For blame, a
pair reported equivalent emits no hunks, so the whole commit passes to
its parent.  In the stat formats such a pair sums to a zero-count entry,
which the "nothing changed" rule omits, as under -w.  The subprocess is
long-running: one startup cost across a traversal, one round-trip per
consulted pair.  Answers travel in struct xdl_hunk, new in
xdiff-interface.h, holding xdiff's 1-based coordinates; nothing feeds
them back to xdiff, since only coordinate consumers consult.

A content-carrying request is the natural extension: it would serve
sides that are not stored blobs and processes that want content pushed
to them, and bring patch output and log -L's range tracking to the same
answer.  As it stands, a process's answers show in blame and the summary
formats while patch output stays builtin.

t4080 exercises the protocol, the per-command gate, and the error paths:

- each adversarial response shape warns and falls back to builtin, the
  request log proving which failures disable the process and which keep
  it alive (a malformed hunk line, coordinates past the blob size, a
  count overflowing strtol(), overlapping or misaligned hunks, an
  unrecognized status, a bare status, an empty packet, a mid-response
  crash, and raw garbage);
- a capability-less process and status=abort degrade without noise, and
  a failed start warns once and returns the path to the store;
- a trailing token on a hunk line is ignored, pinning field
  appendability;
- positive consults for git diff, git show, and diff-tree under
  --ext-diff and --diff-process; textconv output and gitlink sides are
  never identified; a diff.relative run consults by the repo-relative
  path;
- the equivalence answer is pinned from both consumers, and a warming
  run past a deferring process records the pair for a later read.

Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-01 15:09:52 -07:00
..
add.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
advice.adoc Merge branch 'hn/branch-push-slip-advice' 2026-07-13 08:27:27 -07:00
alias.adoc doc: fix list continuation in alias.adoc 2026-03-03 09:59:31 -08:00
am.adoc doc: convert git-am synopsis and options to new style 2026-05-25 20:05:44 +09:00
apply.adoc doc: convert git-apply synopsis and options to new style 2026-05-25 20:05:44 +09:00
attr.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
bitmap-pseudo-merge.adoc pack-bitmap: reject pseudo-merge "sampleRate" of 0 2026-05-12 10:36:18 +09:00
blame.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
branch.adoc doc: improve formatting in branch section 2025-06-30 11:11:36 -07:00
browser.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
bundle.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
checkout.adoc doc: convert git-checkout manpage to new style 2025-05-27 07:50:58 -07:00
clean.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
clone.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
color.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
column.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
commit.adoc doc: config: mention core.commentChar on commit.cleanup 2025-05-27 15:31:06 -07:00
commitgraph.adoc commit-graph: add new config for changed-paths & recommend it in scalar 2025-10-22 10:40:11 -07:00
completion.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
core.adoc diff-hunks: add the store format, library, and command 2026-08-01 15:09:51 -07:00
credential.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
diff-hunks.adoc diff-hunks: add the store format, library, and command 2026-08-01 15:09:51 -07:00
diff.adoc diff: consult oid-only hunk providers via diff.<driver>.process 2026-08-01 15:09:52 -07:00
difftool.adoc doc: convert git-difftool manual page to synopsis style 2026-04-06 09:38:18 -07:00
extensions.adoc Merge branch 'kn/ref-location' 2026-03-04 10:52:59 -08:00
fastimport.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
feature.adoc setup: use "reftable" format when experimental features are enabled 2025-07-07 06:26:21 -07:00
fetch.adoc fetch: add configuration variable fetch.followRemoteHEAD 2026-06-19 09:19:36 -07:00
filter.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
fmt-merge-msg.adoc doc: switch merge config description to new synopsis format 2025-05-27 07:51:00 -07:00
format.adoc Fix docs for format.commitListFormat 2026-04-22 16:16:24 -07:00
fsck.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
fsmonitor--daemon.adoc fsmonitor: implement filesystem change listener for Linux 2026-04-15 08:44:33 -07:00
gc.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
gitcvs.adoc completion: make sed command that generates config-list.h portable. 2025-06-02 17:21:49 -07:00
gitweb.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
gpg.adoc gpg-interface: expand gpg.program as a path 2025-07-14 10:07:02 -07:00
grep.adoc doc: convert git-grep synopsis and options to new style 2026-05-25 20:05:44 +09:00
gui.adoc config: document 'gui.GCWarning' 2025-12-09 07:38:56 +09:00
guitool.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
help.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
hook.adoc doc: hook: don’t self-link via config include 2026-05-22 09:36:20 +09:00
http.adoc doc: clarify http.emptyAuth values 2026-05-01 14:01:57 +09:00
i18n.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
imap.adoc doc: convert git-imap-send synopsis and options to new style 2026-05-25 20:05:45 +09:00
includeif.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
index.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
init.adoc submodule: allow runtime enabling extensions.submodulePathConfig 2026-01-12 11:56:56 -08:00
instaweb.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
interactive.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
log.adoc log: improve --follow following renames for non-linear history 2026-06-22 05:45:09 -07:00
lsrefs.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
mailinfo.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
mailmap.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
maintenance.adoc builtin/maintenance: use "geometric" strategy by default 2026-02-24 07:33:20 -08:00
man.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
merge.adoc merge/pull: extend merge.stat configuration variable to cover --compact-summary 2025-06-13 11:54:14 -07:00
mergetool.adoc doc: convert git-difftool manual page to synopsis style 2026-04-06 09:38:18 -07:00
notes.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
pack.adoc doc: fix plural agreement in pack.preferBitmapTips 2026-04-16 21:22:01 -07:00
pager.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
pretty.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
promisor.adoc Merge branch 'cc/promisor-auto-config-url-more' 2026-07-06 15:50:19 -07:00
protocol.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
pull.adoc pull: add pull.autoStash config option 2025-07-21 15:01:21 -07:00
push.adoc doc: clarify push.default=simple behavior 2026-05-26 20:11:29 +09:00
rebase.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
receive.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
reftable.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
remote.adoc Merge branch 'mh/fetch-follow-remote-head-config' 2026-07-06 15:50:22 -07:00
remotes.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
repack.adoc repack: introduce `--write-midx=incremental` 2026-05-20 11:31:14 +09:00
replay.adoc replay: add replay.refAction config option 2025-11-05 13:34:55 -08:00
rerere.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
revert.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
safe.adoc Merge branch 'ta/doc-config-adoc-fixes' 2026-06-17 11:10:11 -07:00
sendemail.adoc doc: fix self-referential config in sendemail.smtpSSLClientKey 2026-04-16 21:22:01 -07:00
sequencer.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
showbranch.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
sideband.adoc Merge branch 'ta/doc-config-adoc-fixes' 2026-06-17 11:10:11 -07:00
sparse.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
splitindex.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
ssh.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
stash.adoc Merge branch 'dk/stash-apply-index' 2025-10-20 14:12:17 -07:00
status.adoc status: clarify how status.compareBranches deduplicates 2026-03-04 10:13:33 -08:00
submodule.adoc doc: fix grammar errors in submodule description 2026-04-16 21:22:01 -07:00
tag.adoc doc: convert git tag to synopsis style 2025-10-05 16:09:03 -07:00
tar.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
trace2.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
trailer.adoc doc: config: convert trailers section to synopsis style 2026-03-16 15:04:37 -07:00
transfer.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
uploadarchive.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
uploadpack.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
url.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
user.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
versionsort.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
web.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
worktree.adoc doc: convert git worktree to synopsis style 2025-10-05 16:09:03 -07:00