git/Documentation/config
Michael Montalbo 42824db113 diff-hunks: add the store format, library, and command
Blame and "git log --stat" recover hunk coordinates by diffing blob
pairs, and recompute them on every run.  Add a cache of those
coordinates at $GIT_DIR/objects/info/diff-hunks, beside the
commit-graph, so a later run can look them up instead of decompressing
the blobs and running xdiff again.

The store is a single chunk-format file (see gitformat-chunk(5)): an
8-byte header, a DHIX index of fixed-size entries sorted by key, a DHDT
segment of hunk records, and a trailing hash checksum.  An entry is
keyed by the two blob object ids and the xdl_opts the pair was diffed
under, so a stored result is served only where that exact key recurs,
independent of path.  A zero-context diff trims unchanged lines from
hunk edges and can pick a different but equally valid set of hunks than
an untrimmed diff, so a recording caller stores a pair only when its
trimmed and untrimmed diffs are identical; such an entry answers any
consumer at any context, and the rare divergent pair is always
computed.  Identical hunk blocks are interned once and shared across
keys.

The library provides a reader (repo_diff_hunks_store and _replay, gated
by core.diffHunks), loaded once and cached on the object database as the
commit-graph is, and a writer that accumulates entries and flushes them
in one atomic pass.  An absent, corrupt, or disabled store reads as all
misses.  A record with no hunks is invalid too: replaying it would claim
the pair equivalent, which the store never asserts, so it reads as a
miss.

Ordinary reads are diagnostic-free.  Loading parses the chunk table
through read_table_of_contents_quiet(), new in chunk-format, which
prints nothing on a malformed table and takes the repository's hash
algorithm rather than the_hash_algo, so the file is bounds-checked under
the algorithm it is keyed by.

The flush closes the repository's mmapped store and forgets that loading
was attempted before committing the lockfile.  A warming run that also
reads may hold the file it is replacing mapped, and the rename must not
land on a live mapping, which Windows refuses; a read after the flush
then observes the committed file.  commit-graph closes its graph before
committing for the same reason.

Writing is off by default, enabled per run by GIT_DIFF_HUNKS_WRITE or
persistently by diffHunks.write, the environment winning.  A writer
seeds from the existing store, so a flush merges rather than replaces.
The seed's checksum is verified first: a corrupt store is discarded, not
rewritten with a fresh checksum verify could no longer catch.  An entry
that fails the shared diff_provider_check_hunk() or names no blob is
dropped with a warning, since it would only ever read as a miss.  A seed
that discarded or dropped anything forces the flush even when the
warming run computed nothing new.  The writer fsyncs through a new
diff-hunks core.fsync component.

"git diff-hunks" inspects and manages the file: "verify" checks the
checksum, chunk table, sort order, entry bounds, and every entry's hunk
sequence against that shared check, so a store whose entries could only
read as misses fails verify; "clear" removes the file.  Later patches
wire the readers and the writer into the diff and blame paths.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-08-01 15:09:51 -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 Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08: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