git/Documentation/technical
Kristofer Karlsson 351dfe5aa7 commit-reach: introduce struct paint_state with per-side counters
Add a paint_state struct for use by paint_down_to_common() that
wraps a prio_queue with per-side commit counters. Each non-stale
queued commit occupies exactly one counter bucket based on its
paint flags: PARENT1-only, PARENT2-only, or both sides (a pending
merge-base candidate).

The counters are maintained by paint_count_update() which adjusts
the appropriate bucket by a signed delta. An exhaustive switch on
the paint+stale bits documents all valid flag combinations in one
place.

Convert paint_down_to_common() to use paint_state. The loop now
drains the queue via paint_queue_get() which returns NULL when all
counters reach zero, replacing the old pointer-based termination
(max_nonstale). This is equivalent behavior -- both conditions
detect that no non-stale entries remain.

paint_queue_get() uses a "pop first" form: it dequeues a commit,
then checks the counters. This means the loop exits one iteration
earlier than the old code in some topologies (the popped stale
commit is never processed), so a few step counts drop by one.

The existing nonstale_queue is left in place for ahead_behind(),
though nonstale_queue_put_dedup() and nonstale_queue_get_dedup()
became unused and are removed.

Signed-off-by: Kristofer Karlsson <krka@spotify.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-07-11 14:00:11 -07:00
..
.gitignore doc: update gitignore for .adoc extension 2025-01-21 12:56:05 -08:00
api-error-handling.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
api-index-skel.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
api-index.sh doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
api-merge.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
api-parse-options.adoc parse-options: rename `OPT_MAGNITUDE()` to `OPT_UNSIGNED()` 2025-04-17 08:15:15 -07:00
api-path-walk.adoc path-walk: always emit directly-requested objects 2026-05-24 18:41:06 +09:00
api-simple-ipc.adoc doc: *.txt -> *.adoc fixes 2025-03-03 13:49:21 -08:00
api-trace2.adoc doc: replace git config --list/-l with `list` 2026-04-06 09:57:07 -07:00
bitmap-format.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
build-systems.adoc doc: fix typos via codespell 2026-06-08 00:21:35 +09:00
bundle-uri.adoc bundle-uri: copy all bundle references ino the refs/bundle space 2025-04-25 13:36:45 -07:00
commit-graph.adoc doc: commit-graph.adoc: fix up some formatting 2025-10-16 13:55:52 -07:00
directory-rename-detection.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
hash-function-transition.adoc doc: fix typo in GIT_ALTERNATE_OBJECT_DIRECTORIES 2026-06-06 11:04:03 +09:00
large-object-promisors.adoc doc: add large-object-promisors.adoc to the docs build 2025-10-16 13:55:53 -07:00
long-running-process-protocol.adoc doc: check well-formedness of delimited sections 2025-08-11 14:16:03 -07:00
meson.build Documentation/technical: add paint-down-to-common doc 2026-07-11 14:00:10 -07:00
multi-pack-index.adoc Documentation: describe incremental MIDX bitmaps 2025-03-21 04:33:28 -07:00
pack-heuristics.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
packfile-uri.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
paint-down-to-common.adoc commit-reach: introduce struct paint_state with per-side counters 2026-07-11 14:00:11 -07:00
parallel-checkout.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
partial-clone.adoc technical/partial-clone: update reference to rev-list-options.adoc 2025-03-03 13:49:21 -08:00
platform-support.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
racy-git.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
remembering-renames.adoc doc: remembering-renames.adoc: fix asciidoc warnings 2025-10-16 13:55:52 -07:00
repository-version.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
rerere.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
scalar.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
send-pack-pipeline.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
shallow.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
sparse-checkout.adoc doc: sparse-checkout.adoc: fix asciidoc warnings 2025-10-16 13:55:52 -07:00
sparse-index.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
trivial-merge.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
unambiguous-types.adoc doc: define unambiguous type mappings across C and Rust 2025-11-18 14:53:09 -08:00
unit-tests.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00