git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 00/14] git organize: record file placement and apply it
@ 2026-08-23 17:18 Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 01/14] organize: add the git organize builtin Michael Montalbo
                   ` (13 more replies)
  0 siblings, 14 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

This series adds git organize, a command that records where a project's
files belong and moves the files that are not there yet. It is inspired
by the series to move the libgit.a sources under lib/ [1], and the
sub-thread there on grouping files by signals already present in the
tree [2]. That sub-thread asked which such signals identify a group of
files that could move into a subdirectory. This RFC attempts to provide
one answer, a tool that records such groups of files and applies the
appropriate moves.

git organize has two jobs. It records a project's file-placement
guideline in a tracked file, so the guideline travels with the
repository. And it moves a file to its recorded directory, repoints the
references to it, and stages the result; because a move can repoint the
moved file's own references, the change is a rename plus mechanical
reference repoints rather than an exact content-identical rename. The
tool holds no layout of its own: a project states the placement, and git
organize records it and performs the moves.

The guideline is .gitorganize. Its [scope] section lists the governed
files as pathspecs. Its [layout] section holds ordered "label:value =
directory" rules, where the first rule a file matches names its
directory. Its [labels] section records one line per recorded source,
holding its component and role; apply repoints a moved file's line to
its new path, and a file already inside a layout directory before it was
recorded has no line. Two configured commands supply the
project-specific parts: the labeler records a file's labels, and the
organizer returns the reference edits for a move and declines a move
whose references it cannot repoint. A line already in [labels] is kept
as recorded, so git organize apply --labels-only fills a file that has
no line and leaves the rest; a placement set by hand or in an earlier
run stands.

For Git's own tree, the reference labeler answers [2] from signals
already in the history. It reads the "area:" prefix a file's commits
carry most often, mined with git log --follow so a rename keeps the
file's past, and a committed map consolidates those prefixes into
components. A file whose prefix is too broad, unmapped, or absent falls
back to its filename, and a file that its prefix does not place but that
changes chiefly alongside one component is drawn into it. Each recorded
line also carries the prefix, the file's #include coupling, and its
co-change profile, so a reader sees the signals a placement rests on.
The advisory prefix= text is mildly git-version sensitive, because git
log --follow rename heuristics differ across git versions; the placed
component does not vary, because the map keys on both a file's old-name
token and its current-name token, which resolve to the same component.

git organize status reports the governed files in groups: in place, to
move, backlog (a file recorded with no directory), and a recorded path
that no longer exists. With --exit-code it fails when a file is out of
place. Before any carve it reports

    $ git organize status
    organize: 495 in scope (113 in place, 303 to move, 79 backlog)

This series carves the subsystems whose files reference each other: odb,
refs, pack, diff, revision, index, setup, and transport. Measured
intra-component #include coupling puts odb as the most tightly coupled,
so it is carved first; the remaining subsystems are all internally
cohesive, without a strict coupling rank among them. Each carve is one
commit that moves the subsystem's sources and headers into its directory
and repoints every reference: the #include lines, the Makefile and
meson.build entries, the contrib CMake build, and the #include examples
in the tutorials. Because apply --label selects a single subsystem, the
moves arrive one commit at a time, each self-contained and reviewable on
its own, rather than as one sweeping rename. After these eight carves
status reports

    $ git organize status
    organize: 495 in scope (380 in place, 36 to move, 79 backlog)

A carve is a rename plus mechanical reference repoints, including the
moved file's own #include lines, so git blame and git log --follow still
track it; it changes where a file lives, not what it depends on. Where
each file belongs is the project's judgment, recorded in the layout and
offered here to be argued and replaced: bisect.c sits under revision/
because it uses the revision machinery, but whether it should instead
stand on its own, as rev-list and log do, is exactly the kind of call
the labeler makes and the series invites reviewers to correct. A relabel
and a re-run follow any such decision.

Two groups remain: 36 files the layout places but leaves uncarved here
(archive, convert, merge, notes, and submodule), and 79 in backlog with
no directory yet. The same labeler and organizer produce those patches.
Each carve also updates .gitorganize, the tool's own record, so a carve
taken upstream drops that line and stands on its own as ordinary renames
and repoints; the tool need not be merged for a carve to be useful.

The target directories are not built into the tool: changing only the
[layout] entries (component:odb = lib/odb, and so on) yields a layout
nested under lib/, which builds. That is how this pairs with the series
moving the libgit.a sources under lib/ [1]: the directory can be
lib/<component>, so the same tool groups those sources further under
lib/ rather than proposing an alternate top-level layout.

[1] https://lore.kernel.org/git/20260701-pks-libgit-in-subdir-v3-0-5e4860056094@pks.im/T/#m39669398367d8b79af9a40080996d475193a6d2b
[2] https://lore.kernel.org/git/20260701-pks-libgit-in-subdir-v3-0-5e4860056094@pks.im/T/#mfd455931a236cca8d669fdfcc0ef1d7127237cd6

Michael Montalbo (14):
  organize: add the git organize builtin
  organize: add the labeler, organizer, and apply --labels-only
  organize: add status --exit-code
  organize: add the --label selector
  organize: declare Git's scope and layout
  organize: record a label for every source in scope
  odb: gather the odb sources under odb/
  refs: gather the refs sources under refs/
  pack: gather the pack sources under pack/
  diff: gather the diff sources under diff/
  revision: gather the revision sources under revision/
  index: gather the index sources under index/
  setup: gather the setup sources under setup/
  transport: gather the transport sources under transport/

 .gitignore                                    |   1 +
 .gitorganize                                  | 494 ++++++++++++
 Documentation/Makefile                        |   4 +-
 Documentation/MyFirstContribution.adoc        |  10 +-
 Documentation/MyFirstObjectWalk.adoc          |  10 +-
 Documentation/git-organize.adoc               | 199 +++++
 Documentation/meson.build                     |   1 +
 Makefile                                      | 309 ++++----
 add-interactive.c                             |  18 +-
 add-patch.c                                   |  16 +-
 advice.c                                      |   4 +-
 apply.c                                       |  30 +-
 apply.h                                       |   2 +-
 archive-tar.c                                 |   4 +-
 archive-zip.c                                 |   8 +-
 archive.c                                     |  22 +-
 archive.h                                     |   2 +-
 attr.c                                        |  20 +-
 branch.c                                      |  18 +-
 builtin.h                                     |   3 +-
 builtin/add.c                                 |  20 +-
 builtin/am.c                                  |  28 +-
 builtin/apply.c                               |   2 +-
 builtin/archive.c                             |   4 +-
 builtin/backfill.c                            |  28 +-
 builtin/bisect.c                              |  12 +-
 builtin/blame.c                               |  28 +-
 builtin/branch.c                              |  18 +-
 builtin/bugreport.c                           |   6 +-
 builtin/bundle.c                              |   6 +-
 builtin/cat-file.c                            |  32 +-
 builtin/check-attr.c                          |   8 +-
 builtin/check-ignore.c                        |   8 +-
 builtin/check-mailmap.c                       |   6 +-
 builtin/check-ref-format.c                    |   4 +-
 builtin/checkout--worker.c                    |  12 +-
 builtin/checkout-index.c                      |  16 +-
 builtin/checkout.c                            |  56 +-
 builtin/clean.c                               |  12 +-
 builtin/clone.c                               |  42 +-
 builtin/column.c                              |   2 +-
 builtin/commit-graph.c                        |  14 +-
 builtin/commit-tree.c                         |  10 +-
 builtin/commit.c                              |  34 +-
 builtin/config.c                              |  10 +-
 builtin/count-objects.c                       |  10 +-
 builtin/credential-cache--daemon.c            |   2 +-
 builtin/credential-store.c                    |   2 +-
 builtin/credential.c                          |   4 +-
 builtin/describe.c                            |  28 +-
 builtin/diff-files.c                          |  12 +-
 builtin/diff-index.c                          |  14 +-
 builtin/diff-pairs.c                          |  12 +-
 builtin/diff-tree.c                           |  16 +-
 builtin/diff.c                                |  26 +-
 builtin/difftool.c                            |  20 +-
 builtin/fast-export.c                         |  32 +-
 builtin/fast-import.c                         |  32 +-
 builtin/fetch-pack.c                          |  14 +-
 builtin/fetch.c                               |  38 +-
 builtin/fmt-merge-msg.c                       |   2 +-
 builtin/for-each-ref.c                        |  10 +-
 builtin/for-each-repo.c                       |   4 +-
 builtin/fsck.c                                |  40 +-
 builtin/fsmonitor--daemon.c                   |  14 +-
 builtin/gc.c                                  |  30 +-
 builtin/get-tar-commit-id.c                   |   2 +-
 builtin/grep.c                                |  26 +-
 builtin/hash-object.c                         |  12 +-
 builtin/help.c                                |   8 +-
 builtin/history.c                             |  26 +-
 builtin/hook.c                                |   6 +-
 builtin/index-pack.c                          |  38 +-
 builtin/init-db.c                             |   6 +-
 builtin/interpret-trailers.c                  |   4 +-
 builtin/last-modified.c                       |  24 +-
 builtin/log.c                                 |  52 +-
 builtin/ls-files.c                            |  20 +-
 builtin/ls-remote.c                           |   8 +-
 builtin/ls-tree.c                             |  12 +-
 builtin/mailinfo.c                            |   2 +-
 builtin/merge-base.c                          |  10 +-
 builtin/merge-file.c                          |  14 +-
 builtin/merge-index.c                         |   4 +-
 builtin/merge-ours.c                          |   6 +-
 builtin/merge-recursive.c                     |   4 +-
 builtin/merge-tree.c                          |  20 +-
 builtin/merge.c                               |  44 +-
 builtin/mktag.c                               |  10 +-
 builtin/mktree.c                              |   6 +-
 builtin/multi-pack-index.c                    |  12 +-
 builtin/mv.c                                  |  20 +-
 builtin/name-rev.c                            |  22 +-
 builtin/notes.c                               |  16 +-
 builtin/organize.c                            | 153 ++++
 builtin/pack-objects.c                        |  66 +-
 builtin/pack-redundant.c                      |   4 +-
 builtin/pack-refs.c                           |   2 +-
 builtin/patch-id.c                            |  10 +-
 builtin/prune-packed.c                        |   2 +-
 builtin/prune.c                               |  24 +-
 builtin/pull.c                                |  22 +-
 builtin/push.c                                |  16 +-
 builtin/range-diff.c                          |   6 +-
 builtin/read-tree.c                           |  22 +-
 builtin/rebase.c                              |  26 +-
 builtin/receive-pack.c                        |  52 +-
 builtin/reflog.c                              |  14 +-
 builtin/refs.c                                |  10 +-
 builtin/remote-ext.c                          |   4 +-
 builtin/remote-fd.c                           |   2 +-
 builtin/remote.c                              |  16 +-
 builtin/repack.c                              |  18 +-
 builtin/replace.c                             |  16 +-
 builtin/replay.c                              |   8 +-
 builtin/repo.c                                |  22 +-
 builtin/rerere.c                              |   6 +-
 builtin/reset.c                               |  32 +-
 builtin/rev-list.c                            |  40 +-
 builtin/rev-parse.c                           |  34 +-
 builtin/revert.c                              |   6 +-
 builtin/rm.c                                  |  20 +-
 builtin/send-pack.c                           |  18 +-
 builtin/shortlog.c                            |  12 +-
 builtin/show-branch.c                         |  16 +-
 builtin/show-index.c                          |   4 +-
 builtin/show-ref.c                            |  10 +-
 builtin/sparse-checkout.c                     |  20 +-
 builtin/stash.c                               |  42 +-
 builtin/stripspace.c                          |   6 +-
 builtin/submodule--helper.c                   |  36 +-
 builtin/symbolic-ref.c                        |   6 +-
 builtin/tag.c                                 |  24 +-
 builtin/unpack-file.c                         |  10 +-
 builtin/unpack-objects.c                      |  24 +-
 builtin/update-index.c                        |  34 +-
 builtin/update-ref.c                          |  10 +-
 builtin/update-server-info.c                  |   6 +-
 builtin/upload-archive.c                      |   6 +-
 builtin/upload-pack.c                         |  16 +-
 builtin/var.c                                 |   8 +-
 builtin/verify-commit.c                       |   8 +-
 builtin/verify-pack.c                         |   4 +-
 builtin/verify-tag.c                          |  10 +-
 builtin/worktree.c                            |  22 +-
 builtin/write-tree.c                          |   8 +-
 chdir-notify.c                                |   2 +-
 color.c                                       |   2 +-
 column.c                                      |   2 +-
 command-list.txt                              |   1 +
 common-init.c                                 |   8 +-
 compat/fsmonitor/fsm-health-darwin.c          |   6 +-
 compat/fsmonitor/fsm-health-linux.c           |   6 +-
 compat/fsmonitor/fsm-health-win32.c           |   6 +-
 compat/fsmonitor/fsm-ipc-unix.c               |  10 +-
 compat/fsmonitor/fsm-ipc-win32.c              |   4 +-
 compat/fsmonitor/fsm-listen-darwin.c          |   6 +-
 compat/fsmonitor/fsm-listen-linux.c           |   8 +-
 compat/fsmonitor/fsm-listen-win32.c           |   6 +-
 compat/fsmonitor/fsm-path-utils-darwin.c      |   4 +-
 compat/fsmonitor/fsm-path-utils-linux.c       |   4 +-
 compat/fsmonitor/fsm-path-utils-win32.c       |   4 +-
 compat/fsmonitor/fsm-settings-unix.c          |  10 +-
 compat/fsmonitor/fsm-settings-win32.c         |  10 +-
 compat/mingw.c                                |  12 +-
 compat/precompose_utf8.c                      |   4 +-
 compat/regex/regex.c                          |   2 +-
 compat/sha1-chunked.c                         |   2 +-
 compat/simple-ipc/ipc-win32.c                 |   2 +-
 compat/win32/path-utils.c                     |   4 +-
 compat/win32/trace2_win32_process_info.c      |   2 +-
 contrib/buildsystems/CMakeLists.txt           |   6 +-
 contrib/libgit-sys/public_symbol_export.c     |   4 +-
 contrib/organize/git-layout.map               |  41 +
 contrib/organize/labeler                      | 333 ++++++++
 contrib/organize/organizer                    | 334 ++++++++
 convert.c                                     |   8 +-
 convert.h                                     |   2 +-
 credential.c                                  |   6 +-
 csum-file.c                                   |   2 +-
 csum-file.h                                   |   2 +-
 daemon.c                                      |  10 +-
 diagnose.c                                    |   8 +-
 combine-diff.c => diff/combine-diff.c         |  26 +-
 diff-lib.c => diff/diff-lib.c                 |  30 +-
 diff-merges.c => diff/diff-merges.c           |   4 +-
 diff-merges.h => diff/diff-merges.h           |   0
 diff-no-index.c => diff/diff-no-index.c       |  12 +-
 diff.c => diff/diff.c                         |  38 +-
 diff.h => diff/diff.h                         |   4 +-
 diffcore-break.c => diff/diffcore-break.c     |   8 +-
 diffcore-delta.c => diff/diffcore-delta.c     |   2 +-
 diffcore-order.c => diff/diffcore-order.c     |   4 +-
 diffcore-pickaxe.c => diff/diffcore-pickaxe.c |  10 +-
 diffcore-rename.c => diff/diffcore-rename.c   |  10 +-
 diffcore-rotate.c => diff/diffcore-rotate.c   |   4 +-
 diffcore.h => diff/diffcore.h                 |   2 +-
 patch-ids.c => diff/patch-ids.c               |   8 +-
 patch-ids.h => diff/patch-ids.h               |   2 +-
 range-diff.c => diff/range-diff.c             |  20 +-
 range-diff.h => diff/range-diff.h             |   2 +-
 tree-diff.c => diff/tree-diff.c               |  14 +-
 userdiff.c => diff/userdiff.c                 |   6 +-
 userdiff.h => diff/userdiff.h                 |   0
 xdiff-interface.c => diff/xdiff-interface.c   |   8 +-
 xdiff-interface.h => diff/xdiff-interface.h   |   2 +-
 editor.c                                      |   4 +-
 exec-cmd.c                                    |   2 +-
 fmt-merge-msg.c                               |  20 +-
 gettext.c                                     |   2 +-
 git.c                                         |  17 +-
 gpg-interface.c                               |  10 +-
 grep.c                                        |  14 +-
 grep.h                                        |   2 +-
 help.c                                        |  16 +-
 hex.c                                         |   2 +-
 hex.h                                         |   2 +-
 http-backend.c                                |  22 +-
 http-fetch.c                                  |  10 +-
 http-push.c                                   |  34 +-
 imap-send.c                                   |   8 +-
 cache-tree.c => index/cache-tree.c            |  18 +-
 cache-tree.h => index/cache-tree.h            |   4 +-
 checkout.c => index/checkout.c                |  12 +-
 checkout.h => index/checkout.h                |   2 +-
 dir-iterator.c => index/dir-iterator.c        |   4 +-
 dir-iterator.h => index/dir-iterator.h        |   0
 dir.c => index/dir.c                          |  28 +-
 dir.h => index/dir.h                          |   6 +-
 entry.c => index/entry.c                      |  18 +-
 entry.h => index/entry.h                      |   0
 .../fsmonitor--daemon.h                       |   2 +-
 fsmonitor-ipc.c => index/fsmonitor-ipc.c      |   4 +-
 fsmonitor-ipc.h => index/fsmonitor-ipc.h      |   0
 fsmonitor-ll.h => index/fsmonitor-ll.h        |   0
 .../fsmonitor-path-utils.h                    |   0
 .../fsmonitor-settings.c                      |  10 +-
 .../fsmonitor-settings.h                      |   0
 fsmonitor.c => index/fsmonitor.c              |  14 +-
 fsmonitor.h => index/fsmonitor.h              |  10 +-
 name-hash.c => index/name-hash.c              |  10 +-
 name-hash.h => index/name-hash.h              |   0
 .../parallel-checkout.c                       |  14 +-
 .../parallel-checkout.h                       |   0
 pathspec.c => index/pathspec.c                |  14 +-
 pathspec.h => index/pathspec.h                |   0
 preload-index.c => index/preload-index.c      |  18 +-
 preload-index.h => index/preload-index.h      |   0
 read-cache-ll.h => index/read-cache-ll.h      |   4 +-
 read-cache.c => index/read-cache.c            |  50 +-
 read-cache.h => index/read-cache.h            |   8 +-
 resolve-undo.c => index/resolve-undo.c        |  10 +-
 resolve-undo.h => index/resolve-undo.h        |   2 +-
 sparse-index.c => index/sparse-index.c        |  22 +-
 sparse-index.h => index/sparse-index.h        |   0
 split-index.c => index/split-index.c          |   8 +-
 split-index.h => index/split-index.h          |   2 +-
 statinfo.c => index/statinfo.c                |   6 +-
 statinfo.h => index/statinfo.h                |   0
 symlinks.c => index/symlinks.c                |   4 +-
 symlinks.h => index/symlinks.h                |   0
 unpack-trees.c => index/unpack-trees.c        |  38 +-
 unpack-trees.h => index/unpack-trees.h        |   4 +-
 wt-status.c => index/wt-status.c              |  36 +-
 wt-status.h => index/wt-status.h              |   4 +-
 khash.h                                       |   2 +-
 lockfile.c                                    |   2 +-
 mailinfo.c                                    |   4 +-
 mailmap.c                                     |  10 +-
 merge-blobs.c                                 |   4 +-
 merge-ll.c                                    |   4 +-
 merge-ort-wrappers.c                          |  12 +-
 merge-ort.c                                   |  46 +-
 merge-ort.h                                   |   2 +-
 merge.c                                       |  14 +-
 meson.build                                   | 285 +++----
 negotiator/default.c                          |  10 +-
 negotiator/noop.c                             |   2 +-
 negotiator/skipping.c                         |  10 +-
 notes-cache.c                                 |  12 +-
 notes-merge.c                                 |  22 +-
 notes-utils.c                                 |   8 +-
 notes.c                                       |  14 +-
 alloc.c => odb/alloc.c                        |  14 +-
 alloc.h => odb/alloc.h                        |   0
 blob.c => odb/blob.c                          |   4 +-
 blob.h => odb/blob.h                          |   2 +-
 cbtree.c => odb/cbtree.c                      |   2 +-
 cbtree.h => odb/cbtree.h                      |   0
 commit-slab-decl.h => odb/commit-slab-decl.h  |   0
 commit-slab-impl.h => odb/commit-slab-impl.h  |   0
 commit-slab.h => odb/commit-slab.h            |   4 +-
 commit.c => odb/commit.c                      |  42 +-
 commit.h => odb/commit.h                      |   2 +-
 fsck.c => odb/fsck.c                          |  30 +-
 fsck.h => odb/fsck.h                          |   4 +-
 hash-lookup.c => odb/hash-lookup.c            |   6 +-
 hash-lookup.h => odb/hash-lookup.h            |   0
 hash.c => odb/hash.c                          |   2 +-
 hash.h => odb/hash.h                          |   2 +-
 loose.c => odb/loose.c                        |  12 +-
 loose.h => odb/loose.h                        |   0
 match-trees.c => odb/match-trees.c            |  12 +-
 match-trees.h => odb/match-trees.h            |   0
 .../object-file-convert.c                     |  12 +-
 .../object-file-convert.h                     |   2 +-
 object-file.c => odb/object-file.c            |  24 +-
 object-file.h => odb/object-file.h            |   4 +-
 object-name.c => odb/object-name.c            |  40 +-
 object-name.h => odb/object-name.h            |   2 +-
 object.c => odb/object.c                      |  20 +-
 object.h => odb/object.h                      |   2 +-
 odb.c => odb/odb.c                            |  30 +-
 odb.h => odb/odb.h                            |   6 +-
 oid-array.c => odb/oid-array.c                |   4 +-
 oid-array.h => odb/oid-array.h                |   2 +-
 oidmap.c => odb/oidmap.c                      |   4 +-
 oidmap.h => odb/oidmap.h                      |   2 +-
 oidset.c => odb/oidset.c                      |   2 +-
 oidset.h => odb/oidset.h                      |   0
 oidtree.c => odb/oidtree.c                    |   4 +-
 oidtree.h => odb/oidtree.h                    |   4 +-
 replace-object.c => odb/replace-object.c      |  12 +-
 replace-object.h => odb/replace-object.h      |   6 +-
 odb/source-files.c                            |  18 +-
 odb/source-inmemory.c                         |   8 +-
 odb/source-loose.c                            |  12 +-
 odb/source-packed.c                           |  10 +-
 odb/source-packed.h                           |   2 +-
 odb/source.c                                  |   4 +-
 odb/source.h                                  |   4 +-
 odb/streaming.c                               |   8 +-
 odb/streaming.h                               |   4 +-
 tag.c => odb/tag.c                            |  20 +-
 tag.h => odb/tag.h                            |   2 +-
 tmp-objdir.c => odb/tmp-objdir.c              |  12 +-
 tmp-objdir.h => odb/tmp-objdir.h              |   0
 odb/transaction.h                             |   2 +-
 tree-walk.c => odb/tree-walk.c                |  16 +-
 tree-walk.h => odb/tree-walk.h                |   2 +-
 tree.c => odb/tree.c                          |  16 +-
 tree.h => odb/tree.h                          |   2 +-
 organize/gitorganize-format.c                 | 266 +++++++
 organize/gitorganize-format.h                 |  38 +
 organize/labeler-protocol.c                   |  52 ++
 organize/labeler-protocol.h                   |  15 +
 organize/organize.c                           | 487 ++++++++++++
 organize/organize.h                           | 102 +++
 organize/organizer-protocol.c                 | 254 ++++++
 organize/organizer-protocol.h                 |  18 +
 oss-fuzz/fuzz-commit-graph.c                  |   4 +-
 oss-fuzz/fuzz-config.c                        |   2 +-
 oss-fuzz/fuzz-pack-headers.c                  |   2 +-
 oss-fuzz/fuzz-pack-idx.c                      |   4 +-
 bloom.c => pack/bloom.c                       |  20 +-
 bloom.h => pack/bloom.h                       |   0
 chunk-format.c => pack/chunk-format.c         |   4 +-
 chunk-format.h => pack/chunk-format.h         |   2 +-
 commit-graph.c => pack/commit-graph.c         |  34 +-
 commit-graph.h => pack/commit-graph.h         |   4 +-
 delta-islands.c => pack/delta-islands.c       |  26 +-
 delta-islands.h => pack/delta-islands.h       |   0
 delta.h => pack/delta.h                       |   0
 diff-delta.c => pack/diff-delta.c             |   2 +-
 midx-write.c => pack/midx-write.c             |  22 +-
 midx.c => pack/midx.c                         |  16 +-
 midx.h => pack/midx.h                         |   0
 .../pack-bitmap-write.c                       |  38 +-
 pack-bitmap.c => pack/pack-bitmap.c           |  32 +-
 pack-bitmap.h => pack/pack-bitmap.h           |   6 +-
 pack-check.c => pack/pack-check.c             |  12 +-
 pack-mtimes.c => pack/pack-mtimes.c           |   6 +-
 pack-mtimes.h => pack/pack-mtimes.h           |   0
 pack-objects.c => pack/pack-objects.c         |  10 +-
 pack-objects.h => pack/pack-objects.h         |   6 +-
 pack-revindex.c => pack/pack-revindex.c       |  10 +-
 pack-revindex.h => pack/pack-revindex.h       |   0
 pack-write.c => pack/pack-write.c             |  18 +-
 pack.h => pack/pack.h                         |   2 +-
 packfile-list.c => pack/packfile-list.c       |   4 +-
 packfile-list.h => pack/packfile-list.h       |   0
 packfile.c => pack/packfile.c                 |  40 +-
 packfile.h => pack/packfile.h                 |  12 +-
 patch-delta.c => pack/patch-delta.c           |   2 +-
 prune-packed.c => pack/prune-packed.c         |   8 +-
 prune-packed.h => pack/prune-packed.h         |   0
 pseudo-merge.c => pack/pseudo-merge.c         |  14 +-
 pseudo-merge.h => pack/pseudo-merge.h         |   0
 reachable.c => pack/reachable.c               |  28 +-
 reachable.h => pack/reachable.h               |   0
 repack-cruft.c => pack/repack-cruft.c         |   6 +-
 repack-filtered.c => pack/repack-filtered.c   |   4 +-
 repack-geometry.c => pack/repack-geometry.c   |   8 +-
 repack-midx.c => pack/repack-midx.c           |  14 +-
 repack-promisor.c => pack/repack-promisor.c   |   8 +-
 repack.c => pack/repack.c                     |  12 +-
 repack.h => pack/repack.h                     |   2 +-
 server-info.c => pack/server-info.c           |  20 +-
 server-info.h => pack/server-info.h           |   0
 pager.c                                       |   8 +-
 parse-options-cb.c                            |  10 +-
 path-walk.c                                   |  28 +-
 path-walk.h                                   |   2 +-
 path.c                                        |  12 +-
 path.h                                        |   2 +-
 progress.c                                    |   2 +-
 prompt.c                                      |   4 +-
 rebase-interactive.c                          |  14 +-
 refs/files-backend.c                          |  24 +-
 refs/iterator.c                               |   2 +-
 ls-refs.c => refs/ls-refs.c                   |  14 +-
 ls-refs.h => refs/ls-refs.h                   |   0
 pack-refs.c => refs/pack-refs.c               |  10 +-
 pack-refs.h => refs/pack-refs.h               |   0
 refs/packed-backend.c                         |  14 +-
 refs/ref-cache.c                              |   6 +-
 refs/ref-cache.h                              |   2 +-
 ref-filter.c => refs/ref-filter.c             |  36 +-
 ref-filter.h => refs/ref-filter.h             |   6 +-
 reflog-walk.c => refs/reflog-walk.c           |  12 +-
 reflog-walk.h => refs/reflog-walk.h           |   0
 reflog.c => refs/reflog.c                     |  16 +-
 reflog.h => refs/reflog.h                     |   2 +-
 refs/refs-internal.h                          |   2 +-
 refs.c => refs/refs.c                         |  26 +-
 refs.h => refs/refs.h                         |   8 +-
 refspec.c => refs/refspec.c                   |   8 +-
 refspec.h => refs/refspec.h                   |   0
 refs/reftable-backend.c                       |  20 +-
 worktree.c => refs/worktree.c                 |  16 +-
 worktree.h => refs/worktree.h                 |   2 +-
 replay.c                                      |  10 +-
 replay.h                                      |   2 +-
 rerere.c                                      |  18 +-
 reset.c                                       |  14 +-
 reset.h                                       |   4 +-
 bisect.c => revision/bisect.c                 |  30 +-
 bisect.h => revision/bisect.h                 |   0
 blame.c => revision/blame.c                   |  30 +-
 blame.h => revision/blame.h                   |   4 +-
 commit-reach.c => revision/commit-reach.c     |  14 +-
 commit-reach.h => revision/commit-reach.h     |   4 +-
 decorate.c => revision/decorate.c             |   4 +-
 decorate.h => revision/decorate.h             |   0
 graph.c => revision/graph.c                   |   8 +-
 graph.h => revision/graph.h                   |   2 +-
 line-log.c => revision/line-log.c             |  28 +-
 line-log.h => revision/line-log.h             |   2 +-
 line-range.c => revision/line-range.c         |   6 +-
 line-range.h => revision/line-range.h         |   0
 .../list-objects-filter-options.c             |   6 +-
 .../list-objects-filter-options.h             |   2 +-
 .../list-objects-filter.c                     |  20 +-
 .../list-objects-filter.h                     |   0
 list-objects.c => revision/list-objects.c     |  26 +-
 list-objects.h => revision/list-objects.h     |   0
 list.h => revision/list.h                     |   0
 log-tree.c => revision/log-tree.c             |  42 +-
 log-tree.h => revision/log-tree.h             |   0
 pretty.c => revision/pretty.c                 |  18 +-
 pretty.h => revision/pretty.h                 |   0
 revision.c => revision/revision.c             |  68 +-
 revision.h => revision/revision.h             |  18 +-
 shallow.c => revision/shallow.c               |  28 +-
 shallow.h => revision/shallow.h               |   6 +-
 run-command.c                                 |   8 +-
 scalar.c                                      |  14 +-
 sequencer.c                                   |  44 +-
 sequencer.h                                   |   2 +-
 alias.c => setup/alias.c                      |   4 +-
 alias.h => setup/alias.h                      |   0
 config.c => setup/config.c                    |  16 +-
 config.h => setup/config.h                    |   2 +-
 environment.c => setup/environment.c          |  16 +-
 environment.h => setup/environment.h          |   2 +-
 hook.c => setup/hook.c                        |   8 +-
 hook.h => setup/hook.h                        |   2 +-
 ident.c => setup/ident.c                      |   4 +-
 ident.h => setup/ident.h                      |   0
 repo-settings.c => setup/repo-settings.c      |  12 +-
 repo-settings.h => setup/repo-settings.h      |   0
 repository.c => setup/repository.c            |  24 +-
 repository.h => setup/repository.h            |   4 +-
 setup.c => setup/setup.c                      |  20 +-
 setup.h => setup/setup.h                      |   2 +-
 version.c => setup/version.c                  |   2 +-
 version.h => setup/version.h                  |   0
 shell.c                                       |   2 +-
 simple-ipc.h                                  |   2 +-
 sub-process.c                                 |   2 +-
 submodule-config.c                            |  14 +-
 submodule-config.h                            |   4 +-
 submodule.c                                   |  36 +-
 t/helper/test-advise.c                        |   6 +-
 t/helper/test-bitmap.c                        |   8 +-
 t/helper/test-bloom.c                         |   8 +-
 t/helper/test-bundle-uri.c                    |   6 +-
 t/helper/test-cache-tree.c                    |  10 +-
 t/helper/test-config.c                        |   4 +-
 t/helper/test-delta.c                         |   2 +-
 t/helper/test-dir-iterator.c                  |   2 +-
 t/helper/test-dump-cache-tree.c               |  12 +-
 t/helper/test-dump-fsmonitor.c                |   6 +-
 t/helper/test-dump-split-index.c              |   8 +-
 t/helper/test-dump-untracked-cache.c          |   8 +-
 t/helper/test-find-pack.c                     |   8 +-
 t/helper/test-fsmonitor-client.c              |   8 +-
 t/helper/test-hash-speed.c                    |   2 +-
 t/helper/test-lazy-init-name-hash.c           |  10 +-
 t/helper/test-match-trees.c                   |  10 +-
 t/helper/test-name-hash.c                     |   2 +-
 t/helper/test-pack-deltas.c                   |  10 +-
 t/helper/test-pack-mtimes.c                   |   8 +-
 t/helper/test-parse-pathspec-file.c           |   2 +-
 t/helper/test-partial-clone.c                 |   6 +-
 t/helper/test-path-utils.c                    |   6 +-
 t/helper/test-path-walk.c                     |  18 +-
 t/helper/test-pkt-line.c                      |   4 +-
 t/helper/test-proc-receive.c                  |   4 +-
 t/helper/test-progress.c                      |   2 +-
 t/helper/test-reach.c                         |  12 +-
 t/helper/test-read-cache.c                    |  10 +-
 t/helper/test-read-graph.c                    |  10 +-
 t/helper/test-read-midx.c                     |  14 +-
 t/helper/test-ref-store.c                     |  12 +-
 t/helper/test-reftable.c                      |   2 +-
 t/helper/test-repository.c                    |  14 +-
 t/helper/test-revision-walking.c              |  14 +-
 t/helper/test-rot13-filter.c                  |   2 +-
 t/helper/test-scrap-cache-tree.c              |  10 +-
 t/helper/test-serve-v2.c                      |   6 +-
 t/helper/test-sha1.c                          |   2 +-
 t/helper/test-sha256.c                        |   2 +-
 t/helper/test-submodule-config.c              |  10 +-
 t/helper/test-submodule-nested-repo-config.c  |   4 +-
 t/helper/test-submodule.c                     |   6 +-
 t/helper/test-subprocess.c                    |   2 +-
 t/helper/test-synthesize.c                    |  12 +-
 t/helper/test-trace2.c                        |   4 +-
 t/helper/test-userdiff.c                      |   6 +-
 t/helper/test-write-cache.c                   |   6 +-
 t/meson.build                                 |   1 +
 t/t0096-organize.sh                           | 739 ++++++++++++++++++
 t/unit-tests/lib-oid.h                        |   2 +-
 t/unit-tests/test-lib.c                       |   2 +-
 t/unit-tests/u-dir.c                          |   2 +-
 t/unit-tests/u-example-decorate.c             |   6 +-
 t/unit-tests/u-list-objects-filter-options.c  |   2 +-
 t/unit-tests/u-odb-inmemory.c                 |   6 +-
 t/unit-tests/u-oid-array.c                    |   2 +-
 t/unit-tests/u-oidmap.c                       |   4 +-
 t/unit-tests/u-oidtree.c                      |   4 +-
 t/unit-tests/u-reftable-stack.c               |   2 +-
 t/unit-tests/u-strcmp-offset.c                |   2 +-
 tempfile.h                                    |   2 +-
 trace.c                                       |   4 +-
 trace2.c                                      |   4 +-
 trace2/tr2_cfg.c                              |   2 +-
 trace2/tr2_sysenv.c                           |   4 +-
 trace2/tr2_tgt_event.c                        |   6 +-
 trace2/tr2_tgt_normal.c                       |   6 +-
 trace2/tr2_tgt_perf.c                         |   6 +-
 trailer.c                                     |   8 +-
 trailer.h                                     |   2 +-
 bundle-uri.c => transport/bundle-uri.c        |  16 +-
 bundle-uri.h => transport/bundle-uri.h        |   0
 bundle.c => transport/bundle.c                |  24 +-
 bundle.h => transport/bundle.h                |   2 +-
 connect.c => transport/connect.c              |  26 +-
 connect.h => transport/connect.h              |   2 +-
 connected.c => transport/connected.c          |  10 +-
 connected.h => transport/connected.h          |   0
 .../fetch-negotiator.c                        |   4 +-
 .../fetch-negotiator.h                        |   0
 .../fetch-object-info.c                       |  10 +-
 .../fetch-object-info.h                       |   4 +-
 fetch-pack.c => transport/fetch-pack.c        |  50 +-
 fetch-pack.h => transport/fetch-pack.h        |   6 +-
 .../git-curl-compat.h                         |   0
 http-walker.c => transport/http-walker.c      |  16 +-
 http.c => transport/http.c                    |  22 +-
 http.h => transport/http.h                    |   2 +-
 pkt-line.c => transport/pkt-line.c            |   4 +-
 pkt-line.h => transport/pkt-line.h            |   0
 .../promisor-remote.c                         |  14 +-
 .../promisor-remote.h                         |   2 +-
 protocol-caps.c => transport/protocol-caps.c  |  12 +-
 protocol-caps.h => transport/protocol-caps.h  |   0
 protocol.c => transport/protocol.c            |   6 +-
 protocol.h => transport/protocol.h            |   0
 remote-curl.c => transport/remote-curl.c      |  26 +-
 remote.c => transport/remote.c                |  30 +-
 remote.h => transport/remote.h                |   4 +-
 send-pack.c => transport/send-pack.c          |  24 +-
 send-pack.h => transport/send-pack.h          |   0
 serve.c => transport/serve.c                  |  22 +-
 serve.h => transport/serve.h                  |   0
 sideband.c => transport/sideband.c            |   6 +-
 sideband.h => transport/sideband.h            |   0
 .../transport-helper.c                        |  22 +-
 .../transport-internal.h                      |   2 +-
 transport.c => transport/transport.c          |  38 +-
 transport.h => transport/transport.h          |   6 +-
 upload-pack.c => transport/upload-pack.c      |  42 +-
 upload-pack.h => transport/upload-pack.h      |   0
 walker.c => transport/walker.c                |  18 +-
 walker.h => transport/walker.h                |   2 +-
 urlmatch.h                                    |   2 +-
 versioncmp.c                                  |   2 +-
 609 files changed, 6909 insertions(+), 3368 deletions(-)
 create mode 100644 .gitorganize
 create mode 100644 Documentation/git-organize.adoc
 create mode 100644 builtin/organize.c
 create mode 100644 contrib/organize/git-layout.map
 create mode 100755 contrib/organize/labeler
 create mode 100755 contrib/organize/organizer
 rename combine-diff.c => diff/combine-diff.c (99%)
 rename diff-lib.c => diff/diff-lib.c (98%)
 rename diff-merges.c => diff/diff-merges.c (98%)
 rename diff-merges.h => diff/diff-merges.h (100%)
 rename diff-no-index.c => diff/diff-no-index.c (98%)
 rename diff.c => diff/diff.c (99%)
 rename diff.h => diff/diff.h (99%)
 rename diffcore-break.c => diff/diffcore-break.c (98%)
 rename diffcore-delta.c => diff/diffcore-delta.c (99%)
 rename diffcore-order.c => diff/diffcore-order.c (97%)
 rename diffcore-pickaxe.c => diff/diffcore-pickaxe.c (98%)
 rename diffcore-rename.c => diff/diffcore-rename.c (99%)
 rename diffcore-rotate.c => diff/diffcore-rotate.c (95%)
 rename diffcore.h => diff/diffcore.h (99%)
 rename patch-ids.c => diff/patch-ids.c (97%)
 rename patch-ids.h => diff/patch-ids.h (98%)
 rename range-diff.c => diff/range-diff.c (98%)
 rename range-diff.h => diff/range-diff.h (98%)
 rename tree-diff.c => diff/tree-diff.c (99%)
 rename userdiff.c => diff/userdiff.c (99%)
 rename userdiff.h => diff/userdiff.h (100%)
 rename xdiff-interface.c => diff/xdiff-interface.c (98%)
 rename xdiff-interface.h => diff/xdiff-interface.h (99%)
 rename cache-tree.c => index/cache-tree.c (99%)
 rename cache-tree.h => index/cache-tree.h (97%)
 rename checkout.c => index/checkout.c (91%)
 rename checkout.h => index/checkout.h (94%)
 rename dir-iterator.c => index/dir-iterator.c (99%)
 rename dir-iterator.h => index/dir-iterator.h (100%)
 rename dir.c => index/dir.c (99%)
 rename dir.h => index/dir.h (99%)
 rename entry.c => index/entry.c (98%)
 rename entry.h => index/entry.h (100%)
 rename fsmonitor--daemon.h => index/fsmonitor--daemon.h (99%)
 rename fsmonitor-ipc.c => index/fsmonitor-ipc.c (98%)
 rename fsmonitor-ipc.h => index/fsmonitor-ipc.h (100%)
 rename fsmonitor-ll.h => index/fsmonitor-ll.h (100%)
 rename fsmonitor-path-utils.h => index/fsmonitor-path-utils.h (100%)
 rename fsmonitor-settings.c => index/fsmonitor-settings.c (97%)
 rename fsmonitor-settings.h => index/fsmonitor-settings.h (100%)
 rename fsmonitor.c => index/fsmonitor.c (99%)
 rename fsmonitor.h => index/fsmonitor.h (94%)
 rename name-hash.c => index/name-hash.c (99%)
 rename name-hash.h => index/name-hash.h (100%)
 rename parallel-checkout.c => index/parallel-checkout.c (98%)
 rename parallel-checkout.h => index/parallel-checkout.h (100%)
 rename pathspec.c => index/pathspec.c (99%)
 rename pathspec.h => index/pathspec.h (100%)
 rename preload-index.c => index/preload-index.c (94%)
 rename preload-index.h => index/preload-index.h (100%)
 rename read-cache-ll.h => index/read-cache-ll.h (99%)
 rename read-cache.c => index/read-cache.c (99%)
 rename read-cache.h => index/read-cache.h (91%)
 rename resolve-undo.c => index/resolve-undo.c (96%)
 rename resolve-undo.h => index/resolve-undo.h (97%)
 rename sparse-index.c => index/sparse-index.c (98%)
 rename sparse-index.h => index/sparse-index.h (100%)
 rename split-index.c => index/split-index.c (99%)
 rename split-index.h => index/split-index.h (98%)
 rename statinfo.c => index/statinfo.c (97%)
 rename statinfo.h => index/statinfo.h (100%)
 rename symlinks.c => index/symlinks.c (99%)
 rename symlinks.h => index/symlinks.h (100%)
 rename unpack-trees.c => index/unpack-trees.c (99%)
 rename unpack-trees.h => index/unpack-trees.h (98%)
 rename wt-status.c => index/wt-status.c (99%)
 rename wt-status.h => index/wt-status.h (98%)
 rename alloc.c => odb/alloc.c (94%)
 rename alloc.h => odb/alloc.h (100%)
 rename blob.c => odb/blob.c (89%)
 rename blob.h => odb/blob.h (96%)
 rename cbtree.c => odb/cbtree.c (99%)
 rename cbtree.h => odb/cbtree.h (100%)
 rename commit-slab-decl.h => odb/commit-slab-decl.h (100%)
 rename commit-slab-impl.h => odb/commit-slab-impl.h (100%)
 rename commit-slab.h => odb/commit-slab.h (97%)
 rename commit.c => odb/commit.c (98%)
 rename commit.h => odb/commit.h (99%)
 rename fsck.c => odb/fsck.c (99%)
 rename fsck.h => odb/fsck.h (99%)
 rename hash-lookup.c => odb/hash-lookup.c (97%)
 rename hash-lookup.h => odb/hash-lookup.h (100%)
 rename hash.c => odb/hash.c (99%)
 rename hash.h => odb/hash.h (99%)
 rename loose.c => odb/loose.c (97%)
 rename loose.h => odb/loose.h (100%)
 rename match-trees.c => odb/match-trees.c (98%)
 rename match-trees.h => odb/match-trees.h (100%)
 rename object-file-convert.c => odb/object-file-convert.c (98%)
 rename object-file-convert.h => odb/object-file-convert.h (96%)
 rename object-file.c => odb/object-file.c (99%)
 rename object-file.h => odb/object-file.h (99%)
 rename object-name.c => odb/object-name.c (98%)
 rename object-name.h => odb/object-name.h (99%)
 rename object.c => odb/object.c (98%)
 rename object.h => odb/object.h (99%)
 rename odb.c => odb/odb.c (98%)
 rename odb.h => odb/odb.h (99%)
 rename oid-array.c => odb/oid-array.c (97%)
 rename oid-array.h => odb/oid-array.h (99%)
 rename oidmap.c => odb/oidmap.c (97%)
 rename oidmap.h => odb/oidmap.h (99%)
 rename oidset.c => odb/oidset.c (99%)
 rename oidset.h => odb/oidset.h (100%)
 rename oidtree.c => odb/oidtree.c (98%)
 rename oidtree.h => odb/oidtree.h (97%)
 rename replace-object.c => odb/replace-object.c (94%)
 rename replace-object.h => odb/replace-object.h (96%)
 rename tag.c => odb/tag.c (95%)
 rename tag.h => odb/tag.h (96%)
 rename tmp-objdir.c => odb/tmp-objdir.c (97%)
 rename tmp-objdir.h => odb/tmp-objdir.h (100%)
 rename tree-walk.c => odb/tree-walk.c (99%)
 rename tree-walk.h => odb/tree-walk.h (99%)
 rename tree.c => odb/tree.c (96%)
 rename tree.h => odb/tree.h (98%)
 create mode 100644 organize/gitorganize-format.c
 create mode 100644 organize/gitorganize-format.h
 create mode 100644 organize/labeler-protocol.c
 create mode 100644 organize/labeler-protocol.h
 create mode 100644 organize/organize.c
 create mode 100644 organize/organize.h
 create mode 100644 organize/organizer-protocol.c
 create mode 100644 organize/organizer-protocol.h
 rename bloom.c => pack/bloom.c (98%)
 rename bloom.h => pack/bloom.h (100%)
 rename chunk-format.c => pack/chunk-format.c (98%)
 rename chunk-format.h => pack/chunk-format.h (98%)
 rename commit-graph.c => pack/commit-graph.c (99%)
 rename commit-graph.h => pack/commit-graph.h (99%)
 rename delta-islands.c => pack/delta-islands.c (97%)
 rename delta-islands.h => pack/delta-islands.h (100%)
 rename delta.h => pack/delta.h (100%)
 rename diff-delta.c => pack/diff-delta.c (99%)
 rename midx-write.c => pack/midx-write.c (99%)
 rename midx.c => pack/midx.c (99%)
 rename midx.h => pack/midx.h (100%)
 rename pack-bitmap-write.c => pack/pack-bitmap-write.c (98%)
 rename pack-bitmap.c => pack/pack-bitmap.c (99%)
 rename pack-bitmap.h => pack/pack-bitmap.h (98%)
 rename pack-check.c => pack/pack-check.c (97%)
 rename pack-mtimes.c => pack/pack-mtimes.c (97%)
 rename pack-mtimes.h => pack/pack-mtimes.h (100%)
 rename pack-objects.c => pack/pack-objects.c (97%)
 rename pack-objects.h => pack/pack-objects.h (99%)
 rename pack-revindex.c => pack/pack-revindex.c (99%)
 rename pack-revindex.h => pack/pack-revindex.h (100%)
 rename pack-write.c => pack/pack-write.c (98%)
 rename pack.h => pack/pack.h (99%)
 rename packfile-list.c => pack/packfile-list.c (96%)
 rename packfile-list.h => pack/packfile-list.h (100%)
 rename packfile.c => pack/packfile.c (99%)
 rename packfile.h => pack/packfile.h (98%)
 rename patch-delta.c => pack/patch-delta.c (98%)
 rename prune-packed.c => pack/prune-packed.c (89%)
 rename prune-packed.h => pack/prune-packed.h (100%)
 rename pseudo-merge.c => pack/pseudo-merge.c (99%)
 rename pseudo-merge.h => pack/pseudo-merge.h (100%)
 rename reachable.c => pack/reachable.c (95%)
 rename reachable.h => pack/reachable.h (100%)
 rename repack-cruft.c => pack/repack-cruft.c (97%)
 rename repack-filtered.c => pack/repack-filtered.c (96%)
 rename repack-geometry.c => pack/repack-geometry.c (98%)
 rename repack-midx.c => pack/repack-midx.c (99%)
 rename repack-promisor.c => pack/repack-promisor.c (97%)
 rename repack.c => pack/repack.c (98%)
 rename repack.h => pack/repack.h (99%)
 rename server-info.c => pack/server-info.c (96%)
 rename server-info.h => pack/server-info.h (100%)
 rename ls-refs.c => refs/ls-refs.c (96%)
 rename ls-refs.h => refs/ls-refs.h (100%)
 rename pack-refs.c => refs/pack-refs.c (92%)
 rename pack-refs.h => refs/pack-refs.h (100%)
 rename ref-filter.c => refs/ref-filter.c (99%)
 rename ref-filter.h => refs/ref-filter.h (98%)
 rename reflog-walk.c => refs/reflog-walk.c (98%)
 rename reflog-walk.h => refs/reflog-walk.h (100%)
 rename reflog.c => refs/reflog.c (98%)
 rename reflog.h => refs/reflog.h (99%)
 rename refs.c => refs/refs.c (99%)
 rename refs.h => refs/refs.h (99%)
 rename refspec.c => refs/refspec.c (99%)
 rename refspec.h => refs/refspec.h (100%)
 rename worktree.c => refs/worktree.c (99%)
 rename worktree.h => refs/worktree.h (99%)
 rename bisect.c => revision/bisect.c (98%)
 rename bisect.h => revision/bisect.h (100%)
 rename blame.c => revision/blame.c (99%)
 rename blame.h => revision/blame.h (98%)
 rename commit-reach.c => revision/commit-reach.c (99%)
 rename commit-reach.h => revision/commit-reach.h (99%)
 rename decorate.c => revision/decorate.c (97%)
 rename decorate.h => revision/decorate.h (100%)
 rename graph.c => revision/graph.c (99%)
 rename graph.h => revision/graph.h (99%)
 rename line-log.c => revision/line-log.c (98%)
 rename line-log.h => revision/line-log.h (96%)
 rename line-range.c => revision/line-range.c (98%)
 rename line-range.h => revision/line-range.h (100%)
 rename list-objects-filter-options.c => revision/list-objects-filter-options.c (99%)
 rename list-objects-filter-options.h => revision/list-objects-filter-options.h (99%)
 rename list-objects-filter.c => revision/list-objects-filter.c (98%)
 rename list-objects-filter.h => revision/list-objects-filter.h (100%)
 rename list-objects.c => revision/list-objects.c (96%)
 rename list-objects.h => revision/list-objects.h (100%)
 rename list.h => revision/list.h (100%)
 rename log-tree.c => revision/log-tree.c (98%)
 rename log-tree.h => revision/log-tree.h (100%)
 rename pretty.c => revision/pretty.c (99%)
 rename pretty.h => revision/pretty.h (100%)
 rename revision.c => revision/revision.c (99%)
 rename revision.h => revision/revision.h (98%)
 rename shallow.c => revision/shallow.c (98%)
 rename shallow.h => revision/shallow.h (97%)
 rename alias.c => setup/alias.c (98%)
 rename alias.h => setup/alias.h (100%)
 rename config.c => setup/config.c (99%)
 rename config.h => setup/config.h (99%)
 rename environment.c => setup/environment.c (98%)
 rename environment.h => setup/environment.h (99%)
 rename hook.c => setup/hook.c (99%)
 rename hook.h => setup/hook.h (99%)
 rename ident.c => setup/ident.c (99%)
 rename ident.h => setup/ident.h (100%)
 rename repo-settings.c => setup/repo-settings.c (97%)
 rename repo-settings.h => setup/repo-settings.h (100%)
 rename repository.c => setup/repository.c (97%)
 rename repository.h => setup/repository.h (99%)
 rename setup.c => setup/setup.c (99%)
 rename setup.h => setup/setup.h (99%)
 rename version.c => setup/version.c (98%)
 rename version.h => setup/version.h (100%)
 create mode 100755 t/t0096-organize.sh
 rename bundle-uri.c => transport/bundle-uri.c (99%)
 rename bundle-uri.h => transport/bundle-uri.h (100%)
 rename bundle.c => transport/bundle.c (97%)
 rename bundle.h => transport/bundle.h (97%)
 rename connect.c => transport/connect.c (99%)
 rename connect.h => transport/connect.h (98%)
 rename connected.c => transport/connected.c (97%)
 rename connected.h => transport/connected.h (100%)
 rename fetch-negotiator.c => transport/fetch-negotiator.c (90%)
 rename fetch-negotiator.h => transport/fetch-negotiator.h (100%)
 rename fetch-object-info.c => transport/fetch-object-info.c (96%)
 rename fetch-object-info.h => transport/fetch-object-info.h (91%)
 rename fetch-pack.c => transport/fetch-pack.c (98%)
 rename fetch-pack.h => transport/fetch-pack.h (97%)
 rename git-curl-compat.h => transport/git-curl-compat.h (100%)
 rename http-walker.c => transport/http-walker.c (98%)
 rename http.c => transport/http.c (99%)
 rename http.h => transport/http.h (99%)
 rename pkt-line.c => transport/pkt-line.c (99%)
 rename pkt-line.h => transport/pkt-line.h (100%)
 rename promisor-remote.c => transport/promisor-remote.c (99%)
 rename promisor-remote.h => transport/promisor-remote.h (99%)
 rename protocol-caps.c => transport/protocol-caps.c (95%)
 rename protocol-caps.h => transport/protocol-caps.h (100%)
 rename protocol.c => transport/protocol.c (96%)
 rename protocol.h => transport/protocol.h (100%)
 rename remote-curl.c => transport/remote-curl.c (99%)
 rename remote.c => transport/remote.c (99%)
 rename remote.h => transport/remote.h (99%)
 rename send-pack.c => transport/send-pack.c (98%)
 rename send-pack.h => transport/send-pack.h (100%)
 rename serve.c => transport/serve.c (96%)
 rename serve.h => transport/serve.h (100%)
 rename sideband.c => transport/sideband.c (99%)
 rename sideband.h => transport/sideband.h (100%)
 rename transport-helper.c => transport/transport-helper.c (99%)
 rename transport-internal.h => transport/transport-internal.h (98%)
 rename transport.c => transport/transport.c (98%)
 rename transport.h => transport/transport.h (98%)
 rename upload-pack.c => transport/upload-pack.c (98%)
 rename upload-pack.h => transport/upload-pack.h (100%)
 rename walker.c => transport/walker.c (97%)
 rename walker.h => transport/walker.h (97%)


base-commit: 1a3e64c6c4a623626ff0687008732a8e007e2a1c
-- 
2.54.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [RFC PATCH 01/14] organize: add the git organize builtin
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 02/14] organize: add the labeler, organizer, and apply --labels-only Michael Montalbo
                   ` (12 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Add "git organize", a builtin that reconciles a source tree against a
layout the project declares. A project records where each file belongs,
and git organize reports the files that sit elsewhere and, on request,
moves them into place. As .gitignore declares what stays untracked and
.mailmap declares canonical author names, git organize adds .gitorganize,
which declares the directory a file belongs in.

.gitorganize has three sections. [scope] lists the pathspecs of the files
in scope, one per line; with no [scope] section nothing is in scope.
[layout] is the project's placement map, hand-authored: ordered
"label:value = directory" rules, and a file takes the directory of the
first rule its labels satisfy, so rule order matters. Git lists
role:public = . and role:program = . ahead of the component rules, so an
interface header or a program that also matches a component stays at root.
[labels] records each file's labels, one line per source in scope with its
key=value labels.

"git organize status" reads [labels] and reports the files that sit outside
their directory, the backlog, and a recorded path that no longer exists. It
runs nothing and changes nothing.

"git organize apply" moves each out-of-place file into its directory as one
git apply --index transaction; a content-identical rename lets git log
--follow and git blame track the file. It stages the result and repoints
each moved file's [labels] line to its new path.

The .gitorganize reader and writer live in organize/gitorganize-format.c;
the engine that plans and applies the moves lives in organize/organize.c.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitignore                      |   1 +
 Documentation/git-organize.adoc |  82 ++++++++
 Documentation/meson.build       |   1 +
 Makefile                        |   3 +
 builtin.h                       |   1 +
 builtin/organize.c              | 110 +++++++++++
 command-list.txt                |   1 +
 git.c                           |   1 +
 meson.build                     |   3 +
 organize/gitorganize-format.c   | 261 ++++++++++++++++++++++++++
 organize/gitorganize-format.h   |  38 ++++
 organize/organize.c             | 320 ++++++++++++++++++++++++++++++++
 organize/organize.h             |  77 ++++++++
 t/meson.build                   |   1 +
 t/t0096-organize.sh             | 185 ++++++++++++++++++
 15 files changed, 1085 insertions(+)
 create mode 100644 Documentation/git-organize.adoc
 create mode 100644 builtin/organize.c
 create mode 100644 organize/gitorganize-format.c
 create mode 100644 organize/gitorganize-format.h
 create mode 100644 organize/organize.c
 create mode 100644 organize/organize.h
 create mode 100755 t/t0096-organize.sh

diff --git a/.gitignore b/.gitignore
index 4da58c6754..b85ce2b13a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -118,6 +118,7 @@
 /git-mv
 /git-name-rev
 /git-notes
+/git-organize
 /git-p4
 /git-pack-redundant
 /git-pack-objects
diff --git a/Documentation/git-organize.adoc b/Documentation/git-organize.adoc
new file mode 100644
index 0000000000..4ff76f5c13
--- /dev/null
+++ b/Documentation/git-organize.adoc
@@ -0,0 +1,82 @@
+git-organize(1)
+===============
+
+NAME
+----
+git-organize - Reconcile a source tree against a declared layout
+
+
+SYNOPSIS
+--------
+[verse]
+'git organize status'
+'git organize apply'
+
+
+DESCRIPTION
+-----------
+A project declares where each of its files belongs, and git organize
+reports the files that sit elsewhere and, on request, moves them into
+place. As `.gitignore` declares what stays untracked and `.mailmap`
+declares canonical author names, `.gitorganize` declares the directory a
+file belongs in.
+
+`.gitorganize` at the repository root has three sections. `[scope]` names
+the files in scope, one pathspec per line; with no `[scope]` section
+nothing is in scope. `[layout]` is the project's placement map, authored by
+hand: ordered `<label>:<value> = <directory>` rules (`.` is the repository
+root). A file's labels are matched against the rules in order, and the first
+rule it satisfies places it; a file matching no rule is the backlog.
+`[labels]` holds the recorded labels, one line per
+source in scope, `<path> <key>=<value> ...`, with every label the project
+defines. A placed file is listed too, so its `[labels]` line records its
+labels, independently of the directory name. Only a label named in a rule
+places a file.
+
+`git organize status` reads `[labels]` and reports the out-of-place files,
+the backlog, a file in scope that `[labels]` does not record, and a
+recorded path that no longer exists. It runs nothing and
+changes nothing.
+
+`git organize apply` reconciles the tree. It moves each out-of-place file
+into its directory. A move is a content-identical rename, so `git log
+--follow` and `git blame` track the file exactly. apply stages the result
+and repoints each carved file's `[labels]` line to its new path, carrying
+its labels. It commits nothing. apply requires a clean worktree.
+
+
+COMMANDS
+--------
+
+status::
+	Report the files whose placement value names a directory they are not
+	in (the moves), the backlog (recorded files with no matching
+	rule), a file in scope that `[labels]` does not record, and a recorded
+	path that no longer exists. Changes nothing.
+
+apply::
+	Move each out-of-place file into its directory as a content-identical
+	rename, repoint each carved file's `[labels]` line to its new path, and
+	stage the result. apply requires a clean worktree, so the change can be
+	discarded as a whole.
+
+
+FILES
+-----
+`.gitorganize`::
+	The declaration, at the repository root, in three sections. `[scope]`
+	names the files in scope, one pathspec per line; with no `[scope]`
+	section nothing is in scope. `[layout]` is the project's placement map:
+	ordered `<label>:<value> = <directory>` rules (`.` is the root), where a
+	file takes the directory of the first rule its labels satisfy, and a
+	file matching no rule is the backlog. `[labels]` holds the recorded
+	labels, one `<path> <key>=<value> ...` line per source in scope,
+	including placed files. The project writes `[scope]` and `[layout]`; the
+	move apply repoints a carved file's line. A `#` line is a comment; git
+	organize rewrites the file whole, keeping the hand-authored `[scope]`
+	and `[layout]` verbatim.
+
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Documentation/meson.build b/Documentation/meson.build
index f4854f802d..8793c927b5 100644
--- a/Documentation/meson.build
+++ b/Documentation/meson.build
@@ -98,6 +98,7 @@ manpages = {
   'git-mv.adoc' : 1,
   'git-name-rev.adoc' : 1,
   'git-notes.adoc' : 1,
+  'git-organize.adoc' : 1,
   'git-p4.adoc' : 1,
   'git-pack-objects.adoc' : 1,
   'git-pack-refs.adoc' : 1,
diff --git a/Makefile b/Makefile
index d4b775953d..da7c4df7d3 100644
--- a/Makefile
+++ b/Makefile
@@ -1237,6 +1237,8 @@ LIB_OBJS += oid-array.o
 LIB_OBJS += oidmap.o
 LIB_OBJS += oidset.o
 LIB_OBJS += oidtree.o
+LIB_OBJS += organize/gitorganize-format.o
+LIB_OBJS += organize/organize.o
 LIB_OBJS += pack-bitmap-write.o
 LIB_OBJS += pack-bitmap.o
 LIB_OBJS += pack-check.o
@@ -1465,6 +1467,7 @@ BUILTIN_OBJS += builtin/multi-pack-index.o
 BUILTIN_OBJS += builtin/mv.o
 BUILTIN_OBJS += builtin/name-rev.o
 BUILTIN_OBJS += builtin/notes.o
+BUILTIN_OBJS += builtin/organize.o
 BUILTIN_OBJS += builtin/pack-objects.o
 ifndef WITH_BREAKING_CHANGES
 BUILTIN_OBJS += builtin/pack-redundant.o
diff --git a/builtin.h b/builtin.h
index 4e47a4ebd3..0ac855e534 100644
--- a/builtin.h
+++ b/builtin.h
@@ -224,6 +224,7 @@ int cmd_multi_pack_index(int argc, const char **argv, const char *prefix, struct
 int cmd_mv(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_name_rev(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_notes(int argc, const char **argv, const char *prefix, struct repository *repo);
+int cmd_organize(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_pack_objects(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_pack_redundant(int argc, const char **argv, const char *prefix, struct repository *repo);
 int cmd_patch_id(int argc, const char **argv, const char *prefix, struct repository *repo);
diff --git a/builtin/organize.c b/builtin/organize.c
new file mode 100644
index 0000000000..9462d8687f
--- /dev/null
+++ b/builtin/organize.c
@@ -0,0 +1,110 @@
+/*
+ * "git organize": reconcile a source tree against a declared layout.
+ *
+ * cmd_organize parses arguments and drives the organize engine (organize.c).
+ * status reports the files in scope whose matching rule names a directory they
+ * are not in yet (the moves), the backlog (files with no matching rule), and a
+ * declared path that no longer exists. apply moves the misplaced files and
+ * stages the result.
+ */
+#include "builtin.h"
+#include "gettext.h"
+#include "organize/organize.h"
+#include "parse-options.h"
+#include "repository.h"
+
+static const char *const organize_usage[] = {
+	"git organize status",
+	"git organize apply",
+	NULL
+};
+
+static int organize_status(struct repository *repo)
+{
+	struct organize_plan plan = ORGANIZE_PLAN_INIT;
+	int to_move, backlog, unrecorded, orphans;
+
+	organize_plan_build(repo, &plan);
+	to_move = (int)plan.moves_nr;
+	backlog = (int)plan.backlog.nr;
+	unrecorded = (int)plan.unrecorded.nr;
+	orphans = (int)plan.orphans.nr;
+
+	/*
+	 * A summary over the files in scope: how many are already in place,
+	 * how many move, and how many match no rule.
+	 */
+	if (plan.in_scope)
+		printf(_("organize: %d in scope (%d in place, %d to move, "
+			 "%d backlog)\n"),
+		       plan.in_scope, plan.in_place, to_move, backlog);
+
+	if (to_move) {
+		printf(_("to move:\n"));
+		for (size_t i = 0; i < plan.moves_nr; i++)
+			printf("  %-32s -> %s\n", plan.moves[i].src,
+			       plan.moves[i].dst);
+		printf(_("%d file(s) would move\n"), to_move);
+	} else {
+		printf(_("in place; nothing to move\n"));
+	}
+	if (backlog) {
+		printf(_("backlog:\n"));
+		for (size_t i = 0; i < plan.backlog.nr; i++)
+			printf("  %s\n", plan.backlog.items[i].string);
+	}
+	if (unrecorded) {
+		printf(_("in scope but unrecorded:\n"));
+		for (size_t i = 0; i < plan.unrecorded.nr; i++)
+			printf("  %s\n", plan.unrecorded.items[i].string);
+	}
+	if (orphans) {
+		printf(_("declared but missing:\n"));
+		for (size_t i = 0; i < plan.orphans.nr; i++)
+			printf("  %s\n", plan.orphans.items[i].string);
+	}
+
+	organize_plan_release(&plan);
+	return 0;
+}
+
+static int organize_apply(struct repository *repo)
+{
+	struct organize_plan plan = ORGANIZE_PLAN_INIT;
+
+	organize_plan_build(repo, &plan);
+	if (!plan.moves_nr) {
+		printf(_("organize apply: nothing to do\n"));
+		organize_plan_release(&plan);
+		return 0;
+	}
+
+	organize_plan_apply(repo, &plan);
+
+	printf(_("organize apply: %d move(s).\n"), (int)plan.moves_nr);
+	printf(_("organize apply: the result is staged; nothing is committed.\n"));
+
+	organize_plan_release(&plan);
+	return 0;
+}
+
+int cmd_organize(int argc,
+		 const char **argv,
+		 const char *prefix,
+		 struct repository *repo)
+{
+	struct option options[] = {
+		OPT_END()
+	};
+	const char *subcmd;
+
+	argc = parse_options(argc, argv, prefix, options, organize_usage, 0);
+	subcmd = argc ? argv[0] : "status";
+	if (argc > 1)
+		die(_("git organize: too many arguments"));
+	if (!strcmp(subcmd, "status"))
+		return organize_status(repo);
+	else if (!strcmp(subcmd, "apply"))
+		return organize_apply(repo);
+	die(_("git organize: unknown subcommand '%s'"), subcmd);
+}
diff --git a/command-list.txt b/command-list.txt
index 21b802c420..c9892258f2 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -147,6 +147,7 @@ git-multi-pack-index                    plumbingmanipulators
 git-mv                                  mainporcelain           worktree
 git-name-rev                            plumbinginterrogators
 git-notes                               mainporcelain
+git-organize                            ancillarymanipulators           complete
 git-p4                                  foreignscminterface
 git-pack-objects                        plumbingmanipulators
 git-pack-redundant                      plumbinginterrogators
diff --git a/git.c b/git.c
index e5f1811b6b..cd2d325585 100644
--- a/git.c
+++ b/git.c
@@ -617,6 +617,7 @@ static struct cmd_struct commands[] = {
 	{ "mv", cmd_mv, RUN_SETUP | NEED_WORK_TREE },
 	{ "name-rev", cmd_name_rev, RUN_SETUP },
 	{ "notes", cmd_notes, RUN_SETUP },
+	{ "organize", cmd_organize, RUN_SETUP | NEED_WORK_TREE },
 	{ "pack-objects", cmd_pack_objects, RUN_SETUP },
 #ifndef WITH_BREAKING_CHANGES
 	{ "pack-redundant", cmd_pack_redundant, RUN_SETUP | NO_PARSEOPT | DEPRECATED },
diff --git a/meson.build b/meson.build
index d86f2acd2b..a2d987b124 100644
--- a/meson.build
+++ b/meson.build
@@ -442,6 +442,8 @@ libgit_sources = [
   'oidmap.c',
   'oidset.c',
   'oidtree.c',
+  'organize/gitorganize-format.c',
+  'organize/organize.c',
   'pack-bitmap-write.c',
   'pack-bitmap.c',
   'pack-check.c',
@@ -677,6 +679,7 @@ builtin_sources = [
   'builtin/mv.c',
   'builtin/name-rev.c',
   'builtin/notes.c',
+  'builtin/organize.c',
   'builtin/pack-objects.c',
   'builtin/pack-refs.c',
   'builtin/patch-id.c',
diff --git a/organize/gitorganize-format.c b/organize/gitorganize-format.c
new file mode 100644
index 0000000000..cdade12f5b
--- /dev/null
+++ b/organize/gitorganize-format.c
@@ -0,0 +1,261 @@
+#include "git-compat-util.h"
+#include "gitorganize-format.h"
+#include "gettext.h"
+#include "quote.h"
+#include "read-cache-ll.h"
+#include "strbuf.h"
+#include "string-list.h"
+#include "wrapper.h"
+
+void gitorganize_clear(struct gitorganize *g)
+{
+	for (size_t i = 0; i < g->rules_nr; i++) {
+		free(g->rules[i].label);
+		free(g->rules[i].value);
+		free(g->rules[i].dir);
+	}
+	FREE_AND_NULL(g->rules);
+	g->rules_nr = g->rules_alloc = 0;
+	strbuf_release(&g->header);
+	string_list_clear(&g->scope, 0);
+	string_list_clear(&g->records, 1);	/* util is an xstrdup'd string */
+}
+
+static void layout_add(struct gitorganize *g, const char *label,
+		       const char *value, const char *dir)
+{
+	struct layout_rule *rule;
+
+	ALLOC_GROW(g->rules, g->rules_nr + 1, g->rules_alloc);
+	rule = &g->rules[g->rules_nr++];
+	rule->label = xstrdup(label);
+	rule->value = xstrdup(value);
+	rule->dir = xstrdup(dir);
+}
+
+/* Read a path token (C-quoted or bare) at `p` into `out`; return its end. */
+const char *read_path_token(const char *p, struct strbuf *out)
+{
+	size_t len;
+
+	strbuf_reset(out);
+	if (*p == '"') {
+		const char *endp;
+		if (unquote_c_style(out, p, &endp))
+			die(_("organize: malformed quoted path"));
+		return endp;
+	}
+	len = strcspn(p, " \t\n");
+	strbuf_add(out, p, len);
+	return p + len;
+}
+
+/*
+ * Copy the value of `key` from the space-separated "k=value ..." string
+ * `labels` into `out`. Return out->buf, or NULL when `key` is absent.
+ */
+static const char *label_value(const char *labels, const char *key,
+			struct strbuf *out)
+{
+	size_t keylen = strlen(key);
+
+	while (*labels) {
+		const char *end = strchrnul(labels, ' ');	/* this token is [labels, end) */
+
+		if (!strncmp(labels, key, keylen) && labels[keylen] == '=') {
+			const char *value = labels + keylen + 1;	/* just past "key=" */
+
+			strbuf_reset(out);
+			strbuf_add(out, value, end - value);
+			return out->buf;
+		}
+		if (!*end)
+			break;		/* that was the last token */
+		labels = end + 1;	/* step over the space to the next */
+	}
+	return NULL;
+}
+
+/*
+ * The first rule a file's labels satisfy, or NULL (the backlog). Rules are
+ * tried in order, so an earlier rule takes precedence.
+ */
+struct layout_rule *layout_match(struct gitorganize *g, const char *labels,
+				 struct strbuf *value_buf)
+{
+	for (size_t i = 0; i < g->rules_nr; i++) {
+		struct layout_rule *rule = &g->rules[i];
+		const char *value = label_value(labels, rule->label, value_buf);
+
+		if (value && !strcmp(value, rule->value))
+			return rule;
+	}
+	return NULL;
+}
+
+/*
+ * Parse a `label:value = directory` [layout] rule and add it to `g`; die on a
+ * malformed rule or an unsafe directory. `line` is the original text, for
+ * error messages.
+ */
+static void parse_layout_rule(struct gitorganize *g, const char *trimmed,
+			      const char *line)
+{
+	const char *equals = strchr(trimmed, '='), *colon;
+	struct strbuf left = STRBUF_INIT, dir = STRBUF_INIT;
+	struct strbuf label = STRBUF_INIT, value = STRBUF_INIT;
+
+	if (!equals)
+		die(_("organize: .gitorganize: [layout] requires "
+		      "'label:value = directory' in: %s"), line);
+	strbuf_add(&left, trimmed, equals - trimmed);
+	strbuf_trim(&left);
+	strbuf_addstr(&dir, equals + 1);
+	strbuf_trim(&dir);
+	while (dir.len && dir.buf[dir.len - 1] == '/')
+		strbuf_setlen(&dir, dir.len - 1);	/* tolerate a trailing slash */
+	colon = strchr(left.buf, ':');
+	if (!colon)
+		die(_("organize: .gitorganize: [layout] requires "
+		      "'label:value = directory' in: %s"), line);
+	strbuf_add(&label, left.buf, colon - left.buf);
+	strbuf_trim(&label);
+	strbuf_addstr(&value, colon + 1);
+	strbuf_trim(&value);
+	if (!label.len || !value.len || !dir.len)
+		die(_("organize: .gitorganize: [layout] requires "
+		      "'label:value = directory' in: %s"), line);
+	if (strcmp(dir.buf, ".") && !verify_path(dir.buf, 0))
+		die(_("organize: .gitorganize: [layout] directory "
+		      "must be inside the tree: %s"), dir.buf);
+	layout_add(g, label.buf, value.buf, dir.buf);
+	strbuf_release(&left);
+	strbuf_release(&dir);
+	strbuf_release(&label);
+	strbuf_release(&value);
+}
+
+/*
+ * Parse .gitorganize into `g`: the [scope] pathspecs (g->scope), the [layout]
+ * rules (g->rules), the verbatim [scope] and [layout] header (g->header, kept
+ * for round-tripping on write), and the [labels] records (g->records, each
+ * path -> its "k=value k=value" string in util). A missing file leaves `g`
+ * empty.
+ */
+void gitorganize_read(struct gitorganize *g)
+{
+	struct strbuf buf = STRBUF_INIT;
+	struct string_list lines = STRING_LIST_INIT_NODUP;
+	struct strbuf path = STRBUF_INIT;
+	enum { NONE, SCOPE, LAYOUT, LABELS } section = NONE;
+
+	if (strbuf_read_file(&buf, ".gitorganize", 0) < 0) {
+		strbuf_release(&buf);
+		return;
+	}
+	string_list_split_in_place(&lines, buf.buf, "\n", -1);
+	for (size_t i = 0; i < lines.nr; i++) {
+		char *line = lines.items[i].string;
+		size_t len = strlen(line);
+		const char *trimmed;
+
+		if (len && line[len - 1] == '\r')
+			line[len - 1] = '\0';	/* tolerate CRLF line endings */
+		if (!*line && i + 1 == lines.nr)
+			continue;	/* trailing empty from the final newline */
+		trimmed = line + strspn(line, " \t");
+
+		if (!strcmp(trimmed, "[scope]")) {
+			section = SCOPE;
+			strbuf_addf(&g->header, "%s\n", line);
+			continue;
+		}
+		if (!strcmp(trimmed, "[layout]")) {
+			section = LAYOUT;
+			strbuf_addf(&g->header, "%s\n", line);
+			continue;
+		}
+		if (!strcmp(trimmed, "[labels]")) {
+			section = LABELS;
+			continue;
+		}
+
+		/*
+		 * [scope] and [layout] are hand-authored and round-tripped, so
+		 * every line (comments and blanks included) is kept in the
+		 * header; only a content line feeds the parsed rules.
+		 */
+		if (section == SCOPE || section == LAYOUT) {
+			strbuf_addf(&g->header, "%s\n", line);
+			if (!*trimmed || *trimmed == '#')
+				continue;
+			if (section == SCOPE)
+				string_list_append(&g->scope, trimmed);
+			else
+				parse_layout_rule(g, trimmed, line);
+			continue;
+		}
+
+		if (section == LABELS) {
+			const char *p;
+
+			if (!*trimmed || *trimmed == '#')
+				continue;
+			p = read_path_token(trimmed, &path);
+			if (!path.len)
+				die(_("organize: .gitorganize: [labels] line has "
+				      "no path: %s"), line);
+			/*
+			 * A quoted path token can end mid-line ("a"junk); a
+			 * label list must be set off by whitespace, so require
+			 * whitespace or end-of-line after the path.
+			 */
+			if (*p && *p != ' ' && *p != '\t' && *p != '\n')
+				die(_("organize: .gitorganize: trailing text "
+				      "after path: %s"), line);
+			p += strspn(p, " \t");
+			if (string_list_has_string(&g->records, path.buf))
+				die(_("organize: .gitorganize: '%s' listed twice"),
+				    path.buf);
+			string_list_insert(&g->records, path.buf)->util =
+				xstrdup(p);
+			continue;
+		}
+
+		if (*trimmed && *trimmed != '#')
+			die(_("organize: .gitorganize: line outside "
+			      "[scope]/[layout]/[labels]: %s"), line);
+	}
+	string_list_clear(&lines, 0);
+	strbuf_release(&path);
+	strbuf_release(&buf);
+}
+
+/*
+ * Write .gitorganize from `g`: its verbatim [scope] and [layout] header
+ * (g->header), then the [labels] records (g->records, each path -> its
+ * "k=value k=value" string in util), one `<path> <k=value ...>` line per entry
+ * in the list's sorted order. A path that needs it is C-quoted.
+ */
+void gitorganize_write(struct gitorganize *g)
+{
+	struct strbuf out = STRBUF_INIT;
+
+	if (g->header.len)
+		strbuf_addbuf(&out, &g->header);
+	else
+		strbuf_addstr(&out, "[layout]\n");
+	strbuf_addstr(&out, "[labels]\n");
+	for (size_t i = 0; i < g->records.nr; i++) {
+		const char *labels = g->records.items[i].util;
+
+		quote_c_style(g->records.items[i].string, &out, NULL, 0);
+		if (labels && *labels) {
+			strbuf_addch(&out, ' ');
+			strbuf_addstr(&out, labels);
+		}
+		strbuf_addch(&out, '\n');
+	}
+	write_file_buf(".gitorganize", out.buf, out.len);
+	strbuf_release(&out);
+}
diff --git a/organize/gitorganize-format.h b/organize/gitorganize-format.h
new file mode 100644
index 0000000000..d499545a25
--- /dev/null
+++ b/organize/gitorganize-format.h
@@ -0,0 +1,38 @@
+#ifndef GITORGANIZE_FORMAT_H
+#define GITORGANIZE_FORMAT_H
+
+#include "strbuf.h"
+#include "string-list.h"
+
+struct layout_rule {
+	char *label;
+	char *value;
+	char *dir;
+};
+
+/*
+ * The parsed .gitorganize file: the [scope] pathspecs, the [layout] rules, the
+ * verbatim [scope] and [layout] header (round-tripped on write), and the
+ * [labels] records (each path -> its "k=value ..." string in util).
+ */
+struct gitorganize {
+	struct string_list scope;
+	struct layout_rule *rules;
+	size_t rules_nr, rules_alloc;
+	struct strbuf header;
+	struct string_list records;
+};
+#define GITORGANIZE_INIT { \
+	.scope = STRING_LIST_INIT_DUP, \
+	.header = STRBUF_INIT, \
+	.records = STRING_LIST_INIT_DUP, \
+}
+
+void gitorganize_clear(struct gitorganize *g);
+const char *read_path_token(const char *p, struct strbuf *out);
+struct layout_rule *layout_match(struct gitorganize *g, const char *labels,
+				 struct strbuf *value_buf);
+void gitorganize_read(struct gitorganize *g);
+void gitorganize_write(struct gitorganize *g);
+
+#endif /* GITORGANIZE_FORMAT_H */
diff --git a/organize/organize.c b/organize/organize.c
new file mode 100644
index 0000000000..0d9850dfc0
--- /dev/null
+++ b/organize/organize.c
@@ -0,0 +1,320 @@
+#include "git-compat-util.h"
+#include "organize.h"
+#include "gitorganize-format.h"
+#include "gettext.h"
+#include "pathspec.h"
+#include "quote.h"
+#include "read-cache-ll.h"
+#include "repository.h"
+#include "run-command.h"
+#include "strbuf.h"
+#include "string-list.h"
+#include "strvec.h"
+#include "wrapper.h"
+#include "wt-status.h"
+
+/*
+ * The [layout] rule whose directory equals `path`'s directory, or NULL when
+ * `path` is a root file or its directory matches no rule. A file in a [layout]
+ * directory is in place, whatever its recorded label; its directory alone
+ * tells git organize it is in place.
+ */
+static struct layout_rule *layout_dir_rule(struct gitorganize *g,
+					   const char *path)
+{
+	const char *slash = strrchr(path, '/');
+	size_t dirlen;
+
+	if (!slash)
+		return NULL;		/* a root file */
+	dirlen = slash - path;
+	for (size_t i = 0; i < g->rules_nr; i++) {
+		struct layout_rule *r = &g->rules[i];
+
+		if (strcmp(r->dir, ".") && strlen(r->dir) == dirlen &&
+		    !strncmp(path, r->dir, dirlen))
+			return r;
+	}
+	return NULL;
+}
+
+/*
+ * Read the index once into two lists: every tracked file in `tracked_files`,
+ * and the governed subset in `scoped_files`. A file is governed when it matches
+ * the [scope] pathspecs (a candidate to label and move) or when it already sits
+ * in a [layout] directory (kept in scope so a file added under a carved
+ * directory does not slip in ungoverned). With no [scope] pathspecs and no
+ * [layout] rules, no file is governed.
+ */
+static void collect_index(struct repository *repo, struct gitorganize *g,
+			  struct string_list *scoped_files,
+			  struct string_list *tracked_files)
+{
+	struct pathspec pathspec;
+	struct strvec specs = STRVEC_INIT;
+
+	for (size_t i = 0; i < g->scope.nr; i++)
+		strvec_push(&specs, g->scope.items[i].string);
+	parse_pathspec(&pathspec, 0, PATHSPEC_PREFER_FULL, "", specs.v);
+
+	if (repo_read_index(repo) < 0)
+		die(_("organize: could not read the index"));
+	for (size_t i = 0; i < repo->index->cache_nr; i++) {
+		const char *name = repo->index->cache[i]->name;
+
+		string_list_insert(tracked_files, name);
+		if (g->scope.nr &&
+		    match_pathspec(repo->index, &pathspec, name,
+				   strlen(name), 0, NULL, 0))
+			string_list_insert(scoped_files, name);
+		else if (layout_dir_rule(g, name))
+			string_list_insert(scoped_files, name);
+	}
+	clear_pathspec(&pathspec);
+	strvec_clear(&specs);
+}
+
+/*
+ * The parsed .gitorganize (gitorg) and the tree state that status, apply, and
+ * labeling all read: the files in scope (scoped_files) and every tracked_files
+ * file.
+ */
+struct organize_ctx {
+	struct gitorganize gitorg;
+	struct string_list scoped_files;
+	struct string_list tracked_files;
+};
+#define ORGANIZE_CTX_INIT { \
+	.gitorg = GITORGANIZE_INIT, \
+	.scoped_files = STRING_LIST_INIT_DUP, \
+	.tracked_files = STRING_LIST_INIT_DUP, \
+}
+
+static void organize_ctx_load(struct repository *repo, struct organize_ctx *ctx)
+{
+	gitorganize_read(&ctx->gitorg);
+	collect_index(repo, &ctx->gitorg, &ctx->scoped_files,
+		      &ctx->tracked_files);
+}
+
+static void organize_ctx_release(struct organize_ctx *ctx)
+{
+	gitorganize_clear(&ctx->gitorg);
+	string_list_clear(&ctx->scoped_files, 0);
+	string_list_clear(&ctx->tracked_files, 0);
+}
+
+static void add_move(struct organize_plan *plan, const char *src,
+		     char *dst, const char *value)
+{
+	struct organize_move *m;
+
+	ALLOC_GROW(plan->moves, plan->moves_nr + 1, plan->moves_alloc);
+	m = &plan->moves[plan->moves_nr++];
+	m->src = xstrdup(src);
+	m->dst = dst;
+	m->rule_value = xstrdup(value);
+}
+
+void organize_plan_build(struct repository *repo, struct organize_plan *plan)
+{
+	struct organize_ctx ctx = ORGANIZE_CTX_INIT;
+	struct string_list seen = STRING_LIST_INIT_DUP;
+	struct strbuf value_buf = STRBUF_INIT;
+
+	organize_ctx_load(repo, &ctx);
+
+	/*
+	 * Classify each recorded entry by the rule its labels match. A file
+	 * already in the rule's directory is in place. A file in another
+	 * directory is a move. A file whose labels match no rule is backlog.
+	 */
+	for (size_t i = 0; i < ctx.gitorg.records.nr; i++) {
+		const char *path = ctx.gitorg.records.items[i].string;
+		const char *labels = ctx.gitorg.records.items[i].util;
+		const char *base, *target, *slash;
+		struct layout_rule *rule;
+		struct strbuf dst = STRBUF_INIT;
+
+		if (!string_list_has_string(&ctx.tracked_files, path))
+			continue;	/* an orphan, handled below */
+		string_list_insert(&seen, path);
+		plan->in_scope++;
+
+		rule = layout_match(&ctx.gitorg, labels, &value_buf);
+		if (!rule) {
+			string_list_append(&plan->backlog, path);
+			continue;
+		}
+		target = rule->dir;
+
+		/* the path the rule names: dir/base, or base at the root */
+		slash = strrchr(path, '/');
+		base = slash ? slash + 1 : path;
+		if (!strcmp(target, "."))
+			strbuf_addstr(&dst, base);
+		else
+			strbuf_addf(&dst, "%s/%s", target, base);
+
+		if (!strcmp(dst.buf, path))
+			plan->in_place++;	/* already in place */
+		else
+			add_move(plan, path, strbuf_detach(&dst, NULL), rule->value);
+		strbuf_release(&dst);
+	}
+
+	/*
+	 * The loop above covered every file with a [labels] line. A file in scope
+	 * with no such line falls into one of two groups. A file already in a
+	 * [layout] directory is in place; the tree is truth, so it needs no
+	 * [labels] line. A root file with no line is unrecorded; it is a mismatch
+	 * between the tree and [labels] and does not count toward in_scope, like
+	 * an orphan.
+	 */
+	for (size_t i = 0; i < ctx.scoped_files.nr; i++) {
+		const char *path = ctx.scoped_files.items[i].string;
+
+		if (string_list_has_string(&seen, path))
+			continue;
+		if (layout_dir_rule(&ctx.gitorg, path)) {
+			plan->in_scope++;
+			plan->in_place++;
+		} else {
+			string_list_append(&plan->unrecorded, path);
+		}
+	}
+
+	/* A recorded path that is no longer a tracked_files file is an orphan. */
+	for (size_t i = 0; i < ctx.gitorg.records.nr; i++)
+		if (!string_list_has_string(&ctx.tracked_files, ctx.gitorg.records.items[i].string))
+			string_list_append(&plan->orphans, ctx.gitorg.records.items[i].string);
+
+	organize_ctx_release(&ctx);
+	string_list_clear(&seen, 0);
+	strbuf_release(&value_buf);
+}
+
+/* Whether the worktree has staged or unstaged changes to any tracked file. */
+static int worktree_dirty(struct repository *repo)
+{
+	if (repo_read_index(repo) < 0)
+		die(_("organize: could not read the index"));
+	return has_unstaged_changes(repo, 0) || has_uncommitted_changes(repo, 0);
+}
+
+/* Map each move's src to its dst, in `dst_of`. */
+static void plan_dst_map(struct organize_plan *plan, struct string_list *dst_of)
+{
+	for (size_t i = 0; i < plan->moves_nr; i++)
+		string_list_insert(dst_of, plan->moves[i].src)->util =
+			plan->moves[i].dst;
+}
+
+/* A content-identical rename entry per move. */
+static void build_rename_patch(struct organize_plan *plan, struct strbuf *out)
+{
+	for (size_t i = 0; i < plan->moves_nr; i++) {
+		struct organize_move *m = &plan->moves[i];
+
+		/* These are tracked_files source paths, which need no quoting. */
+		strbuf_addf(out, "diff --git a/%s b/%s\n", m->src, m->dst);
+		strbuf_addstr(out, "similarity index 100%\n");
+		strbuf_addf(out, "rename from %s\n", m->src);
+		strbuf_addf(out, "rename to %s\n", m->dst);
+	}
+}
+
+static int git_apply_index(const char *patch, size_t len)
+{
+	struct child_process cp = CHILD_PROCESS_INIT;
+
+	cp.git_cmd = 1;
+	strvec_pushl(&cp.args, "apply", "--index", NULL);
+	return pipe_command(&cp, patch, len, NULL, 0, NULL, 0);
+}
+
+/*
+ * Repoint each carved file's [labels] line to its new path, carrying its labels
+ * unchanged: only its location changes. Returns nonzero when [labels] changed.
+ */
+static int repoint_moved_declarations(struct organize_plan *plan)
+{
+	struct gitorganize g = GITORGANIZE_INIT;
+	struct string_list dst_of = STRING_LIST_INIT_NODUP;
+	struct string_list new_records = STRING_LIST_INIT_DUP;
+	int changed = 0;
+
+	plan_dst_map(plan, &dst_of);
+	gitorganize_read(&g);
+
+	/*
+	 * Rewrite [labels]: an entry whose file moved (found in dst_of) takes
+	 * its new path (dst_of's util) and keeps its labels (the record's util).
+	 */
+	for (size_t i = 0; i < g.records.nr; i++) {
+		const char *path = g.records.items[i].string;
+		const char *labels = g.records.items[i].util;
+		struct string_list_item *moved =
+			string_list_lookup(&dst_of, path);
+
+		if (moved) {
+			path = moved->util;
+			changed = 1;
+		}
+		string_list_insert(&new_records, path)->util = xstrdup(labels);
+	}
+
+	/* Install the rewritten [labels]; gitorganize_clear frees it below. */
+	string_list_clear(&g.records, 1);
+	g.records = new_records;
+	if (changed)
+		gitorganize_write(&g);
+
+	gitorganize_clear(&g);
+	string_list_clear(&dst_of, 0);
+	return changed;
+}
+
+void organize_plan_apply(struct repository *repo, struct organize_plan *plan)
+{
+	struct strbuf patch = STRBUF_INIT;
+
+	if (worktree_dirty(repo))
+		die(_("organize apply: the worktree has uncommitted changes; "
+		      "commit or stash first"));
+
+	/*
+	 * Content-identical renames for every move, applied as one
+	 * git apply --index transaction, so a failure leaves the tree untouched.
+	 */
+	build_rename_patch(plan, &patch);
+	if (patch.len && git_apply_index(patch.buf, patch.len))
+		die(_("organize apply: the change does not apply cleanly; "
+		      "nothing was changed"));
+
+	if (repoint_moved_declarations(plan)) {
+		struct child_process add = CHILD_PROCESS_INIT;
+
+		add.git_cmd = 1;
+		strvec_pushl(&add.args, "add", ".gitorganize", NULL);
+		if (run_command(&add))
+			die(_("organize apply: staging .gitorganize failed; "
+			      "restore with git reset --hard"));
+	}
+
+	strbuf_release(&patch);
+}
+
+void organize_plan_release(struct organize_plan *plan)
+{
+	for (size_t i = 0; i < plan->moves_nr; i++) {
+		free(plan->moves[i].src);
+		free(plan->moves[i].dst);
+		free(plan->moves[i].rule_value);
+	}
+	FREE_AND_NULL(plan->moves);
+	plan->moves_nr = plan->moves_alloc = 0;
+	string_list_clear(&plan->backlog, 0);
+	string_list_clear(&plan->unrecorded, 0);
+	string_list_clear(&plan->orphans, 0);
+}
diff --git a/organize/organize.h b/organize/organize.h
new file mode 100644
index 0000000000..c26453d2be
--- /dev/null
+++ b/organize/organize.h
@@ -0,0 +1,77 @@
+#ifndef ORGANIZE_H
+#define ORGANIZE_H
+
+#include "string-list.h"
+
+struct repository;
+
+/*
+ * The git organize engine. A project declares where each file belongs, and
+ * git organize reconciles the tree against that declaration.
+ *
+ * The committed declaration lives in .gitorganize, a file organize owns, in
+ * three sections:
+ *
+ *   [scope]    the scope pathspecs, one per line; no [scope] section means
+ *     nothing is in scope.
+ *
+ *   [layout]   the project's placement map, hand-authored: ordered
+ *     `<label>:<value> = <directory>` rules (`.` is the root). A file's labels
+ *     are matched against the rules in order, and the first rule it satisfies
+ *     places it; a file matching no rule is backlog. Only a label named in
+ *     a rule places a file.
+ *
+ *   [labels]   the recorded labels, one line per source in scope, `<path> <key>=
+ *     <value> ...`, with every label the project defines. Placed files are listed
+ *     too, so a placed file's [labels] line records its labels, independently of
+ *     the directory name.
+ *
+ *   status  Read [labels] and report the files in scope whose matching rule
+ *     names a directory they are not in yet (the moves), the backlog, and a
+ *     recorded path that no longer exists.
+ *
+ *   apply   Perform the moves. A move is a content-identical rename, applied as
+ *     one git apply --index transaction. A carved file's [labels] line is
+ *     repointed to its new path, carrying its labels.
+ */
+
+struct organize_move {
+	char *src;	/* current path */
+	char *dst;	/* declared path */
+	char *rule_value;	/* the matched rule's value */
+};
+
+struct organize_plan {
+	struct organize_move *moves;
+	size_t moves_nr, moves_alloc;
+	struct string_list backlog;	/* recorded files that match no rule */
+	struct string_list unrecorded;	/* scope files with no [labels] record */
+	struct string_list orphans;	/* declared paths that no longer exist */
+	int in_scope;			/* files in scope */
+	int in_place;			/* files in scope already at their declared location */
+};
+
+#define ORGANIZE_PLAN_INIT { \
+	.backlog = STRING_LIST_INIT_DUP, \
+	.unrecorded = STRING_LIST_INIT_DUP, \
+	.orphans = STRING_LIST_INIT_DUP, \
+}
+
+/*
+ * Read the .gitorganize declaration and record every file whose matching
+ * rule names a directory it is not in as a move. Also record the backlog
+ * (recorded files that match no rule), the unrecorded files (in scope,
+ * no [labels] line), and the orphans (declared paths
+ * that no longer exist).
+ */
+void organize_plan_build(struct repository *repo, struct organize_plan *plan);
+
+/*
+ * Perform the plan: apply the moves as one content-identical-rename
+ * transaction; the result is staged. Requires a clean worktree.
+ */
+void organize_plan_apply(struct repository *repo, struct organize_plan *plan);
+
+void organize_plan_release(struct organize_plan *plan);
+
+#endif /* ORGANIZE_H */
diff --git a/t/meson.build b/t/meson.build
index 2133c840da..fba20fc069 100644
--- a/t/meson.build
+++ b/t/meson.build
@@ -127,6 +127,7 @@ integration_tests = [
   't0092-diagnose.sh',
   't0093-verify-cache-df-gap.sh',
   't0095-bloom.sh',
+  't0096-organize.sh',
   't0100-previous.sh',
   't0101-at-syntax.sh',
   't0200-gettext-basic.sh',
diff --git a/t/t0096-organize.sh b/t/t0096-organize.sh
new file mode 100755
index 0000000000..a352a1c7d1
--- /dev/null
+++ b/t/t0096-organize.sh
@@ -0,0 +1,185 @@
+#!/bin/sh
+
+test_description='git organize reconciles a tree against a declared layout'
+
+. ./test-lib.sh
+
+# There is no labeler yet, so tests write .gitorganize by hand: root *.c/*.h in
+# scope, odb/refs components, and a [labels] census.
+write_declaration () {
+	cat >.gitorganize <<-\EOF
+	[scope]
+	:(glob)*.c
+	:(glob)*.h
+	[layout]
+	role:public = .
+	role:program = .
+	component:odb = odb
+	component:refs = refs
+	[labels]
+	blob.c component=odb role=lib
+	header.h component=? role=public
+	refs.c component=refs role=lib
+	EOF
+}
+
+test_expect_success 'setup a tree and a declaration' '
+	echo blob >blob.c &&
+	echo refs >refs.c &&
+	echo header >header.h &&
+	git add . &&
+	git commit -m init &&
+	write_declaration &&
+	git add .gitorganize &&
+	git commit -m declare
+'
+
+test_expect_success 'status reports the files to move' '
+	git organize status >actual &&
+	# header.h is public (in place at root); blob.c and refs.c move next
+	test_grep "organize: 3 in scope (1 in place, 2 to move, 0 backlog)" actual &&
+	test_grep "blob.c  *-> odb/blob.c" actual &&
+	test_grep "refs.c  *-> refs/refs.c" actual &&
+	test_grep ! header.h actual &&
+	test_grep "2 file(s) would move" actual
+'
+
+test_expect_success 'apply moves files as content-identical renames and repoints [labels]' '
+	git organize apply &&
+	git diff --cached -M --name-status >actual &&
+	test_grep "^R100.*blob.c.*odb/blob.c" actual &&
+	test_grep "^R100.*refs.c.*refs/refs.c" actual &&
+	test_path_is_file odb/blob.c &&
+	test_path_is_file refs/refs.c &&
+	test_path_is_file header.h &&
+	test_path_is_missing blob.c &&
+	test_path_is_missing refs.c &&
+	git diff --cached --name-only >staged &&
+	test_grep "^.gitorganize$" staged &&
+	git commit -m reconciled &&
+	git organize status >actual &&
+	test_grep "nothing to move" actual &&
+	test_grep "^odb/blob.c component=odb" .gitorganize &&
+	test_grep "^refs/refs.c component=refs" .gitorganize &&
+	test_grep ! "^blob.c " .gitorganize &&
+	test_grep ! "^refs.c " .gitorganize &&
+	test_grep "^header.h component=? role=public" .gitorganize
+'
+
+test_expect_success 'apply refuses a dirty worktree' '
+	git init dirty &&
+	(
+		cd dirty &&
+		echo blob >blob.c &&
+		echo other >other.c &&
+		git add . &&
+		git commit -m init &&
+		cat >.gitorganize <<-\EOF &&
+		[scope]
+		:(glob)*.c
+		[layout]
+		component:odb = odb
+		[labels]
+		blob.c component=odb
+		other.c component=?
+		EOF
+		git add .gitorganize &&
+		git commit -m declare &&
+		echo dirty >>other.c &&
+		test_must_fail git organize apply 2>err &&
+		test_grep "uncommitted changes" err
+	)
+'
+
+test_expect_success 'a file in scope with no matching rule is backlog' '
+	git init backlog &&
+	(
+		cd backlog &&
+		echo a >a.c &&
+		git add . &&
+		git commit -m init &&
+		cat >.gitorganize <<-\EOF &&
+		[scope]
+		:(glob)*.c
+		[layout]
+		component:odb = odb
+		[labels]
+		a.c component=?
+		EOF
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize status >actual &&
+		test_grep "backlog" actual &&
+		test_grep "^  a.c$" actual
+	)
+'
+
+test_expect_success 'status reports a declared path that no longer exists' '
+	git init orphan &&
+	(
+		cd orphan &&
+		echo a >a.c &&
+		echo b >b.c &&
+		git add . &&
+		git commit -m init &&
+		cat >.gitorganize <<-\EOF &&
+		[scope]
+		:(glob)*.c
+		[layout]
+		role:public = .
+		[labels]
+		a.c role=public
+		b.c role=public
+		EOF
+		git add .gitorganize &&
+		git commit -m declare &&
+		git rm -q b.c &&
+		git commit -m drop-b &&
+		git organize status >actual &&
+		test_grep "declared but missing" actual &&
+		test_grep "  b.c" actual
+	)
+'
+
+test_expect_success 'status rejects a malformed .gitorganize' '
+	git init bad &&
+	(
+		cd bad &&
+		echo a >a.c &&
+		git add . &&
+		git commit -m init &&
+		cat >.gitorganize <<-\EOF &&
+		[layout]
+		component:odb = odb
+		[labels]
+		a.c component=odb
+		a.c component=odb
+		EOF
+		test_must_fail git organize status 2>err &&
+		test_grep "listed twice" err &&
+		cat >.gitorganize <<-\EOF &&
+		[layout]
+		nocolon = .
+		EOF
+		test_must_fail git organize status 2>err &&
+		test_grep "label:value = directory" err &&
+		cat >.gitorganize <<-\EOF &&
+		[layout]
+		component:x = ../evil
+		EOF
+		test_must_fail git organize status 2>err &&
+		test_grep "must be inside the tree" err &&
+		cat >.gitorganize <<-\EOF &&
+		stray line
+		EOF
+		test_must_fail git organize status 2>err &&
+		test_grep "line outside" err
+	)
+'
+
+test_expect_success 'a subcommand rejects extra operands' '
+	test_must_fail git -C bad organize status junk 2>err &&
+	test_grep "too many arguments" err
+'
+
+test_done
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 02/14] organize: add the labeler, organizer, and apply --labels-only
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 01/14] organize: add the git organize builtin Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 03/14] organize: add status --exit-code Michael Montalbo
                   ` (11 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

The core builtin reconciles a tree against a hand-written [labels] section,
but nothing fills [labels] in and every move is a bare rename. A project
needs to record where each file belongs and to repoint the references a
move breaks.

Add the two configured commands that supply that judgment, the way a merge
driver's command is configured in git config:

  organize.labeler    records a [labels] line per root file in scope
  organize.organizer  returns edits for the files a move touches

git organize apply --labels-only runs the labeler and writes [labels],
preserving the lines of already placed files. Plain git organize apply,
when an organizer is configured, hands it the standing moves over a pipe;
the organizer returns a patch of the edits and a reason for any move it
declines. The moves and the patch apply as one git apply transaction, so a
failure leaves the tree untouched. A declined move keeps its file and its
[labels] line.

The organizer patch is validated before anything applies. It may edit a
referring file, or rename a moved file as it edits it, but it must not add,
delete, or copy files, and any rename must match a planned move.

Add a reference labeler and organizer under contrib/organize for Git's own
tree. The labeler places each source by the "area:" prefix its own commits
carry most often, mined with git log --follow: the area its authors name
need not be its filename, so ws.c files under whitespace and
diffcore-pickaxe.c under pickaxe. git-layout.map groups these prefix tokens
into components under [tokens]; odb owns object, object-file, blob, tag, and
so on. A source whose prefix is a broad area name that also swept its
neighbors, or that has too little history to name an area, falls back to its
filename through the [names] section. A source that neither section places,
but that changes chiefly alongside one component, is promoted there. A
source that couples broadly stays at the root. Each record also carries the
prefix, the #include coupling, and the co-change profile as advisory
signals. The organizer repoints the moved build object in the Makefile and
meson.build, and rewrites the #include of each moved header to its new path
across the tree.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 Documentation/git-organize.adoc | 108 ++++++-
 Makefile                        |   2 +
 builtin/organize.c              |  48 +++-
 contrib/organize/git-layout.map |  41 +++
 contrib/organize/labeler        | 333 ++++++++++++++++++++++
 contrib/organize/organizer      | 334 ++++++++++++++++++++++
 meson.build                     |   2 +
 organize/gitorganize-format.c   |   5 +
 organize/labeler-protocol.c     |  52 ++++
 organize/labeler-protocol.h     |  15 +
 organize/organize.c             | 165 ++++++++++-
 organize/organize.h             |  50 +++-
 organize/organizer-protocol.c   | 254 +++++++++++++++++
 organize/organizer-protocol.h   |  18 ++
 t/t0096-organize.sh             | 479 +++++++++++++++++++++++++++++---
 15 files changed, 1817 insertions(+), 89 deletions(-)
 create mode 100644 contrib/organize/git-layout.map
 create mode 100755 contrib/organize/labeler
 create mode 100755 contrib/organize/organizer
 create mode 100644 organize/labeler-protocol.c
 create mode 100644 organize/labeler-protocol.h
 create mode 100644 organize/organizer-protocol.c
 create mode 100644 organize/organizer-protocol.h

diff --git a/Documentation/git-organize.adoc b/Documentation/git-organize.adoc
index 4ff76f5c13..8b216146b6 100644
--- a/Documentation/git-organize.adoc
+++ b/Documentation/git-organize.adoc
@@ -11,6 +11,7 @@ SYNOPSIS
 [verse]
 'git organize status'
 'git organize apply'
+'git organize apply' --labels-only [--reseed]
 
 
 DESCRIPTION
@@ -31,18 +32,36 @@ rule it satisfies places it; a file matching no rule is the backlog.
 source in scope, `<path> <key>=<value> ...`, with every label the project
 defines. A placed file is listed too, so its `[labels]` line records its
 labels, independently of the directory name. Only a label named in a rule
-places a file.
+places a file; a label named in no rule places nothing and is recorded for a
+reader.
+
+The labeler and organizer live in config: `organize.labeler` and
+`organize.organizer`. A label is a key and value the labeler attaches to a
+file. `git organize apply --labels-only` runs the labeler and records the
+labels. A file is out of place when its matching rule names a directory it
+is not in yet.
 
 `git organize status` reads `[labels]` and reports the out-of-place files,
 the backlog, a file in scope that `[labels]` does not record, and a
-recorded path that no longer exists. It runs nothing and
-changes nothing.
+recorded path that no longer exists. status runs no
+configured command and changes nothing.
 
 `git organize apply` reconciles the tree. It moves each out-of-place file
-into its directory. A move is a content-identical rename, so `git log
---follow` and `git blame` track the file exactly. apply stages the result
-and repoints each carved file's `[labels]` line to its new path, carrying
-its labels. It commits nothing. apply requires a clean worktree.
+into its directory. A move that git organize makes on its own is a
+content-identical rename, so `git log --follow` and `git blame` track the
+file exactly. apply stages the result and repoints each carved file's
+`[labels]` line to its new path, carrying its labels. It commits nothing.
+
+A move can require an edit elsewhere, such as repointing a reference in
+another file, or an edit to the moved file itself, such as repointing its
+own references. A project supplies those edits with an organizer, its
+`organize.organizer` command. apply hands the organizer its
+moves. The organizer returns a patch of the edits and, for any move it
+cannot complete, a reason to skip it. When the organizer edits a file as it
+moves, git's rename detection matches it while its similarity stays above
+the rename threshold. apply applies the moves and the patch as one
+transaction. With no organizer configured, apply moves the files and makes
+no other edit.
 
 
 COMMANDS
@@ -52,13 +71,59 @@ status::
 	Report the files whose placement value names a directory they are not
 	in (the moves), the backlog (recorded files with no matching
 	rule), a file in scope that `[labels]` does not record, and a recorded
-	path that no longer exists. Changes nothing.
+	path that no longer exists. Runs no configured
+	command and changes nothing.
 
 apply::
 	Move each out-of-place file into its directory as a content-identical
-	rename, repoint each carved file's `[labels]` line to its new path, and
-	stage the result. apply requires a clean worktree, so the change can be
-	discarded as a whole.
+	rename, apply the organizer's edits, repoint each carved file's
+	`[labels]` line to its new path, and stage the result. apply requires a
+	clean worktree, so the change can be discarded as a whole.
++
+With `--labels-only`, apply instead records the `[labels]` line for every root
+file in scope and stages the file. A file already recorded keeps its line, so a
+placement chosen by hand or in an earlier run stands; the labeler only seeds a
+file that has no line yet. With `--reseed`, re-derive every line from the
+labeler, discarding the recorded placements. This is the only path that runs a
+labeler; `git organize apply` without `--labels-only` and `git organize status`
+never do.
+
+
+OPTIONS
+-------
+
+--labels-only::
+	With apply, run the labeler and record the labels; move no file. A
+	recorded file keeps its line; the labeler only seeds a file that has no
+	line yet.
+
+--reseed::
+	With apply `--labels-only`, re-derive every `[labels]` line from the
+	labeler, discarding the recorded placements. Use it to re-apply the
+	labeler after its map changes; without it a recorded line is kept.
+
+
+CONFIGURATION
+-------------
+organize.labeler::
+	The command that records the labels. `git organize apply
+	--labels-only` runs it over the root files in scope. It writes one
+	record per file on its standard output: the path, a NUL, its
+	space-separated `key=value` labels, a NUL. A file in scope with no
+	record is unrecorded, reported apart from the backlog. Use user or
+	system config for this setting; do
+	not take it from a repository file.
+
+organize.organizer::
+	The command that returns move edits. apply runs it over the moves. It
+	reads the pending moves on its standard input and returns a patch and
+	any skip reasons; see PROTOCOL. Optional. Without it, apply performs the
+	moves and makes no other edit. Use user or system config for this
+	setting; do not take it from a repository file.
+
+The labeler and organizer are trusted, the way a clean or smudge filter or a
+hook is trusted. Set them in user or system config, so a repository you clone
+cannot supply its own.
 
 
 FILES
@@ -71,10 +136,23 @@ FILES
 	file takes the directory of the first rule its labels satisfy, and a
 	file matching no rule is the backlog. `[labels]` holds the recorded
 	labels, one `<path> <key>=<value> ...` line per source in scope,
-	including placed files. The project writes `[scope]` and `[layout]`; the
-	move apply repoints a carved file's line. A `#` line is a comment; git
-	organize rewrites the file whole, keeping the hand-authored `[scope]`
-	and `[layout]` verbatim.
+	including placed files. The project writes `[scope]` and `[layout]`;
+	`git organize apply --labels-only` writes `[labels]`, and the move apply
+	repoints a carved file's line. A `#` line is a comment; git organize
+	rewrites the file whole, keeping the hand-authored `[scope]` and
+	`[layout]` verbatim.
+
+
+PROTOCOL
+--------
+apply speaks a line protocol with the organizer over a pipe. It writes the
+version line `git-organize 1 organize`, then a `move <src> <dst> <label>`
+line per pending move, with C-quoted paths. The organizer replies with the
+same version line. For each declined move, it writes `reject <src>
+<reason>`. It may then write `patch`, followed by a git patch that runs to
+the end of its output. The patch may edit referring files and may rename a
+moved file as it edits it, but it must not add, delete, or copy files, and
+any rename must match a planned move.
 
 
 GIT
diff --git a/Makefile b/Makefile
index da7c4df7d3..86297e9459 100644
--- a/Makefile
+++ b/Makefile
@@ -1238,7 +1238,9 @@ LIB_OBJS += oidmap.o
 LIB_OBJS += oidset.o
 LIB_OBJS += oidtree.o
 LIB_OBJS += organize/gitorganize-format.o
+LIB_OBJS += organize/labeler-protocol.o
 LIB_OBJS += organize/organize.o
+LIB_OBJS += organize/organizer-protocol.o
 LIB_OBJS += pack-bitmap-write.o
 LIB_OBJS += pack-bitmap.o
 LIB_OBJS += pack-check.o
diff --git a/builtin/organize.c b/builtin/organize.c
index 9462d8687f..354ba2151f 100644
--- a/builtin/organize.c
+++ b/builtin/organize.c
@@ -5,7 +5,8 @@
  * status reports the files in scope whose matching rule names a directory they
  * are not in yet (the moves), the backlog (files with no matching rule), and a
  * declared path that no longer exists. apply moves the misplaced files and
- * stages the result.
+ * stages the result; apply --labels-only instead runs the labeler and records
+ * the labels.
  */
 #include "builtin.h"
 #include "gettext.h"
@@ -16,6 +17,7 @@
 static const char *const organize_usage[] = {
 	"git organize status",
 	"git organize apply",
+	"git organize apply --labels-only [--reseed]",
 	NULL
 };
 
@@ -71,6 +73,7 @@ static int organize_status(struct repository *repo)
 static int organize_apply(struct repository *repo)
 {
 	struct organize_plan plan = ORGANIZE_PLAN_INIT;
+	int moved = 0, rejected = 0;
 
 	organize_plan_build(repo, &plan);
 	if (!plan.moves_nr) {
@@ -81,7 +84,17 @@ static int organize_apply(struct repository *repo)
 
 	organize_plan_apply(repo, &plan);
 
-	printf(_("organize apply: %d move(s).\n"), (int)plan.moves_nr);
+	for (size_t i = 0; i < plan.moves_nr; i++) {
+		if (plan.moves[i].skip_reason)
+			rejected++;
+		else
+			moved++;
+	}
+	printf(_("organize apply: %d move(s), %d skipped.\n"), moved, rejected);
+	for (size_t i = 0; i < plan.moves_nr; i++)
+		if (plan.moves[i].skip_reason)
+			printf("  skipped %-28s %s\n", plan.moves[i].src,
+			       plan.moves[i].skip_reason);
 	printf(_("organize apply: the result is staged; nothing is committed.\n"));
 
 	organize_plan_release(&plan);
@@ -93,18 +106,39 @@ int cmd_organize(int argc,
 		 const char *prefix,
 		 struct repository *repo)
 {
+	int labels_only = 0, reseed = 0;
 	struct option options[] = {
+		OPT_BOOL(0, "labels-only", &labels_only,
+			 N_("with apply, run the labeler and record the labels")),
+		OPT_BOOL(0, "reseed", &reseed,
+			 N_("with apply --labels-only, re-derive every recorded label")),
 		OPT_END()
 	};
 	const char *subcmd;
+	int ret;
 
 	argc = parse_options(argc, argv, prefix, options, organize_usage, 0);
 	subcmd = argc ? argv[0] : "status";
 	if (argc > 1)
 		die(_("git organize: too many arguments"));
-	if (!strcmp(subcmd, "status"))
-		return organize_status(repo);
-	else if (!strcmp(subcmd, "apply"))
-		return organize_apply(repo);
-	die(_("git organize: unknown subcommand '%s'"), subcmd);
+	if (reseed && !labels_only)
+		die(_("git organize: --reseed is a --labels-only option"));
+	if (!strcmp(subcmd, "status")) {
+		if (labels_only)
+			die(_("git organize: --labels-only is an apply option"));
+		ret = organize_status(repo);
+	} else if (!strcmp(subcmd, "apply")) {
+		if (labels_only) {
+			organize_run_labeler(repo, reseed);
+			printf(_("organize apply --labels-only: the declaration is "
+				 "staged; nothing is committed.\n"));
+			ret = 0;
+		} else {
+			ret = organize_apply(repo);
+		}
+	} else {
+		die(_("git organize: unknown subcommand '%s'"), subcmd);
+	}
+
+	return ret;
 }
diff --git a/contrib/organize/git-layout.map b/contrib/organize/git-layout.map
new file mode 100644
index 0000000000..580d556b92
--- /dev/null
+++ b/contrib/organize/git-layout.map
@@ -0,0 +1,41 @@
+# Git component layout for the reference labeler, in two sections.
+#
+# [tokens] lists, per component directory, the commit-subject prefix tokens
+# that belong to it. A file is placed by the "area:" prefix its own commits
+# carry most often, mined with git log --follow. The area its authors name need
+# not be its filename (ws.c files under whitespace, diffcore-pickaxe.c under
+# pickaxe). The fine tokens consolidate into a component; that consolidation is
+# the project knowledge a mechanical pass cannot supply.
+#
+# [names] lists the filename token, the name before the first hyphen. A file
+# whose dominant prefix is a broad area name that also swept its neighbors
+# (commit, config, refs, ...), or whose commits name no area, is placed by
+# its filename instead. Program sources stay at the root.
+[tokens]
+odb: blob commit-slab fsck hash loose match-trees object object-file object-file-convert object-name odb oidmap oidset oidtree replace-object replace_object sha1-array sha1-lookup sha1_name tag tmp-objdir tree tree-walk
+refs: ls-refs pack-refs ref-filter reflog reflog-walk refspec worktree
+pack: bloom chunk-format commit-graph delta-islands diff-delta midx pack-bitmap pack-bitmap-write pack-check pack-mtimes pack-objects pack-revindex pack-write packfile patch-delta prune prune-packed pseudo-merge reachable repack repack-promisor server-info
+diff: combine-diff diff diff-merges diffcore-break diffcore-delta diffcore-order diffcore-rename patch-ids pickaxe range-diff tree-diff userdiff xdiff-interface
+merge: fmt-merge-msg ll-merge merge merge-blobs merge-ort rerere
+revision: bisect blame commit-reach decorate format-patch graph line-log line-range list list-objects list-objects-filter list-objects-filter-options pretty revision shallow
+index: cache-tree checkout dir dir-iterator entry fsmonitor fsmonitor--daemon fsmonitor-ll fsmonitor-settings name-hash parallel-checkout pathspec preload-index read-cache resolve-undo sparse-index split-index statinfo symlinks unpack-trees wt-status
+setup: alias hook ident repository setup version
+convert: attr convert whitespace
+transport: bundle bundle-uri cat-file connect connected fetch-negotiator fetch-pack http pkt-line promisor-remote protocol protocol-caps remote remote-curl send-pack serve sideband transport transport-helper upload-pack walker
+notes: notes notes-cache notes-merge
+submodule: submodule submodule-config
+archive: archive archive-tar archive-zip
+[names]
+odb: object odb oid oidmap oidset oidtree loose blob tag commit tree replace match tmp fsck hash sha1dc streaming
+refs: refs refspec reflog ref ls worktree
+pack: pack packfile midx delta prune reachable server bloom chunk pseudo repack
+diff: diff diffcore combine range userdiff xdiff patch pickaxe
+merge: merge rerere fmt
+revision: revision log bisect shallow blame line graph decorate list pretty
+index: read cache split sparse unpack name preload resolve statinfo entry parallel dir pathspec checkout symlinks fsmonitor wt
+setup: config setup environment repository repo ident alias version hook
+convert: attr convert ws whitespace
+transport: transport remote connect connected send fetch upload walker http protocol serve pkt sideband bundle promisor
+notes: notes
+submodule: submodule
+archive: archive
diff --git a/contrib/organize/labeler b/contrib/organize/labeler
new file mode 100755
index 0000000000..2116015f2d
--- /dev/null
+++ b/contrib/organize/labeler
@@ -0,0 +1,333 @@
+#!/usr/bin/perl
+# Reference labeler for git organize(1). This is a demonstration; a real
+# project supplies its own.
+#
+# git organize keeps the root *.c and *.h sources in scope. The labeler prints
+# one NUL-terminated label record per file,
+#
+#     <path> \0 component=<dir> role=<role> prefix=<token> \
+#               includes=<c>:<n>,... cochange=<c>:<n>,... \0
+#
+# component names the directory to move the file into. component and role are
+# the labels git organize acts on. prefix, includes, and cochange are advisory
+# signals the labeler records for a human to read.
+#
+# COMPONENT. The labeler names each file's component from the "area:" prefix its
+# own commits carry most often, mined with `git log --follow` over the file's
+# whole history. The area its authors name need not match its filename: ws.c
+# goes under whitespace, diffcore-pickaxe.c under pickaxe. The [tokens] section
+# of git-layout.map maps the fine prefix tokens to component directories. When a
+# file's dominant prefix is a broad area name that also swept its neighbors
+# (commit, config, refs, ...), or its commits name no area, the labeler falls
+# back to the file's name through the [names] section.
+# When neither section names a component, the labeler applies a co-change test:
+# a file that changes chiefly alongside one component moves there, and any other
+# file gets component=? (backlog). Programs (Makefile PROGRAM_OBJS) stay at the
+# root.
+#
+# ADVISORY. prefix is the dominant token itself. includes is the file's #include
+# coupling, each included in-scope header bucketed by its component. cochange
+# is the components the file co-changes with, mined from focused commits (<= 25
+# files). includes and cochange list the strongest components first, capped at
+# five. A human reads them to see where a file couples and whether git-layout.map
+# named a different component than a raw signal would.
+#
+# Usage:
+#     labeler                the label records on stdout
+
+use strict;
+use warnings;
+use File::Temp qw(tempdir);
+use POSIX ();
+
+my $CAP = 5;			# most-coupled components kept in an advisory list
+
+my $top = `git rev-parse --show-toplevel`;
+chomp $top;
+chdir $top or die "organize labeler: cannot cd to $top: $!\n";
+(my $here = $0) =~ s{/[^/]*$}{};
+my $mapfile = "$here/git-layout.map";
+
+# git-layout.map: [tokens] maps a commit-prefix token to its component, [names]
+# maps a filename token to its component.
+my (%tok_dir, %name_dir, $section);
+open my $map, '<', $mapfile or die "organize labeler: cannot read $mapfile: $!\n";
+while (<$map>) {
+	next if /^#/;
+	if (/^\[(\w+)\]\s*$/) { $section = $1; next; }
+	next unless /:/;
+	my ($dir, $tokens) = split /:/, $_, 2;
+	my $into = $section eq 'tokens' ? \%tok_dir : \%name_dir;
+	$into->{$_} = $dir for split ' ', $tokens;
+}
+close $map;
+
+# The standalone programs, from the Makefile.
+my %is_program;
+open my $mk, '<', 'Makefile' or die "organize labeler: cannot read Makefile: $!\n";
+while (<$mk>) {
+	$is_program{"$1.c"} = 1 if /^\s*PROGRAM_OBJS\s*\+?=\s*(\S+)\.o/;
+}
+close $mk;
+
+# Prefix tokens that name no area: mass-change and non-source markers. The
+# labeler ignores a commit subject led by one of these when tallying components.
+my %noise = map { $_ => 1 } qw(
+	treewide cocci coccinelle comments comment makefile doc docs
+	documentation style cleanup misc various global build ci test tests
+	config.mak wildmatch);
+
+# The name of a file with its extension and directory removed, lowercased.
+sub stem {
+	my ($p) = @_;
+	$p =~ s{.*/}{};
+	$p =~ s/\.[ch]$//;
+	return lc $p;
+}
+
+# The filename token: the stem up to its first hyphen (object-file -> object).
+sub name_token {
+	my ($s) = @_;
+	$s =~ s/-.*//;
+	return $s;
+}
+
+# A prefix token with a file-suffix variant folded to its base (commit.c and
+# serve.[ch] -> commit and serve), lowercased and trimmed.
+sub normalize {
+	my ($t) = @_;
+	$t = lc $t;
+	$t =~ s/^\s+//;
+	$t =~ s/\s+$//;
+	$t =~ s/\*?\.\[ch\]$//;
+	$t =~ s/\*?\.[ch]$//;
+	$t =~ s/\*?\.py$//;
+	return $t;
+}
+
+sub is_noise {
+	my ($t) = @_;
+	return 1 if $t eq '';
+	return 1 if $t =~ m{[ ,\[\]{}()*/'"]};
+	return 1 if $noise{$t};
+	return 0;
+}
+
+# The token matches the file's name: it is the stem, an extension of it, or a
+# hyphen-prefix of it. Used only to break a tie between equally frequent tokens.
+sub affinity {
+	my ($t, $s) = @_;
+	return 1 if $t eq $s;
+	return 1 if index($s, "$t-") == 0;
+	return 1 if index($t, $s) == 0;
+	return 0;
+}
+
+# The commit-prefix token a file's history carries most often, or undef when its
+# history names no area. Ties break toward a token that matches the file's name,
+# then by name.
+sub dominant_prefix {
+	my ($file) = @_;
+	my $s = stem($file);
+	my %count;
+	for my $subject (split /\n/, `git log --follow --no-merges --format=%s -- "$file"`) {
+		my $i = index($subject, ':');
+		next if $i <= 0;
+		my $t = normalize(substr($subject, 0, $i));
+		next if is_noise($t);
+		$count{$t} += 1;
+	}
+	return undef unless %count;
+	my @ranked = sort {
+		$count{$b} <=> $count{$a}
+			or affinity($b, $s) <=> affinity($a, $s)
+			or $a cmp $b
+	} keys %count;
+	return $ranked[0];
+}
+
+# The component and dominant prefix for a file: the component from the prefix
+# token via [tokens], else from the filename token via [names], else the
+# backlog. Programs stay at the root. Kept side-effect free so a worker process
+# can call it (see pass 1).
+sub classify {
+	my ($file) = @_;
+	my $p = dominant_prefix($file);
+	my $prefix = defined $p ? $p : '?';
+	return ('?', $prefix) if $is_program{$file};
+	return ($tok_dir{$p}, $prefix) if defined $p && exists $tok_dir{$p};
+	my $d = $name_dir{ name_token(stem($file)) };
+	return (defined $d ? $d : '?', $prefix);
+}
+
+# Pass 1: name the component for every scoped file, recording its component and
+# dominant prefix. The `git log --follow` mining dominates the run, so fan the
+# files across a pool of worker processes (ORGANIZE_JOBS, default the CPU count).
+# Each worker writes "path<TAB>component<TAB>prefix" for its share, and the
+# parent reads them back.
+my (%component, %prefix);
+my @files = grep { length } (split(/\n/, `git ls-files ':(glob)*.c'`),
+			     split(/\n/, `git ls-files ':(glob)*.h'`));
+{
+	my $jobs = $ENV{ORGANIZE_JOBS};
+	if (!$jobs) { chomp($jobs = `nproc 2>/dev/null`); $jobs ||= 4; }
+	$jobs = scalar(@files) if @files && $jobs > @files;
+	$jobs = 1 if $jobs < 1;
+	my $dir = tempdir(CLEANUP => 1);
+	my @pids;
+	for my $j (0 .. $jobs - 1) {
+		my $pid = fork();
+		die "organize labeler: cannot fork: $!\n" unless defined $pid;
+		if (!$pid) {
+			open my $out, '>', "$dir/$j" or POSIX::_exit(1);
+			my $n = 0;
+			for (my $i = $j; $i < @files; $i += $jobs) {
+				my ($c, $p) = classify($files[$i]);
+				print {$out} "$files[$i]\t$c\t$p\n";
+				$n++;
+			}
+			# Write a trailing sentinel line to prove the worker ran
+			# to the end. A worker that dies mid-run leaves a
+			# truncated file with no sentinel, which the parent
+			# rejects rather than read as a short but valid share.
+			# The parent matches this exact line, "# done <count>";
+			# a record line is TAB-separated, so it cannot collide.
+			print {$out} "# done $n\n";
+			close $out or POSIX::_exit(1);
+			POSIX::_exit(0);	# skip END/DESTROY so the tempdir survives
+		}
+		push @pids, $pid;
+	}
+	for my $pid (@pids) {
+		waitpid($pid, 0);
+		die "organize labeler: a worker failed\n" if $?;
+	}
+	for my $j (0 .. $jobs - 1) {
+		open my $in, '<', "$dir/$j"
+			or die "organize labeler: worker $j left no output\n";
+		my $sentinel = 0;
+		while (<$in>) {
+			chomp;
+			if (/^# done [0-9]+$/) { $sentinel = 1; next; }
+			my ($f, $c, $p) = split /\t/, $_, 3;
+			$component{$f} = $c;
+			$prefix{$f} = $p;
+		}
+		close $in;
+		die "organize labeler: worker $j left truncated output\n"
+			unless $sentinel;
+	}
+}
+
+# Pass 2a: the #include coupling profile, each included in-scope header
+# bucketed by its component.
+sub includes_profile {
+	my ($file) = @_;
+	open my $fh, '<', $file or return {};
+	my %prof;
+	while (<$fh>) {
+		next unless /^\s*#\s*include\s*"([^"]+)"/;
+		(my $inc = $1) =~ s{.*/}{};	# includes name the header directly
+		my $c = $component{$inc};
+		$prof{$c}++ if defined $c && $c ne '?';
+	}
+	close $fh;
+	return \%prof;
+}
+
+# Pass 2b: the co-change profile. A focused commit (<= 25 files) ties every pair
+# of files it touches; tally each file's scoped neighbors by their component.
+my %cochange;
+{
+	my @batch;
+	my $flush = sub {
+		return if @batch > 25;
+		my @scoped = grep { exists $component{$_} } @batch;
+		return if @scoped < 2;
+		for my $f (@scoped) {
+			for my $g (@scoped) {
+				next if $g eq $f;
+				my $c = $component{$g};
+				$cochange{$f}{$c}++ if $c ne '?';
+			}
+		}
+	};
+	open my $log, '-|', qw(git log --no-merges --format=%x01 --name-only)
+		or die "organize labeler: cannot read the commit log: $!\n";
+	my $started = 0;
+	while (my $line = <$log>) {
+		chomp $line;
+		if ($line =~ /^\x01/) {
+			$flush->() if $started;
+			@batch = ();
+			$started = 1;
+		} elsif ($line ne '') {
+			push @batch, $line;
+		}
+	}
+	$flush->() if $started;
+	close $log;
+}
+
+# Pass 3: promote a backlog file whose co-change coupling concentrates on one
+# component. The prefix and name gave this file no component, but it co-changes
+# chiefly with a single component, and its #includes do not point elsewhere, so
+# the labeler moves it to that component. A file that couples broadly stays at
+# the root. A .c and its .h combine their coupling and take the same component,
+# so a pair moves as one. The thresholds keep only a concentrated signal with
+# enough evidence behind it (alloc and cbtree join odb, git-curl-compat joins
+# transport; csum-file and mem-pool stay at the root as too diffuse or too
+# sparse).
+my $PROMOTE_SHARE = 0.60;
+my $PROMOTE_COUNT = 15;
+{
+	my %pair;
+	for my $file (@files) {
+		next if $component{$file} ne '?' || $is_program{$file};
+		(my $stem = $file) =~ s/\.[ch]$//;
+		push @{$pair{$stem}}, $file;
+	}
+	my @promote;			# [ [files], component ], decided before applying
+	for my $stem (sort keys %pair) {
+		my (%co, %inc);
+		for my $file (@{$pair{$stem}}) {
+			$co{$_}  += $cochange{$file}{$_} for keys %{$cochange{$file} || {}};
+			my $ip = includes_profile($file);
+			$inc{$_} += $ip->{$_} for keys %$ip;
+		}
+		next unless %co;
+		my $total = 0; $total += $_ for values %co;
+		my ($top) = sort { $co{$b} <=> $co{$a} or $a cmp $b } keys %co;
+		next unless $co{$top} >= $PROMOTE_COUNT
+			 && $co{$top} / $total >= $PROMOTE_SHARE;
+		if (%inc) {		# an #include profile must not point elsewhere
+			my ($itop) = sort { $inc{$b} <=> $inc{$a} or $a cmp $b } keys %inc;
+			next unless $itop eq $top;
+		}
+		push @promote, [ $pair{$stem}, $top ];
+	}
+	for my $p (@promote) {
+		$component{$_} = $p->[1] for @{$p->[0]};
+	}
+}
+
+# A "c:n,c:n" advisory list: the strongest components first, capped at $CAP.
+sub advisory {
+	my ($prof) = @_;
+	my @c = sort { $prof->{$b} <=> $prof->{$a} or $a cmp $b } keys %$prof;
+	@c = @c[0 .. $CAP - 1] if @c > $CAP;
+	return join ',', map { "$_:$prof->{$_}" } @c;
+}
+
+for my $file (@files) {
+	my $c = $component{$file};
+	my $role = $is_program{$file} ? 'program'
+		 : $file =~ /\.h$/ ? ($c eq '?' ? 'public' : 'header')
+		 : 'lib';
+	my $rec = "component=$c role=$role prefix=$prefix{$file}";
+	my $inc = advisory(includes_profile($file));
+	my $cox = advisory($cochange{$file} || {});
+	$rec .= " includes=$inc" if length $inc;
+	$rec .= " cochange=$cox" if length $cox;
+	print "$file\0$rec\0";
+}
diff --git a/contrib/organize/organizer b/contrib/organize/organizer
new file mode 100755
index 0000000000..56c805301b
--- /dev/null
+++ b/contrib/organize/organizer
@@ -0,0 +1,334 @@
+#!/usr/bin/perl
+# Reference organizer for git organize(1). This is a demonstration; a real
+# project supplies its own.
+#
+# When a .c source moves into a component directory, its build object moves
+# with it; when a .h header moves, every #include of it must be repointed to
+# the new path (the Git build uses -I. only, so an include names the full path).
+# The organizer reads the pending moves and returns a patch that repoints
+# every reference the reorganization leaves stale across Git's build systems:
+#
+#   Makefile                 the moved object list (stem.o/.s/.sp) and any
+#                            bare source name in a list (LOCALIZED_C_CORE)
+#   meson.build              the moved source path
+#   Documentation/Makefile   a moved header named by a ../<name>.h argument
+#   contrib/buildsystems/CMakeLists.txt
+#                            a moved .c named bare or by ${CMAKE_SOURCE_DIR}/
+#   #include "foo.h"         -> #include "dir/foo.h" in every C includer
+#   Documentation/**/*.adoc  a tutorial #include "foo.h" example line
+#
+# An include may name the header bare or by a ../ path (from a subdirectory),
+# and may write "#include" or "# include"; the repoint names the full path,
+# which -I. resolves from any directory. An includer that itself moves is
+# renamed-with-modification (its rename plus the repoint); a stationary
+# includer is edited in place. The .adoc tutorials always name the full new
+# path, so their #include example lines are repointed unconditionally, without
+# the shadow/depth resolution a real C include needs.
+#
+# The organizer declines any move whose references it cannot repoint. It
+# repoints every #include in the tracked C sources and tutorials, except that
+# frozen test data under t/tNNNN/ is deliberately left alone: those files are
+# fixtures (for example a mailinfo.c that git am replays byte for byte), so an
+# apparent #include in them is data, not a reference to follow. Outside those
+# fixtures, the only reference it can miss is one in a build file. After it
+# edits the build files above, it rejects a move whose old path a build file
+# still names (in a build file it does not edit, or in a form its edit missed).
+# That file stays at the root with its references intact, and apply moves the
+# rest.
+#
+# The code runs in four phases:
+#   Phase 1  read the "move <src> <dst>" lines from stdin.
+#   Phase 2  edit the build files as if every move happened, then reject a
+#            move a build file still names (build_edits, names_missing_path).
+#   Phase 3  build the new content of every file the accepted moves change
+#            (build_edits, include_edits, adoc_edits).
+#   Phase 4  emit one diff per changed file: a stationary file in place, an
+#            includer that itself moves as a rename-with-modification.
+# Name matching lives in the boundary regexes ($LB, $LB_ROOT, $RB) and in
+# include_names_root.
+
+use strict;
+use warnings;
+use File::Temp qw(tempdir);
+
+my $protocol = "git-organize 1 organize";
+chomp(my $top = `git rev-parse --show-toplevel`);
+chdir $top or die "organize organizer: cannot cd to $top: $!\n";
+
+sub unquote {
+	my ($s) = @_;
+	return $s unless $s =~ /\A"(.*)"\z/s;
+	my $body = $1;
+	my %esc = (a=>"\a", b=>"\b", t=>"\t", n=>"\n", v=>"\013",
+		f=>"\f", r=>"\r", '"'=>'"', '\\'=>'\\');
+	$body =~ s{\\([0-7]{1,3}|.)}
+		{ exists $esc{$1} ? $esc{$1} : $1 =~ /\A[0-7]/ ? chr(oct $1) : $1 }ges;
+	return $body;
+}
+sub shift_token {
+	$_[0] =~ s/\A\s+//;
+	my $tok = $_[0] =~ s/\A("(?:\\.|[^"\\])*")// ? $1 : $_[0] =~ s/\A(\S+)// ? $1
+		: die "organize organizer: malformed move line\n";
+	return unquote($tok);
+}
+sub slurp { open my $fh,'<',$_[0] or die "cannot read $_[0]: $!\n"; local $/; <$fh> }
+
+# Boundary vocabulary. A moved name matches only as a whole path component, so
+# remote.c never matches inside ls-remote.c and a subdirectory sibling
+# (builtin/remote.c) keeps its prefix and stays. Every name match below flanks
+# the name with these boundaries:
+#   $LB       left: not preceded by a name character
+#   $LB_ROOT  left, root only: also not preceded by a path separator
+#   $RB       right: the name token ends here
+#   $DIRS     an optional ../ and directory prefix before a name
+my $LB      = qr/(?<![A-Za-z0-9_.\-])/;
+my $LB_ROOT = qr/(?<![A-Za-z0-9_.\-\/])/;
+my $RB      = qr/(?![A-Za-z0-9])/;
+my $DIRS    = qr/(?:\.\.?\/)*(?:[A-Za-z0-9_.\-]+\/)*/;
+# bare_re: a bare root name, at a hard left boundary with no path separator, so
+# a subdir sibling (builtin/remote.c) keeps its prefix and stays.
+sub bare_re { my ($name) = @_; qr/$LB_ROOT\Q$name\E$RB/ }
+# cmake_re: a root .c named bare or as ${CMAKE_SOURCE_DIR}/<name> (captured in
+# $1). The name follows the CMAKE variable slash or a hard boundary, never a
+# real subdirectory component, so a nested source (compat/win32/headless.c)
+# stays.
+sub cmake_re {
+	my ($name) = @_;
+	qr/$LB(?:(\$\{CMAKE_SOURCE_DIR\}\/)|$LB_ROOT)\Q$name\E$RB/;
+}
+
+# === Phase 1: read the pending moves ===
+my @moves;
+while (my $line = <STDIN>) {
+	next unless $line =~ s/\Amove //;
+	my $src = shift_token($line); my $dst = shift_token($line);
+	push @moves, [$src, $dst];
+}
+
+# The build files the organizer edits. A moved .c is a build object (Makefile /
+# meson) and may also appear as a bare source name in a Makefile list and as a
+# path in the contrib CMake build. A moved .h is named by a ../ argument in
+# Documentation/Makefile. An absent build file is skipped.
+my @buildfiles = ('Makefile', 'meson.build',
+	'Documentation/Makefile', 'contrib/buildsystems/CMakeLists.txt');
+
+# Edit the build files for the given moves, returning path -> edited content
+# (undef for an absent file).
+sub build_edits {
+	my ($moves) = @_;
+	my %build = map { $_ => (-e $_ ? slurp($_) : undef) } @buildfiles;
+	for my $m (@$moves) {
+		my ($src, $dst) = @$m;
+		(my $stem = $src) =~ s/\.[ch]\z//;
+		(my $dir = $dst) =~ s{/[^/]*\z}{};
+		# A ../ argument in Documentation/Makefile names a moved header
+		# (../fsck.h feeds lint-fsck-msgids.perl). The ../ steps out of
+		# Documentation/ to the root, so ../<dst> names the new path.
+		if ($src !~ /\.c\z/) {
+			my $mk = 'Documentation/Makefile';
+			$build{$mk} =~ s{$LB\.\./\Q$src\E$RB}{../$dst}g
+				if defined $build{$mk};
+			next;
+		}
+		# A moved .c: Makefile object (stem.o/.s/.sp) and meson path.
+		$build{'Makefile'} =~ s{(^|\s)\Q$stem\E\.(sp|s|o)$RB}{$1$dir/$stem.$2}mg
+			if defined $build{'Makefile'};
+		$build{'meson.build'} =~ s{'\Q$src\E'}{'$dst'}g
+			if defined $build{'meson.build'};
+		# A bare source name in a Makefile list (LOCALIZED_C_CORE).
+		if (defined $build{'Makefile'}) {
+			my $re = bare_re($src);
+			$build{'Makefile'} =~ s{$re}{$dst}g;
+		}
+		# The contrib CMake names a .c bare or by ${CMAKE_SOURCE_DIR}/.
+		if (defined $build{'contrib/buildsystems/CMakeLists.txt'}) {
+			my $re = cmake_re($src);
+			$build{'contrib/buildsystems/CMakeLists.txt'} =~
+				s{$re}{($1 // '') . $dst}ge;
+		}
+	}
+	return \%build;
+}
+
+# The paths that exist once every move is made: the tracked files, less each
+# old path, plus each new path.
+my %exists = map { $_ => 1 } split /\n/, `git ls-files`;
+for my $m (@moves) { delete $exists{$m->[0]}; $exists{$m->[1]} = 1; }
+
+# A referenced path token, normalized to a repository-relative path.
+sub norm_ref {
+	my ($t) = @_;
+	while ($t =~ m{\A\.\.?/}) { $t =~ s{\A[^/]*/}{}; }
+	$t =~ s{\A/+}{};
+	return $t;
+}
+# Whether a build file's content still names $old at a path that will not exist
+# once the moves are made. A comment names a file rather than a rule, so it is
+# skipped.
+sub names_missing_path {
+	my ($content, $old) = @_;
+	(my $base = $old) =~ s{.*/}{};
+	for my $line (split /\n/, $content) {
+		next if $line =~ /\A\s*#/;
+		while ($line =~ /$LB($DIRS)\Q$base\E$RB/g) {
+			return 1 unless $exists{norm_ref($1 . $base)};
+		}
+	}
+	return 0;
+}
+
+# === Phase 2: decide the rejects (completeness contract) ===
+# Edit the build files as if every move happened, then a move whose old path a
+# build file still names is one the organizer cannot fully repoint. The search
+# covers the edited build files and every other build file in the tree.
+my $build_for_rejects = build_edits(\@moves);
+my @rejects;
+for my $m (@moves) {
+	my ($src) = @$m;
+	(my $base = $src) =~ s{.*/}{};
+	my $grep = "git grep -lF -e '$base' --"
+		. " '*Makefile' '*.mak' '*meson.build' '*CMakeLists.txt'"
+		. " 'config.mak*' 2>/dev/null";
+	my @files = grep { length } split /\n/, `$grep`;
+	for my $f (@files) {
+		my $edited = $build_for_rejects->{$f};
+		my $content = defined $edited ? $edited : slurp($f);
+		if (names_missing_path($content, $src)) {
+			push @rejects, [$src, "a build file names it and the "
+				. "organizer cannot repoint that reference"];
+			last;
+		}
+	}
+}
+
+my %rejected = map { $_->[0] => 1 } @rejects;
+my @accepted = grep { !$rejected{$_->[0]} } @moves;
+my %dst_of = map { $_->[0] => $_->[1] } @accepted;
+
+# Whether a #include names the moved ROOT header rather than a same-named header
+# in the includer's own directory. A ../ include names the root only when its
+# ../ count matches the includer's depth (one ../ from a depth-1 file reaches
+# the root). A bare include names the root unless a sibling header in the
+# includer's own directory shadows it (reftable/tree.h shadows a root tree.h).
+sub include_names_root {
+	my ($dots, $depth, $fdir, $src) = @_;
+	my $up = $dots =~ tr{/}{};
+	return $up == $depth if $up;
+	return $depth == 0 || !(-e "$fdir/$src");
+}
+
+# For each accepted header move, repoint #include "foo.h" (bare or ../ path) to
+# the full new path in every C includer, keeping an include that resolves to a
+# shadowing local header (per include_names_root) unchanged. Returns includer
+# path -> edited content.
+sub include_edits {
+	my ($moves) = @_;
+	my %repoint;   # includer -> list of [src, dst]
+	for my $m (@$moves) {
+		my ($src, $dst) = @$m;
+		next unless $src =~ /\.h\z/;
+		(my $re = $src) =~ s/\./\\./g;
+		my $pat = '#[[:blank:]]*include[[:blank:]]*"(\.\./)*' . $re . '"';
+		my $grep = "git grep -lE '$pat' --"
+			. " '*.c' '*.h' ':(exclude)t/t[0-9][0-9][0-9][0-9]/**'";
+		for my $inc (split /\n/, `$grep`) {
+			push @{$repoint{$inc}}, [$src, $dst];
+		}
+	}
+	my %edited;
+	for my $f (keys %repoint) {
+		my $text = slurp($f);
+		(my $fdir = $f) =~ s{/?[^/]*\z}{};
+		my $depth = $fdir eq '' ? 0 : 1 + ($fdir =~ tr{/}{});
+		for my $e (@{$repoint{$f}}) {
+			my ($src, $dst) = @$e;
+			$text =~ s{^(\h*#\h*include\h*")((?:\.\./)*)\Q$src\E(")}{
+				include_names_root($2, $depth, $fdir, $src)
+					? "$1$dst$3" : "$1$2$src$3"
+			}egm;
+		}
+		$edited{$f} = $text;
+	}
+	return \%edited;
+}
+
+# For each accepted header move, repoint the tutorial #include "foo.h" example
+# lines. A tutorial always names the full new path, so the repoint is
+# unconditional (no shadow/depth resolution) and matches the #include anywhere
+# in the line, at the start of a code block or in backticks mid-prose. Only the
+# quoted path changes; the #include spelling is left as written. Returns
+# tutorial path -> edited content.
+sub adoc_edits {
+	my ($moves) = @_;
+	my %repoint;   # tutorial -> list of [src, dst]
+	for my $m (@$moves) {
+		my ($src, $dst) = @$m;
+		next unless $src =~ /\.h\z/;
+		(my $re = $src) =~ s/\./\\./g;
+		my $apat = '#[[:blank:]]*include[[:blank:]]*"' . $re . '"';
+		my $grep = "git grep -lE '$apat' --"
+			. " 'Documentation/*.adoc' 'Documentation/**/*.adoc'"
+			. " ':(exclude)t/t[0-9][0-9][0-9][0-9]/**'";
+		for my $doc (split /\n/, `$grep`) {
+			push @{$repoint{$doc}}, [$src, $dst];
+		}
+	}
+	my %edited;
+	for my $f (keys %repoint) {
+		my $text = slurp($f);
+		for my $e (@{$repoint{$f}}) {
+			my ($src, $dst) = @$e;
+			$text =~ s{(#\h*include\h*")\Q$src\E(")}{$1$dst$2}g;
+		}
+		$edited{$f} = $text;
+	}
+	return \%edited;
+}
+
+# === Phase 3: collect the edits over the accepted moves ===
+# A rejected move stays at the root, so its build references, includers, and
+# tutorials keep naming it unchanged.
+my $build = build_edits(\@accepted);
+my $includers = include_edits(\@accepted);
+my $tutorials = adoc_edits(\@accepted);
+
+# === Phase 4: emit the patch ===
+my $tmp = tempdir(CLEANUP => 1);
+# hunk body (from the first @@) of a diff between $orig and the edited $text
+sub hunk {
+	my ($orig, $text) = @_;
+	open my $o, '>', "$tmp/e" or die; print {$o} $text; close $o;
+	my $d = `git diff --no-index -- "$orig" "$tmp/e"`;
+	my $i = index($d, "\n\@\@");
+	return $i < 0 ? '' : substr($d, $i + 1);
+}
+# A file's diff for the emitted patch: a plain hunk when $from and $to match, a
+# rename-with-modification when they differ. An empty $hunk yields no diff.
+sub diff_hunk {
+	my ($from, $to, $hunk) = @_;
+	return '' unless length $hunk;
+	my $out = "diff --git a/$from b/$to\n";
+	$out .= "rename from $from\nrename to $to\n" if $from ne $to;
+	return $out . "--- a/$from\n+++ b/$to\n$hunk";
+}
+
+# One diff per edited file, in a fixed order: build files, then includers, then
+# tutorials. A build file and a tutorial stay in place; an includer that itself
+# moves is a rename-with-modification (its new path is $dst_of{$f}).
+my $patch = '';
+for my $f (@buildfiles) {
+	next unless defined $build->{$f};
+	my $orig = slurp($f);
+	next if $build->{$f} eq $orig;
+	$patch .= diff_hunk($f, $f, hunk($f, $build->{$f}));
+}
+for my $f (sort keys %$includers) {
+	$patch .= diff_hunk($f, $dst_of{$f} // $f, hunk($f, $includers->{$f}));
+}
+for my $f (sort keys %$tutorials) {
+	$patch .= diff_hunk($f, $f, hunk($f, $tutorials->{$f}));
+}
+
+print "$protocol\n";
+print "reject $_->[0] $_->[1]\n" for @rejects;
+if (length $patch) { print "patch\n"; print $patch; }
diff --git a/meson.build b/meson.build
index a2d987b124..38ec7d4f40 100644
--- a/meson.build
+++ b/meson.build
@@ -443,7 +443,9 @@ libgit_sources = [
   'oidset.c',
   'oidtree.c',
   'organize/gitorganize-format.c',
+  'organize/labeler-protocol.c',
   'organize/organize.c',
+  'organize/organizer-protocol.c',
   'pack-bitmap-write.c',
   'pack-bitmap.c',
   'pack-check.c',
diff --git a/organize/gitorganize-format.c b/organize/gitorganize-format.c
index cdade12f5b..541dd373aa 100644
--- a/organize/gitorganize-format.c
+++ b/organize/gitorganize-format.c
@@ -246,6 +246,11 @@ void gitorganize_write(struct gitorganize *g)
 	else
 		strbuf_addstr(&out, "[layout]\n");
 	strbuf_addstr(&out, "[labels]\n");
+	strbuf_addstr(&out,
+		      "# The recorded placement of each source; edit a line to "
+		      "change it.\n"
+		      "# apply --labels-only fills in unrecorded sources; "
+		      "--reseed re-derives all.\n");
 	for (size_t i = 0; i < g->records.nr; i++) {
 		const char *labels = g->records.items[i].util;
 
diff --git a/organize/labeler-protocol.c b/organize/labeler-protocol.c
new file mode 100644
index 0000000000..6541412c18
--- /dev/null
+++ b/organize/labeler-protocol.c
@@ -0,0 +1,52 @@
+#include "git-compat-util.h"
+#include "labeler-protocol.h"
+#include "gettext.h"
+#include "run-command.h"
+#include "strbuf.h"
+#include "string-list.h"
+#include "strvec.h"
+#include "wrapper.h"
+
+/*
+ * Run the labeler and record, in `labeled` (path -> its "k=value k=value" string in
+ * util), each scoped_files file it labels. The labeler writes `path \0 labels \0`
+ * per file, where labels is its space-separated key=value labels.
+ */
+void run_labeler(const char *cmd, struct string_list *scoped_files,
+		 struct string_list *labeled)
+{
+	struct child_process cp = CHILD_PROCESS_INIT;
+	struct strbuf out = STRBUF_INIT;
+	const char *p, *end;
+
+	strvec_push(&cp.args, cmd);
+	cp.use_shell = 1;
+	if (capture_command(&cp, &out, 0))
+		die(_("organize apply --labels-only: labeler failed: %s"), cmd);
+
+	p = out.buf;
+	end = out.buf + out.len;
+	while (p < end) {
+		const char *path = p;
+		const char *labels;
+
+		p += strlen(p) + 1;
+		if (p > end)
+			die(_("organize apply --labels-only: truncated labeler record"));
+		labels = p;
+		p += strlen(p) + 1;
+		if (p > end)
+			die(_("organize apply --labels-only: truncated labeler record"));
+		if (strchr(labels, '\n'))
+			die(_("organize apply --labels-only: a label must not "
+			      "contain a newline: %s"), path);
+
+		if (!string_list_has_string(scoped_files, path))
+			continue;	/* not a scoped_files file */
+		if (string_list_has_string(labeled, path))
+			die(_("organize: duplicate labeler record for '%s'"),
+			    path);
+		string_list_insert(labeled, path)->util = xstrdup(labels);
+	}
+	strbuf_release(&out);
+}
diff --git a/organize/labeler-protocol.h b/organize/labeler-protocol.h
new file mode 100644
index 0000000000..0c2ea01686
--- /dev/null
+++ b/organize/labeler-protocol.h
@@ -0,0 +1,15 @@
+#ifndef LABELER_PROTOCOL_H
+#define LABELER_PROTOCOL_H
+
+struct string_list;
+
+/*
+ * The labeler protocol. git organize runs the configured labeler and
+ * records, in `labeled` (path -> its "k=value ..." string in util), the
+ * labels it returns for every file in `scoped_files`. The labeler writes one
+ * `path \0 labels \0` record per file.
+ */
+void run_labeler(const char *cmd, struct string_list *scoped_files,
+		 struct string_list *labeled);
+
+#endif /* LABELER_PROTOCOL_H */
diff --git a/organize/organize.c b/organize/organize.c
index 0d9850dfc0..8c623444c0 100644
--- a/organize/organize.c
+++ b/organize/organize.c
@@ -1,6 +1,9 @@
 #include "git-compat-util.h"
 #include "organize.h"
 #include "gitorganize-format.h"
+#include "labeler-protocol.h"
+#include "organizer-protocol.h"
+#include "config.h"
 #include "gettext.h"
 #include "pathspec.h"
 #include "quote.h"
@@ -13,6 +16,19 @@
 #include "wrapper.h"
 #include "wt-status.h"
 
+/* The configured command organize.<key> (labeler or organizer), or NULL. */
+static const char *organize_command(struct repository *repo, const char *key)
+{
+	struct strbuf k = STRBUF_INIT;
+	const char *cmd;
+
+	strbuf_addf(&k, "organize.%s", key);
+	if (repo_config_get_string_tmp(repo, k.buf, &cmd))
+		cmd = NULL;
+	strbuf_release(&k);
+	return cmd;
+}
+
 /*
  * The [layout] rule whose directory equals `path`'s directory, or NULL when
  * `path` is a root file or its directory matches no rule. A file in a [layout]
@@ -114,6 +130,7 @@ static void add_move(struct organize_plan *plan, const char *src,
 	m->src = xstrdup(src);
 	m->dst = dst;
 	m->rule_value = xstrdup(value);
+	m->skip_reason = NULL;
 }
 
 void organize_plan_build(struct repository *repo, struct organize_plan *plan)
@@ -202,25 +219,66 @@ static int worktree_dirty(struct repository *repo)
 	return has_unstaged_changes(repo, 0) || has_uncommitted_changes(repo, 0);
 }
 
-/* Map each move's src to its dst, in `dst_of`. */
+/* Map each standing (non-rejected) move's src to its dst, in `dst_of`. */
 static void plan_dst_map(struct organize_plan *plan, struct string_list *dst_of)
 {
 	for (size_t i = 0; i < plan->moves_nr; i++)
-		string_list_insert(dst_of, plan->moves[i].src)->util =
-			plan->moves[i].dst;
+		if (!plan->moves[i].skip_reason)
+			string_list_insert(dst_of, plan->moves[i].src)->util =
+				plan->moves[i].dst;
+}
+
+/*
+ * Emit `<prefix><name>` for a `diff --git` header the way git's diff does: when
+ * the prefixed path needs C-quoting, wrap the whole unit in one pair of double
+ * quotes ("a/<escaped>") rather than quoting the name alone. An ordinary path
+ * is emitted verbatim, so the header is byte-identical to git's diff.
+ */
+static void add_diff_git_path(struct strbuf *out, const char *prefix,
+			      const char *name)
+{
+	if (quote_c_style(prefix, NULL, NULL, CQUOTE_NODQ) ||
+	    quote_c_style(name, NULL, NULL, CQUOTE_NODQ)) {
+		strbuf_addch(out, '"');
+		quote_c_style(prefix, out, NULL, CQUOTE_NODQ);
+		quote_c_style(name, out, NULL, CQUOTE_NODQ);
+		strbuf_addch(out, '"');
+	} else {
+		strbuf_addstr(out, prefix);
+		strbuf_addstr(out, name);
+	}
 }
 
-/* A content-identical rename entry per move. */
-static void build_rename_patch(struct organize_plan *plan, struct strbuf *out)
+/*
+ * A content-identical rename entry per standing move the organizer did not
+ * claim. A claimed move is one the organizer renames itself, with content
+ * changes, so git leaves that entry to the organizer's patch.
+ */
+static void build_rename_patch(struct organize_plan *plan,
+			       struct string_list *claimed, struct strbuf *out)
 {
 	for (size_t i = 0; i < plan->moves_nr; i++) {
 		struct organize_move *m = &plan->moves[i];
 
-		/* These are tracked_files source paths, which need no quoting. */
-		strbuf_addf(out, "diff --git a/%s b/%s\n", m->src, m->dst);
+		if (m->skip_reason || string_list_has_string(claimed, m->src))
+			continue;
+		/*
+		 * C-quote the paths the way git's diff does, so a byte special
+		 * to the patch format (newline, quote, ...) is escaped. An
+		 * ordinary path passes through unquoted, so this is byte-for-
+		 * byte git's rename header.
+		 */
+		strbuf_addstr(out, "diff --git ");
+		add_diff_git_path(out, "a/", m->src);
+		strbuf_addch(out, ' ');
+		add_diff_git_path(out, "b/", m->dst);
+		strbuf_addch(out, '\n');
 		strbuf_addstr(out, "similarity index 100%\n");
-		strbuf_addf(out, "rename from %s\n", m->src);
-		strbuf_addf(out, "rename to %s\n", m->dst);
+		strbuf_addstr(out, "rename from ");
+		quote_c_style(m->src, out, NULL, 0);
+		strbuf_addstr(out, "\nrename to ");
+		quote_c_style(m->dst, out, NULL, 0);
+		strbuf_addch(out, '\n');
 	}
 }
 
@@ -235,7 +293,8 @@ static int git_apply_index(const char *patch, size_t len)
 
 /*
  * Repoint each carved file's [labels] line to its new path, carrying its labels
- * unchanged: only its location changes. Returns nonzero when [labels] changed.
+ * unchanged: only its location changes. A rejected move stays put and keeps its
+ * line. Returns nonzero when [labels] changed.
  */
 static int repoint_moved_declarations(struct organize_plan *plan)
 {
@@ -278,19 +337,32 @@ static int repoint_moved_declarations(struct organize_plan *plan)
 void organize_plan_apply(struct repository *repo, struct organize_plan *plan)
 {
 	struct strbuf patch = STRBUF_INIT;
+	struct strbuf combined = STRBUF_INIT;
+	struct string_list claimed = STRING_LIST_INIT_DUP;
+	const char *organizer;
 
 	if (worktree_dirty(repo))
 		die(_("organize apply: the worktree has uncommitted changes; "
 		      "commit or stash first"));
 
+	organizer = organize_command(repo, "organizer");
+	if (organizer)
+		run_organizer(organizer, plan, &patch, &claimed);
+
 	/*
-	 * Content-identical renames for every move, applied as one
-	 * git apply --index transaction, so a failure leaves the tree untouched.
+	 * Content-identical renames for every unclaimed move, then the
+	 * organizer's edits (when any), apply as one git apply --index: git
+	 * checks the whole patch before it writes, so a patch that does not
+	 * apply changes nothing. The [labels] update in .gitorganize follows the
+	 * apply and is staged separately rather than as part of it.
 	 */
-	build_rename_patch(plan, &patch);
-	if (patch.len && git_apply_index(patch.buf, patch.len))
+	build_rename_patch(plan, &claimed, &combined);
+	if (patch.len)
+		strbuf_addbuf(&combined, &patch);
+	if (combined.len && git_apply_index(combined.buf, combined.len))
 		die(_("organize apply: the change does not apply cleanly; "
 		      "nothing was changed"));
+	strbuf_release(&combined);
 
 	if (repoint_moved_declarations(plan)) {
 		struct child_process add = CHILD_PROCESS_INIT;
@@ -302,15 +374,80 @@ void organize_plan_apply(struct repository *repo, struct organize_plan *plan)
 			      "restore with git reset --hard"));
 	}
 
+	string_list_clear(&claimed, 0);
 	strbuf_release(&patch);
 }
 
+void organize_run_labeler(struct repository *repo, int reseed)
+{
+	struct organize_ctx ctx = ORGANIZE_CTX_INIT;
+	struct string_list labeled = STRING_LIST_INIT_DUP;
+	struct string_list records = STRING_LIST_INIT_DUP;
+	struct child_process add = CHILD_PROCESS_INIT;
+	const char *cmd;
+
+	organize_ctx_load(repo, &ctx);
+	cmd = organize_command(repo, "labeler");
+	if (!cmd)
+		die(_("organize: organize.labeler is not set"));
+	run_labeler(cmd, &ctx.scoped_files, &labeled);
+
+	/*
+	 * A [labels] line for every scoped_files file. A file already recorded
+	 * keeps its line: the recorded placement is authoritative, so a decision
+	 * made by hand or in an earlier run survives, and the labeler only seeds a
+	 * file it has not yet placed. With reseed, take the labeler's fresh label
+	 * for every file instead, discarding the recorded placements. Walking the
+	 * scoped_files set keeps a new, unrecorded source visible either way. The
+	 * loop below then preserves every placed file already listed.
+	 */
+	for (size_t i = 0; i < ctx.scoped_files.nr; i++) {
+		const char *path = ctx.scoped_files.items[i].string;
+		struct string_list_item *rec =
+			string_list_lookup(&ctx.gitorg.records, path);
+		struct string_list_item *it;
+
+		if (rec && !reseed) {
+			string_list_insert(&records, path)->util =
+				xstrdup((const char *)rec->util);
+			continue;
+		}
+		if (layout_dir_rule(&ctx.gitorg, path))
+			continue;	/* placed by its directory; no line needed */
+		it = string_list_lookup(&labeled, path);
+		string_list_insert(&records, path)->util =
+			xstrdup(it ? (const char *)it->util : "");
+	}
+	for (size_t i = 0; i < ctx.gitorg.records.nr; i++) {
+		const char *path = ctx.gitorg.records.items[i].string;
+
+		if (strchr(path, '/') &&
+		    string_list_has_string(&ctx.tracked_files, path) &&
+		    !string_list_has_string(&records, path))
+			string_list_insert(&records, path)->util =
+				xstrdup(ctx.gitorg.records.items[i].util);
+	}
+
+	string_list_clear(&ctx.gitorg.records, 1);
+	ctx.gitorg.records = records;	/* ctx.gitorg owns the fresh [labels] */
+	gitorganize_write(&ctx.gitorg);
+
+	add.git_cmd = 1;
+	strvec_pushl(&add.args, "add", ".gitorganize", NULL);
+	if (run_command(&add))
+		die(_("organize apply --labels-only: staging .gitorganize failed"));
+
+	organize_ctx_release(&ctx);
+	string_list_clear(&labeled, 1);
+}
+
 void organize_plan_release(struct organize_plan *plan)
 {
 	for (size_t i = 0; i < plan->moves_nr; i++) {
 		free(plan->moves[i].src);
 		free(plan->moves[i].dst);
 		free(plan->moves[i].rule_value);
+		free(plan->moves[i].skip_reason);
 	}
 	FREE_AND_NULL(plan->moves);
 	plan->moves_nr = plan->moves_alloc = 0;
diff --git a/organize/organize.h b/organize/organize.h
index c26453d2be..84e6558f8b 100644
--- a/organize/organize.h
+++ b/organize/organize.h
@@ -15,30 +15,42 @@ struct repository;
  *   [scope]    the scope pathspecs, one per line; no [scope] section means
  *     nothing is in scope.
  *
- *   [layout]   the project's placement map, hand-authored: ordered
- *     `<label>:<value> = <directory>` rules (`.` is the root). A file's labels
- *     are matched against the rules in order, and the first rule it satisfies
- *     places it; a file matching no rule is backlog. Only a label named in
- *     a rule places a file.
+ *   [layout]   the project's directory map, hand-authored: ordered
+ *     `<label>:<value> = <directory>` rules (`.` is the root). git organize
+ *     matches a file's labels against the rules in order; the first rule it
+ *     satisfies names the file's directory. A file matching no rule is backlog.
+ *     Only a rule named in [layout] moves a file.
  *
  *   [labels]   the recorded labels, one line per source in scope, `<path> <key>=
- *     <value> ...`, with every label the project defines. Placed files are listed
- *     too, so a placed file's [labels] line records its labels, independently of
- *     the directory name.
+ *     <value> ...`, with every label the project defines. A file already in its
+ *     directory is listed too, so its [labels] line records its labels, apart
+ *     from the directory name. A label named in no rule moves no file; git
+ *     organize records it for a reader.
+ *
+ * The labeler and organizer commands live in config, organize.labeler and
+ * organize.organizer.
  *
  *   status  Read [labels] and report the files in scope whose matching rule
  *     names a directory they are not in yet (the moves), the backlog, and a
  *     recorded path that no longer exists.
  *
- *   apply   Perform the moves. A move is a content-identical rename, applied as
- *     one git apply --index transaction. A carved file's [labels] line is
- *     repointed to its new path, carrying its labels.
+ *   apply   Perform the moves. A move is a content-preserving rename. When an
+ *     organizer is configured, hand it the moves; it returns edits to referring
+ *     files as a patch and a reason for any move it declines. Moves and the
+ *     patch apply as one git apply. With no organizer, each move is a plain git
+ *     mv. A carved file's [labels] line is repointed to its new path, carrying
+ *     its labels.
+ *
+ *   apply --labels-only  Run the labeler and write a [labels] line for every
+ *     file in scope, keeping the line of a file already in its directory.
+ *     Staged. This is the only path that runs a labeler.
  */
 
 struct organize_move {
 	char *src;	/* current path */
 	char *dst;	/* declared path */
-	char *rule_value;	/* the matched rule's value */
+	char *rule_value;	/* the matched rule's value, sent to the organizer */
+	char *skip_reason;	/* why the organizer declined it; NULL when it stands */
 };
 
 struct organize_plan {
@@ -67,11 +79,21 @@ struct organize_plan {
 void organize_plan_build(struct repository *repo, struct organize_plan *plan);
 
 /*
- * Perform the plan: apply the moves as one content-identical-rename
- * transaction; the result is staged. Requires a clean worktree.
+ * Perform the plan: consult the organizer when one is configured, then apply
+ * the standing moves and the organizer's patch; the result is staged.
+ * Requires a clean worktree. Records each declined move's reason in the plan.
  */
 void organize_plan_apply(struct repository *repo, struct organize_plan *plan);
 
+/*
+ * Fill the [labels] record for every file in scope, staged. A file already
+ * recorded keeps its line (the recorded placement is authoritative); an
+ * unrecorded file is seeded from the labeler (its labels, or empty when the
+ * labeler leaves it unplaced). With reseed, re-derive every line from the
+ * labeler, discarding the recorded placements.
+ */
+void organize_run_labeler(struct repository *repo, int reseed);
+
 void organize_plan_release(struct organize_plan *plan);
 
 #endif /* ORGANIZE_H */
diff --git a/organize/organizer-protocol.c b/organize/organizer-protocol.c
new file mode 100644
index 0000000000..d50617e010
--- /dev/null
+++ b/organize/organizer-protocol.c
@@ -0,0 +1,254 @@
+#include "git-compat-util.h"
+#include "organizer-protocol.h"
+#include "organize.h"
+#include "gitorganize-format.h"
+#include "apply.h"
+#include "gettext.h"
+#include "quote.h"
+#include "run-command.h"
+#include "strbuf.h"
+#include "string-list.h"
+#include "strvec.h"
+#include "wrapper.h"
+
+#define ORGANIZE_PROTOCOL "git-organize 1 organize"
+
+/* Record a skip reason for a standing move, taking ownership of `reason`. */
+static void reject_move(struct organize_plan *plan, const char *src,
+			char *reason)
+{
+	for (size_t move_idx = 0; move_idx < plan->moves_nr; move_idx++) {
+		struct organize_move *move = &plan->moves[move_idx];
+
+		if (!strcmp(move->src, src)) {
+			free(move->skip_reason);
+			move->skip_reason = reason;
+			return;
+		}
+	}
+	free(reason);	/* a skip_reason for a move we did not propose is ignored */
+}
+
+/* Serialize the standing moves as the organizer request. */
+static void build_request(struct organize_plan *plan, struct strbuf *request)
+{
+	strbuf_addstr(request, ORGANIZE_PROTOCOL "\n");
+	for (size_t move_idx = 0; move_idx < plan->moves_nr; move_idx++) {
+		struct organize_move *move = &plan->moves[move_idx];
+
+		if (move->skip_reason)
+			continue;
+		strbuf_addstr(request, "move ");
+		quote_c_style(move->src, request, NULL, 0);
+		strbuf_addch(request, ' ');
+		quote_c_style(move->dst, request, NULL, 0);
+		strbuf_addf(request, " %s\n", move->rule_value);
+	}
+}
+
+/* The next "diff --git " line, at column 0, at or after `from`, or `end`. */
+static const char *next_entry(const char *from, const char *end)
+{
+	while (from < end) {
+		if (starts_with(from, "diff --git "))
+			return from;
+		from = memchr(from, '\n', end - from);
+		if (!from)
+			return end;
+		from++;
+	}
+	return end;
+}
+
+/*
+ * Whether an entry's text mentions a directory the plan moves into, so that an
+ * in-place edit is one that repoints a reference toward a moved file rather
+ * than an edit of an unrelated file.
+ */
+static int repoints_a_move(const char *entry, const char *entry_end,
+			   const struct string_list *dstdirs)
+{
+	for (size_t i = 0; i < dstdirs->nr; i++) {
+		const char *dir = dstdirs->items[i].string;
+
+		if (memmem(entry, entry_end - entry, dir, strlen(dir)))
+			return 1;
+	}
+	return 0;
+}
+
+/*
+ * The organizer is a trusted command that the repository configures, like a
+ * clean or smudge filter. This is an integrity check on the organizer patch,
+ * not a sandbox against a hostile organizer. It reads each entry's per-entry
+ * header with git's own diff-header parser (parse_git_diff_header), the same
+ * names `git apply` acts on, and refuses a header that steps outside the plan.
+ * It does not confine what the hunks the applying patch carries may change.
+ *
+ * Check each entry's header and record which moves the patch claims. An entry
+ * is one of:
+ *   - old == new: an in-place edit. The file must stay put (not be a move) and
+ *     the edit must repoint a reference into a directory the plan moves a file
+ *     into, which bounds a mistaken organizer to files the moves touch.
+ *   - old != new: a rename-with-modification. It must match a planned move
+ *     (old -> new), which git organize then assigns to the organizer (a claim).
+ * Refuse a header that adds, deletes, or copies a file, or changes a file's
+ * mode; git organize controls which files exist and their modes. The patch
+ * must be in git diff format.
+ */
+static void validate_patch(struct organize_plan *plan,
+			   const struct strbuf *patch,
+			   struct string_list *claimed)
+{
+	struct string_list dst_map = STRING_LIST_INIT_NODUP;
+	struct string_list dstdirs = STRING_LIST_INIT_DUP;
+	struct strbuf root = STRBUF_INIT;
+	const char *cursor = patch->buf;
+	const char *end = patch->buf + patch->len;
+
+	for (size_t move_idx = 0; move_idx < plan->moves_nr; move_idx++) {
+		struct organize_move *move = &plan->moves[move_idx];
+		const char *slash;
+
+		if (move->skip_reason)
+			continue;
+		string_list_insert(&dst_map, move->src)->util = move->dst;
+		slash = strrchr(move->dst, '/');
+		if (slash) {
+			struct strbuf dir = STRBUF_INIT;
+
+			strbuf_add(&dir, move->dst, slash - move->dst + 1);
+			string_list_insert(&dstdirs, dir.buf);
+			strbuf_release(&dir);
+		}
+	}
+
+	while (cursor < end && *cursor == '\n')
+		cursor++;
+	if (cursor < end && !starts_with(cursor, "diff --git "))
+		die(_("organize apply: the organizer patch is not in git diff format"));
+
+	while (cursor < end && starts_with(cursor, "diff --git ")) {
+		const char *newline = memchr(cursor, '\n', end - cursor);
+		size_t first = newline ? (size_t)(newline - cursor + 1)
+				       : (size_t)(end - cursor);
+		struct patch entry;
+		int linenr = 0, hdrlen;
+		const char *old_name, *new_name, *entry_end;
+		struct string_list_item *dst;
+
+		memset(&entry, 0, sizeof(entry));
+		hdrlen = parse_git_diff_header(&root, NULL, &linenr, 1, cursor,
+					       first, end - cursor, &entry);
+		if (hdrlen < 0)
+			die(_("organize apply: cannot parse the organizer patch"));
+		entry_end = next_entry(cursor + hdrlen, end);
+		if (entry.is_new || entry.is_delete || entry.is_copy)
+			die(_("organize apply: the organizer patch must not add, "
+			      "delete, or copy files"));
+		if (entry.old_mode != entry.new_mode)
+			die(_("organize apply: the organizer patch must not change "
+			      "a file's mode"));
+		old_name = entry.old_name ? entry.old_name : entry.def_name;
+		new_name = entry.new_name ? entry.new_name : entry.def_name;
+		if (!old_name || !new_name)
+			die(_("organize apply: cannot tell which file the organizer "
+			      "patch touches"));
+
+		dst = string_list_lookup(&dst_map, old_name);
+		if (!strcmp(old_name, new_name)) {
+			if (dst)
+				die(_("organize apply: the organizer patch edits %s "
+				      "in place, but it is part of a move"), old_name);
+			if (!repoints_a_move(cursor, entry_end, &dstdirs))
+				die(_("organize apply: the organizer patch edits %s "
+				      "in place, but the edit does not repoint a "
+				      "move"), old_name);
+		} else if (!dst || strcmp(dst->util, new_name)) {
+			die(_("organize apply: the organizer patch renames %s to %s, "
+			      "which is not a planned move"), old_name, new_name);
+		} else {
+			string_list_insert(claimed, old_name);
+		}
+		release_patch(&entry);
+		cursor = entry_end;
+	}
+
+	string_list_clear(&dst_map, 0);
+	string_list_clear(&dstdirs, 0);
+	strbuf_release(&root);
+}
+
+/*
+ * Parse the organizer response: the version line, then the reject directives
+ * and the optional patch, which is validated against the plan.
+ */
+static void parse_response(struct organize_plan *plan,
+			   const struct strbuf *response, struct strbuf *patch,
+			   struct string_list *claimed)
+{
+	const char *cursor = response->buf;
+	const char *end = response->buf + response->len;
+	struct strbuf path = STRBUF_INIT;
+
+	if (!skip_prefix(cursor, ORGANIZE_PROTOCOL, &cursor) || *cursor != '\n')
+		die(_("organize: organizer did not send the protocol header '%s'"),
+		    ORGANIZE_PROTOCOL);
+	cursor++;
+
+	while (cursor < end) {
+		const char *newline = memchr(cursor, '\n', end - cursor);
+		const char *args;
+
+		if (!newline)
+			die(_("organize: truncated organizer response"));
+
+		if (skip_prefix(cursor, "reject ", &args)) {
+			const char *reason = read_path_token(args, &path);
+
+			/*
+			 * read_path_token on a quoted path unquotes past a raw
+			 * newline, so its end (or the trimmed reason) can lie
+			 * beyond this line's newline; a negative length would
+			 * wrap in xstrndup below.
+			 */
+			if (reason > newline)
+				die(_("organize: malformed reject line"));
+			while (reason < newline && *reason == ' ')
+				reason++;
+			reject_move(plan, path.buf,
+				    xstrndup(reason, newline - reason));
+			cursor = newline + 1;
+		} else if (starts_with(cursor, "patch\n")) {
+			const char *body = newline + 1;
+
+			strbuf_add(patch, body, end - body);
+			if (patch->len)
+				validate_patch(plan, patch, claimed);
+			break;
+		} else if (newline == cursor) {
+			cursor = newline + 1;	/* skip a blank line */
+		} else {
+			die(_("organize: unexpected organizer line"));
+		}
+	}
+	strbuf_release(&path);
+}
+
+/* Run the organizer over the standing moves, then validate its patch. */
+void run_organizer(const char *command, struct organize_plan *plan,
+		   struct strbuf *patch, struct string_list *claimed)
+{
+	struct child_process child = CHILD_PROCESS_INIT;
+	struct strbuf request = STRBUF_INIT, response = STRBUF_INIT;
+
+	build_request(plan, &request);
+	strvec_push(&child.args, command);
+	child.use_shell = 1;
+	if (pipe_command(&child, request.buf, request.len, &response,
+			 0, NULL, 0))
+		die(_("organize: organizer failed: %s"), command);
+	parse_response(plan, &response, patch, claimed);
+	strbuf_release(&request);
+	strbuf_release(&response);
+}
diff --git a/organize/organizer-protocol.h b/organize/organizer-protocol.h
new file mode 100644
index 0000000000..4159d4ef24
--- /dev/null
+++ b/organize/organizer-protocol.h
@@ -0,0 +1,18 @@
+#ifndef ORGANIZER_PROTOCOL_H
+#define ORGANIZER_PROTOCOL_H
+
+struct organize_plan;
+struct strbuf;
+struct string_list;
+
+/*
+ * The organizer protocol. git organize sends the standing moves to the
+ * configured organizer, which may reject moves or return a patch of content
+ * edits. run_organizer validates that patch against the plan, fills `patch`
+ * with the edits and `claimed` with the moves the organizer renames itself,
+ * and records each rejected move on the plan.
+ */
+void run_organizer(const char *command, struct organize_plan *plan,
+		   struct strbuf *patch, struct string_list *claimed);
+
+#endif /* ORGANIZER_PROTOCOL_H */
diff --git a/t/t0096-organize.sh b/t/t0096-organize.sh
index a352a1c7d1..c2e6539ef2 100755
--- a/t/t0096-organize.sh
+++ b/t/t0096-organize.sh
@@ -4,9 +4,39 @@ test_description='git organize reconciles a tree against a declared layout'
 
 . ./test-lib.sh
 
-# There is no labeler yet, so tests write .gitorganize by hand: root *.c/*.h in
-# scope, odb/refs components, and a [labels] census.
-write_declaration () {
+# A labeler records blob.c under odb, refs.c under refs, header.h as public.
+# It writes a NUL-separated path and key=value label record per file.
+write_labeler () {
+	write_script labeler <<-\EOF
+	printf 'blob.c\0component=odb role=lib\0'
+	printf 'refs.c\0component=refs role=lib\0'
+	printf 'header.h\0component=? role=public\0'
+	EOF
+}
+
+# Point a stub organizer at the patch on its standard input; $2, if given, is
+# the reason it declines a move.
+write_organizer () {
+	cat >"$1.patch" &&
+	write_script "$1" <<-EOF
+	cat >/dev/null
+	printf 'git-organize 1 organize\n'
+	${2:+printf 'reject %s\n' '$2'}
+	printf 'patch\n'
+	cat $1.patch
+	EOF
+}
+
+# Point organize at the given labeler (and optional organizer), the way a
+# project points a merge driver at a command, and write the project-authored
+# [scope] pathspecs and [layout] rules: role:public and role:program keep a
+# file at the root (first match wins), a component value routes to its directory.
+configure_organize () {
+	git config organize.labeler "$1" &&
+	if test $# -gt 1
+	then
+		git config organize.organizer "$2"
+	fi &&
 	cat >.gitorganize <<-\EOF
 	[scope]
 	:(glob)*.c
@@ -16,24 +46,106 @@ write_declaration () {
 	role:program = .
 	component:odb = odb
 	component:refs = refs
-	[labels]
-	blob.c component=odb role=lib
-	header.h component=? role=public
-	refs.c component=refs role=lib
 	EOF
 }
 
-test_expect_success 'setup a tree and a declaration' '
+test_expect_success 'setup a tree and a labeler' '
 	echo blob >blob.c &&
 	echo refs >refs.c &&
 	echo header >header.h &&
 	git add . &&
 	git commit -m init &&
-	write_declaration &&
+	write_labeler &&
+	configure_organize ./labeler &&
 	git add .gitorganize &&
 	git commit -m declare
 '
 
+test_expect_success 'apply --labels-only records the labels' '
+	git organize apply --labels-only &&
+	cat >expect <<-\EOF &&
+	[scope]
+	:(glob)*.c
+	:(glob)*.h
+	[layout]
+	role:public = .
+	role:program = .
+	component:odb = odb
+	component:refs = refs
+	[labels]
+	# The recorded placement of each source; edit a line to change it.
+	# apply --labels-only fills in unrecorded sources; --reseed re-derives all.
+	blob.c component=odb role=lib
+	header.h component=? role=public
+	refs.c component=refs role=lib
+	EOF
+	test_cmp expect .gitorganize &&
+	git diff --cached --name-only >staged &&
+	test_grep "^.gitorganize$" staged &&
+	git commit -m labels
+'
+
+test_expect_success 'apply --labels-only preserves a recorded label; --reseed re-derives' '
+	git init preserve &&
+	(
+		cd preserve &&
+		echo blob >blob.c &&
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		configure_organize ./labeler &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		test_grep "^blob.c component=odb" .gitorganize &&
+		# a hand-made placement decision the labeler would not make
+		sed "s|^blob.c component=odb|blob.c component=refs|" .gitorganize >edited &&
+		mv edited .gitorganize &&
+		# a plain re-run keeps the recorded decision
+		git organize apply --labels-only &&
+		test_grep "^blob.c component=refs" .gitorganize &&
+		test_grep ! "^blob.c component=odb" .gitorganize &&
+		# --reseed discards it and re-derives from the labeler
+		git organize apply --labels-only --reseed &&
+		test_grep "^blob.c component=odb" .gitorganize
+	)
+'
+
+test_expect_success 'a file added under a carved directory is governed in place' '
+	git init subdirs &&
+	(
+		cd subdirs &&
+		echo blob >blob.c &&
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		configure_organize ./labeler &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		git organize apply &&
+		git commit -m carve &&
+		test_path_is_file odb/blob.c &&
+		# the carved file alone is in scope and in place
+		git organize status >before &&
+		test_grep "1 in scope" before &&
+		# a NEW file added directly under the carved odb/ directory is
+		# governed by its location: in scope and in place, not invisible
+		echo extra >odb/extra.c &&
+		git add odb/extra.c &&
+		git organize status >after &&
+		test_grep "2 in scope (2 in place" after &&
+		git organize status --exit-code &&
+		# a file outside any [layout] directory stays ungoverned
+		mkdir vendor &&
+		echo v >vendor/z.c &&
+		git add vendor/z.c &&
+		git organize status >vend &&
+		test_grep "2 in scope" vend
+	)
+'
+
 test_expect_success 'status reports the files to move' '
 	git organize status >actual &&
 	# header.h is public (in place at root); blob.c and refs.c move next
@@ -74,47 +186,319 @@ test_expect_success 'apply refuses a dirty worktree' '
 		echo other >other.c &&
 		git add . &&
 		git commit -m init &&
-		cat >.gitorganize <<-\EOF &&
-		[scope]
-		:(glob)*.c
-		[layout]
-		component:odb = odb
-		[labels]
-		blob.c component=odb
-		other.c component=?
-		EOF
+		write_labeler &&
+		configure_organize ./labeler &&
 		git add .gitorganize &&
 		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
 		echo dirty >>other.c &&
 		test_must_fail git organize apply 2>err &&
 		test_grep "uncommitted changes" err
 	)
 '
 
-test_expect_success 'a file in scope with no matching rule is backlog' '
-	git init backlog &&
+test_expect_success 'organizer may decline a move and patch a referrer' '
+	git init sub &&
+	(
+		cd sub &&
+		echo blob >blob.c &&
+		echo refs >refs.c &&
+		printf "blob.o\n" >build.list &&
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		write_organizer organizer "refs.c held for test" <<-\EOF &&
+		diff --git a/build.list b/build.list
+		--- a/build.list
+		+++ b/build.list
+		@@ -1 +1 @@
+		-blob.o
+		+odb/blob.o
+		EOF
+		configure_organize ./labeler ./organizer &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		git organize apply >out &&
+		test_grep "1 move(s), 1 skipped" out &&
+		test_grep "skipped refs.c" out &&
+		git diff --cached -M --name-status >actual &&
+		test_grep "^R100.*blob.c.*odb/blob.c" actual &&
+		test_grep "^M.*build.list" actual &&
+		echo odb/blob.o >expect &&
+		test_cmp expect build.list &&
+		test_path_is_file refs.c &&
+		test_path_is_file odb/blob.c &&
+		test_path_is_missing blob.c &&
+		# the carved file is repointed; the declined file keeps its line
+		test_grep "^odb/blob.c component=odb" .gitorganize &&
+		test_grep "^refs.c component=refs" .gitorganize &&
+		test_grep ! "^blob.c " .gitorganize
+	)
+'
+
+test_expect_success 'apply rejects an in-place edit of a moved file' '
+	git init tamper &&
 	(
-		cd backlog &&
+		cd tamper &&
+		echo blob >blob.c &&
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		write_organizer tamper_organizer <<-\EOF &&
+		diff --git a/blob.c b/blob.c
+		--- a/blob.c
+		+++ b/blob.c
+		@@ -1 +1 @@
+		-blob
+		+tampered
+		EOF
+		configure_organize ./labeler ./tamper_organizer &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		test_must_fail git organize apply 2>err &&
+		test_grep "part of a move" err &&
+		# the rejected apply changed nothing
+		test_path_is_file blob.c &&
+		test_path_is_missing odb/blob.c
+	)
+'
+
+test_expect_success 'apply rejects a rename that is not a planned move' '
+	git init renamer &&
+	(
+		cd renamer &&
+		echo blob >blob.c &&
+		echo readme >README &&
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		write_organizer rename_organizer <<-\EOF &&
+		diff --git a/README b/MOVED
+		similarity index 100%
+		rename from README
+		rename to MOVED
+		EOF
+		configure_organize ./labeler ./rename_organizer &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		test_must_fail git organize apply 2>err &&
+		test_grep "not a planned move" err &&
+		# the rejected apply changed nothing
+		test_path_is_file README &&
+		test_path_is_missing MOVED &&
+		test_path_is_file blob.c
+	)
+'
+
+test_expect_success 'apply rejects a body that edits a file the header does not name' '
+	git init header-lies &&
+	(
+		cd header-lies &&
+		echo blob >blob.c &&
+		echo refs >refs.c &&
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		# the diff --git header claims the planned blob.c move, but the body
+		# edits refs.c (another moved file); apply resolves the real target
+		# from the patch, not the header, and rejects it.
+		write_organizer liar <<-\EOF &&
+		diff --git a/blob.c b/odb/blob.c
+		--- a/refs.c
+		+++ b/refs.c
+		@@ -1 +1 @@
+		-refs
+		+tampered
+		EOF
+		configure_organize ./labeler ./liar &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		test_must_fail git organize apply 2>err &&
+		test_grep "part of a move" err &&
+		# the rejected apply changed nothing
+		test_grep "^refs$" refs.c &&
+		test_path_is_missing refs/refs.c &&
+		test_path_is_missing odb/blob.c
+	)
+'
+
+test_expect_success 'apply rejects an in-place edit that repoints no move' '
+	git init meddle &&
+	(
+		cd meddle &&
+		echo blob >blob.c &&
+		echo other >other.c &&
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		# other.c does not move, and the edit names no directory the plan
+		# moves into, so it is not repointing a reference to a moved file
+		write_organizer meddler <<-\EOF &&
+		diff --git a/other.c b/other.c
+		--- a/other.c
+		+++ b/other.c
+		@@ -1 +1 @@
+		-other
+		+meddled
+		EOF
+		configure_organize ./labeler ./meddler &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		test_must_fail git organize apply 2>err &&
+		test_grep "does not repoint" err &&
+		# the rejected apply changed nothing
+		test_grep "^other$" other.c &&
+		test_path_is_file blob.c &&
+		test_path_is_missing odb/blob.c
+	)
+'
+
+test_expect_success 'organizer may rename-with-modification a moved file' '
+	git init renamemod &&
+	(
+		cd renamemod &&
+		cat >blob.c <<-\EOF &&
+		#include "a.h"
+		#include "b.h"
+		#include "x.h"
+		#include "c.h"
+		#include "d.h"
+		EOF
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		write_organizer renamemod_organizer <<-\EOF &&
+		diff --git a/blob.c b/odb/blob.c
+		rename from blob.c
+		rename to odb/blob.c
+		--- a/blob.c
+		+++ b/odb/blob.c
+		@@ -1,5 +1,5 @@
+		 #include "a.h"
+		 #include "b.h"
+		-#include "x.h"
+		+#include "sub/x.h"
+		 #include "c.h"
+		 #include "d.h"
+		EOF
+		configure_organize ./labeler ./renamemod_organizer &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		git organize apply &&
+		test_path_is_file odb/blob.c &&
+		test_path_is_missing blob.c &&
+		test_grep "sub/x.h" odb/blob.c &&
+		git diff --cached -M --name-status >actual &&
+		test_grep "^R[0-9]*.*blob.c.*odb/blob.c" actual &&
+		test_grep "^odb/blob.c component=odb role=lib" .gitorganize &&
+		test_grep ! "^blob.c " .gitorganize &&
+		git diff --cached --name-only >staged &&
+		test_grep "^.gitorganize$" staged
+	)
+'
+
+test_expect_success 'a basename shared across directories does not collide' '
+	git init dup &&
+	(
+		cd dup &&
+		echo root >dup.c &&
+		mkdir sub &&
+		echo sub >sub/dup.c &&
+		git add . &&
+		git commit -m init &&
+		# a labeler that labels only the root dup.c
+		write_script duplabeler <<-\EOF &&
+		printf "dup.c\0component=odb role=lib\0"
+		EOF
+		configure_organize ./duplabeler &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		git organize status >actual &&
+		test_grep "dup.c  *-> odb/dup.c" actual &&
+		test_grep ! "sub/dup.c" actual &&
+		git organize apply &&
+		test_path_is_file odb/dup.c &&
+		test_path_is_file sub/dup.c &&
+		test_path_is_missing dup.c &&
+		git commit -m reconciled
+	)
+'
+
+test_expect_success 'a rule that maps a label to the root keeps its file in place' '
+	git init prog &&
+	(
+		cd prog &&
+		echo lib >lib.c &&
+		echo tool >tool.c &&
+		git add . &&
+		git commit -m init &&
+		# tool.c carries role=program, which the layout maps to the root
+		# (role:program = .), so it stays; lib.c matches component:odb and moves
+		write_script proglabeler <<-\EOF &&
+		printf "lib.c\0component=odb role=lib\0"
+		printf "tool.c\0component=? role=program\0"
+		EOF
+		configure_organize ./proglabeler &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		test_grep "^tool.c component=? role=program" .gitorganize &&
+		git commit -m labels &&
+		git organize status >actual &&
+		test_grep "organize: 2 in scope (1 in place, 1 to move, 0 backlog)" actual &&
+		test_grep ! "tool.c  *->" actual &&
+		git organize apply &&
+		test_path_is_file tool.c &&
+		test_path_is_file odb/lib.c &&
+		test_path_is_missing lib.c
+	)
+'
+
+test_expect_success 'a file in scope with no recorded label is unrecorded' '
+	git init scoped &&
+	(
+		cd scoped &&
 		echo a >a.c &&
 		git add . &&
 		git commit -m init &&
-		cat >.gitorganize <<-\EOF &&
-		[scope]
-		:(glob)*.c
-		[layout]
-		component:odb = odb
-		[labels]
-		a.c component=?
+		write_script alabeler <<-\EOF &&
+		printf "a.c\0component=? role=lib\0"
 		EOF
+		configure_organize ./alabeler &&
 		git add .gitorganize &&
 		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		# a.c is recorded but matches no rule: backlog
 		git organize status >actual &&
-		test_grep "backlog" actual &&
-		test_grep "^  a.c$" actual
+		test_grep "backlog:" actual &&
+		test_grep "^  a.c$" actual &&
+		# a source in scope that [labels] never recorded is unrecorded
+		echo b >b.c &&
+		git add b.c &&
+		git commit -m add-b &&
+		git organize status >actual &&
+		test_grep "in scope but unrecorded:" actual &&
+		test_grep "^  b.c$" actual
 	)
 '
 
-test_expect_success 'status reports a declared path that no longer exists' '
+test_expect_success 'status reports a recorded path that no longer exists' '
 	git init orphan &&
 	(
 		cd orphan &&
@@ -122,17 +506,15 @@ test_expect_success 'status reports a declared path that no longer exists' '
 		echo b >b.c &&
 		git add . &&
 		git commit -m init &&
-		cat >.gitorganize <<-\EOF &&
-		[scope]
-		:(glob)*.c
-		[layout]
-		role:public = .
-		[labels]
-		a.c role=public
-		b.c role=public
+		write_script twolabeler <<-\EOF &&
+		printf '\''a.c\0component=? role=public\0b.c\0component=? role=public\0'\''
 		EOF
+		configure_organize ./twolabeler &&
 		git add .gitorganize &&
 		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		# remove a recorded file outside the tool
 		git rm -q b.c &&
 		git commit -m drop-b &&
 		git organize status >actual &&
@@ -177,6 +559,25 @@ test_expect_success 'status rejects a malformed .gitorganize' '
 	)
 '
 
+test_expect_success 'the recorded labels carry arbitrary key=value pairs' '
+	git init extra &&
+	(
+		cd extra &&
+		echo z >z.c &&
+		git add . &&
+		git commit -m init &&
+		write_script extralabeler <<-\EOF &&
+		printf '\''z.c\0component=? role=lib note=demo\0'\''
+		EOF
+		configure_organize ./extralabeler &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		# a label the engine does not place still round-trips into [labels]
+		test_grep "^z.c component=? role=lib note=demo" .gitorganize
+	)
+'
+
 test_expect_success 'a subcommand rejects extra operands' '
 	test_must_fail git -C bad organize status junk 2>err &&
 	test_grep "too many arguments" err
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 03/14] organize: add status --exit-code
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 01/14] organize: add the git organize builtin Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 02/14] organize: add the labeler, organizer, and apply --labels-only Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 04/14] organize: add the --label selector Michael Montalbo
                   ` (10 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

git organize status reports and always returns zero. A project that keeps
its tree reconciled needs status to fail when the tree drifts, so a check
can gate on the result.

Add --exit-code. status returns 1 when a file is out of place or a recorded
path no longer exists, and 0 otherwise. A standing backlog alone does not
fail it: a backlog file matches no rule, so it is not out of place.
--exit-code changes no output.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 Documentation/git-organize.adoc | 15 ++++++++++++---
 builtin/organize.c              | 12 +++++++-----
 t/t0096-organize.sh             | 20 +++++++++++++++-----
 3 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/Documentation/git-organize.adoc b/Documentation/git-organize.adoc
index 8b216146b6..37ada38234 100644
--- a/Documentation/git-organize.adoc
+++ b/Documentation/git-organize.adoc
@@ -9,7 +9,7 @@ git-organize - Reconcile a source tree against a declared layout
 SYNOPSIS
 --------
 [verse]
-'git organize status'
+'git organize status' [--exit-code]
 'git organize apply'
 'git organize apply' --labels-only [--reseed]
 
@@ -44,7 +44,9 @@ is not in yet.
 `git organize status` reads `[labels]` and reports the out-of-place files,
 the backlog, a file in scope that `[labels]` does not record, and a
 recorded path that no longer exists. status runs no
-configured command and changes nothing.
+configured command and changes nothing. With `--exit-code` it exits
+non-zero when a file is out of place, a file in scope is unrecorded, or a
+recorded path is missing; a standing backlog alone does not fail it.
 
 `git organize apply` reconciles the tree. It moves each out-of-place file
 into its directory. A move that git organize makes on its own is a
@@ -72,7 +74,9 @@ status::
 	in (the moves), the backlog (recorded files with no matching
 	rule), a file in scope that `[labels]` does not record, and a recorded
 	path that no longer exists. Runs no configured
-	command and changes nothing.
+	command and changes nothing. With `--exit-code`, exit non-zero when a
+	file is out of place, a file in scope is unrecorded, or a recorded path
+	is missing.
 
 apply::
 	Move each out-of-place file into its directory as a content-identical
@@ -92,6 +96,11 @@ never do.
 OPTIONS
 -------
 
+--exit-code::
+	Exit non-zero from status when a file is out of place, a file in scope
+	is unrecorded, or a recorded path is missing. A standing backlog alone
+	does not fail it. Changes no output.
+
 --labels-only::
 	With apply, run the labeler and record the labels; move no file. A
 	recorded file keeps its line; the labeler only seeds a file that has no
diff --git a/builtin/organize.c b/builtin/organize.c
index 354ba2151f..35247c5aef 100644
--- a/builtin/organize.c
+++ b/builtin/organize.c
@@ -15,13 +15,13 @@
 #include "repository.h"
 
 static const char *const organize_usage[] = {
-	"git organize status",
+	"git organize status [--exit-code]",
 	"git organize apply",
 	"git organize apply --labels-only [--reseed]",
 	NULL
 };
 
-static int organize_status(struct repository *repo)
+static int organize_status(struct repository *repo, int exit_code)
 {
 	struct organize_plan plan = ORGANIZE_PLAN_INIT;
 	int to_move, backlog, unrecorded, orphans;
@@ -67,7 +67,7 @@ static int organize_status(struct repository *repo)
 	}
 
 	organize_plan_release(&plan);
-	return 0;
+	return exit_code && (to_move || unrecorded || orphans) ? 1 : 0;
 }
 
 static int organize_apply(struct repository *repo)
@@ -106,8 +106,10 @@ int cmd_organize(int argc,
 		 const char *prefix,
 		 struct repository *repo)
 {
-	int labels_only = 0, reseed = 0;
+	int exit_code = 0, labels_only = 0, reseed = 0;
 	struct option options[] = {
+		OPT_BOOL(0, "exit-code", &exit_code,
+			 N_("exit non-zero from status when a file is out of place")),
 		OPT_BOOL(0, "labels-only", &labels_only,
 			 N_("with apply, run the labeler and record the labels")),
 		OPT_BOOL(0, "reseed", &reseed,
@@ -126,7 +128,7 @@ int cmd_organize(int argc,
 	if (!strcmp(subcmd, "status")) {
 		if (labels_only)
 			die(_("git organize: --labels-only is an apply option"));
-		ret = organize_status(repo);
+		ret = organize_status(repo, exit_code);
 	} else if (!strcmp(subcmd, "apply")) {
 		if (labels_only) {
 			organize_run_labeler(repo, reseed);
diff --git a/t/t0096-organize.sh b/t/t0096-organize.sh
index c2e6539ef2..d8de3c7e90 100755
--- a/t/t0096-organize.sh
+++ b/t/t0096-organize.sh
@@ -156,6 +156,10 @@ test_expect_success 'status reports the files to move' '
 	test_grep "2 file(s) would move" actual
 '
 
+test_expect_success 'status --exit-code fails when a file is out of place' '
+	test_expect_code 1 git organize status --exit-code
+'
+
 test_expect_success 'apply moves files as content-identical renames and repoints [labels]' '
 	git organize apply &&
 	git diff --cached -M --name-status >actual &&
@@ -169,6 +173,7 @@ test_expect_success 'apply moves files as content-identical renames and repoints
 	git diff --cached --name-only >staged &&
 	test_grep "^.gitorganize$" staged &&
 	git commit -m reconciled &&
+	git organize status --exit-code &&
 	git organize status >actual &&
 	test_grep "nothing to move" actual &&
 	test_grep "^odb/blob.c component=odb" .gitorganize &&
@@ -435,7 +440,8 @@ test_expect_success 'a basename shared across directories does not collide' '
 		test_path_is_file odb/dup.c &&
 		test_path_is_file sub/dup.c &&
 		test_path_is_missing dup.c &&
-		git commit -m reconciled
+		git commit -m reconciled &&
+		git organize status --exit-code
 	)
 '
 
@@ -484,17 +490,20 @@ test_expect_success 'a file in scope with no recorded label is unrecorded' '
 		git commit -m declare &&
 		git organize apply --labels-only &&
 		git commit -m labels &&
-		# a.c is recorded but matches no rule: backlog
+		# a.c is recorded but matches no rule, so it is backlog; a
+		# standing backlog alone does not fail --exit-code
 		git organize status >actual &&
 		test_grep "backlog:" actual &&
 		test_grep "^  a.c$" actual &&
-		# a source in scope that [labels] never recorded is unrecorded
+		git organize status --exit-code &&
+		# a source in scope that [labels] never recorded is unrecorded drift
 		echo b >b.c &&
 		git add b.c &&
 		git commit -m add-b &&
 		git organize status >actual &&
 		test_grep "in scope but unrecorded:" actual &&
-		test_grep "^  b.c$" actual
+		test_grep "^  b.c$" actual &&
+		test_expect_code 1 git organize status --exit-code
 	)
 '
 
@@ -519,7 +528,8 @@ test_expect_success 'status reports a recorded path that no longer exists' '
 		git commit -m drop-b &&
 		git organize status >actual &&
 		test_grep "declared but missing" actual &&
-		test_grep "  b.c" actual
+		test_grep "  b.c" actual &&
+		test_expect_code 1 git organize status --exit-code
 	)
 '
 
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 04/14] organize: add the --label selector
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (2 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 03/14] organize: add status --exit-code Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 05/14] organize: declare Git's scope and layout Michael Montalbo
                   ` (9 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

status and apply act on every out-of-place file at once. To reconcile one
group at a time, a caller needs a way to name a subset.

Add --label <key[=value]>. A key=value selector matches a file whose
recorded labels include it; a bare key matches any value of that label. The
selector is repeatable and the matches combine, so a file matching any
selector is included. A selector can name any recorded label, not only
the ones [layout] places files by.

git organize apply --label component=<name> then reconciles one component
at a time, which is how a large layout is carved in reviewable steps.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 Documentation/git-organize.adoc | 118 ++++++++++++++++----------
 builtin/organize.c              |  25 ++++--
 organize/organize.c             |  34 +++++++-
 organize/organize.h             |   7 +-
 t/t0096-organize.sh             | 143 ++++++++++++++++++++++++++++++++
 5 files changed, 270 insertions(+), 57 deletions(-)

diff --git a/Documentation/git-organize.adoc b/Documentation/git-organize.adoc
index 37ada38234..aca8934b26 100644
--- a/Documentation/git-organize.adoc
+++ b/Documentation/git-organize.adoc
@@ -9,8 +9,8 @@ git-organize - Reconcile a source tree against a declared layout
 SYNOPSIS
 --------
 [verse]
-'git organize status' [--exit-code]
-'git organize apply'
+'git organize status' [--exit-code] [--label <key[=value]>...]
+'git organize apply' [--label <key[=value]>...]
 'git organize apply' --labels-only [--reseed]
 
 
@@ -24,16 +24,18 @@ file belongs in.
 
 `.gitorganize` at the repository root has three sections. `[scope]` names
 the files in scope, one pathspec per line; with no `[scope]` section
-nothing is in scope. `[layout]` is the project's placement map, authored by
-hand: ordered `<label>:<value> = <directory>` rules (`.` is the repository
-root). A file's labels are matched against the rules in order, and the first
-rule it satisfies places it; a file matching no rule is the backlog.
-`[labels]` holds the recorded labels, one line per
-source in scope, `<path> <key>=<value> ...`, with every label the project
-defines. A placed file is listed too, so its `[labels]` line records its
-labels, independently of the directory name. Only a label named in a rule
-places a file; a label named in no rule places nothing and is recorded for a
-reader.
+nothing is in scope. `[layout]` is the project's map of where each file
+belongs, authored by hand: ordered `<label>:<value> = <directory>` rules
+(`.` is the repository root). A file's labels are matched against the rules in
+order, and the first rule it satisfies gives the file its directory; a file
+matching no rule is the backlog.
+`[labels]` holds the recorded labels: one line, `<path> <key>=<value>
+...`, per recorded in-scope source, with every label the project
+defines. apply repoints a moved file's line to its new path and keeps
+it, so a placed file keeps its record. A file that already sits inside a
+`[layout]` directory before it is recorded has no line; its location
+alone places it. Only a label named in a rule places a file; a label
+named in no rule places nothing and is recorded for a reader.
 
 The labeler and organizer live in config: `organize.labeler` and
 `organize.organizer`. A label is a key and value the labeler attaches to a
@@ -60,7 +62,7 @@ own references. A project supplies those edits with an organizer, its
 `organize.organizer` command. apply hands the organizer its
 moves. The organizer returns a patch of the edits and, for any move it
 cannot complete, a reason to skip it. When the organizer edits a file as it
-moves, git's rename detection matches it while its similarity stays above
+moves, Git's rename detection matches it while its similarity stays above
 the rename threshold. apply applies the moves and the patch as one
 transaction. With no organizer configured, apply moves the files and makes
 no other edit.
@@ -70,25 +72,28 @@ COMMANDS
 --------
 
 status::
-	Report the files whose placement value names a directory they are not
+	Report the files whose matching rule names a directory they are not
 	in (the moves), the backlog (recorded files with no matching
 	rule), a file in scope that `[labels]` does not record, and a recorded
 	path that no longer exists. Runs no configured
-	command and changes nothing. With `--exit-code`, exit non-zero when a
-	file is out of place, a file in scope is unrecorded, or a recorded path
-	is missing.
+	command and changes nothing. With `--label`, limit the moves to the
+	files a label selects (see OPTIONS); the backlog, unrecorded, and
+	missing lists are always reported. With `--exit-code`, exit non-zero
+	when a file is out of place, a file in scope is unrecorded, or a
+	recorded path is missing.
 
 apply::
 	Move each out-of-place file into its directory as a content-identical
 	rename, apply the organizer's edits, repoint each carved file's
-	`[labels]` line to its new path, and stage the result. apply requires a
-	clean worktree, so the change can be discarded as a whole.
+	`[labels]` line to its new path, and stage the result. With `--label`,
+	reconcile only the files a label selects. apply requires a clean
+	worktree, so the change can be discarded as a whole.
 +
 With `--labels-only`, apply instead records the `[labels]` line for every root
 file in scope and stages the file. A file already recorded keeps its line, so a
-placement chosen by hand or in an earlier run stands; the labeler only seeds a
+directory chosen by hand or in an earlier run stands; the labeler only seeds a
 file that has no line yet. With `--reseed`, re-derive every line from the
-labeler, discarding the recorded placements. This is the only path that runs a
+labeler, discarding the recorded lines. This is the only path that runs a
 labeler; `git organize apply` without `--labels-only` and `git organize status`
 never do.
 
@@ -96,6 +101,14 @@ never do.
 OPTIONS
 -------
 
+--label <key[=value]>::
+	Limit the moves that status reports and apply makes to the files a
+	label selects. A `<key>=<value>` selector matches a file whose
+	recorded labels include it; a bare `<key>` matches any value of that
+	label. A selector can name any recorded label, not only the ones
+	`[layout]` places files by. Repeatable; the selectors combine, so a
+	file matching any of them is included.
+
 --exit-code::
 	Exit non-zero from status when a file is out of place, a file in scope
 	is unrecorded, or a recorded path is missing. A standing backlog alone
@@ -107,9 +120,11 @@ OPTIONS
 	line yet.
 
 --reseed::
-	With apply `--labels-only`, re-derive every `[labels]` line from the
-	labeler, discarding the recorded placements. Use it to re-apply the
-	labeler after its map changes; without it a recorded line is kept.
+	With apply `--labels-only`, discard the recorded lines and re-derive
+	them from the labeler. A file already placed in a `[layout]`
+	directory keeps its line, because the labeler derives labels from the
+	sources at the root. Use it to re-apply the labeler after its map
+	changes; without it a recorded line is kept.
 
 
 CONFIGURATION
@@ -119,20 +134,23 @@ organize.labeler::
 	--labels-only` runs it over the root files in scope. It writes one
 	record per file on its standard output: the path, a NUL, its
 	space-separated `key=value` labels, a NUL. A file in scope with no
-	record is unrecorded, reported apart from the backlog. Use user or
-	system config for this setting; do
-	not take it from a repository file.
+	record is unrecorded, reported apart from the backlog. This command is
+	honored from config at any level, repo-local `.git/config` included, and
+	so requires the trust you give `core.hooksPath`.
 
 organize.organizer::
 	The command that returns move edits. apply runs it over the moves. It
 	reads the pending moves on its standard input and returns a patch and
 	any skip reasons; see PROTOCOL. Optional. Without it, apply performs the
-	moves and makes no other edit. Use user or system config for this
-	setting; do not take it from a repository file.
+	moves and makes no other edit. This command is honored from config at
+	any level, repo-local `.git/config` included, and so requires the trust
+	you give `core.hooksPath`.
 
 The labeler and organizer are trusted, the way a clean or smudge filter or a
-hook is trusted. Set them in user or system config, so a repository you clone
-cannot supply its own.
+hook is trusted. Both are honored from config at any level, repo-local
+`.git/config` included. A repository you clone does not ship its `.git/config`,
+so a clone cannot supply them by that route, but treat a command written into
+`.git/config` with the same care you give `core.hooksPath`.
 
 
 FILES
@@ -140,16 +158,17 @@ FILES
 `.gitorganize`::
 	The declaration, at the repository root, in three sections. `[scope]`
 	names the files in scope, one pathspec per line; with no `[scope]`
-	section nothing is in scope. `[layout]` is the project's placement map:
-	ordered `<label>:<value> = <directory>` rules (`.` is the root), where a
-	file takes the directory of the first rule its labels satisfy, and a
-	file matching no rule is the backlog. `[labels]` holds the recorded
-	labels, one `<path> <key>=<value> ...` line per source in scope,
-	including placed files. The project writes `[scope]` and `[layout]`;
-	`git organize apply --labels-only` writes `[labels]`, and the move apply
-	repoints a carved file's line. A `#` line is a comment; git organize
-	rewrites the file whole, keeping the hand-authored `[scope]` and
-	`[layout]` verbatim.
+	section nothing is in scope. `[layout]` is the project's map of where
+	each file belongs: ordered `<label>:<value> = <directory>` rules (`.` is
+	the root), where a file takes the directory of the first rule its labels
+	satisfy, and a file matching no rule is the backlog. `[labels]` holds
+	the recorded labels, one `<path> <key>=<value> ...` line per in-scope
+	source that a rule, not its location, places; a file already inside a
+	`[layout]` directory is placed by its location and has no line. The
+	project writes `[scope]` and `[layout]`; `git organize apply
+	--labels-only` writes `[labels]`, and the move apply repoints a carved
+	file's line. A `#` line is a comment; git organize rewrites the file
+	whole, keeping the hand-authored `[scope]` and `[layout]` verbatim.
 
 
 PROTOCOL
@@ -159,9 +178,20 @@ version line `git-organize 1 organize`, then a `move <src> <dst> <label>`
 line per pending move, with C-quoted paths. The organizer replies with the
 same version line. For each declined move, it writes `reject <src>
 <reason>`. It may then write `patch`, followed by a git patch that runs to
-the end of its output. The patch may edit referring files and may rename a
-moved file as it edits it, but it must not add, delete, or copy files, and
-any rename must match a planned move.
+the end of its output.
+
+Before it runs `git apply`, git organize checks each entry in the patch with
+Git's own diff-header parser and refuses the patch if an entry adds, deletes,
+or copies a file, changes a file's mode, or renames a file to anything but a
+planned move. An in-place edit must repoint a move: it must leave the file
+where it is and mention a directory the plan moves into. So the patch git
+organize accepts is limited to edits of referring files and to renames that
+match a planned move.
+
+The organizer is a trusted, config-defined command, honored the way a clean or
+smudge filter is. These checks catch a well-meaning organizer's mistakes; they
+do not sandbox a hostile one, and they do not certify that the whole patch is
+sound.
 
 
 GIT
diff --git a/builtin/organize.c b/builtin/organize.c
index 35247c5aef..925ef17128 100644
--- a/builtin/organize.c
+++ b/builtin/organize.c
@@ -6,27 +6,30 @@
  * are not in yet (the moves), the backlog (files with no matching rule), and a
  * declared path that no longer exists. apply moves the misplaced files and
  * stages the result; apply --labels-only instead runs the labeler and records
- * the labels.
+ * the labels. --label <key[=value]> (repeatable) limits status and the move
+ * apply to files carrying a matching label.
  */
 #include "builtin.h"
 #include "gettext.h"
 #include "organize/organize.h"
 #include "parse-options.h"
 #include "repository.h"
+#include "strvec.h"
 
 static const char *const organize_usage[] = {
-	"git organize status [--exit-code]",
-	"git organize apply",
+	"git organize status [--exit-code] [--label <key[=value]>...]",
+	"git organize apply [--label <key[=value]>...]",
 	"git organize apply --labels-only [--reseed]",
 	NULL
 };
 
-static int organize_status(struct repository *repo, int exit_code)
+static int organize_status(struct repository *repo,
+			   const struct strvec *selectors, int exit_code)
 {
 	struct organize_plan plan = ORGANIZE_PLAN_INIT;
 	int to_move, backlog, unrecorded, orphans;
 
-	organize_plan_build(repo, &plan);
+	organize_plan_build(repo, selectors, &plan);
 	to_move = (int)plan.moves_nr;
 	backlog = (int)plan.backlog.nr;
 	unrecorded = (int)plan.unrecorded.nr;
@@ -70,12 +73,12 @@ static int organize_status(struct repository *repo, int exit_code)
 	return exit_code && (to_move || unrecorded || orphans) ? 1 : 0;
 }
 
-static int organize_apply(struct repository *repo)
+static int organize_apply(struct repository *repo, const struct strvec *selectors)
 {
 	struct organize_plan plan = ORGANIZE_PLAN_INIT;
 	int moved = 0, rejected = 0;
 
-	organize_plan_build(repo, &plan);
+	organize_plan_build(repo, selectors, &plan);
 	if (!plan.moves_nr) {
 		printf(_("organize apply: nothing to do\n"));
 		organize_plan_release(&plan);
@@ -106,8 +109,11 @@ int cmd_organize(int argc,
 		 const char *prefix,
 		 struct repository *repo)
 {
+	struct strvec selectors = STRVEC_INIT;
 	int exit_code = 0, labels_only = 0, reseed = 0;
 	struct option options[] = {
+		OPT_STRVEC(0, "label", &selectors, N_("key[=value]"),
+			   N_("limit to files carrying a matching label (repeatable)")),
 		OPT_BOOL(0, "exit-code", &exit_code,
 			 N_("exit non-zero from status when a file is out of place")),
 		OPT_BOOL(0, "labels-only", &labels_only,
@@ -128,7 +134,7 @@ int cmd_organize(int argc,
 	if (!strcmp(subcmd, "status")) {
 		if (labels_only)
 			die(_("git organize: --labels-only is an apply option"));
-		ret = organize_status(repo, exit_code);
+		ret = organize_status(repo, &selectors, exit_code);
 	} else if (!strcmp(subcmd, "apply")) {
 		if (labels_only) {
 			organize_run_labeler(repo, reseed);
@@ -136,11 +142,12 @@ int cmd_organize(int argc,
 				 "staged; nothing is committed.\n"));
 			ret = 0;
 		} else {
-			ret = organize_apply(repo);
+			ret = organize_apply(repo, &selectors);
 		}
 	} else {
 		die(_("git organize: unknown subcommand '%s'"), subcmd);
 	}
 
+	strvec_clear(&selectors);
 	return ret;
 }
diff --git a/organize/organize.c b/organize/organize.c
index 8c623444c0..298557a3da 100644
--- a/organize/organize.c
+++ b/organize/organize.c
@@ -29,6 +29,30 @@ static const char *organize_command(struct repository *repo, const char *key)
 	return cmd;
 }
 
+/*
+ * Whether a file's labels satisfy any --label selector. labels is the file's
+ * space-separated "key=value" list. A "key=value" selector must equal a label
+ * exactly; a bare "key" matches any value of that label.
+ */
+static int label_selected(const char *labels, struct string_list *selectors)
+{
+	for (size_t i = 0; i < selectors->nr; i++) {
+		const char *selector = selectors->items[i].string;
+		size_t sellen = strlen(selector);
+		int bare = !strchr(selector, '=');
+
+		for (const char *l = labels; *l; ) {
+			const char *sp = strchrnul(l, ' ');
+
+			if (!strncmp(l, selector, sellen) &&
+			    (bare ? l[sellen] == '=' : sp == l + sellen))
+				return 1;
+			l = *sp ? sp + 1 : sp;
+		}
+	}
+	return 0;
+}
+
 /*
  * The [layout] rule whose directory equals `path`'s directory, or NULL when
  * `path` is a root file or its directory matches no rule. A file in a [layout]
@@ -133,14 +157,19 @@ static void add_move(struct organize_plan *plan, const char *src,
 	m->skip_reason = NULL;
 }
 
-void organize_plan_build(struct repository *repo, struct organize_plan *plan)
+void organize_plan_build(struct repository *repo, const struct strvec *selectors,
+			 struct organize_plan *plan)
 {
 	struct organize_ctx ctx = ORGANIZE_CTX_INIT;
+	struct string_list want = STRING_LIST_INIT_NODUP;
 	struct string_list seen = STRING_LIST_INIT_DUP;
 	struct strbuf value_buf = STRBUF_INIT;
 
 	organize_ctx_load(repo, &ctx);
 
+	for (size_t i = 0; i < selectors->nr; i++)
+		string_list_append(&want, selectors->v[i]);
+
 	/*
 	 * Classify each recorded entry by the rule its labels match. A file
 	 * already in the rule's directory is in place. A file in another
@@ -175,7 +204,7 @@ void organize_plan_build(struct repository *repo, struct organize_plan *plan)
 
 		if (!strcmp(dst.buf, path))
 			plan->in_place++;	/* already in place */
-		else
+		else if (!want.nr || label_selected(labels, &want))
 			add_move(plan, path, strbuf_detach(&dst, NULL), rule->value);
 		strbuf_release(&dst);
 	}
@@ -207,6 +236,7 @@ void organize_plan_build(struct repository *repo, struct organize_plan *plan)
 			string_list_append(&plan->orphans, ctx.gitorg.records.items[i].string);
 
 	organize_ctx_release(&ctx);
+	string_list_clear(&want, 0);
 	string_list_clear(&seen, 0);
 	strbuf_release(&value_buf);
 }
diff --git a/organize/organize.h b/organize/organize.h
index 84e6558f8b..358298376c 100644
--- a/organize/organize.h
+++ b/organize/organize.h
@@ -4,6 +4,7 @@
 #include "string-list.h"
 
 struct repository;
+struct strvec;
 
 /*
  * The git organize engine. A project declares where each file belongs, and
@@ -74,9 +75,11 @@ struct organize_plan {
  * rule names a directory it is not in as a move. Also record the backlog
  * (recorded files that match no rule), the unrecorded files (in scope,
  * no [labels] line), and the orphans (declared paths
- * that no longer exist).
+ * that no longer exist). selectors limit the moves to files carrying one of the
+ * named labels; an empty strvec keeps them all.
  */
-void organize_plan_build(struct repository *repo, struct organize_plan *plan);
+void organize_plan_build(struct repository *repo, const struct strvec *selectors,
+			 struct organize_plan *plan);
 
 /*
  * Perform the plan: consult the organizer when one is configured, then apply
diff --git a/t/t0096-organize.sh b/t/t0096-organize.sh
index d8de3c7e90..297e616021 100755
--- a/t/t0096-organize.sh
+++ b/t/t0096-organize.sh
@@ -160,6 +160,56 @@ test_expect_success 'status --exit-code fails when a file is out of place' '
 	test_expect_code 1 git organize status --exit-code
 '
 
+test_expect_success 'status --label filters by a recorded label' '
+	git organize status --label component=odb >actual &&
+	test_grep "blob.c  *-> odb/blob.c" actual &&
+	test_grep ! refs.c actual &&
+	# a non-placement label selects too (role, not just the placing component)
+	git organize status --label role=lib >bylib &&
+	test_grep "blob.c  *-> odb/blob.c" bylib &&
+	test_grep "refs.c  *-> refs/refs.c" bylib &&
+	# header.h (role=public, in place) is not over-included by the filter
+	test_grep ! "header.h" bylib &&
+	# a bare key matches any value of that label
+	git organize status --label component >bykey &&
+	test_grep "blob.c  *-> odb/blob.c" bykey &&
+	test_grep "refs.c  *-> refs/refs.c" bykey
+'
+
+test_expect_success 'apply --label moves only the selected files' '
+	git init bylabel &&
+	(
+		cd bylabel &&
+		echo blob >blob.c &&
+		echo refs >refs.c &&
+		echo header >header.h &&
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		configure_organize ./labeler &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		# reconcile only the odb component; refs.c must stay put
+		git organize apply --label component=odb &&
+		git diff --cached -M --name-status >staged &&
+		test_grep "^R100.*blob.c.*odb/blob.c" staged &&
+		test_path_is_file odb/blob.c &&
+		test_path_is_missing blob.c &&
+		# refs.c is not selected: still at the root, absent from the staged set
+		test_path_is_file refs.c &&
+		test_path_is_missing refs/refs.c &&
+		test_grep ! "refs.c" staged &&
+		# [labels] repointed for odb only; the refs.c line is unchanged
+		test_grep "^odb/blob.c component=odb" .gitorganize &&
+		test_grep "^refs.c component=refs" .gitorganize &&
+		# refs.c is still reported as a pending move
+		git organize status >after &&
+		test_grep "refs.c  *-> refs/refs.c" after
+	)
+'
+
 test_expect_success 'apply moves files as content-identical renames and repoints [labels]' '
 	git organize apply &&
 	git diff --cached -M --name-status >actual &&
@@ -588,6 +638,99 @@ test_expect_success 'the recorded labels carry arbitrary key=value pairs' '
 	)
 '
 
+test_expect_success FUNNYNAMES 'apply moves a source whose name needs C-quoting' '
+	git init quoted &&
+	(
+		cd quoted &&
+		# a double-quote in the name forces the diff header to C-quote it
+		name="a\"b.c" &&
+		echo blob >"$name" &&
+		git add . &&
+		git commit -m init &&
+		# a labeler for the single quoted source; the NUL-separated
+		# record carries the quote literally
+		write_script quotedlabeler <<-\EOF &&
+		printf "a\"b.c\0component=odb role=lib\0"
+		EOF
+		configure_organize ./quotedlabeler &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		# the rename header C-quotes the path; the move still applies
+		git organize apply &&
+		test_path_is_file "odb/$name" &&
+		test_path_is_missing "$name" &&
+		git diff --cached --name-only >staged &&
+		test_grep "odb/a" staged
+	)
+'
+
+test_expect_success 'apply rejects a malformed reject line' '
+	git init badreject &&
+	(
+		cd badreject &&
+		echo blob >blob.c &&
+		echo refs >refs.c &&
+		git add . &&
+		git commit -m init &&
+		write_labeler &&
+		# the reject path is quoted but unterminated on its line, so
+		# unquoting scans past the newline into the next line
+		write_script rejector <<-\EOF &&
+		cat >/dev/null
+		printf "git-organize 1 organize\n"
+		printf "reject \"a\nb.c\" reason\n"
+		EOF
+		configure_organize ./labeler ./rejector &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		git organize apply --labels-only &&
+		git commit -m labels &&
+		test_must_fail git organize apply 2>err &&
+		test_grep "malformed reject line" err
+	)
+'
+
+test_expect_success 'apply --labels-only rejects a duplicate labeler record' '
+	git init duprec &&
+	(
+		cd duprec &&
+		echo blob >blob.c &&
+		git add . &&
+		git commit -m init &&
+		# the labeler emits the same scoped path twice
+		write_script duprelabeler <<-\EOF &&
+		printf "blob.c\0component=odb role=lib\0"
+		printf "blob.c\0component=refs role=lib\0"
+		EOF
+		configure_organize ./duprelabeler &&
+		git add .gitorganize &&
+		git commit -m declare &&
+		test_must_fail git organize apply --labels-only 2>err &&
+		test_grep "duplicate labeler record" err
+	)
+'
+
+test_expect_success 'status rejects trailing junk after a quoted path' '
+	git init trailing &&
+	(
+		cd trailing &&
+		echo a >a.c &&
+		git add . &&
+		git commit -m init &&
+		# a quoted [labels] path with junk right after the close quote
+		cat >.gitorganize <<-\EOF &&
+		[layout]
+		component:odb = odb
+		[labels]
+		"a.c"junk component=odb
+		EOF
+		test_must_fail git organize status 2>err &&
+		test_grep "trailing text after path" err
+	)
+'
+
 test_expect_success 'a subcommand rejects extra operands' '
 	test_must_fail git -C bad organize status junk 2>err &&
 	test_grep "too many arguments" err
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 05/14] organize: declare Git's scope and layout
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (3 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 04/14] organize: add the --label selector Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 06/14] organize: record a label for every source in scope Michael Montalbo
                   ` (8 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Author .gitorganize for Git's own tree. [scope] puts the root *.c and *.h
sources in scope. [layout] keeps a public interface (role:public) and a
standalone program (role:program) at the root, and routes each component's
sources to a directory of the same name: transport sources to transport/,
diff sources to diff/, and so on for the thirteen components.

This is the map alone. The next step records a label per source; the carves
that follow move each component into place.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
 create mode 100644 .gitorganize

diff --git a/.gitorganize b/.gitorganize
new file mode 100644
index 0000000000..18cf3228a8
--- /dev/null
+++ b/.gitorganize
@@ -0,0 +1,19 @@
+[scope]
+:(glob)*.c
+:(glob)*.h
+[layout]
+role:public = .
+role:program = .
+component:odb = odb
+component:refs = refs
+component:pack = pack
+component:diff = diff
+component:merge = merge
+component:revision = revision
+component:index = index
+component:setup = setup
+component:convert = convert
+component:transport = transport
+component:notes = notes
+component:submodule = submodule
+component:archive = archive
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 06/14] organize: record a label for every source in scope
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (4 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 05/14] organize: declare Git's scope and layout Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 07/14] odb: gather the odb sources under odb/ Michael Montalbo
                   ` (7 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Run the reference labeler over Git's tree and record its labels in
.gitorganize. Each source's component comes from the "area:" prefix its
commits carry most often, consolidated by git-layout.map; a source the
prefix cannot place falls back to its filename, and one that neither places
but changes chiefly alongside a component is promoted there. Standalone
programs stay at the root, and a source that stays diffuse is component=?.
Each line also carries the prefix, the #include coupling, and the co-change
profile as advisory signals.

status now reports the whole to-move set across thirteen components:

  495 in scope (113 in place, 303 to move, 79 backlog)

The 79 backlog sources, recorded component=? with role=lib, are left at
the root as the frontier. A public header or program also records
component=? but is kept at the root by its role.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize | 475 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 475 insertions(+)

diff --git a/.gitorganize b/.gitorganize
index 18cf3228a8..522821522e 100644
--- a/.gitorganize
+++ b/.gitorganize
@@ -17,3 +17,478 @@ component:transport = transport
 component:notes = notes
 component:submodule = submodule
 component:archive = archive
+[labels]
+# The recorded placement of each source; edit a line to change it.
+# apply --labels-only fills in unrecorded sources; --reseed re-derives all.
+abspath.c component=? role=lib prefix=abspath cochange=setup:12,diff:6,refs:5,index:3,submodule:3
+abspath.h component=? role=public prefix=abspath cochange=setup:1
+add-interactive.c component=? role=lib prefix=add-interactive includes=index:3,odb:2,diff:1,refs:1,revision:1 cochange=diff:19,index:16,revision:16,odb:7,refs:6
+add-interactive.h component=? role=public prefix=add-patch cochange=odb:2
+add-patch.c component=? role=lib prefix=add-patch includes=setup:3,index:2,odb:2,diff:1 cochange=index:10,transport:8,odb:6,merge:4,refs:4
+add-patch.h component=? role=public prefix=add-patch cochange=odb:1
+advice.c component=? role=lib prefix=advice includes=setup:2 cochange=transport:18,index:12,odb:9,diff:8,revision:8
+advice.h component=? role=public prefix=advice cochange=transport:14,index:9,odb:6,submodule:4,pack:3
+alias.c component=setup role=lib prefix=alias includes=setup:2 cochange=setup:8,diff:4,transport:3,convert:2,index:2
+alias.h component=setup role=header prefix=completion cochange=setup:3,transport:2,pack:1,revision:1
+alloc.c component=odb role=lib prefix=alloc includes=odb:6,setup:1 cochange=odb:54,revision:8,diff:6,pack:6,index:3
+alloc.h component=odb role=header prefix=alloc cochange=odb:16,refs:1,revision:1
+apply.c component=? role=lib prefix=apply includes=index:5,setup:4,odb:3,diff:2,merge:2 cochange=index:93,setup:43,diff:41,odb:26,merge:24
+apply.h component=? role=public prefix=apply includes=odb:1 cochange=diff:2
+archive-tar.c component=archive role=lib prefix=archive-tar includes=archive:1,odb:1,setup:1 cochange=archive:59,index:12,diff:9,odb:9,transport:8
+archive-zip.c component=archive role=lib prefix=archive-zip includes=diff:2,archive:1,odb:1,setup:1 cochange=archive:57,diff:12,odb:8,index:7,transport:6
+archive.c component=archive role=lib prefix=archive includes=odb:5,setup:3,convert:2,archive:1,index:1 cochange=archive:54,convert:42,odb:39,index:36,revision:31
+archive.h component=archive role=header prefix=archive includes=index:1 cochange=archive:58,index:3,revision:3,convert:2,diff:1
+attr.c component=convert role=lib prefix=attr includes=odb:3,setup:3,index:2,convert:1,refs:1 cochange=index:55,convert:54,diff:41,setup:26,revision:22
+attr.h component=convert role=header prefix=attr cochange=convert:50,index:13,diff:9,archive:8,setup:3
+banned.h component=? role=public prefix=banned
+base85.c component=? role=lib prefix=base85 cochange=diff:4,pack:2,convert:1,transport:1
+base85.h component=? role=public prefix=base85 cochange=diff:1
+bisect.c component=revision role=lib prefix=bisect includes=odb:5,revision:5,setup:2,diff:1,index:1 cochange=revision:61,odb:32,transport:31,refs:13,diff:9
+bisect.h component=revision role=header prefix=bisect cochange=revision:29,odb:2
+blame.c component=revision role=lib prefix=blame includes=odb:5,diff:2,index:2,pack:2,revision:2 cochange=diff:68,revision:66,odb:56,index:29,pack:22
+blame.h component=revision role=header prefix=blame includes=diff:1,odb:1 cochange=revision:19,odb:7,diff:4,archive:1,index:1
+blob.c component=odb role=lib prefix=object includes=odb:2 cochange=odb:131,transport:12,pack:11,revision:10,refs:5
+blob.h component=odb role=header prefix=blob includes=odb:1 cochange=odb:33,revision:4,pack:3,transport:2
+bloom.c component=pack role=lib prefix=bloom includes=odb:4,diff:2,pack:2,setup:2 cochange=pack:38,revision:25,diff:15,odb:6,index:2
+bloom.h component=pack role=header prefix=bloom cochange=pack:28,revision:12,odb:1
+branch.c component=? role=lib prefix=branch includes=refs:3,setup:3,odb:2,submodule:1,transport:1 cochange=refs:62,transport:41,setup:28,index:19,revision:12
+branch.h component=? role=public prefix=branch cochange=setup:8,refs:4,submodule:4
+builtin.h component=? role=public prefix=builtin includes=setup:1 cochange=diff:15,index:15,transport:12,odb:6,notes:5
+bundle-uri.c component=transport role=lib prefix=bundle-uri includes=transport:5,odb:1,refs:1,setup:1 cochange=transport:28,setup:7,odb:4,merge:2,pack:2
+bundle-uri.h component=transport role=header prefix=bundle-uri cochange=transport:14
+bundle.c component=transport role=lib prefix=bundle includes=odb:3,revision:3,setup:2,transport:2,diff:1 cochange=transport:63,odb:24,revision:21,refs:17,pack:10
+bundle.h component=transport role=header prefix=bundle includes=revision:1 cochange=transport:37,revision:5
+cache-tree.c component=index role=lib prefix=cache-tree includes=odb:5,index:2,setup:1,transport:1 cochange=index:94,odb:69,revision:27,transport:21,diff:20
+cache-tree.h component=index role=header prefix=cache-tree includes=odb:2 cochange=index:42,diff:4,revision:4,odb:3,refs:1
+cbtree.c component=odb role=lib prefix=cbtree includes=odb:1 cochange=odb:9,diff:1,merge:1,pack:1
+cbtree.h component=odb role=header prefix=cbtree cochange=odb:12,pack:3,setup:1,transport:1
+chdir-notify.c component=? role=lib prefix=chdir-notify includes=revision:1 cochange=index:2,archive:1,merge:1,revision:1
+chdir-notify.h component=? role=public prefix=chdir-notify
+checkout.c component=index role=lib prefix=checkout includes=setup:2,index:1,odb:1,refs:1,transport:1 cochange=transport:16,refs:6,setup:5,index:3,odb:2
+checkout.h component=index role=header prefix=checkout includes=odb:1 cochange=index:4,diff:1,odb:1,refs:1,revision:1
+chunk-format.c component=pack role=lib prefix=chunk-format includes=odb:1,pack:1 cochange=pack:20,odb:1,transport:1
+chunk-format.h component=pack role=header prefix=chunk-format includes=odb:1 cochange=pack:15,odb:2,setup:1,transport:1
+color.c component=? role=lib prefix=color includes=setup:1 cochange=diff:21,index:14,revision:13,setup:7,transport:7
+color.h component=? role=public prefix=color cochange=diff:18,index:12,revision:12,transport:2,odb:1
+column.c component=? role=lib prefix=column includes=setup:1 cochange=transport:6,setup:5,diff:4,revision:3,index:2
+column.h component=? role=public prefix=column
+combine-diff.c component=diff role=lib prefix=combine-diff includes=odb:5,diff:4,revision:2,convert:1,refs:1 cochange=diff:198,revision:67,index:35,odb:16,transport:16
+commit-graph.c component=pack role=lib prefix=commit-graph includes=odb:9,pack:4,setup:2,refs:1,revision:1 cochange=pack:206,odb:125,revision:47,transport:34,setup:22
+commit-graph.h component=pack role=header prefix=commit-graph includes=odb:2 cochange=pack:92,odb:14,setup:9,revision:8,transport:5
+commit-reach.c component=revision role=lib prefix=commit-reach includes=revision:3,odb:2,pack:1,refs:1 cochange=revision:38,odb:17,pack:15,transport:9,index:5
+commit-reach.h component=revision role=header prefix=commit-reach includes=odb:2 cochange=revision:32,odb:9,transport:8,pack:3,refs:3
+commit-slab-decl.h component=odb role=header prefix=commit-slab cochange=odb:6,revision:1
+commit-slab-impl.h component=odb role=header prefix=commit-slab cochange=odb:7,pack:3,revision:1,setup:1,transport:1
+commit-slab.h component=odb role=header prefix=commit-slab includes=odb:2 cochange=odb:8,revision:2,transport:2,index:1,merge:1
+commit.c component=odb role=lib prefix=commit includes=odb:10,setup:4,revision:3,diff:1,index:1 cochange=odb:403,revision:147,transport:87,pack:57,setup:45
+commit.h component=odb role=header prefix=commit includes=odb:1 cochange=odb:237,revision:205,transport:49,pack:25,notes:22
+common-exit.c component=? role=lib prefix=common-main
+common-init.c component=? role=lib prefix=common-main includes=odb:2,setup:2,convert:1 cochange=setup:1
+common-init.h component=? role=public prefix=common-main
+common-main.c component=? role=lib prefix=common-main cochange=setup:5,transport:4,convert:3,index:1
+config.c component=setup role=lib prefix=config includes=setup:4,odb:2,convert:1,index:1,refs:1 cochange=setup:274,index:93,diff:75,refs:48,revision:46
+config.h component=setup role=header prefix=config includes=setup:1 cochange=setup:100,index:30,transport:23,submodule:21,merge:6
+connect.c component=transport role=lib prefix=connect includes=transport:7,setup:4,odb:1,refs:1 cochange=transport:238,setup:19,diff:13,index:10,refs:10
+connect.h component=transport role=header prefix=connect includes=transport:1 cochange=transport:58,refs:1
+connected.c component=transport role=lib prefix=connected includes=transport:3,odb:1,pack:1 cochange=transport:39,pack:31,odb:7,diff:6,index:5
+connected.h component=transport role=header prefix=connected cochange=transport:23
+convert.c component=convert role=lib prefix=convert includes=convert:2,index:1,merge:1,odb:1,setup:1 cochange=convert:59,diff:43,index:41,setup:30,transport:30
+convert.h component=convert role=header prefix=convert includes=odb:1 cochange=convert:29,index:18,diff:8,setup:8,archive:4
+copy.c component=? role=lib prefix=copy cochange=pack:6,transport:5,diff:3,odb:3,merge:2
+copy.h component=? role=public prefix=copy cochange=transport:3,merge:2,convert:1,setup:1
+credential.c component=? role=lib prefix=credential includes=setup:3 cochange=transport:13,index:4,odb:4,convert:2,merge:2
+credential.h component=? role=public prefix=credential cochange=transport:6
+csum-file.c component=? role=lib prefix=csum-file includes=odb:1 cochange=pack:49,odb:13,index:10,transport:10,diff:8
+csum-file.h component=? role=public prefix=csum-file includes=odb:1 cochange=pack:44,odb:8,diff:5,index:5,transport:5
+ctype.c component=? role=lib prefix=ctype cochange=setup:3,index:2,odb:1,pack:1,refs:1
+daemon.c component=? role=program prefix=daemon includes=setup:3,transport:2 cochange=transport:77,index:14,setup:13,diff:7,refs:5
+date.c component=? role=lib prefix=date cochange=revision:17,odb:16,refs:14,setup:9,diff:7
+date.h component=? role=public prefix=date cochange=refs:7,revision:4,setup:2,archive:1,odb:1
+decorate.c component=revision role=lib prefix=decorate includes=odb:1,revision:1 cochange=diff:6,odb:5,revision:5,pack:2,transport:2
+decorate.h component=revision role=header prefix=decorate cochange=revision:4,odb:1
+delta-islands.c component=pack role=lib prefix=delta-islands includes=odb:6,pack:4,diff:1,refs:1,setup:1 cochange=pack:20,odb:17,revision:7,transport:7,diff:5
+delta-islands.h component=pack role=header prefix=delta-islands cochange=pack:6
+delta.h component=pack role=header prefix=diff-delta cochange=pack:27,odb:19,diff:5,transport:3,convert:1
+diagnose.c component=? role=lib prefix=diagnose includes=archive:1,index:1,odb:1,pack:1,setup:1 cochange=index:4,revision:4,odb:3,pack:3,transport:3
+diagnose.h component=? role=public prefix=diagnose cochange=revision:2,refs:1,transport:1
+diff-delta.c component=pack role=lib prefix=diff-delta includes=pack:1 cochange=pack:24,diff:7,index:2,odb:2,transport:2
+diff-lib.c component=diff role=lib prefix=diff includes=index:6,odb:3,diff:2,revision:2,refs:1 cochange=diff:150,index:124,revision:47,submodule:18,odb:8
+diff-merges.c component=diff role=lib prefix=diff-merges includes=diff:1,revision:1 cochange=revision:18,diff:17,odb:4,refs:3,index:2
+diff-merges.h component=diff role=header prefix=diff-merges cochange=diff:11,revision:4,merge:1
+diff-no-index.c component=diff role=lib prefix=diff includes=diff:2,index:2,odb:1,revision:1 cochange=diff:76,revision:21,index:19,refs:8,notes:7
+diff.c component=diff role=lib prefix=diff includes=odb:5,diff:4,setup:3,convert:2,index:2 cochange=diff:610,revision:121,index:100,transport:71,setup:69
+diff.h component=diff role=header prefix=diff includes=index:1,odb:1 cochange=diff:471,revision:83,index:29,submodule:18,odb:14
+diffcore-break.c component=diff role=lib prefix=diffcore-break includes=odb:2,diff:1,transport:1 cochange=diff:71,pack:8,revision:7,index:5,merge:3
+diffcore-delta.c component=diff role=lib prefix=diffcore-delta includes=diff:1 cochange=diff:26,revision:7,odb:4,index:2,refs:2
+diffcore-order.c component=diff role=lib prefix=diffcore-order includes=diff:2 cochange=diff:19,index:8,refs:7,revision:7,pack:5
+diffcore-pickaxe.c component=diff role=lib prefix=pickaxe includes=diff:3,odb:1,revision:1 cochange=diff:97,revision:15,notes:3,odb:3,merge:2
+diffcore-rename.c component=diff role=lib prefix=diffcore-rename includes=diff:2,odb:2,transport:1 cochange=diff:188,index:38,revision:37,odb:21,pack:17
+diffcore-rotate.c component=diff role=lib prefix=diff includes=diff:2 cochange=diff:14,revision:5,pack:2,merge:1,refs:1
+diffcore.h component=diff role=header prefix=diff includes=odb:1 cochange=diff:175,revision:11,merge:10,submodule:4,odb:2
+dir-iterator.c component=index role=lib prefix=dir-iterator includes=index:2 cochange=index:7,refs:1
+dir-iterator.h component=index role=header prefix=dir-iterator cochange=index:7,refs:1
+dir.c component=index role=lib prefix=dir includes=index:7,setup:4,odb:2,convert:1,refs:1 cochange=index:343,diff:61,setup:49,odb:37,convert:29
+dir.h component=index role=header prefix=dir includes=index:2,odb:1 cochange=index:236,odb:13,setup:12,submodule:11,convert:10
+editor.c component=? role=lib prefix=editor includes=setup:2 cochange=transport:20,setup:12,index:8,odb:4,submodule:4
+editor.h component=? role=public prefix=editor cochange=transport:1
+entry.c component=index role=lib prefix=entry includes=index:7,odb:1,setup:1,submodule:1 cochange=index:96,diff:28,convert:20,setup:17,odb:10
+entry.h component=index role=header prefix=entry includes=convert:1 cochange=index:18,submodule:4,revision:3,transport:2,convert:1
+environment.c component=setup role=lib prefix=environment includes=setup:5,convert:3,odb:2,merge:1,refs:1 cochange=setup:281,index:77,odb:48,refs:36,transport:28
+environment.h component=setup role=header prefix=environment includes=setup:1 cochange=setup:135,index:37,odb:15,refs:11,pack:9
+exec-cmd.c component=? role=lib prefix=strvec includes=setup:1
+exec-cmd.h component=? role=public prefix=argv-array cochange=refs:4,transport:4,odb:1,setup:1,submodule:1
+fetch-negotiator.c component=transport role=lib prefix=repo-settings includes=setup:1,transport:1 cochange=setup:8,transport:7,index:2,odb:1
+fetch-negotiator.h component=transport role=header prefix=fetch-negotiator cochange=transport:7,setup:3,odb:1,pack:1,revision:1
+fetch-object-info.c component=transport role=lib prefix=cat-file includes=transport:3,odb:2 cochange=transport:7,odb:1
+fetch-object-info.h component=transport role=header prefix=cat-file includes=transport:2 cochange=transport:7,odb:1
+fetch-pack.c component=transport role=lib prefix=fetch-pack includes=transport:8,odb:7,setup:4,pack:3,revision:2 cochange=transport:303,odb:96,revision:46,pack:40,setup:25
+fetch-pack.h component=transport role=header prefix=fetch-pack includes=odb:1,revision:1,transport:1 cochange=transport:108,odb:2,pack:2,refs:2,diff:1
+fmt-merge-msg.c component=merge role=lib prefix=fmt-merge-msg includes=odb:3,diff:2,revision:2,setup:2,merge:1 cochange=revision:10,odb:7,index:6,diff:4,setup:4
+fmt-merge-msg.h component=merge role=header prefix=fmt-merge-msg cochange=merge:3,setup:2
+for-each-ref.h component=? role=public prefix=?
+fsck.c component=odb role=lib prefix=fsck includes=odb:9,setup:3,convert:1,index:1,pack:1 cochange=odb:113,revision:46,transport:43,pack:20,setup:15
+fsck.h component=odb role=header prefix=fsck includes=odb:2 cochange=odb:50,diff:5,revision:5,transport:5,refs:4
+fsmonitor--daemon.h component=index role=header prefix=fsmonitor--daemon includes=index:1 cochange=index:1
+fsmonitor-ipc.c component=index role=lib prefix=fsmonitor includes=index:1,setup:1 cochange=index:6,transport:2,merge:1,notes:1,pack:1
+fsmonitor-ipc.h component=index role=header prefix=fsmonitor cochange=index:2
+fsmonitor-ll.h component=index role=header prefix=fsmonitor-ll cochange=index:4
+fsmonitor-path-utils.h component=index role=header prefix=fsmonitor cochange=index:2
+fsmonitor-settings.c component=index role=lib prefix=fsmonitor includes=index:3,setup:2 cochange=index:17,setup:10,transport:2,diff:1,odb:1
+fsmonitor-settings.h component=index role=header prefix=fsmonitor-settings cochange=index:11,setup:4
+fsmonitor.c component=index role=lib prefix=fsmonitor includes=index:4,setup:3 cochange=index:37,setup:16,transport:4,merge:2,refs:2
+fsmonitor.h component=index role=header prefix=fsmonitor includes=index:4,odb:1 cochange=index:24,setup:7,diff:3,submodule:1
+gettext.c component=? role=lib prefix=gettext includes=setup:1 cochange=pack:5,refs:3,setup:2,transport:2,merge:1
+gettext.h component=? role=public prefix=i18n cochange=transport:2,setup:1
+git-compat-util.h component=? role=public prefix=git-compat-util cochange=setup:48,index:35,odb:22,pack:21,diff:17
+git-curl-compat.h component=transport role=header prefix=git-curl-compat cochange=transport:22
+git-zlib.c component=? role=lib prefix=git-zlib cochange=archive:2,odb:1,transport:1
+git-zlib.h component=? role=public prefix=git-zlib cochange=archive:3,setup:2,odb:1,transport:1
+git.c component=? role=lib prefix=git includes=setup:4,odb:2,convert:1,index:1,revision:1 cochange=setup:70,revision:54,transport:47,index:28,diff:25
+gpg-interface.c component=? role=lib prefix=gpg-interface includes=setup:3,index:1,odb:1 cochange=revision:25,odb:22,setup:13,transport:11,diff:8
+gpg-interface.h component=? role=public prefix=gpg-interface cochange=odb:22,revision:15,merge:4,transport:3,refs:1
+graph.c component=revision role=lib prefix=graph includes=revision:2,odb:1,setup:1 cochange=revision:38,diff:23,index:4,odb:3,transport:3
+graph.h component=revision role=header prefix=graph includes=diff:1 cochange=revision:19,diff:2,odb:1
+grep.c component=? role=lib prefix=grep includes=diff:4,odb:1,revision:1,setup:1 cochange=diff:40,revision:28,transport:10,index:7,refs:7
+grep.h component=? role=public prefix=grep includes=diff:1 cochange=revision:23,diff:10,transport:4,index:2,refs:2
+hash-lookup.c component=odb role=lib prefix=hash includes=odb:2,index:1 cochange=pack:14,odb:12,diff:1,index:1,merge:1
+hash-lookup.h component=odb role=header prefix=hash-lookup cochange=odb:10,pack:8,diff:1,merge:1,revision:1
+hash.c component=odb role=lib prefix=hash includes=odb:1 cochange=odb:15,diff:2,setup:2,index:1,transport:1
+hash.h component=odb role=header prefix=hash includes=setup:1 cochange=odb:32,pack:11,index:9,diff:7,transport:4
+hashmap.c component=? role=lib prefix=hashmap cochange=diff:33,revision:19,index:17,refs:13,submodule:13
+hashmap.h component=? role=public prefix=hashmap cochange=diff:39,revision:23,index:18,submodule:14,refs:13
+help.c component=? role=lib prefix=help includes=setup:4,index:1,odb:1,refs:1,transport:1 cochange=setup:19,transport:19,diff:9,index:8,odb:7
+help.h component=? role=public prefix=help cochange=diff:1,odb:1,revision:1,transport:1
+hex-ll.c component=? role=lib prefix=hex-ll
+hex-ll.h component=? role=public prefix=hex-ll
+hex.c component=? role=lib prefix=hex includes=odb:1 cochange=odb:7,revision:5,notes:3,transport:3,refs:2
+hex.h component=? role=public prefix=hex includes=odb:1 cochange=revision:3,odb:2,convert:1,merge:1,pack:1
+hook.c component=setup role=lib prefix=hook includes=setup:4 cochange=setup:37,transport:10,odb:8,refs:5,diff:3
+hook.h component=setup role=header prefix=hook includes=setup:1 cochange=setup:34,transport:6,odb:5,refs:5,pack:3
+http-backend.c component=? role=program prefix=http-backend includes=setup:4,odb:3,transport:2,pack:1,refs:1 cochange=transport:57,pack:41,setup:19,refs:14,revision:13
+http-fetch.c component=? role=program prefix=http-fetch includes=setup:3,transport:2 cochange=transport:46,setup:10,pack:9,index:7,refs:7
+http-push.c component=? role=program prefix=http-push includes=odb:7,revision:3,setup:3,transport:2,diff:1 cochange=transport:272,odb:134,revision:82,pack:60,diff:34
+http-walker.c component=transport role=lib prefix=http includes=transport:3,odb:2,pack:1,revision:1,setup:1 cochange=transport:73,pack:40,odb:17,index:11,refs:7
+http.c component=transport role=lib prefix=http includes=transport:4,setup:3,odb:2,pack:2 cochange=transport:195,pack:71,odb:27,diff:8,setup:8
+http.h component=transport role=header prefix=http includes=transport:1 cochange=transport:149,pack:15,diff:6,odb:4,archive:3
+ident.c component=setup role=lib prefix=ident includes=setup:2 cochange=setup:19,revision:10,odb:6,refs:6,pack:4
+ident.h component=setup role=header prefix=ident cochange=setup:3,revision:1
+imap-send.c component=? role=program prefix=imap-send includes=setup:3,transport:1 cochange=transport:47,diff:16,index:16,refs:9,odb:8
+iterator.h component=? role=public prefix=refs cochange=index:2,refs:2
+json-writer.c component=? role=lib prefix=json-writer
+json-writer.h component=? role=public prefix=json-writer cochange=transport:1
+khash.h component=? role=public prefix=khash includes=odb:1 cochange=odb:7,pack:5,diff:4,revision:4,index:3
+kwset.c component=? role=lib prefix=kwset cochange=convert:2,diff:1,pack:1,revision:1
+kwset.h component=? role=public prefix=kwset
+levenshtein.c component=? role=lib prefix=? cochange=diff:2,revision:2,odb:1
+levenshtein.h component=? role=public prefix=? cochange=transport:2,diff:1,refs:1,setup:1
+line-log.c component=revision role=lib prefix=line-log includes=odb:4,revision:4,diff:3,setup:2,pack:1 cochange=revision:52,diff:48,odb:23,pack:15,notes:8
+line-log.h component=revision role=header prefix=line-log includes=diff:1 cochange=revision:20,odb:3,diff:2,setup:1,submodule:1
+line-range.c component=revision role=lib prefix=line-range includes=diff:2,revision:1 cochange=revision:14,diff:8,archive:1,odb:1,pack:1
+line-range.h component=revision role=header prefix=line-range cochange=revision:13
+linear-assignment.c component=? role=lib prefix=linear-assignment cochange=diff:1,revision:1
+linear-assignment.h component=? role=public prefix=linear-assignment
+list-objects-filter-options.c component=revision role=lib prefix=list-objects-filter-options includes=revision:1,setup:1,transport:1 cochange=revision:39,transport:21,setup:9,diff:6,index:4
+list-objects-filter-options.h component=revision role=header prefix=list-objects-filter includes=odb:1 cochange=revision:40,transport:17,odb:4,diff:3,refs:2
+list-objects-filter.c component=revision role=lib prefix=list-objects-filter includes=odb:5,revision:3,diff:1,index:1 cochange=revision:32,odb:13,index:10,diff:6,pack:3
+list-objects-filter.h component=revision role=header prefix=list-objects cochange=revision:16,odb:1
+list-objects.c component=revision role=lib prefix=list-objects includes=odb:6,revision:4,diff:1,pack:1,setup:1 cochange=revision:91,odb:68,pack:40,transport:28,index:15
+list-objects.h component=revision role=header prefix=list-objects cochange=revision:32,pack:13,transport:4,odb:1
+list.h component=revision role=header prefix=list cochange=submodule:2,transport:2,index:1,revision:1
+lockfile.c component=? role=lib prefix=lockfile includes=setup:1 cochange=refs:18,index:13,setup:9,diff:8,merge:3
+lockfile.h component=? role=public prefix=lockfile cochange=index:5,revision:4,diff:3,refs:3,odb:2
+log-tree.c component=revision role=lib prefix=format-patch includes=odb:8,revision:5,diff:3,setup:3,refs:2 cochange=revision:222,diff:112,odb:112,refs:31,transport:16
+log-tree.h component=revision role=header prefix=format-patch cochange=revision:64,diff:11,refs:3,odb:2,transport:2
+loose.c component=odb role=lib prefix=loose includes=odb:5,setup:1 cochange=odb:31,pack:18,setup:7,transport:6,refs:2
+loose.h component=odb role=header prefix=loose cochange=odb:8,setup:3
+ls-refs.c component=refs role=lib prefix=ls-refs includes=setup:3,refs:2,odb:1,transport:1 cochange=refs:26,transport:17,pack:10,revision:5,odb:4
+ls-refs.h component=refs role=header prefix=ls-refs cochange=transport:11,refs:5,submodule:1
+mailinfo.c component=? role=lib prefix=mailinfo includes=setup:2 cochange=transport:5,index:3,notes:3,odb:3,revision:3
+mailinfo.h component=? role=public prefix=mailinfo
+mailmap.c component=? role=lib prefix=mailmap includes=setup:3,odb:2 cochange=setup:13,transport:11,refs:10,index:8,revision:5
+mailmap.h component=? role=public prefix=mailmap cochange=setup:8,revision:4,transport:2,diff:1,index:1
+match-trees.c component=odb role=lib prefix=match-trees includes=odb:5,setup:1 cochange=odb:33,index:15,notes:15,revision:12,pack:10
+match-trees.h component=odb role=header prefix=match-trees cochange=merge:1,odb:1
+mem-pool.c component=? role=lib prefix=mem-pool cochange=index:6
+mem-pool.h component=? role=public prefix=mem-pool cochange=index:4
+merge-blobs.c component=merge role=lib prefix=object-store includes=merge:2,odb:2 cochange=merge:9,notes:3,diff:2,convert:1,odb:1
+merge-blobs.h component=merge role=header prefix=merge-blobs cochange=merge:2
+merge-ll.c component=merge role=lib prefix=merge-ll includes=convert:2,diff:1,merge:1,setup:1 cochange=merge:11,diff:6,transport:4,convert:2,index:2
+merge-ll.h component=merge role=header prefix=merge-ll cochange=merge:11,diff:2,convert:1,notes:1
+merge-ort-wrappers.c component=merge role=lib prefix=merge-ort includes=odb:4,merge:2,index:1,setup:1 cochange=merge:7,odb:2,notes:1,revision:1
+merge-ort-wrappers.h component=merge role=header prefix=merge includes=merge:1 cochange=merge:9,odb:2,revision:1
+merge-ort.c component=merge role=lib prefix=merge-ort includes=odb:8,index:6,diff:3,merge:2,revision:2 cochange=diff:41,merge:32,index:23,odb:23,revision:16
+merge-ort.h component=merge role=header prefix=merge-ort includes=odb:1 cochange=merge:19,odb:2,revision:2,diff:1
+merge.c component=merge role=lib prefix=merge includes=odb:4,index:2,merge:1,setup:1 cochange=index:22,merge:6,setup:4,diff:2,odb:2
+merge.h component=merge role=header prefix=merge cochange=merge:1
+mergesort.h component=? role=public prefix=mergesort cochange=odb:1
+midx-write.c component=pack role=lib prefix=midx-write includes=pack:5,odb:2,revision:2,refs:1,setup:1 cochange=pack:100,odb:20,refs:7,transport:6,setup:4
+midx.c component=pack role=lib prefix=midx includes=pack:5,index:1,odb:1,setup:1 cochange=pack:220,odb:34,transport:11,index:6,setup:4
+midx.h component=pack role=header prefix=midx cochange=pack:134,odb:5,setup:2,transport:2,refs:1
+name-hash.c component=index role=lib prefix=name-hash includes=index:3,odb:1,setup:1 cochange=diff:43,index:39,revision:18,setup:14,refs:12
+name-hash.h component=index role=header prefix=name-hash cochange=index:7
+notes-cache.c component=notes role=lib prefix=notes includes=odb:3,notes:1,refs:1,revision:1,setup:1 cochange=notes:37,odb:29,diff:10,index:10,revision:9
+notes-cache.h component=notes role=header prefix=notes-cache includes=notes:1 cochange=diff:7,notes:3
+notes-merge.c component=notes role=lib prefix=notes-merge includes=odb:4,diff:3,notes:3,index:1,merge:1 cochange=diff:54,revision:41,odb:37,notes:36,index:30
+notes-merge.h component=notes role=header prefix=notes-merge includes=notes:1 cochange=notes:18,odb:2
+notes-utils.c component=notes role=lib prefix=commit includes=setup:2,notes:1,odb:1,refs:1 cochange=notes:33,odb:15,refs:9,transport:9,revision:8
+notes-utils.h component=notes role=header prefix=notes includes=notes:1 cochange=notes:17,odb:6
+notes.c component=notes role=lib prefix=notes includes=odb:4,setup:2,notes:1,refs:1 cochange=notes:63,odb:58,revision:41,transport:36,index:24
+notes.h component=notes role=header prefix=notes cochange=notes:55,revision:20,setup:9,odb:3,refs:2
+object-file-convert.c component=odb role=lib prefix=object-file-convert includes=odb:5,setup:1 cochange=odb:8,setup:2,transport:1
+object-file-convert.h component=odb role=header prefix=object-file-convert includes=odb:1 cochange=odb:4
+object-file.c component=odb role=lib prefix=object-file includes=odb:6,index:2,pack:2,setup:2,convert:1 cochange=odb:183,pack:96,index:55,setup:30,transport:27
+object-file.h component=odb role=header prefix=object-file includes=odb:2 cochange=odb:113,pack:30,index:12,notes:5,transport:5
+object-name.c component=odb role=lib prefix=object-name includes=odb:8,setup:5,index:2,revision:2,pack:1 cochange=odb:46,pack:31,revision:23,setup:19,refs:18
+object-name.h component=odb role=header prefix=object-name includes=odb:1 cochange=odb:5,revision:3,refs:2,index:1
+object.c component=odb role=lib prefix=object includes=odb:8,index:1,pack:1 cochange=odb:265,pack:61,revision:55,transport:34,refs:17
+object.h component=odb role=header prefix=object includes=odb:1 cochange=odb:187,revision:54,transport:41,pack:29,refs:20
+odb.c component=odb role=lib prefix=odb includes=odb:7,pack:3,setup:3,index:1,submodule:1 cochange=odb:123,pack:64,setup:13,transport:12,index:8
+odb.h component=odb role=header prefix=odb includes=odb:3 cochange=odb:117,pack:71,transport:16,setup:13,index:10
+oid-array.c component=odb role=lib prefix=oid-array includes=odb:2 cochange=odb:13,pack:10,merge:2,diff:1,revision:1
+oid-array.h component=odb role=header prefix=oid-array includes=odb:1 cochange=odb:3,diff:1,index:1,refs:1,revision:1
+oidmap.c component=odb role=lib prefix=oidmap includes=odb:2 cochange=diff:11,revision:7,odb:6,refs:5,index:4
+oidmap.h component=odb role=header prefix=oidmap includes=odb:1 cochange=odb:6,revision:4,index:2,transport:2,convert:1
+oidset.c component=odb role=lib prefix=oidset includes=odb:1 cochange=odb:17,convert:2,diff:2,transport:2,index:1
+oidset.h component=odb role=header prefix=oidset cochange=odb:17,revision:1,transport:1
+oidtree.c component=odb role=lib prefix=oidtree includes=odb:2 cochange=odb:14,index:3,setup:2,diff:1,merge:1
+oidtree.h component=odb role=header prefix=oidtree includes=odb:2 cochange=odb:9
+pack-bitmap-write.c component=pack role=lib prefix=pack-bitmap-write includes=odb:7,pack:6,revision:2,setup:2,diff:1 cochange=pack:132,odb:32,revision:27,transport:10,diff:4
+pack-bitmap.c component=pack role=lib prefix=pack-bitmap includes=pack:7,odb:3,revision:3,setup:2,diff:1 cochange=pack:232,revision:30,odb:18,transport:14,refs:7
+pack-bitmap.h component=pack role=header prefix=pack-bitmap includes=pack:2,refs:1 cochange=pack:117,refs:5,odb:2,setup:2,revision:1
+pack-check.c component=pack role=lib prefix=pack-check includes=odb:2,pack:2,setup:2 cochange=pack:59,odb:26,transport:23,diff:11,index:10
+pack-mtimes.c component=pack role=lib prefix=pack-mtimes includes=pack:2,odb:1 cochange=pack:10,odb:3,transport:2,notes:1
+pack-mtimes.h component=pack role=header prefix=pack-mtimes cochange=pack:4,odb:2,setup:1,transport:1
+pack-objects.c component=pack role=lib prefix=pack-objects includes=pack:3,odb:1,setup:1 cochange=pack:66,diff:17,odb:16,transport:9,index:5
+pack-objects.h component=pack role=header prefix=pack-objects includes=pack:2,odb:1 cochange=pack:44,setup:5,odb:1
+pack-refs.c component=refs role=lib prefix=pack-refs includes=refs:2,setup:2,revision:1 cochange=refs:12,transport:8,index:2,merge:2,odb:2
+pack-refs.h component=refs role=header prefix=pack-refs cochange=refs:5
+pack-revindex.c component=pack role=lib prefix=pack-revindex includes=pack:3,odb:1,setup:1 cochange=pack:94,odb:7,index:6,transport:5,setup:4
+pack-revindex.h component=pack role=header prefix=pack-revindex cochange=pack:32,odb:1
+pack-write.c component=pack role=lib prefix=pack-write includes=pack:5,setup:2,odb:1,transport:1 cochange=pack:88,odb:21,transport:21,setup:14,index:10
+pack.h component=pack role=header prefix=pack-write includes=odb:1 cochange=pack:72,odb:13,transport:9,setup:5,revision:1
+packfile-list.c component=pack role=lib prefix=packfile includes=pack:2 cochange=pack:3
+packfile-list.h component=pack role=header prefix=packfile cochange=pack:3
+packfile.c component=pack role=lib prefix=packfile includes=odb:8,pack:7,setup:2,index:1,revision:1 cochange=pack:317,odb:134,transport:52,revision:36,index:27
+packfile.h component=pack role=header prefix=packfile includes=odb:3,pack:1,revision:1,setup:1 cochange=pack:234,odb:66,transport:32,revision:9,setup:7
+pager.c component=? role=lib prefix=pager includes=setup:4 cochange=setup:23,diff:9,transport:7,revision:3,submodule:3
+pager.h component=? role=public prefix=pager cochange=diff:3,setup:2,revision:1
+parallel-checkout.c component=index role=lib prefix=parallel-checkout includes=index:4,odb:1,setup:1,transport:1 cochange=index:26,transport:7,odb:6,diff:3,merge:3
+parallel-checkout.h component=index role=header prefix=parallel-checkout includes=convert:1 cochange=index:12,convert:1
+parse-options-cb.c component=? role=lib prefix=parse-options includes=odb:3,setup:2 cochange=revision:10,transport:10,diff:7,odb:4,refs:3
+parse-options.c component=? role=lib prefix=parse-options cochange=index:14,diff:12,setup:10,transport:10,odb:6
+parse-options.h component=? role=public prefix=parse-options cochange=diff:7,merge:4,archive:3,index:3,refs:3
+parse.c component=? role=lib prefix=parse cochange=setup:6,index:3,pack:2,convert:1
+parse.h component=? role=public prefix=config cochange=setup:6,index:3,pack:2,convert:1
+patch-delta.c component=pack role=lib prefix=patch-delta includes=pack:1 cochange=pack:23,diff:2,odb:2,transport:2,convert:1
+patch-ids.c component=diff role=lib prefix=patch-ids includes=diff:2,odb:2 cochange=diff:73,revision:34,index:14,odb:13,refs:12
+patch-ids.h component=diff role=header prefix=patch-ids includes=diff:1 cochange=diff:15,revision:3,index:1
+path-walk.c component=? role=lib prefix=path-walk includes=odb:9,revision:3,index:1,setup:1 cochange=index:2,revision:2,transport:2,odb:1,pack:1
+path-walk.h component=? role=public prefix=path-walk includes=odb:1 cochange=index:2
+path.c component=? role=lib prefix=path includes=setup:2,index:1,odb:1,pack:1,refs:1 cochange=setup:78,refs:29,index:26,transport:15,odb:12
+path.h component=? role=public prefix=path includes=setup:1 cochange=setup:23,refs:13,odb:11,index:10,pack:8
+pathspec.c component=index role=lib prefix=pathspec includes=index:4,setup:3,convert:1 cochange=index:89,setup:23,convert:16,diff:16,revision:9
+pathspec.h component=index role=header prefix=pathspec cochange=index:67,diff:11,odb:9,convert:6,submodule:4
+pkt-line.c component=transport role=lib prefix=pkt-line includes=transport:2 cochange=transport:102,pack:6,convert:5,diff:5,odb:3
+pkt-line.h component=transport role=header prefix=pkt-line cochange=transport:94,pack:5,convert:4,odb:2,diff:1
+preload-index.c component=index role=lib prefix=preload-index includes=index:6,setup:3 cochange=index:52,setup:15,diff:12,revision:5,merge:3
+preload-index.h component=index role=header prefix=preload-index cochange=index:2,setup:1
+pretty.c component=revision role=lib prefix=pretty includes=odb:3,revision:2,setup:2,diff:1,notes:1 cochange=revision:115,odb:72,refs:29,notes:23,transport:19
+pretty.h component=revision role=header prefix=pretty cochange=revision:26,refs:7,diff:5,odb:5,archive:4
+prio-queue.c component=? role=lib prefix=prio-queue cochange=odb:5,revision:5,diff:2,pack:2,transport:2
+prio-queue.h component=? role=public prefix=prio-queue cochange=odb:3,revision:2,transport:2,pack:1
+progress.c component=? role=lib prefix=progress includes=setup:1 cochange=index:11,diff:6,setup:6,pack:4,revision:2
+progress.h component=? role=public prefix=progress cochange=index:5,diff:3
+promisor-remote.c component=transport role=lib prefix=promisor-remote includes=setup:3,transport:2,odb:1,pack:1 cochange=transport:32,setup:15,odb:6,pack:5,index:4
+promisor-remote.h component=transport role=header prefix=promisor-remote includes=setup:1 cochange=transport:18,setup:7,diff:4,index:3,revision:3
+prompt.c component=? role=lib prefix=prompt includes=setup:2 cochange=index:7,setup:6,pack:4,diff:3,transport:2
+prompt.h component=? role=public prefix=prompt cochange=transport:1
+protocol-caps.c component=transport role=lib prefix=protocol-caps includes=odb:3,transport:2,setup:1 cochange=transport:6,odb:3,refs:2,merge:1,setup:1
+protocol-caps.h component=transport role=header prefix=protocol-caps cochange=transport:6,refs:2
+protocol.c component=transport role=lib prefix=protocol includes=setup:2,transport:1 cochange=transport:21,index:4,setup:4,refs:2,diff:1
+protocol.h component=transport role=header prefix=protocol cochange=transport:5
+prune-packed.c component=pack role=lib prefix=environment includes=pack:2,odb:1,setup:1 cochange=pack:13,odb:7,setup:5,diff:3,revision:3
+prune-packed.h component=pack role=header prefix=? cochange=pack:1
+pseudo-merge.c component=pack role=lib prefix=pseudo-merge includes=odb:3,pack:2,refs:1,setup:1 cochange=pack:21,refs:3
+pseudo-merge.h component=pack role=header prefix=pseudo-merge cochange=pack:17
+quote.c component=? role=lib prefix=quote cochange=index:15,diff:12,transport:7,odb:6,revision:6
+quote.h component=? role=public prefix=quote cochange=diff:8,transport:6,index:5,odb:5,refs:5
+range-diff.c component=diff role=lib prefix=range-diff includes=diff:4,odb:2,revision:2,setup:2 cochange=diff:49,revision:26,index:9,submodule:8,setup:7
+range-diff.h component=diff role=header prefix=range-diff includes=diff:1 cochange=diff:13,revision:4
+reachable.c component=pack role=lib prefix=reachable includes=pack:4,odb:3,refs:2,revision:2,diff:1 cochange=odb:60,pack:57,revision:47,transport:17,refs:14
+reachable.h component=pack role=header prefix=prune cochange=pack:5
+read-cache-ll.h component=index role=header prefix=read-cache includes=index:1,odb:1 cochange=index:8,diff:1,odb:1,revision:1
+read-cache.c component=index role=lib prefix=read-cache includes=index:10,odb:6,setup:4,diff:2,submodule:2 cochange=index:240,odb:81,setup:79,diff:67,pack:46
+read-cache.h component=index role=header prefix=read-cache includes=index:2,odb:1,setup:1 cochange=index:4,setup:4,diff:2
+rebase-interactive.c component=? role=lib prefix=rebase-interactive includes=odb:3,setup:3,index:1 cochange=revision:4,transport:4,index:3,odb:3,merge:2
+rebase-interactive.h component=? role=public prefix=rebase-interactive
+rebase.c component=? role=lib prefix=rebase cochange=index:3,pack:3,setup:2,convert:1,diff:1
+rebase.h component=? role=public prefix=pull
+ref-filter.c component=refs role=lib prefix=ref-filter includes=odb:6,setup:5,refs:3,revision:2,index:1 cochange=refs:112,revision:59,odb:41,transport:40,index:30
+ref-filter.h component=refs role=header prefix=ref-filter includes=odb:2,revision:1 cochange=refs:62,revision:7,transport:6,diff:5,index:4
+reflog-walk.c component=refs role=lib prefix=reflog-walk includes=refs:2,diff:1,odb:1,revision:1,setup:1 cochange=refs:34,revision:26,index:13,diff:9,transport:8
+reflog-walk.h component=refs role=header prefix=reflog-walk cochange=revision:23,refs:19,odb:6,archive:2,index:2
+reflog.c component=refs role=lib prefix=refs includes=odb:3,refs:2,setup:2,revision:1 cochange=refs:18,transport:13,odb:9,revision:7,diff:4
+reflog.h component=refs role=header prefix=reflog includes=refs:1 cochange=refs:8,odb:3,index:1,revision:1,transport:1
+refs.c component=refs role=lib prefix=refs includes=setup:6,odb:5,refs:2,submodule:1 cochange=refs:373,transport:133,setup:116,odb:82,revision:77
+refs.h component=refs role=header prefix=refs includes=odb:2,setup:2 cochange=refs:352,transport:55,revision:34,setup:25,odb:16
+refspec.c component=refs role=lib prefix=refspec includes=refs:2,odb:1,transport:1 cochange=refs:27,transport:26,index:2,submodule:2
+refspec.h component=refs role=header prefix=refspec cochange=transport:31,refs:29,submodule:3,index:2
+remote-curl.c component=transport role=lib prefix=remote-curl includes=transport:9,setup:3,odb:1 cochange=transport:226,diff:9,revision:6,setup:5,archive:4
+remote.c component=transport role=lib prefix=remote includes=odb:3,setup:3,transport:3,refs:2,revision:2 cochange=transport:272,refs:91,revision:56,index:51,odb:30
+remote.h component=transport role=header prefix=remote includes=odb:1,refs:1 cochange=transport:245,refs:24,index:12,revision:6,setup:2
+repack-cruft.c component=pack role=lib prefix=repack includes=pack:2,setup:1 cochange=pack:8,transport:2,odb:1
+repack-filtered.c component=pack role=lib prefix=repack includes=pack:1,setup:1 cochange=pack:1
+repack-geometry.c component=pack role=lib prefix=repack includes=pack:3,setup:1 cochange=pack:25,transport:2,odb:1
+repack-midx.c component=pack role=lib prefix=repack includes=odb:3,pack:3,refs:1 cochange=pack:23,refs:3,setup:2,merge:1,odb:1
+repack-promisor.c component=pack role=lib prefix=repack-promisor includes=pack:3,setup:1 cochange=pack:8,odb:3,revision:2
+repack.c component=pack role=lib prefix=repack includes=pack:3,index:1,odb:1,setup:1 cochange=pack:31,transport:2,odb:1
+repack.h component=pack role=header prefix=repack includes=revision:1 cochange=pack:28
+replace-object.c component=odb role=lib prefix=refs includes=odb:4,refs:1,setup:1 cochange=odb:8,setup:6,refs:5,pack:3,diff:2
+replace-object.h component=odb role=header prefix=replace-object includes=odb:2,setup:1 cochange=odb:11,setup:9,pack:4,revision:3,merge:1
+replay.c component=? role=lib prefix=replay includes=odb:2,merge:1,refs:1,revision:1,setup:1 cochange=transport:1
+replay.h component=? role=public prefix=replay includes=odb:1
+repo-settings.c component=setup role=lib prefix=repo-settings includes=setup:4,pack:2 cochange=setup:65,pack:17,index:8,transport:8,odb:6
+repo-settings.h component=setup role=header prefix=environment cochange=setup:40,pack:7,refs:6,odb:4,diff:2
+repository.c component=setup role=lib prefix=repository includes=setup:4,odb:3,index:2,transport:2,refs:1 cochange=setup:141,odb:39,index:27,refs:18,submodule:17
+repository.h component=setup role=header prefix=repository includes=setup:2 cochange=setup:157,index:31,refs:25,pack:22,odb:19
+rerere.c component=merge role=lib prefix=rerere includes=index:4,merge:2,odb:2,setup:2,diff:1 cochange=index:54,merge:29,pack:26,odb:25,transport:25
+rerere.h component=merge role=header prefix=rerere cochange=merge:16,odb:1
+reset.c component=? role=lib prefix=reset includes=odb:3,index:2,refs:1,setup:1 cochange=index:9,merge:5,odb:3,notes:2,revision:2
+reset.h component=? role=public prefix=reset includes=odb:1,setup:1
+resolve-undo.c component=index role=lib prefix=resolve-undo includes=index:4,odb:1 cochange=index:33,merge:5,revision:4,diff:3,notes:2
+resolve-undo.h component=index role=header prefix=resolve-undo includes=odb:1 cochange=index:12,merge:3,archive:1,revision:1
+revision.c component=revision role=lib prefix=revision includes=odb:9,revision:8,index:4,setup:4,diff:3 cochange=revision:379,diff:194,odb:181,refs:109,pack:101
+revision.h component=revision role=header prefix=revision includes=odb:4,revision:3,diff:1,notes:1,setup:1 cochange=revision:304,odb:48,diff:24,pack:19,refs:15
+run-command.c component=? role=lib prefix=run-command includes=setup:2,index:1,pack:1 cochange=transport:27,index:21,setup:14,odb:8,submodule:6
+run-command.h component=? role=public prefix=run-command cochange=transport:21,setup:8,odb:6,submodule:5,refs:4
+sane-ctype.h component=? role=public prefix=sane-ctype
+scalar.c component=? role=lib prefix=scalar includes=index:3,setup:2,pack:1,refs:1 cochange=setup:9,transport:7,pack:4,index:3,merge:3
+send-pack.c component=transport role=lib prefix=send-pack includes=transport:6,odb:3,setup:2,revision:1 cochange=transport:177,odb:29,revision:17,refs:15,pack:8
+send-pack.h component=transport role=header prefix=send-pack cochange=transport:39
+sequencer.c component=? role=lib prefix=sequencer includes=odb:8,index:5,merge:4,setup:4,revision:3 cochange=revision:84,odb:83,index:77,refs:60,transport:55
+sequencer.h component=? role=public prefix=sequencer includes=index:1 cochange=revision:5,index:4,notes:3,odb:3,transport:3
+serve.c component=transport role=lib prefix=serve includes=transport:6,setup:3,odb:1,refs:1 cochange=transport:53,refs:7,odb:4,setup:3,index:1
+serve.h component=transport role=header prefix=serve cochange=transport:9,refs:3,submodule:1
+server-info.c component=pack role=lib prefix=server-info includes=odb:5,pack:2,index:1,refs:1,setup:1 cochange=pack:40,transport:34,odb:33,setup:13,refs:10
+server-info.h component=pack role=header prefix=server-info cochange=pack:2
+setup.c component=setup role=lib prefix=setup includes=setup:4,odb:2,refs:2,index:1,revision:1 cochange=setup:177,refs:47,transport:44,index:39,odb:24
+setup.h component=setup role=header prefix=setup includes=refs:1 cochange=setup:70,refs:8,index:5,revision:4,submodule:4
+sh-i18n--envsubst.c component=? role=program prefix=sh-i18n--envsubst cochange=index:3,diff:1,transport:1
+sha1dc_git.c component=? role=lib prefix=sha1dc cochange=diff:3,odb:2,revision:2,setup:1
+sha1dc_git.h component=? role=public prefix=sha1dc cochange=odb:2
+shallow.c component=revision role=lib prefix=shallow includes=odb:5,revision:4,diff:1,index:1,refs:1 cochange=odb:83,transport:73,revision:31,index:20,refs:14
+shallow.h component=revision role=header prefix=shallow includes=odb:2,setup:1 cochange=revision:10,transport:7,odb:5,diff:3,index:2
+shell.c component=? role=program prefix=shell includes=setup:1 cochange=transport:10,setup:4,revision:2
+shortlog.h component=? role=public prefix=shortlog cochange=revision:2
+sideband.c component=transport role=lib prefix=sideband includes=transport:2,setup:1 cochange=transport:51,revision:6,diff:5,index:5,refs:4
+sideband.h component=transport role=header prefix=sideband cochange=transport:23
+sigchain.c component=? role=lib prefix=sigchain cochange=diff:2,transport:1
+sigchain.h component=? role=public prefix=sigchain cochange=diff:2
+simple-ipc.h component=? role=public prefix=simple-ipc includes=transport:1 cochange=submodule:1
+sparse-index.c component=index role=lib prefix=sparse-index includes=index:7,setup:3,odb:1 cochange=index:42,setup:17,diff:2,odb:2,revision:1
+sparse-index.h component=index role=header prefix=sparse-index cochange=index:16,setup:4,merge:1,revision:1
+split-index.c component=index role=lib prefix=split-index includes=index:2,odb:1,setup:1 cochange=index:46,odb:5,revision:4,pack:3,merge:2
+split-index.h component=index role=header prefix=split-index includes=odb:1 cochange=index:21,archive:1,merge:1,revision:1
+stable-qsort.c component=? role=lib prefix=stable-qsort
+statinfo.c component=index role=lib prefix=environment includes=setup:2,index:1 cochange=index:9,setup:6,diff:2,odb:1,revision:1
+statinfo.h component=index role=header prefix=statinfo cochange=index:8,odb:1,revision:1
+strbuf.c component=? role=lib prefix=strbuf cochange=index:16,odb:12,setup:11,revision:10,transport:10
+strbuf.h component=? role=public prefix=strbuf cochange=revision:15,index:14,odb:14,diff:7,setup:7
+string-list.c component=? role=lib prefix=string-list cochange=transport:14,index:8,notes:7,refs:7,diff:5
+string-list.h component=? role=public prefix=string-list cochange=transport:19,index:6,notes:6,diff:5,refs:5
+strmap.c component=? role=lib prefix=strmap
+strmap.h component=? role=public prefix=strmap
+strvec.c component=? role=lib prefix=strvec
+strvec.h component=? role=public prefix=strvec cochange=submodule:3,revision:2,index:1,transport:1
+sub-process.c component=? role=lib prefix=sub-process includes=transport:1 cochange=diff:19,convert:12,revision:11,index:8,refs:8
+sub-process.h component=? role=public prefix=sub-process cochange=convert:8,transport:6,refs:5,diff:4,odb:4
+submodule-config.c component=submodule role=lib prefix=submodule-config includes=odb:3,setup:3,submodule:2,index:1 cochange=submodule:60,setup:41,diff:36,revision:27,odb:22
+submodule-config.h component=submodule role=header prefix=submodule-config includes=odb:1,setup:1,submodule:1 cochange=submodule:54,setup:9,odb:3,diff:2,index:2
+submodule.c component=submodule role=lib prefix=submodule includes=odb:5,setup:4,diff:2,index:2,refs:2 cochange=submodule:134,diff:83,setup:66,index:60,revision:49
+submodule.h component=submodule role=header prefix=submodule cochange=submodule:128,index:22,diff:21,transport:17,setup:6
+symlinks.c component=index role=lib prefix=symlinks includes=index:1,setup:1 cochange=index:23,diff:3,archive:2,convert:1,revision:1
+symlinks.h component=index role=header prefix=symlinks cochange=index:9,diff:1
+tag.c component=odb role=lib prefix=tag includes=odb:7,setup:2,pack:1 cochange=odb:189,transport:36,pack:32,revision:29,refs:14
+tag.h component=odb role=header prefix=tag includes=odb:1 cochange=odb:60,transport:10,revision:8,refs:7,pack:6
+tar.h component=? role=public prefix=tar-tree
+tempfile.c component=? role=lib prefix=tempfile cochange=pack:5,setup:4,index:3,odb:3,revision:3
+tempfile.h component=? role=public prefix=tempfile includes=revision:1 cochange=revision:3,diff:2,index:2,setup:2
+thread-utils.c component=? role=lib prefix=thread-utils cochange=diff:1
+thread-utils.h component=? role=public prefix=thread-utils cochange=transport:1
+tmp-objdir.c component=odb role=lib prefix=tmp-objdir includes=odb:3,setup:2,index:1 cochange=pack:24,odb:23,setup:8,transport:5,revision:3
+tmp-objdir.h component=odb role=header prefix=tmp-objdir cochange=odb:8,revision:3,setup:1
+trace.c component=? role=lib prefix=trace includes=setup:2 cochange=setup:26,transport:13,index:11,odb:4,diff:2
+trace.h component=? role=public prefix=trace cochange=transport:6,index:5,odb:4,pack:3,revision:3
+trace2.c component=? role=lib prefix=trace2 includes=setup:2 cochange=setup:2
+trace2.h component=? role=public prefix=trace2 cochange=setup:2
+trailer.c component=? role=lib prefix=trailer includes=setup:2,odb:1,revision:1 cochange=transport:13,revision:12,odb:8,index:7,refs:6
+trailer.h component=? role=public prefix=trailer includes=revision:1 cochange=revision:7,refs:1
+transport-helper.c component=transport role=lib prefix=transport-helper includes=transport:4,odb:2,refs:2,setup:2,pack:1 cochange=transport:210,refs:23,revision:16,odb:14,index:12
+transport-internal.h component=transport role=header prefix=transport includes=transport:1 cochange=transport:42,refs:3,odb:1,submodule:1
+transport.c component=transport role=lib prefix=transport includes=transport:12,setup:3,odb:2,refs:2,submodule:1 cochange=transport:482,refs:35,setup:31,submodule:29,revision:21
+transport.h component=transport role=header prefix=transport includes=transport:2,revision:1 cochange=transport:249,submodule:6,odb:4,revision:2,diff:1
+tree-diff.c component=diff role=lib prefix=tree-diff includes=odb:3,diff:2,index:1,setup:1 cochange=diff:115,odb:56,revision:53,index:36,notes:12
+tree-walk.c component=odb role=lib prefix=tree-walk includes=odb:4,index:3,setup:1 cochange=odb:70,index:61,diff:31,revision:24,pack:13
+tree-walk.h component=odb role=header prefix=tree-walk includes=odb:1 cochange=odb:64,diff:23,index:23,revision:21,notes:7
+tree.c component=odb role=lib prefix=tree includes=odb:6,setup:2 cochange=odb:212,revision:45,index:36,pack:25,transport:21
+tree.h component=odb role=header prefix=tree includes=odb:1 cochange=odb:75,revision:12,archive:8,index:6,pack:5
+unicode-width.h component=? role=public prefix=unicode
+unix-socket.c component=? role=lib prefix=unix-socket cochange=diff:3,revision:2,setup:1
+unix-socket.h component=? role=public prefix=unix-socket
+unix-stream-server.c component=? role=lib prefix=unix-stream-server
+unix-stream-server.h component=? role=public prefix=unix-stream-server
+unpack-trees.c component=index role=lib prefix=unpack-trees includes=index:11,odb:3,setup:3,submodule:2,convert:1 cochange=index:262,odb:49,diff:41,transport:19,revision:18
+unpack-trees.h component=index role=header prefix=unpack-trees includes=convert:1,index:1,odb:1 cochange=index:75,diff:9,odb:6,setup:5,merge:4
+upload-pack.c component=transport role=lib prefix=upload-pack includes=transport:6,odb:4,revision:4,setup:4,diff:1 cochange=transport:198,odb:88,revision:80,refs:55,pack:34
+upload-pack.h component=transport role=header prefix=upload-pack cochange=transport:18,refs:5,submodule:1
+url.c component=? role=lib prefix=url cochange=transport:12,revision:8,diff:6,index:2,refs:2
+url.h component=? role=public prefix=url cochange=transport:9,revision:4,submodule:1
+urlmatch.c component=? role=lib prefix=urlmatch cochange=diff:3,odb:2,revision:2,setup:2,transport:2
+urlmatch.h component=? role=public prefix=urlmatch includes=setup:1 cochange=transport:1
+usage.c component=? role=lib prefix=usage cochange=index:3,odb:2,diff:1,revision:1,setup:1
+userdiff.c component=diff role=lib prefix=userdiff includes=setup:2,convert:1,diff:1 cochange=diff:41,convert:34,archive:11,index:7,transport:6
+userdiff.h component=diff role=header prefix=diff includes=notes:1 cochange=diff:40,notes:2,archive:1,merge:1,revision:1
+utf8.c component=? role=lib prefix=utf8 cochange=revision:6,index:3,setup:3,transport:2,convert:1
+utf8.h component=? role=public prefix=utf8 cochange=revision:6,index:2,setup:2,transport:2,convert:1
+varint.c component=? role=lib prefix=varint cochange=index:2,transport:1
+varint.h component=? role=public prefix=varint cochange=index:2,transport:1
+version.c component=setup role=lib prefix=version includes=setup:1 cochange=setup:8,transport:2
+version.h component=setup role=header prefix=version cochange=setup:8,transport:2
+versioncmp.c component=? role=lib prefix=versioncmp includes=setup:1 cochange=setup:5,pack:3,transport:3,index:2,refs:2
+versioncmp.h component=? role=public prefix=versioncmp cochange=refs:1
+walker.c component=transport role=lib prefix=refs includes=odb:6,refs:1,setup:1,transport:1 cochange=odb:70,transport:55,revision:42,refs:24,pack:17
+walker.h component=transport role=header prefix=walker includes=transport:1 cochange=transport:19
+wildmatch.c component=? role=lib prefix=hex cochange=index:4,refs:3,diff:1,odb:1,revision:1
+wildmatch.h component=? role=public prefix=? cochange=index:3,refs:2,diff:1,revision:1,setup:1
+worktree.c component=refs role=lib prefix=worktree includes=setup:4,index:2,refs:2 cochange=refs:73,setup:53,index:22,submodule:13,pack:11
+worktree.h component=refs role=header prefix=worktree includes=refs:1 cochange=refs:61,revision:10,pack:5,setup:5,odb:4
+wrapper.c component=? role=lib prefix=wrapper cochange=setup:21,index:16,pack:6,transport:5,convert:4
+wrapper.h component=? role=public prefix=wrapper cochange=index:2,revision:1,setup:1
+write-or-die.c component=? role=lib prefix=write-or-die cochange=pack:6,setup:6,index:4,transport:2,convert:1
+write-or-die.h component=? role=public prefix=write-or-die
+ws.c component=convert role=lib prefix=whitespace includes=convert:2 cochange=convert:24,diff:18,archive:9,index:5,setup:5
+ws.h component=convert role=header prefix=whitespace cochange=diff:5,convert:2,setup:2
+wt-status.c component=index role=lib prefix=wt-status includes=odb:5,index:4,setup:3,diff:2,refs:2 cochange=index:149,diff:83,transport:55,refs:45,revision:45
+wt-status.h component=index role=header prefix=wt-status includes=index:1,transport:1 cochange=index:89,diff:10,refs:9,revision:4,transport:4
+xdiff-interface.c component=diff role=lib prefix=xdiff-interface includes=setup:2,diff:1,odb:1 cochange=diff:73,index:5,merge:3,notes:3,refs:3
+xdiff-interface.h component=diff role=header prefix=xdiff-interface includes=odb:1 cochange=diff:62,index:2,notes:2,merge:1,odb:1
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 07/14] odb: gather the odb sources under odb/
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (5 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 06/14] organize: record a label for every source in scope Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-24 14:08   ` Oswald Buddenhagen
  2026-08-23 17:18 ` [RFC PATCH 08/14] refs: gather the refs sources under refs/ Michael Montalbo
                   ` (6 subsequent siblings)
  13 siblings, 1 reply; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Move the 23 odb C sources and 26 headers into odb/ as renames. Repoint
every reference to their old paths to the new ones: the #include lines
across the tree, the Makefile and meson.build build entries, the
Documentation/Makefile argument, and the tutorial #include examples.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize                                  | 98 +++++++++----------
 Documentation/Makefile                        |  4 +-
 Documentation/MyFirstContribution.adoc        |  2 +-
 Documentation/MyFirstObjectWalk.adoc          |  2 +-
 Makefile                                      | 46 ++++-----
 add-interactive.c                             |  4 +-
 add-patch.c                                   |  4 +-
 apply.c                                       |  6 +-
 apply.h                                       |  2 +-
 archive-tar.c                                 |  2 +-
 archive-zip.c                                 |  2 +-
 archive.c                                     | 10 +-
 attr.c                                        |  6 +-
 bisect.c                                      | 10 +-
 blame.c                                       | 10 +-
 blame.h                                       |  2 +-
 bloom.c                                       |  8 +-
 branch.c                                      |  4 +-
 builtin/add.c                                 |  4 +-
 builtin/am.c                                  |  4 +-
 builtin/apply.c                               |  2 +-
 builtin/backfill.c                            | 14 +--
 builtin/bisect.c                              |  4 +-
 builtin/blame.c                               |  8 +-
 builtin/branch.c                              |  4 +-
 builtin/cat-file.c                            | 10 +-
 builtin/check-attr.c                          |  2 +-
 builtin/checkout.c                            | 12 +--
 builtin/clone.c                               |  8 +-
 builtin/commit-graph.c                        |  8 +-
 builtin/commit-tree.c                         |  6 +-
 builtin/commit.c                              |  4 +-
 builtin/count-objects.c                       |  2 +-
 builtin/describe.c                            | 12 +--
 builtin/diff-files.c                          |  2 +-
 builtin/diff-index.c                          |  2 +-
 builtin/diff-pairs.c                          |  4 +-
 builtin/diff-tree.c                           |  6 +-
 builtin/diff.c                                |  8 +-
 builtin/difftool.c                            |  4 +-
 builtin/fast-export.c                         | 12 +--
 builtin/fast-import.c                         | 14 +--
 builtin/fetch-pack.c                          |  4 +-
 builtin/fetch.c                               | 10 +-
 builtin/for-each-ref.c                        |  4 +-
 builtin/fsck.c                                | 18 ++--
 builtin/gc.c                                  |  6 +-
 builtin/get-tar-commit-id.c                   |  2 +-
 builtin/grep.c                                | 12 +--
 builtin/hash-object.c                         |  6 +-
 builtin/history.c                             |  8 +-
 builtin/index-pack.c                          | 22 ++---
 builtin/last-modified.c                       |  8 +-
 builtin/log.c                                 | 18 ++--
 builtin/ls-files.c                            |  4 +-
 builtin/ls-tree.c                             |  6 +-
 builtin/merge-base.c                          |  4 +-
 builtin/merge-file.c                          |  6 +-
 builtin/merge-recursive.c                     |  4 +-
 builtin/merge-tree.c                          | 12 +--
 builtin/merge.c                               |  6 +-
 builtin/mktag.c                               |  8 +-
 builtin/mktree.c                              |  6 +-
 builtin/multi-pack-index.c                    |  4 +-
 builtin/mv.c                                  |  2 +-
 builtin/name-rev.c                            | 10 +-
 builtin/notes.c                               |  6 +-
 builtin/pack-objects.c                        | 22 ++---
 builtin/pack-redundant.c                      |  2 +-
 builtin/patch-id.c                            |  2 +-
 builtin/prune.c                               | 10 +-
 builtin/pull.c                                |  4 +-
 builtin/range-diff.c                          |  2 +-
 builtin/read-tree.c                           |  8 +-
 builtin/rebase.c                              |  6 +-
 builtin/receive-pack.c                        | 16 +--
 builtin/reflog.c                              |  2 +-
 builtin/refs.c                                |  2 +-
 builtin/remote.c                              |  2 +-
 builtin/replace.c                             | 10 +-
 builtin/replay.c                              |  2 +-
 builtin/repo.c                                | 10 +-
 builtin/reset.c                               |  8 +-
 builtin/rev-list.c                            | 14 +--
 builtin/rev-parse.c                           |  8 +-
 builtin/rm.c                                  |  6 +-
 builtin/send-pack.c                           |  2 +-
 builtin/shortlog.c                            |  2 +-
 builtin/show-branch.c                         |  6 +-
 builtin/show-index.c                          |  2 +-
 builtin/show-ref.c                            |  6 +-
 builtin/sparse-checkout.c                     |  4 +-
 builtin/stash.c                               |  8 +-
 builtin/submodule--helper.c                   |  6 +-
 builtin/tag.c                                 | 12 +--
 builtin/unpack-file.c                         |  6 +-
 builtin/unpack-objects.c                      | 12 +--
 builtin/update-index.c                        |  8 +-
 builtin/update-ref.c                          |  4 +-
 builtin/upload-pack.c                         |  4 +-
 builtin/verify-commit.c                       |  4 +-
 builtin/verify-tag.c                          |  4 +-
 builtin/worktree.c                            |  4 +-
 builtin/write-tree.c                          |  2 +-
 bundle-uri.c                                  |  2 +-
 bundle.c                                      |  6 +-
 cache-tree.c                                  | 10 +-
 cache-tree.h                                  |  4 +-
 checkout.c                                    |  2 +-
 checkout.h                                    |  2 +-
 chunk-format.c                                |  2 +-
 chunk-format.h                                |  2 +-
 combine-diff.c                                | 10 +-
 commit-graph.c                                | 18 ++--
 commit-graph.h                                |  4 +-
 commit-reach.c                                |  4 +-
 commit-reach.h                                |  4 +-
 common-init.c                                 |  4 +-
 compat/mingw.c                                |  2 +-
 compat/sha1-chunked.c                         |  2 +-
 config.c                                      |  4 +-
 connect.c                                     |  2 +-
 connected.c                                   |  2 +-
 convert.c                                     |  2 +-
 convert.h                                     |  2 +-
 csum-file.c                                   |  2 +-
 csum-file.h                                   |  2 +-
 decorate.c                                    |  2 +-
 delta-islands.c                               | 12 +--
 diagnose.c                                    |  2 +-
 diff-lib.c                                    |  6 +-
 diff-no-index.c                               |  2 +-
 diff.c                                        | 10 +-
 diff.h                                        |  2 +-
 diffcore-break.c                              |  4 +-
 diffcore-pickaxe.c                            |  2 +-
 diffcore-rename.c                             |  4 +-
 diffcore.h                                    |  2 +-
 dir.c                                         |  4 +-
 dir.h                                         |  2 +-
 entry.c                                       |  2 +-
 environment.c                                 |  4 +-
 fetch-object-info.c                           |  4 +-
 fetch-pack.c                                  | 14 +--
 fetch-pack.h                                  |  2 +-
 fmt-merge-msg.c                               |  6 +-
 fsmonitor.h                                   |  2 +-
 git.c                                         |  4 +-
 gpg-interface.c                               |  2 +-
 graph.c                                       |  2 +-
 grep.c                                        |  2 +-
 help.c                                        |  2 +-
 hex.c                                         |  2 +-
 hex.h                                         |  2 +-
 http-backend.c                                |  6 +-
 http-push.c                                   | 14 +--
 http-walker.c                                 |  4 +-
 http.c                                        |  4 +-
 khash.h                                       |  2 +-
 line-log.c                                    |  8 +-
 list-objects-filter-options.h                 |  2 +-
 list-objects-filter.c                         | 10 +-
 list-objects.c                                | 12 +--
 log-tree.c                                    | 16 +--
 ls-refs.c                                     |  2 +-
 mailmap.c                                     |  4 +-
 merge-blobs.c                                 |  4 +-
 merge-ort-wrappers.c                          |  8 +-
 merge-ort.c                                   | 16 +--
 merge-ort.h                                   |  2 +-
 merge.c                                       |  8 +-
 meson.build                                   | 46 ++++-----
 midx-write.c                                  |  4 +-
 midx.c                                        |  2 +-
 name-hash.c                                   |  2 +-
 negotiator/default.c                          |  4 +-
 negotiator/skipping.c                         |  4 +-
 notes-cache.c                                 |  6 +-
 notes-merge.c                                 |  8 +-
 notes-utils.c                                 |  2 +-
 notes.c                                       |  8 +-
 alloc.c => odb/alloc.c                        | 12 +--
 alloc.h => odb/alloc.h                        |  0
 blob.c => odb/blob.c                          |  4 +-
 blob.h => odb/blob.h                          |  2 +-
 cbtree.c => odb/cbtree.c                      |  2 +-
 cbtree.h => odb/cbtree.h                      |  0
 commit-slab-decl.h => odb/commit-slab-decl.h  |  0
 commit-slab-impl.h => odb/commit-slab-impl.h  |  0
 commit-slab.h => odb/commit-slab.h            |  4 +-
 commit.c => odb/commit.c                      | 20 ++--
 commit.h => odb/commit.h                      |  2 +-
 fsck.c => odb/fsck.c                          | 18 ++--
 fsck.h => odb/fsck.h                          |  4 +-
 hash-lookup.c => odb/hash-lookup.c            |  4 +-
 hash-lookup.h => odb/hash-lookup.h            |  0
 hash.c => odb/hash.c                          |  2 +-
 hash.h => odb/hash.h                          |  0
 loose.c => odb/loose.c                        | 10 +-
 loose.h => odb/loose.h                        |  0
 match-trees.c => odb/match-trees.c            | 10 +-
 match-trees.h => odb/match-trees.h            |  0
 .../object-file-convert.c                     | 10 +-
 .../object-file-convert.h                     |  2 +-
 object-file.c => odb/object-file.c            | 12 +--
 object-file.h => odb/object-file.h            |  4 +-
 object-name.c => odb/object-name.c            | 16 +--
 object-name.h => odb/object-name.h            |  2 +-
 object.c => odb/object.c                      | 16 +--
 object.h => odb/object.h                      |  2 +-
 odb.c => odb/odb.c                            | 14 +--
 odb.h => odb/odb.h                            |  6 +-
 oid-array.c => odb/oid-array.c                |  4 +-
 oid-array.h => odb/oid-array.h                |  2 +-
 oidmap.c => odb/oidmap.c                      |  4 +-
 oidmap.h => odb/oidmap.h                      |  2 +-
 oidset.c => odb/oidset.c                      |  2 +-
 oidset.h => odb/oidset.h                      |  0
 oidtree.c => odb/oidtree.c                    |  4 +-
 oidtree.h => odb/oidtree.h                    |  4 +-
 replace-object.c => odb/replace-object.c      |  8 +-
 replace-object.h => odb/replace-object.h      |  4 +-
 odb/source-files.c                            |  8 +-
 odb/source-inmemory.c                         |  6 +-
 odb/source-loose.c                            | 10 +-
 odb/source.c                                  |  2 +-
 odb/source.h                                  |  4 +-
 odb/streaming.c                               |  4 +-
 odb/streaming.h                               |  4 +-
 tag.c => odb/tag.c                            | 14 +--
 tag.h => odb/tag.h                            |  2 +-
 tmp-objdir.c => odb/tmp-objdir.c              |  6 +-
 tmp-objdir.h => odb/tmp-objdir.h              |  0
 odb/transaction.h                             |  2 +-
 tree-walk.c => odb/tree-walk.c                |  8 +-
 tree-walk.h => odb/tree-walk.h                |  2 +-
 tree.c => odb/tree.c                          | 12 +--
 tree.h => odb/tree.h                          |  2 +-
 oss-fuzz/fuzz-pack-idx.c                      |  2 +-
 pack-bitmap-write.c                           | 14 +--
 pack-bitmap.c                                 |  6 +-
 pack-check.c                                  |  4 +-
 pack-mtimes.c                                 |  2 +-
 pack-objects.c                                |  2 +-
 pack-objects.h                                |  2 +-
 pack-revindex.c                               |  2 +-
 pack-write.c                                  |  2 +-
 pack.h                                        |  2 +-
 packfile.c                                    | 16 +--
 packfile.h                                    |  6 +-
 parallel-checkout.c                           |  2 +-
 parse-options-cb.c                            |  6 +-
 patch-ids.c                                   |  4 +-
 path-walk.c                                   | 18 ++--
 path-walk.h                                   |  2 +-
 path.c                                        |  2 +-
 pretty.c                                      |  6 +-
 promisor-remote.c                             |  2 +-
 protocol-caps.c                               |  6 +-
 prune-packed.c                                |  2 +-
 pseudo-merge.c                                |  6 +-
 range-diff.c                                  |  4 +-
 reachable.c                                   |  6 +-
 read-cache-ll.h                               |  2 +-
 read-cache.c                                  | 12 +--
 read-cache.h                                  |  2 +-
 rebase-interactive.c                          |  6 +-
 ref-filter.c                                  | 12 +--
 ref-filter.h                                  |  4 +-
 reflog-walk.c                                 |  2 +-
 reflog.c                                      |  6 +-
 refs.c                                        | 10 +-
 refs.h                                        |  4 +-
 refs/files-backend.c                          |  4 +-
 refs/packed-backend.c                         |  4 +-
 refs/ref-cache.c                              |  2 +-
 refs/ref-cache.h                              |  2 +-
 refs/reftable-backend.c                       |  4 +-
 refspec.c                                     |  2 +-
 remote-curl.c                                 |  2 +-
 remote.c                                      |  6 +-
 remote.h                                      |  2 +-
 repack-midx.c                                 |  6 +-
 repack.c                                      |  2 +-
 replay.c                                      |  4 +-
 replay.h                                      |  2 +-
 repository.c                                  |  6 +-
 rerere.c                                      |  4 +-
 reset.c                                       |  6 +-
 reset.h                                       |  2 +-
 resolve-undo.c                                |  2 +-
 resolve-undo.h                                |  2 +-
 revision.c                                    | 18 ++--
 revision.h                                    |  8 +-
 send-pack.c                                   |  6 +-
 sequencer.c                                   | 16 +--
 serve.c                                       |  2 +-
 server-info.c                                 | 10 +-
 setup.c                                       |  4 +-
 shallow.c                                     | 10 +-
 shallow.h                                     |  4 +-
 sparse-index.c                                |  2 +-
 split-index.c                                 |  2 +-
 split-index.h                                 |  2 +-
 submodule-config.c                            |  6 +-
 submodule-config.h                            |  2 +-
 submodule.c                                   | 10 +-
 t/helper/test-bitmap.c                        |  2 +-
 t/helper/test-bloom.c                         |  2 +-
 t/helper/test-cache-tree.c                    |  2 +-
 t/helper/test-dump-cache-tree.c               |  4 +-
 t/helper/test-find-pack.c                     |  4 +-
 t/helper/test-hash-speed.c                    |  2 +-
 t/helper/test-match-trees.c                   |  6 +-
 t/helper/test-pack-deltas.c                   |  2 +-
 t/helper/test-pack-mtimes.c                   |  2 +-
 t/helper/test-partial-clone.c                 |  2 +-
 t/helper/test-path-walk.c                     |  6 +-
 t/helper/test-reach.c                         |  6 +-
 t/helper/test-read-graph.c                    |  2 +-
 t/helper/test-read-midx.c                     |  2 +-
 t/helper/test-ref-store.c                     |  2 +-
 t/helper/test-reftable.c                      |  2 +-
 t/helper/test-repository.c                    |  6 +-
 t/helper/test-revision-walking.c              |  4 +-
 t/helper/test-scrap-cache-tree.c              |  2 +-
 t/helper/test-sha1.c                          |  2 +-
 t/helper/test-sha256.c                        |  2 +-
 t/helper/test-submodule-config.c              |  4 +-
 t/helper/test-synthesize.c                    |  6 +-
 t/unit-tests/lib-oid.h                        |  2 +-
 t/unit-tests/u-example-decorate.c             |  2 +-
 t/unit-tests/u-odb-inmemory.c                 |  4 +-
 t/unit-tests/u-oid-array.c                    |  2 +-
 t/unit-tests/u-oidmap.c                       |  4 +-
 t/unit-tests/u-oidtree.c                      |  4 +-
 trailer.c                                     |  2 +-
 transport-helper.c                            |  4 +-
 transport.c                                   |  4 +-
 tree-diff.c                                   |  6 +-
 unpack-trees.c                                |  6 +-
 unpack-trees.h                                |  2 +-
 upload-pack.c                                 |  8 +-
 walker.c                                      | 12 +--
 wt-status.c                                   | 10 +-
 xdiff-interface.c                             |  2 +-
 xdiff-interface.h                             |  2 +-
 347 files changed, 1006 insertions(+), 1006 deletions(-)
 rename alloc.c => odb/alloc.c (95%)
 rename alloc.h => odb/alloc.h (100%)
 rename blob.c => odb/blob.c (89%)
 rename blob.h => odb/blob.h (96%)
 rename cbtree.c => odb/cbtree.c (99%)
 rename cbtree.h => odb/cbtree.h (100%)
 rename commit-slab-decl.h => odb/commit-slab-decl.h (100%)
 rename commit-slab-impl.h => odb/commit-slab-impl.h (100%)
 rename commit-slab.h => odb/commit-slab.h (97%)
 rename commit.c => odb/commit.c (99%)
 rename commit.h => odb/commit.h (99%)
 rename fsck.c => odb/fsck.c (99%)
 rename fsck.h => odb/fsck.h (99%)
 rename hash-lookup.c => odb/hash-lookup.c (98%)
 rename hash-lookup.h => odb/hash-lookup.h (100%)
 rename hash.c => odb/hash.c (99%)
 rename hash.h => odb/hash.h (100%)
 rename loose.c => odb/loose.c (98%)
 rename loose.h => odb/loose.h (100%)
 rename match-trees.c => odb/match-trees.c (98%)
 rename match-trees.h => odb/match-trees.h (100%)
 rename object-file-convert.c => odb/object-file-convert.c (98%)
 rename object-file-convert.h => odb/object-file-convert.h (96%)
 rename object-file.c => odb/object-file.c (99%)
 rename object-file.h => odb/object-file.h (99%)
 rename object-name.c => odb/object-name.c (99%)
 rename object-name.h => odb/object-name.h (99%)
 rename object.c => odb/object.c (98%)
 rename object.h => odb/object.h (99%)
 rename odb.c => odb/odb.c (99%)
 rename odb.h => odb/odb.h (99%)
 rename oid-array.c => odb/oid-array.c (97%)
 rename oid-array.h => odb/oid-array.h (99%)
 rename oidmap.c => odb/oidmap.c (97%)
 rename oidmap.h => odb/oidmap.h (99%)
 rename oidset.c => odb/oidset.c (99%)
 rename oidset.h => odb/oidset.h (100%)
 rename oidtree.c => odb/oidtree.c (98%)
 rename oidtree.h => odb/oidtree.h (97%)
 rename replace-object.c => odb/replace-object.c (96%)
 rename replace-object.h => odb/replace-object.h (97%)
 rename tag.c => odb/tag.c (97%)
 rename tag.h => odb/tag.h (96%)
 rename tmp-objdir.c => odb/tmp-objdir.c (99%)
 rename tmp-objdir.h => odb/tmp-objdir.h (100%)
 rename tree-walk.c => odb/tree-walk.c (99%)
 rename tree-walk.h => odb/tree-walk.h (99%)
 rename tree.c => odb/tree.c (97%)
 rename tree.h => odb/tree.h (98%)

diff --git a/.gitorganize b/.gitorganize
index 522821522e..5da6d0b2b1 100644
--- a/.gitorganize
+++ b/.gitorganize
@@ -30,8 +30,6 @@ advice.c component=? role=lib prefix=advice includes=setup:2 cochange=transport:
 advice.h component=? role=public prefix=advice cochange=transport:14,index:9,odb:6,submodule:4,pack:3
 alias.c component=setup role=lib prefix=alias includes=setup:2 cochange=setup:8,diff:4,transport:3,convert:2,index:2
 alias.h component=setup role=header prefix=completion cochange=setup:3,transport:2,pack:1,revision:1
-alloc.c component=odb role=lib prefix=alloc includes=odb:6,setup:1 cochange=odb:54,revision:8,diff:6,pack:6,index:3
-alloc.h component=odb role=header prefix=alloc cochange=odb:16,refs:1,revision:1
 apply.c component=? role=lib prefix=apply includes=index:5,setup:4,odb:3,diff:2,merge:2 cochange=index:93,setup:43,diff:41,odb:26,merge:24
 apply.h component=? role=public prefix=apply includes=odb:1 cochange=diff:2
 archive-tar.c component=archive role=lib prefix=archive-tar includes=archive:1,odb:1,setup:1 cochange=archive:59,index:12,diff:9,odb:9,transport:8
@@ -47,8 +45,6 @@ bisect.c component=revision role=lib prefix=bisect includes=odb:5,revision:5,set
 bisect.h component=revision role=header prefix=bisect cochange=revision:29,odb:2
 blame.c component=revision role=lib prefix=blame includes=odb:5,diff:2,index:2,pack:2,revision:2 cochange=diff:68,revision:66,odb:56,index:29,pack:22
 blame.h component=revision role=header prefix=blame includes=diff:1,odb:1 cochange=revision:19,odb:7,diff:4,archive:1,index:1
-blob.c component=odb role=lib prefix=object includes=odb:2 cochange=odb:131,transport:12,pack:11,revision:10,refs:5
-blob.h component=odb role=header prefix=blob includes=odb:1 cochange=odb:33,revision:4,pack:3,transport:2
 bloom.c component=pack role=lib prefix=bloom includes=odb:4,diff:2,pack:2,setup:2 cochange=pack:38,revision:25,diff:15,odb:6,index:2
 bloom.h component=pack role=header prefix=bloom cochange=pack:28,revision:12,odb:1
 branch.c component=? role=lib prefix=branch includes=refs:3,setup:3,odb:2,submodule:1,transport:1 cochange=refs:62,transport:41,setup:28,index:19,revision:12
@@ -60,8 +56,6 @@ bundle.c component=transport role=lib prefix=bundle includes=odb:3,revision:3,se
 bundle.h component=transport role=header prefix=bundle includes=revision:1 cochange=transport:37,revision:5
 cache-tree.c component=index role=lib prefix=cache-tree includes=odb:5,index:2,setup:1,transport:1 cochange=index:94,odb:69,revision:27,transport:21,diff:20
 cache-tree.h component=index role=header prefix=cache-tree includes=odb:2 cochange=index:42,diff:4,revision:4,odb:3,refs:1
-cbtree.c component=odb role=lib prefix=cbtree includes=odb:1 cochange=odb:9,diff:1,merge:1,pack:1
-cbtree.h component=odb role=header prefix=cbtree cochange=odb:12,pack:3,setup:1,transport:1
 chdir-notify.c component=? role=lib prefix=chdir-notify includes=revision:1 cochange=index:2,archive:1,merge:1,revision:1
 chdir-notify.h component=? role=public prefix=chdir-notify
 checkout.c component=index role=lib prefix=checkout includes=setup:2,index:1,odb:1,refs:1,transport:1 cochange=transport:16,refs:6,setup:5,index:3,odb:2
@@ -77,11 +71,6 @@ commit-graph.c component=pack role=lib prefix=commit-graph includes=odb:9,pack:4
 commit-graph.h component=pack role=header prefix=commit-graph includes=odb:2 cochange=pack:92,odb:14,setup:9,revision:8,transport:5
 commit-reach.c component=revision role=lib prefix=commit-reach includes=revision:3,odb:2,pack:1,refs:1 cochange=revision:38,odb:17,pack:15,transport:9,index:5
 commit-reach.h component=revision role=header prefix=commit-reach includes=odb:2 cochange=revision:32,odb:9,transport:8,pack:3,refs:3
-commit-slab-decl.h component=odb role=header prefix=commit-slab cochange=odb:6,revision:1
-commit-slab-impl.h component=odb role=header prefix=commit-slab cochange=odb:7,pack:3,revision:1,setup:1,transport:1
-commit-slab.h component=odb role=header prefix=commit-slab includes=odb:2 cochange=odb:8,revision:2,transport:2,index:1,merge:1
-commit.c component=odb role=lib prefix=commit includes=odb:10,setup:4,revision:3,diff:1,index:1 cochange=odb:403,revision:147,transport:87,pack:57,setup:45
-commit.h component=odb role=header prefix=commit includes=odb:1 cochange=odb:237,revision:205,transport:49,pack:25,notes:22
 common-exit.c component=? role=lib prefix=common-main
 common-init.c component=? role=lib prefix=common-main includes=odb:2,setup:2,convert:1 cochange=setup:1
 common-init.h component=? role=public prefix=common-main
@@ -146,8 +135,6 @@ fetch-pack.h component=transport role=header prefix=fetch-pack includes=odb:1,re
 fmt-merge-msg.c component=merge role=lib prefix=fmt-merge-msg includes=odb:3,diff:2,revision:2,setup:2,merge:1 cochange=revision:10,odb:7,index:6,diff:4,setup:4
 fmt-merge-msg.h component=merge role=header prefix=fmt-merge-msg cochange=merge:3,setup:2
 for-each-ref.h component=? role=public prefix=?
-fsck.c component=odb role=lib prefix=fsck includes=odb:9,setup:3,convert:1,index:1,pack:1 cochange=odb:113,revision:46,transport:43,pack:20,setup:15
-fsck.h component=odb role=header prefix=fsck includes=odb:2 cochange=odb:50,diff:5,revision:5,transport:5,refs:4
 fsmonitor--daemon.h component=index role=header prefix=fsmonitor--daemon includes=index:1 cochange=index:1
 fsmonitor-ipc.c component=index role=lib prefix=fsmonitor includes=index:1,setup:1 cochange=index:6,transport:2,merge:1,notes:1,pack:1
 fsmonitor-ipc.h component=index role=header prefix=fsmonitor cochange=index:2
@@ -170,10 +157,6 @@ graph.c component=revision role=lib prefix=graph includes=revision:2,odb:1,setup
 graph.h component=revision role=header prefix=graph includes=diff:1 cochange=revision:19,diff:2,odb:1
 grep.c component=? role=lib prefix=grep includes=diff:4,odb:1,revision:1,setup:1 cochange=diff:40,revision:28,transport:10,index:7,refs:7
 grep.h component=? role=public prefix=grep includes=diff:1 cochange=revision:23,diff:10,transport:4,index:2,refs:2
-hash-lookup.c component=odb role=lib prefix=hash includes=odb:2,index:1 cochange=pack:14,odb:12,diff:1,index:1,merge:1
-hash-lookup.h component=odb role=header prefix=hash-lookup cochange=odb:10,pack:8,diff:1,merge:1,revision:1
-hash.c component=odb role=lib prefix=hash includes=odb:1 cochange=odb:15,diff:2,setup:2,index:1,transport:1
-hash.h component=odb role=header prefix=hash includes=setup:1 cochange=odb:32,pack:11,index:9,diff:7,transport:4
 hashmap.c component=? role=lib prefix=hashmap cochange=diff:33,revision:19,index:17,refs:13,submodule:13
 hashmap.h component=? role=public prefix=hashmap cochange=diff:39,revision:23,index:18,submodule:14,refs:13
 help.c component=? role=lib prefix=help includes=setup:4,index:1,odb:1,refs:1,transport:1 cochange=setup:19,transport:19,diff:9,index:8,odb:7
@@ -218,16 +201,12 @@ lockfile.c component=? role=lib prefix=lockfile includes=setup:1 cochange=refs:1
 lockfile.h component=? role=public prefix=lockfile cochange=index:5,revision:4,diff:3,refs:3,odb:2
 log-tree.c component=revision role=lib prefix=format-patch includes=odb:8,revision:5,diff:3,setup:3,refs:2 cochange=revision:222,diff:112,odb:112,refs:31,transport:16
 log-tree.h component=revision role=header prefix=format-patch cochange=revision:64,diff:11,refs:3,odb:2,transport:2
-loose.c component=odb role=lib prefix=loose includes=odb:5,setup:1 cochange=odb:31,pack:18,setup:7,transport:6,refs:2
-loose.h component=odb role=header prefix=loose cochange=odb:8,setup:3
 ls-refs.c component=refs role=lib prefix=ls-refs includes=setup:3,refs:2,odb:1,transport:1 cochange=refs:26,transport:17,pack:10,revision:5,odb:4
 ls-refs.h component=refs role=header prefix=ls-refs cochange=transport:11,refs:5,submodule:1
 mailinfo.c component=? role=lib prefix=mailinfo includes=setup:2 cochange=transport:5,index:3,notes:3,odb:3,revision:3
 mailinfo.h component=? role=public prefix=mailinfo
 mailmap.c component=? role=lib prefix=mailmap includes=setup:3,odb:2 cochange=setup:13,transport:11,refs:10,index:8,revision:5
 mailmap.h component=? role=public prefix=mailmap cochange=setup:8,revision:4,transport:2,diff:1,index:1
-match-trees.c component=odb role=lib prefix=match-trees includes=odb:5,setup:1 cochange=odb:33,index:15,notes:15,revision:12,pack:10
-match-trees.h component=odb role=header prefix=match-trees cochange=merge:1,odb:1
 mem-pool.c component=? role=lib prefix=mem-pool cochange=index:6
 mem-pool.h component=? role=public prefix=mem-pool cochange=index:4
 merge-blobs.c component=merge role=lib prefix=object-store includes=merge:2,odb:2 cochange=merge:9,notes:3,diff:2,convert:1,odb:1
@@ -254,24 +233,55 @@ notes-utils.c component=notes role=lib prefix=commit includes=setup:2,notes:1,od
 notes-utils.h component=notes role=header prefix=notes includes=notes:1 cochange=notes:17,odb:6
 notes.c component=notes role=lib prefix=notes includes=odb:4,setup:2,notes:1,refs:1 cochange=notes:63,odb:58,revision:41,transport:36,index:24
 notes.h component=notes role=header prefix=notes cochange=notes:55,revision:20,setup:9,odb:3,refs:2
-object-file-convert.c component=odb role=lib prefix=object-file-convert includes=odb:5,setup:1 cochange=odb:8,setup:2,transport:1
-object-file-convert.h component=odb role=header prefix=object-file-convert includes=odb:1 cochange=odb:4
-object-file.c component=odb role=lib prefix=object-file includes=odb:6,index:2,pack:2,setup:2,convert:1 cochange=odb:183,pack:96,index:55,setup:30,transport:27
-object-file.h component=odb role=header prefix=object-file includes=odb:2 cochange=odb:113,pack:30,index:12,notes:5,transport:5
-object-name.c component=odb role=lib prefix=object-name includes=odb:8,setup:5,index:2,revision:2,pack:1 cochange=odb:46,pack:31,revision:23,setup:19,refs:18
-object-name.h component=odb role=header prefix=object-name includes=odb:1 cochange=odb:5,revision:3,refs:2,index:1
-object.c component=odb role=lib prefix=object includes=odb:8,index:1,pack:1 cochange=odb:265,pack:61,revision:55,transport:34,refs:17
-object.h component=odb role=header prefix=object includes=odb:1 cochange=odb:187,revision:54,transport:41,pack:29,refs:20
-odb.c component=odb role=lib prefix=odb includes=odb:7,pack:3,setup:3,index:1,submodule:1 cochange=odb:123,pack:64,setup:13,transport:12,index:8
-odb.h component=odb role=header prefix=odb includes=odb:3 cochange=odb:117,pack:71,transport:16,setup:13,index:10
-oid-array.c component=odb role=lib prefix=oid-array includes=odb:2 cochange=odb:13,pack:10,merge:2,diff:1,revision:1
-oid-array.h component=odb role=header prefix=oid-array includes=odb:1 cochange=odb:3,diff:1,index:1,refs:1,revision:1
-oidmap.c component=odb role=lib prefix=oidmap includes=odb:2 cochange=diff:11,revision:7,odb:6,refs:5,index:4
-oidmap.h component=odb role=header prefix=oidmap includes=odb:1 cochange=odb:6,revision:4,index:2,transport:2,convert:1
-oidset.c component=odb role=lib prefix=oidset includes=odb:1 cochange=odb:17,convert:2,diff:2,transport:2,index:1
-oidset.h component=odb role=header prefix=oidset cochange=odb:17,revision:1,transport:1
-oidtree.c component=odb role=lib prefix=oidtree includes=odb:2 cochange=odb:14,index:3,setup:2,diff:1,merge:1
-oidtree.h component=odb role=header prefix=oidtree includes=odb:2 cochange=odb:9
+odb/alloc.c component=odb role=lib prefix=alloc includes=odb:6,setup:1 cochange=odb:54,revision:8,diff:6,pack:6,index:3
+odb/alloc.h component=odb role=header prefix=alloc cochange=odb:16,refs:1,revision:1
+odb/blob.c component=odb role=lib prefix=object includes=odb:2 cochange=odb:131,transport:12,pack:11,revision:10,refs:5
+odb/blob.h component=odb role=header prefix=blob includes=odb:1 cochange=odb:33,revision:4,pack:3,transport:2
+odb/cbtree.c component=odb role=lib prefix=cbtree includes=odb:1 cochange=odb:9,diff:1,merge:1,pack:1
+odb/cbtree.h component=odb role=header prefix=cbtree cochange=odb:12,pack:3,setup:1,transport:1
+odb/commit-slab-decl.h component=odb role=header prefix=commit-slab cochange=odb:6,revision:1
+odb/commit-slab-impl.h component=odb role=header prefix=commit-slab cochange=odb:7,pack:3,revision:1,setup:1,transport:1
+odb/commit-slab.h component=odb role=header prefix=commit-slab includes=odb:2 cochange=odb:8,revision:2,transport:2,index:1,merge:1
+odb/commit.c component=odb role=lib prefix=commit includes=odb:10,setup:4,revision:3,diff:1,index:1 cochange=odb:403,revision:147,transport:87,pack:57,setup:45
+odb/commit.h component=odb role=header prefix=commit includes=odb:1 cochange=odb:237,revision:205,transport:49,pack:25,notes:22
+odb/fsck.c component=odb role=lib prefix=fsck includes=odb:9,setup:3,convert:1,index:1,pack:1 cochange=odb:113,revision:46,transport:43,pack:20,setup:15
+odb/fsck.h component=odb role=header prefix=fsck includes=odb:2 cochange=odb:50,diff:5,revision:5,transport:5,refs:4
+odb/hash-lookup.c component=odb role=lib prefix=hash includes=odb:2,index:1 cochange=pack:14,odb:12,diff:1,index:1,merge:1
+odb/hash-lookup.h component=odb role=header prefix=hash-lookup cochange=odb:10,pack:8,diff:1,merge:1,revision:1
+odb/hash.c component=odb role=lib prefix=hash includes=odb:1 cochange=odb:15,diff:2,setup:2,index:1,transport:1
+odb/hash.h component=odb role=header prefix=hash includes=setup:1 cochange=odb:32,pack:11,index:9,diff:7,transport:4
+odb/loose.c component=odb role=lib prefix=loose includes=odb:5,setup:1 cochange=odb:31,pack:18,setup:7,transport:6,refs:2
+odb/loose.h component=odb role=header prefix=loose cochange=odb:8,setup:3
+odb/match-trees.c component=odb role=lib prefix=match-trees includes=odb:5,setup:1 cochange=odb:33,index:15,notes:15,revision:12,pack:10
+odb/match-trees.h component=odb role=header prefix=match-trees cochange=merge:1,odb:1
+odb/object-file-convert.c component=odb role=lib prefix=object-file-convert includes=odb:5,setup:1 cochange=odb:8,setup:2,transport:1
+odb/object-file-convert.h component=odb role=header prefix=object-file-convert includes=odb:1 cochange=odb:4
+odb/object-file.c component=odb role=lib prefix=object-file includes=odb:6,index:2,pack:2,setup:2,convert:1 cochange=odb:183,pack:96,index:55,setup:30,transport:27
+odb/object-file.h component=odb role=header prefix=object-file includes=odb:2 cochange=odb:113,pack:30,index:12,notes:5,transport:5
+odb/object-name.c component=odb role=lib prefix=object-name includes=odb:8,setup:5,index:2,revision:2,pack:1 cochange=odb:46,pack:31,revision:23,setup:19,refs:18
+odb/object-name.h component=odb role=header prefix=object-name includes=odb:1 cochange=odb:5,revision:3,refs:2,index:1
+odb/object.c component=odb role=lib prefix=object includes=odb:8,index:1,pack:1 cochange=odb:265,pack:61,revision:55,transport:34,refs:17
+odb/object.h component=odb role=header prefix=object includes=odb:1 cochange=odb:187,revision:54,transport:41,pack:29,refs:20
+odb/odb.c component=odb role=lib prefix=odb includes=odb:7,pack:3,setup:3,index:1,submodule:1 cochange=odb:123,pack:64,setup:13,transport:12,index:8
+odb/odb.h component=odb role=header prefix=odb includes=odb:3 cochange=odb:117,pack:71,transport:16,setup:13,index:10
+odb/oid-array.c component=odb role=lib prefix=oid-array includes=odb:2 cochange=odb:13,pack:10,merge:2,diff:1,revision:1
+odb/oid-array.h component=odb role=header prefix=oid-array includes=odb:1 cochange=odb:3,diff:1,index:1,refs:1,revision:1
+odb/oidmap.c component=odb role=lib prefix=oidmap includes=odb:2 cochange=diff:11,revision:7,odb:6,refs:5,index:4
+odb/oidmap.h component=odb role=header prefix=oidmap includes=odb:1 cochange=odb:6,revision:4,index:2,transport:2,convert:1
+odb/oidset.c component=odb role=lib prefix=oidset includes=odb:1 cochange=odb:17,convert:2,diff:2,transport:2,index:1
+odb/oidset.h component=odb role=header prefix=oidset cochange=odb:17,revision:1,transport:1
+odb/oidtree.c component=odb role=lib prefix=oidtree includes=odb:2 cochange=odb:14,index:3,setup:2,diff:1,merge:1
+odb/oidtree.h component=odb role=header prefix=oidtree includes=odb:2 cochange=odb:9
+odb/replace-object.c component=odb role=lib prefix=refs includes=odb:4,refs:1,setup:1 cochange=odb:8,setup:6,refs:5,pack:3,diff:2
+odb/replace-object.h component=odb role=header prefix=replace-object includes=odb:2,setup:1 cochange=odb:11,setup:9,pack:4,revision:3,merge:1
+odb/tag.c component=odb role=lib prefix=tag includes=odb:7,setup:2,pack:1 cochange=odb:189,transport:36,pack:32,revision:29,refs:14
+odb/tag.h component=odb role=header prefix=tag includes=odb:1 cochange=odb:60,transport:10,revision:8,refs:7,pack:6
+odb/tmp-objdir.c component=odb role=lib prefix=tmp-objdir includes=odb:3,setup:2,index:1 cochange=pack:24,odb:23,setup:8,transport:5,revision:3
+odb/tmp-objdir.h component=odb role=header prefix=tmp-objdir cochange=odb:8,revision:3,setup:1
+odb/tree-walk.c component=odb role=lib prefix=tree-walk includes=odb:4,index:3,setup:1 cochange=odb:70,index:61,diff:31,revision:24,pack:13
+odb/tree-walk.h component=odb role=header prefix=tree-walk includes=odb:1 cochange=odb:64,diff:23,index:23,revision:21,notes:7
+odb/tree.c component=odb role=lib prefix=tree includes=odb:6,setup:2 cochange=odb:212,revision:45,index:36,pack:25,transport:21
+odb/tree.h component=odb role=header prefix=tree includes=odb:1 cochange=odb:75,revision:12,archive:8,index:6,pack:5
 pack-bitmap-write.c component=pack role=lib prefix=pack-bitmap-write includes=odb:7,pack:6,revision:2,setup:2,diff:1 cochange=pack:132,odb:32,revision:27,transport:10,diff:4
 pack-bitmap.c component=pack role=lib prefix=pack-bitmap includes=pack:7,odb:3,revision:3,setup:2,diff:1 cochange=pack:232,revision:30,odb:18,transport:14,refs:7
 pack-bitmap.h component=pack role=header prefix=pack-bitmap includes=pack:2,refs:1 cochange=pack:117,refs:5,odb:2,setup:2,revision:1
@@ -363,8 +373,6 @@ repack-midx.c component=pack role=lib prefix=repack includes=odb:3,pack:3,refs:1
 repack-promisor.c component=pack role=lib prefix=repack-promisor includes=pack:3,setup:1 cochange=pack:8,odb:3,revision:2
 repack.c component=pack role=lib prefix=repack includes=pack:3,index:1,odb:1,setup:1 cochange=pack:31,transport:2,odb:1
 repack.h component=pack role=header prefix=repack includes=revision:1 cochange=pack:28
-replace-object.c component=odb role=lib prefix=refs includes=odb:4,refs:1,setup:1 cochange=odb:8,setup:6,refs:5,pack:3,diff:2
-replace-object.h component=odb role=header prefix=replace-object includes=odb:2,setup:1 cochange=odb:11,setup:9,pack:4,revision:3,merge:1
 replay.c component=? role=lib prefix=replay includes=odb:2,merge:1,refs:1,revision:1,setup:1 cochange=transport:1
 replay.h component=? role=public prefix=replay includes=odb:1
 repo-settings.c component=setup role=lib prefix=repo-settings includes=setup:4,pack:2 cochange=setup:65,pack:17,index:8,transport:8,odb:6
@@ -428,15 +436,11 @@ submodule.c component=submodule role=lib prefix=submodule includes=odb:5,setup:4
 submodule.h component=submodule role=header prefix=submodule cochange=submodule:128,index:22,diff:21,transport:17,setup:6
 symlinks.c component=index role=lib prefix=symlinks includes=index:1,setup:1 cochange=index:23,diff:3,archive:2,convert:1,revision:1
 symlinks.h component=index role=header prefix=symlinks cochange=index:9,diff:1
-tag.c component=odb role=lib prefix=tag includes=odb:7,setup:2,pack:1 cochange=odb:189,transport:36,pack:32,revision:29,refs:14
-tag.h component=odb role=header prefix=tag includes=odb:1 cochange=odb:60,transport:10,revision:8,refs:7,pack:6
 tar.h component=? role=public prefix=tar-tree
 tempfile.c component=? role=lib prefix=tempfile cochange=pack:5,setup:4,index:3,odb:3,revision:3
 tempfile.h component=? role=public prefix=tempfile includes=revision:1 cochange=revision:3,diff:2,index:2,setup:2
 thread-utils.c component=? role=lib prefix=thread-utils cochange=diff:1
 thread-utils.h component=? role=public prefix=thread-utils cochange=transport:1
-tmp-objdir.c component=odb role=lib prefix=tmp-objdir includes=odb:3,setup:2,index:1 cochange=pack:24,odb:23,setup:8,transport:5,revision:3
-tmp-objdir.h component=odb role=header prefix=tmp-objdir cochange=odb:8,revision:3,setup:1
 trace.c component=? role=lib prefix=trace includes=setup:2 cochange=setup:26,transport:13,index:11,odb:4,diff:2
 trace.h component=? role=public prefix=trace cochange=transport:6,index:5,odb:4,pack:3,revision:3
 trace2.c component=? role=lib prefix=trace2 includes=setup:2 cochange=setup:2
@@ -448,10 +452,6 @@ transport-internal.h component=transport role=header prefix=transport includes=t
 transport.c component=transport role=lib prefix=transport includes=transport:12,setup:3,odb:2,refs:2,submodule:1 cochange=transport:482,refs:35,setup:31,submodule:29,revision:21
 transport.h component=transport role=header prefix=transport includes=transport:2,revision:1 cochange=transport:249,submodule:6,odb:4,revision:2,diff:1
 tree-diff.c component=diff role=lib prefix=tree-diff includes=odb:3,diff:2,index:1,setup:1 cochange=diff:115,odb:56,revision:53,index:36,notes:12
-tree-walk.c component=odb role=lib prefix=tree-walk includes=odb:4,index:3,setup:1 cochange=odb:70,index:61,diff:31,revision:24,pack:13
-tree-walk.h component=odb role=header prefix=tree-walk includes=odb:1 cochange=odb:64,diff:23,index:23,revision:21,notes:7
-tree.c component=odb role=lib prefix=tree includes=odb:6,setup:2 cochange=odb:212,revision:45,index:36,pack:25,transport:21
-tree.h component=odb role=header prefix=tree includes=odb:1 cochange=odb:75,revision:12,archive:8,index:6,pack:5
 unicode-width.h component=? role=public prefix=unicode
 unix-socket.c component=? role=lib prefix=unix-socket cochange=diff:3,revision:2,setup:1
 unix-socket.h component=? role=public prefix=unix-socket
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 2699f0b24a..c5b52b6e7a 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -505,10 +505,10 @@ lint-docs-man-section-order: $(LINT_DOCS_MAN_SECTION_ORDER)
 .PHONY: lint-docs-fsck-msgids
 LINT_DOCS_FSCK_MSGIDS = .build/lint-docs/fsck-msgids.ok
 $(LINT_DOCS_FSCK_MSGIDS): lint-fsck-msgids.perl
-$(LINT_DOCS_FSCK_MSGIDS): ../fsck.h fsck-msgids.adoc
+$(LINT_DOCS_FSCK_MSGIDS): ../odb/fsck.h fsck-msgids.adoc
 	$(call mkdir_p_parent_template)
 	$(QUIET_GEN)$(PERL_PATH) lint-fsck-msgids.perl \
-		../fsck.h fsck-msgids.adoc $@
+		../odb/fsck.h fsck-msgids.adoc $@
 lint-docs-fsck-msgids: $(LINT_DOCS_FSCK_MSGIDS)
 
 ## Lint: delimited sections
diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
index 34bfa2e3a9..4b50aaa40e 100644
--- a/Documentation/MyFirstContribution.adoc
+++ b/Documentation/MyFirstContribution.adoc
@@ -428,7 +428,7 @@ require a full format object to be passed.
 Add the following includes:
 
 ----
-#include "commit.h"
+#include "odb/commit.h"
 #include "pretty.h"
 #include "strbuf.h"
 ----
diff --git a/Documentation/MyFirstObjectWalk.adoc b/Documentation/MyFirstObjectWalk.adoc
index 413a9fdb05..87b2433b2c 100644
--- a/Documentation/MyFirstObjectWalk.adoc
+++ b/Documentation/MyFirstObjectWalk.adoc
@@ -779,7 +779,7 @@ be processed in order to populate that list.
 First, add the `struct oidset` and related items we will use to iterate it:
 
 ----
-#include "oidset.h"
+#include "odb/oidset.h"
 
 ...
 
diff --git a/Makefile b/Makefile
index 86297e9459..a95b87d970 100644
--- a/Makefile
+++ b/Makefile
@@ -1103,7 +1103,7 @@ LIB_OBJS += add-interactive.o
 LIB_OBJS += add-patch.o
 LIB_OBJS += advice.o
 LIB_OBJS += alias.o
-LIB_OBJS += alloc.o
+LIB_OBJS += odb/alloc.o
 LIB_OBJS += apply.o
 LIB_OBJS += archive-tar.o
 LIB_OBJS += archive-zip.o
@@ -1112,13 +1112,13 @@ LIB_OBJS += attr.o
 LIB_OBJS += base85.o
 LIB_OBJS += bisect.o
 LIB_OBJS += blame.o
-LIB_OBJS += blob.o
+LIB_OBJS += odb/blob.o
 LIB_OBJS += bloom.o
 LIB_OBJS += branch.o
 LIB_OBJS += bundle-uri.o
 LIB_OBJS += bundle.o
 LIB_OBJS += cache-tree.o
-LIB_OBJS += cbtree.o
+LIB_OBJS += odb/cbtree.o
 LIB_OBJS += chdir-notify.o
 LIB_OBJS += checkout.o
 LIB_OBJS += chunk-format.o
@@ -1127,7 +1127,7 @@ LIB_OBJS += column.o
 LIB_OBJS += combine-diff.o
 LIB_OBJS += commit-graph.o
 LIB_OBJS += commit-reach.o
-LIB_OBJS += commit.o
+LIB_OBJS += odb/commit.o
 LIB_OBJS += common-exit.o
 LIB_OBJS += common-init.o
 LIB_OBJS += compat/nonblock.o
@@ -1172,7 +1172,7 @@ LIB_OBJS += fetch-negotiator.o
 LIB_OBJS += fetch-object-info.o
 LIB_OBJS += fetch-pack.o
 LIB_OBJS += fmt-merge-msg.o
-LIB_OBJS += fsck.o
+LIB_OBJS += odb/fsck.o
 LIB_OBJS += fsmonitor.o
 LIB_OBJS += fsmonitor-ipc.o
 LIB_OBJS += fsmonitor-settings.o
@@ -1181,8 +1181,8 @@ LIB_OBJS += git-zlib.o
 LIB_OBJS += gpg-interface.o
 LIB_OBJS += graph.o
 LIB_OBJS += grep.o
-LIB_OBJS += hash-lookup.o
-LIB_OBJS += hash.o
+LIB_OBJS += odb/hash-lookup.o
+LIB_OBJS += odb/hash.o
 LIB_OBJS += hashmap.o
 LIB_OBJS += help.o
 LIB_OBJS += hex.o
@@ -1200,11 +1200,11 @@ LIB_OBJS += list-objects-filter.o
 LIB_OBJS += list-objects.o
 LIB_OBJS += lockfile.o
 LIB_OBJS += log-tree.o
-LIB_OBJS += loose.o
+LIB_OBJS += odb/loose.o
 LIB_OBJS += ls-refs.o
 LIB_OBJS += mailinfo.o
 LIB_OBJS += mailmap.o
-LIB_OBJS += match-trees.o
+LIB_OBJS += odb/match-trees.o
 LIB_OBJS += mem-pool.o
 LIB_OBJS += merge-blobs.o
 LIB_OBJS += merge-ll.o
@@ -1221,11 +1221,11 @@ LIB_OBJS += notes-cache.o
 LIB_OBJS += notes-merge.o
 LIB_OBJS += notes-utils.o
 LIB_OBJS += notes.o
-LIB_OBJS += object-file-convert.o
-LIB_OBJS += object-file.o
-LIB_OBJS += object-name.o
-LIB_OBJS += object.o
-LIB_OBJS += odb.o
+LIB_OBJS += odb/object-file-convert.o
+LIB_OBJS += odb/object-file.o
+LIB_OBJS += odb/object-name.o
+LIB_OBJS += odb/object.o
+LIB_OBJS += odb/odb.o
 LIB_OBJS += odb/source.o
 LIB_OBJS += odb/source-files.o
 LIB_OBJS += odb/source-inmemory.o
@@ -1233,10 +1233,10 @@ LIB_OBJS += odb/source-loose.o
 LIB_OBJS += odb/source-packed.o
 LIB_OBJS += odb/streaming.o
 LIB_OBJS += odb/transaction.o
-LIB_OBJS += oid-array.o
-LIB_OBJS += oidmap.o
-LIB_OBJS += oidset.o
-LIB_OBJS += oidtree.o
+LIB_OBJS += odb/oid-array.o
+LIB_OBJS += odb/oidmap.o
+LIB_OBJS += odb/oidset.o
+LIB_OBJS += odb/oidtree.o
 LIB_OBJS += organize/gitorganize-format.o
 LIB_OBJS += organize/labeler-protocol.o
 LIB_OBJS += organize/organize.o
@@ -1310,7 +1310,7 @@ LIB_OBJS += repack-filtered.o
 LIB_OBJS += repack-geometry.o
 LIB_OBJS += repack-midx.o
 LIB_OBJS += repack-promisor.o
-LIB_OBJS += replace-object.o
+LIB_OBJS += odb/replace-object.o
 LIB_OBJS += replay.o
 LIB_OBJS += repo-settings.o
 LIB_OBJS += repository.o
@@ -1339,10 +1339,10 @@ LIB_OBJS += sub-process.o
 LIB_OBJS += submodule-config.o
 LIB_OBJS += submodule.o
 LIB_OBJS += symlinks.o
-LIB_OBJS += tag.o
+LIB_OBJS += odb/tag.o
 LIB_OBJS += tempfile.o
 LIB_OBJS += thread-utils.o
-LIB_OBJS += tmp-objdir.o
+LIB_OBJS += odb/tmp-objdir.o
 LIB_OBJS += trace.o
 LIB_OBJS += trace2.o
 LIB_OBJS += trace2/tr2_cfg.o
@@ -1361,8 +1361,8 @@ LIB_OBJS += trailer.o
 LIB_OBJS += transport-helper.o
 LIB_OBJS += transport.o
 LIB_OBJS += tree-diff.o
-LIB_OBJS += tree-walk.o
-LIB_OBJS += tree.o
+LIB_OBJS += odb/tree-walk.o
+LIB_OBJS += odb/tree.o
 LIB_OBJS += unpack-trees.o
 LIB_OBJS += upload-pack.o
 LIB_OBJS += url.o
diff --git a/add-interactive.c b/add-interactive.c
index 3cf8a1dbf8..51ddcc4e87 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -5,7 +5,7 @@
 #include "color.h"
 #include "diffcore.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "preload-index.h"
 #include "read-cache-ll.h"
@@ -17,7 +17,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "prompt.h"
-#include "tree.h"
+#include "odb/tree.h"
 
 void init_add_i_state(struct add_i_state *s, struct repository *r,
 		      struct interactive_options *opts)
diff --git a/add-patch.c b/add-patch.c
index f27edcbe8d..1b4c53e4ce 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -4,14 +4,14 @@
 #include "git-compat-util.h"
 #include "add-patch.h"
 #include "advice.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "config.h"
 #include "diff.h"
 #include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "pager.h"
 #include "read-cache-ll.h"
 #include "repository.h"
diff --git a/apply.c b/apply.c
index f00b7ba4d3..ba486ab51d 100644
--- a/apply.c
+++ b/apply.c
@@ -14,7 +14,7 @@
 #include "abspath.h"
 #include "base85.h"
 #include "config.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "delta.h"
 #include "diff.h"
 #include "dir.h"
@@ -25,8 +25,8 @@
 #include "merge-ll.h"
 #include "lockfile.h"
 #include "name-hash.h"
-#include "object-name.h"
-#include "object-file.h"
+#include "odb/object-name.h"
+#include "odb/object-file.h"
 #include "parse-options.h"
 #include "path.h"
 #include "quote.h"
diff --git a/apply.h b/apply.h
index 5f2f03d3ed..7c22776d41 100644
--- a/apply.h
+++ b/apply.h
@@ -1,7 +1,7 @@
 #ifndef APPLY_H
 #define APPLY_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "lockfile.h"
 #include "string-list.h"
 #include "strmap.h"
diff --git a/archive-tar.c b/archive-tar.c
index 0fc70d13a8..318b9bcc24 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -11,7 +11,7 @@
 #include "hex.h"
 #include "tar.h"
 #include "archive.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
 #include "strbuf.h"
 #include "run-command.h"
diff --git a/archive-zip.c b/archive-zip.c
index 97ea8d60d6..53c50ebc44 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -11,7 +11,7 @@
 #include "git-zlib.h"
 #include "hex.h"
 #include "utf8.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
 #include "strbuf.h"
 #include "userdiff.h"
diff --git a/archive.c b/archive.c
index 59790be986..c0d2e0c44b 100644
--- a/archive.c
+++ b/archive.c
@@ -9,15 +9,15 @@
 #include "gettext.h"
 #include "git-zlib.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "path.h"
 #include "pretty.h"
 #include "setup.h"
 #include "refs.h"
-#include "odb.h"
-#include "commit.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/odb.h"
+#include "odb/commit.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "attr.h"
 #include "archive.h"
 #include "parse-options.h"
diff --git a/attr.c b/attr.c
index 0e63f1b6de..e829149cb4 100644
--- a/attr.c
+++ b/attr.c
@@ -22,11 +22,11 @@
 #include "read-cache-ll.h"
 #include "refs.h"
 #include "revision.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "setup.h"
 #include "thread-utils.h"
-#include "tree-walk.h"
-#include "object-name.h"
+#include "odb/tree-walk.h"
+#include "odb/object-name.h"
 
 char *git_attr_tree;
 
diff --git a/bisect.c b/bisect.c
index d426fcd5a9..2dea7139ad 100644
--- a/bisect.c
+++ b/bisect.c
@@ -3,7 +3,7 @@
 
 #include "git-compat-util.h"
 #include "config.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "environment.h"
 #include "gettext.h"
@@ -15,12 +15,12 @@
 #include "run-command.h"
 #include "log-tree.h"
 #include "bisect.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "strvec.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "commit-reach.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "path.h"
 #include "dir.h"
 
diff --git a/blame.c b/blame.c
index 126e232416..d1cba8811f 100644
--- a/blame.c
+++ b/blame.c
@@ -3,10 +3,10 @@
 
 #include "git-compat-util.h"
 #include "refs.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "cache-tree.h"
 #include "mergesort.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "convert.h"
 #include "diff.h"
 #include "diffcore.h"
@@ -16,11 +16,11 @@
 #include "read-cache.h"
 #include "revision.h"
 #include "setup.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "trace2.h"
 #include "blame.h"
-#include "alloc.h"
-#include "commit-slab.h"
+#include "odb/alloc.h"
+#include "odb/commit-slab.h"
 #include "bloom.h"
 #include "commit-graph.h"
 
diff --git a/blame.h b/blame.h
index 3b34be0e5c..97137099e3 100644
--- a/blame.h
+++ b/blame.h
@@ -1,7 +1,7 @@
 #ifndef BLAME_H
 #define BLAME_H
 
-#include "oidset.h"
+#include "odb/oidset.h"
 #include "xdiff-interface.h"
 #include "prio-queue.h"
 
diff --git a/bloom.c b/bloom.c
index caf22f9831..e61cb05246 100644
--- a/bloom.c
+++ b/bloom.c
@@ -6,10 +6,10 @@
 #include "diffcore.h"
 #include "hashmap.h"
 #include "commit-graph.h"
-#include "commit.h"
-#include "commit-slab.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/commit.h"
+#include "odb/commit-slab.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "config.h"
 #include "repository.h"
 
diff --git a/branch.c b/branch.c
index 22f4f46b96..7593a499a9 100644
--- a/branch.c
+++ b/branch.c
@@ -7,14 +7,14 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "path.h"
 #include "refs.h"
 #include "refspec.h"
 #include "remote.h"
 #include "repository.h"
 #include "sequencer.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "worktree.h"
 #include "submodule-config.h"
 #include "run-command.h"
diff --git a/builtin/add.c b/builtin/add.c
index eab8f03cad..5d6dd91f70 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -14,8 +14,8 @@
 #include "gettext.h"
 #include "pathspec.h"
 #include "run-command.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/transaction.h"
 #include "parse-options.h"
 #include "path.h"
diff --git a/builtin/am.c b/builtin/am.c
index e9623b8307..f138a8fe3d 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -23,11 +23,11 @@
 #include "lockfile.h"
 #include "cache-tree.h"
 #include "refs.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "unpack-trees.h"
 #include "branch.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "preload-index.h"
 #include "sequencer.h"
 #include "revision.h"
diff --git a/builtin/apply.c b/builtin/apply.c
index d642a40251..5fb37cb965 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "apply.h"
 
 static const char * const apply_usage[] = {
diff --git a/builtin/backfill.c b/builtin/backfill.c
index e71e0f4742..3685713205 100644
--- a/builtin/backfill.c
+++ b/builtin/backfill.c
@@ -6,16 +6,16 @@
 #include "config.h"
 #include "parse-options.h"
 #include "repository.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "dir.h"
 #include "environment.h"
 #include "hex.h"
-#include "tree.h"
-#include "tree-walk.h"
-#include "object.h"
-#include "odb.h"
-#include "oid-array.h"
-#include "oidset.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
+#include "odb/object.h"
+#include "odb/odb.h"
+#include "odb/oid-array.h"
+#include "odb/oidset.h"
 #include "promisor-remote.h"
 #include "strmap.h"
 #include "string-list.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 93420ac0ea..a1b7fc9407 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -6,13 +6,13 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "bisect.h"
 #include "refs.h"
 #include "strvec.h"
 #include "run-command.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "path.h"
 #include "prompt.h"
 #include "quote.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index 48d5251c6d..c88fc489f7 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -13,7 +13,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "revision.h"
 #include "quote.h"
@@ -26,13 +26,13 @@
 #include "line-range.h"
 #include "line-log.h"
 #include "progress.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "pager.h"
 #include "blame.h"
 #include "refs.h"
 #include "setup.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "write-or-die.h"
 
 static const char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>");
diff --git a/builtin/branch.c b/builtin/branch.c
index a613148fc7..c50c28c720 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -13,9 +13,9 @@
 #include "editor.h"
 #include "environment.h"
 #include "refs.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "gettext.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "remote.h"
 #include "parse-options.h"
 #include "branch.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index e85e2cfc1b..ccd6b33827 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -18,13 +18,13 @@
 #include "list-objects-filter-options.h"
 #include "parse-options.h"
 #include "userdiff.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "packfile.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "promisor-remote.h"
 #include "mailmap.h"
 #include "write-or-die.h"
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 217d83ea7d..02ff3b4eb5 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -4,7 +4,7 @@
 #include "attr.h"
 #include "environment.h"
 #include "gettext.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "quote.h"
 #include "setup.h"
 #include "parse-options.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 55e3a89a85..2dcebb2cb2 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -6,7 +6,7 @@
 #include "branch.h"
 #include "cache-tree.h"
 #include "checkout.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "config.h"
 #include "diff.h"
 #include "dir.h"
@@ -17,9 +17,9 @@
 #include "merge-ll.h"
 #include "lockfile.h"
 #include "mem-pool.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "parse-options.h"
 #include "path.h"
 #include "preload-index.h"
@@ -36,8 +36,8 @@
 #include "submodule.h"
 #include "symlinks.h"
 #include "trace2.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "unpack-trees.h"
 #include "wt-status.h"
 #include "xdiff-interface.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 5b25cca510..6d6a756a12 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -24,10 +24,10 @@
 #include "parse-options.h"
 #include "refs.h"
 #include "refspec.h"
-#include "object-file.h"
-#include "odb.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "unpack-trees.h"
 #include "transport.h"
 #include "strbuf.h"
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index d62005edc0..0758af3b64 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -1,17 +1,17 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "parse-options.h"
 #include "commit-graph.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "progress.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "strbuf.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "trace2.h"
 
 #define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 30535db131..598ef30372 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -9,10 +9,10 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 
-#include "commit.h"
+#include "odb/commit.h"
 #include "parse-options.h"
 
 static const char * const commit_tree_usage[] = {
diff --git a/builtin/commit.c b/builtin/commit.c
index 28f6174503..e5a6c0b889 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -18,14 +18,14 @@
 #include "editor.h"
 #include "environment.h"
 #include "diff.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "add-interactive.h"
 #include "gettext.h"
 #include "revision.h"
 #include "wt-status.h"
 #include "run-command.h"
 #include "strbuf.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
 #include "preload-index.h"
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index 18f6e33b6f..e256779b1f 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -13,7 +13,7 @@
 #include "parse-options.h"
 #include "quote.h"
 #include "packfile.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 
 static unsigned long garbage;
 static off_t size_garbage;
diff --git a/builtin/describe.c b/builtin/describe.c
index c0abc931a5..75961c5945 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -7,10 +7,10 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "commit.h"
-#include "tag.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
 #include "refs.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "read-cache-ll.h"
 #include "revision.h"
@@ -19,12 +19,12 @@
 #include "setup.h"
 #include "strvec.h"
 #include "run-command.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "list-objects.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "wildmatch.h"
 #include "prio-queue.h"
-#include "oidset.h"
+#include "odb/oidset.h"
 
 #define MAX_TAGS	(FLAG_BITS - 1)
 #define DEFAULT_CANDIDATES 10
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index ea91347ce2..c5b7548e55 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -11,7 +11,7 @@
 #include "config.h"
 #include "diff.h"
 #include "diff-merges.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "preload-index.h"
 #include "revision.h"
 
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index 3db7cffede..a23f444348 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -5,7 +5,7 @@
 #include "config.h"
 #include "diff.h"
 #include "diff-merges.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "preload-index.h"
 #include "revision.h"
 #include "setup.h"
diff --git a/builtin/diff-pairs.c b/builtin/diff-pairs.c
index 71c045331a..315fc7357a 100644
--- a/builtin/diff-pairs.c
+++ b/builtin/diff-pairs.c
@@ -3,9 +3,9 @@
 #include "diff.h"
 #include "diffcore.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
-#include "object.h"
+#include "odb/object.h"
 #include "parse-options.h"
 #include "revision.h"
 #include "strbuf.h"
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 8b8f8b54e4..a3e1e5e020 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -3,14 +3,14 @@
 #include "builtin.h"
 #include "config.h"
 #include "diff.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "gettext.h"
 #include "hex.h"
 #include "log-tree.h"
 #include "read-cache-ll.h"
 #include "revision.h"
-#include "tmp-objdir.h"
-#include "tree.h"
+#include "odb/tmp-objdir.h"
+#include "odb/tree.h"
 
 static struct rev_info log_tree_opt;
 
diff --git a/builtin/diff.c b/builtin/diff.c
index 18b1083e98..c9ccc7e6c5 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -12,9 +12,9 @@
 #include "ewah/ewok.h"
 #include "lockfile.h"
 #include "color.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "gettext.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "diff.h"
 #include "diff-merges.h"
 #include "diffcore.h"
@@ -23,8 +23,8 @@
 #include "revision.h"
 #include "log-tree.h"
 #include "setup.h"
-#include "oid-array.h"
-#include "tree.h"
+#include "odb/oid-array.h"
+#include "odb/tree.h"
 
 #define DIFF_NO_INDEX_EXPLICIT 1
 #define DIFF_NO_INDEX_IMPLICIT 2
diff --git a/builtin/difftool.c b/builtin/difftool.c
index bc7b2ea443..075112d344 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -29,8 +29,8 @@
 #include "strvec.h"
 #include "strbuf.h"
 #include "lockfile.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "dir.h"
 #include "entry.h"
 #include "setup.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 50278bef7a..472877f0e5 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -14,11 +14,11 @@
 #include "hex.h"
 #include "refs.h"
 #include "refspec.h"
-#include "object-file.h"
-#include "odb.h"
-#include "commit.h"
-#include "object.h"
-#include "tag.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
+#include "odb/commit.h"
+#include "odb/object.h"
+#include "odb/tag.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "log-tree.h"
@@ -29,7 +29,7 @@
 #include "parse-options.h"
 #include "quote.h"
 #include "remote.h"
-#include "blob.h"
+#include "odb/blob.h"
 #include "gpg-interface.h"
 
 static const char *const fast_export_usage[] = {
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 4bed9edd7d..1d560d4e71 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -8,10 +8,10 @@
 #include "hex.h"
 #include "config.h"
 #include "lockfile.h"
-#include "object.h"
-#include "blob.h"
-#include "tree.h"
-#include "commit.h"
+#include "odb/object.h"
+#include "odb/blob.h"
+#include "odb/tree.h"
+#include "odb/commit.h"
 #include "delta.h"
 #include "pack.h"
 #include "path.h"
@@ -22,9 +22,9 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "mem-pool.h"
 #include "commit-reach.h"
 #include "khash.h"
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 316badd969..c6ae0197ab 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -4,12 +4,12 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "pkt-line.h"
 #include "fetch-pack.h"
 #include "remote.h"
 #include "connect.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "protocol.h"
 
 static const char fetch_pack_usage[] =
diff --git a/builtin/fetch.c b/builtin/fetch.c
index ab7db2be06..2089e7823e 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -13,11 +13,11 @@
 #include "hex.h"
 #include "refs.h"
 #include "refspec.h"
-#include "object-name.h"
-#include "odb.h"
-#include "oidset.h"
-#include "oid-array.h"
-#include "commit.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/oidset.h"
+#include "odb/oid-array.h"
+#include "odb/commit.h"
 #include "string-list.h"
 #include "remote.h"
 #include "transport.h"
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 4a2fc421db..d3399455ef 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -1,10 +1,10 @@
 #include "builtin.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "config.h"
 #include "environment.h"
 #include "for-each-ref.h"
 #include "gettext.h"
-#include "object.h"
+#include "odb/object.h"
 #include "parse-options.h"
 #include "ref-filter.h"
 #include "strbuf.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index a6c054e45b..3176941c1d 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -2,24 +2,24 @@
 #include "gettext.h"
 #include "hex.h"
 #include "config.h"
-#include "commit.h"
-#include "tree.h"
-#include "blob.h"
-#include "tag.h"
+#include "odb/commit.h"
+#include "odb/tree.h"
+#include "odb/blob.h"
+#include "odb/tag.h"
 #include "refs.h"
 #include "pack.h"
 #include "cache-tree.h"
-#include "fsck.h"
+#include "odb/fsck.h"
 #include "parse-options.h"
 #include "progress.h"
 #include "packfile.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
 #include "path.h"
 #include "read-cache-ll.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "sparse-index.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index de2f9e7fed..f2fdc2c69d 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -26,11 +26,11 @@
 #include "run-command.h"
 #include "sigchain.h"
 #include "strvec.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "commit-graph.h"
 #include "packfile.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "path.h"
 #include "reflog.h"
 #include "rerere.h"
diff --git a/builtin/get-tar-commit-id.c b/builtin/get-tar-commit-id.c
index e4cd1627b4..d78ecd8ab9 100644
--- a/builtin/get-tar-commit-id.c
+++ b/builtin/get-tar-commit-id.c
@@ -2,7 +2,7 @@
  * Copyright (c) 2005, 2006 Rene Scharfe
  */
 #include "builtin.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "tar.h"
 
 static const char builtin_get_tar_commit_id_usage[] =
diff --git a/builtin/grep.c b/builtin/grep.c
index d3d86abe01..d13858caec 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -13,8 +13,8 @@
 #include "gettext.h"
 #include "hex.h"
 #include "config.h"
-#include "tag.h"
-#include "tree-walk.h"
+#include "odb/tag.h"
+#include "odb/tree-walk.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "run-command.h"
@@ -25,11 +25,11 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "odb/source.h"
-#include "oid-array.h"
-#include "oidset.h"
+#include "odb/oid-array.h"
+#include "odb/oidset.h"
 #include "pager.h"
 #include "path.h"
 #include "promisor-remote.h"
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index f306b0643f..335575862c 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -11,9 +11,9 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-file.h"
-#include "odb.h"
-#include "blob.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
+#include "odb/blob.h"
 #include "quote.h"
 #include "parse-options.h"
 #include "setup.h"
diff --git a/builtin/history.c b/builtin/history.c
index 000155ad9c..a2aa224bd1 100644
--- a/builtin/history.c
+++ b/builtin/history.c
@@ -2,7 +2,7 @@
 
 #include "builtin.h"
 #include "cache-tree.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "commit-reach.h"
 #include "config.h"
 #include "editor.h"
@@ -11,7 +11,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "merge-ort.h"
-#include "oidmap.h"
+#include "odb/oidmap.h"
 #include "parse-options.h"
 #include "path.h"
 #include "read-cache.h"
@@ -21,8 +21,8 @@
 #include "revision.h"
 #include "sequencer.h"
 #include "strvec.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "unpack-trees.h"
 #include "wt-status.h"
 
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index bc86925ad0..aa0e04eeee 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -9,24 +9,24 @@
 #include "hex.h"
 #include "pack.h"
 #include "csum-file.h"
-#include "blob.h"
-#include "commit.h"
-#include "tag.h"
-#include "tree.h"
+#include "odb/blob.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
+#include "odb/tree.h"
 #include "progress.h"
-#include "fsck.h"
+#include "odb/fsck.h"
 #include "strbuf.h"
 #include "thread-utils.h"
 #include "packfile.h"
 #include "pack-revindex.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
-#include "oid-array.h"
-#include "oidset.h"
+#include "odb/oid-array.h"
+#include "odb/oidset.h"
 #include "path.h"
-#include "replace-object.h"
-#include "tree-walk.h"
+#include "odb/replace-object.h"
+#include "odb/tree-walk.h"
 #include "promisor-remote.h"
 #include "run-command.h"
 #include "setup.h"
diff --git a/builtin/last-modified.c b/builtin/last-modified.c
index 5478182f2e..e8827b5dc6 100644
--- a/builtin/last-modified.c
+++ b/builtin/last-modified.c
@@ -2,8 +2,8 @@
 #include "bloom.h"
 #include "builtin.h"
 #include "commit-graph.h"
-#include "commit-slab.h"
-#include "commit.h"
+#include "odb/commit-slab.h"
+#include "odb/commit.h"
 #include "config.h"
 #include "diff.h"
 #include "diffcore.h"
@@ -11,8 +11,8 @@
 #include "ewah/ewok.h"
 #include "hashmap.h"
 #include "hex.h"
-#include "object-name.h"
-#include "object.h"
+#include "odb/object-name.h"
+#include "odb/object.h"
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "quote.h"
diff --git a/builtin/log.c b/builtin/log.c
index 350b35c556..ab381e529e 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -14,20 +14,20 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
 #include "pager.h"
 #include "color.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "diff-merges.h"
 #include "revision.h"
 #include "log-tree.h"
-#include "oid-array.h"
-#include "oidset.h"
-#include "tag.h"
+#include "odb/oid-array.h"
+#include "odb/oidset.h"
+#include "odb/tag.h"
 #include "reflog-walk.h"
 #include "patch-ids.h"
 #include "path.h"
@@ -40,15 +40,15 @@
 #include "version.h"
 #include "mailmap.h"
 #include "progress.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "advice.h"
 #include "utf8.h"
 
 #include "commit-reach.h"
 #include "promisor-remote.h"
 #include "range-diff.h"
-#include "tmp-objdir.h"
-#include "tree.h"
+#include "odb/tmp-objdir.h"
+#include "odb/tree.h"
 #include "userdiff.h"
 #include "write-or-die.h"
 
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index b044520f9e..fc3f8f4a72 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -15,7 +15,7 @@
 #include "quote.h"
 #include "dir.h"
 #include "gettext.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "strbuf.h"
 #include "parse-options.h"
 #include "resolve-undo.h"
@@ -26,7 +26,7 @@
 #include "setup.h"
 #include "sparse-index.h"
 #include "submodule.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "hex.h"
 
 
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 46edaffc2e..4f7d1d2b6d 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -10,9 +10,9 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
-#include "odb.h"
-#include "tree.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/tree.h"
 #include "path.h"
 #include "quote.h"
 #include "parse-options.h"
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index a87011c6cd..191e4e7fa0 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -1,11 +1,11 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "config.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "commit-reach.h"
 
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 8fa5765239..22a6862a13 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -5,9 +5,9 @@
 #include "abspath.h"
 #include "diff.h"
 #include "hex.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "config.h"
 #include "gettext.h"
 #include "setup.h"
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 17aa4db37a..2e7bef9ee4 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -2,9 +2,9 @@
 #include "builtin.h"
 #include "advice.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "merge-ort-wrappers.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 
 static const char builtin_merge_recursive_usage[] =
 	"git %s <base>... -- <head> <remote> ...";
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 49f41e520f..27f2944ece 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -2,21 +2,21 @@
 
 #include "builtin.h"
 #include "environment.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 #include "xdiff-interface.h"
 #include "help.h"
 #include "gettext.h"
 #include "hex.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "commit-reach.h"
 #include "merge-ort.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "parse-options.h"
-#include "blob.h"
+#include "odb/blob.h"
 #include "merge-blobs.h"
 #include "quote.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "config.h"
 #include "strvec.h"
 #include "write-or-die.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 5b4eb23a83..56f89b2944 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -18,7 +18,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "lockfile.h"
 #include "repository.h"
@@ -28,7 +28,7 @@
 #include "diff-merges.h"
 #include "refs.h"
 #include "refspec.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diffcore.h"
 #include "path.h"
 #include "revision.h"
@@ -45,7 +45,7 @@
 #include "fmt-merge-msg.h"
 #include "sequencer.h"
 #include "string-list.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "alias.h"
 #include "branch.h"
 #include "commit-reach.h"
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 37c17e6beb..eb25acc4a5 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -4,10 +4,10 @@
 #include "hex.h"
 #include "parse-options.h"
 #include "strbuf.h"
-#include "replace-object.h"
-#include "object-file.h"
-#include "odb.h"
-#include "fsck.h"
+#include "odb/replace-object.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
+#include "odb/fsck.h"
 #include "config.h"
 
 static char const * const builtin_mktag_usage[] = {
diff --git a/builtin/mktree.c b/builtin/mktree.c
index 4084e32476..fc414d5b31 100644
--- a/builtin/mktree.c
+++ b/builtin/mktree.c
@@ -8,10 +8,10 @@
 #include "hex.h"
 #include "quote.h"
 #include "strbuf.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "parse-options.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 
 static struct treeent {
 	unsigned mode;
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index 6e73c85cde..10af1beb5c 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -8,10 +8,10 @@
 #include "midx.h"
 #include "strbuf.h"
 #include "trace2.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "odb/source.h"
 #include "odb/source-files.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "repository.h"
 
 #define BUILTIN_MIDX_WRITE_USAGE \
diff --git a/builtin/mv.c b/builtin/mv.c
index 373d4aeba3..e347c100c0 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -14,7 +14,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "name-hash.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "path.h"
 #include "pathspec.h"
 #include "lockfile.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 60cbbfb4b7..d2870bd37c 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -6,14 +6,14 @@
 #include "gettext.h"
 #include "hex.h"
 #include "config.h"
-#include "commit.h"
-#include "tag.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
 #include "refs.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "pager.h"
 #include "parse-options.h"
-#include "hash-lookup.h"
-#include "commit-slab.h"
+#include "odb/hash-lookup.h"
+#include "odb/commit-slab.h"
 #include "commit-graph.h"
 #include "wildmatch.h"
 #include "mem-pool.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 9f1f0ec840..2cf1437346 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -14,9 +14,9 @@
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "path.h"
 
 #include "pretty.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 1ec5b6f206..3e4c5442dc 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -7,14 +7,14 @@
 #include "hex.h"
 #include "config.h"
 #include "attr.h"
-#include "object.h"
-#include "commit.h"
-#include "tag.h"
+#include "odb/object.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
 #include "delta.h"
 #include "pack.h"
 #include "pack-revindex.h"
 #include "csum-file.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 #include "diff.h"
 #include "revision.h"
 #include "list-objects.h"
@@ -26,16 +26,16 @@
 #include "pack-bitmap.h"
 #include "delta-islands.h"
 #include "reachable.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "strvec.h"
 #include "strmap.h"
 #include "list.h"
 #include "packfile.h"
-#include "object-file.h"
-#include "object-file-convert.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-file-convert.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "dir.h"
 #include "midx.h"
 #include "trace2.h"
@@ -44,8 +44,8 @@
 #include "pack-mtimes.h"
 #include "parse-options.h"
 #include "pkt-line.h"
-#include "blob.h"
-#include "tree.h"
+#include "odb/blob.h"
+#include "odb/tree.h"
 #include "path-walk.h"
 
 /*
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index 86749bb7e7..10e1ce6ab5 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -13,7 +13,7 @@
 #include "hex.h"
 
 #include "packfile.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "strbuf.h"
 
 #define BLKSIZE 512
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 22f36ecf80..e2c1375b41 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -5,7 +5,7 @@
 #include "diff.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "parse-options.h"
 #include "setup.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index 55635a891f..301f59e897 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "dir.h"
 #include "environment.h"
@@ -13,10 +13,10 @@
 #include "path.h"
 #include "progress.h"
 #include "prune-packed.h"
-#include "replace-object.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/replace-object.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "shallow.h"
 
 static const char * const prune_usage[] = {
diff --git a/builtin/pull.c b/builtin/pull.c
index db3ee0aab3..cb3d76cb16 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -15,10 +15,10 @@
 #include "gettext.h"
 #include "hex.h"
 #include "merge.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "run-command.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "remote.h"
 #include "dir.h"
 #include "path.h"
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index e54c0f7fe1..7e37a00d9e 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -2,7 +2,7 @@
 
 #include "builtin.h"
 #include "gettext.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "range-diff.h"
 #include "config.h"
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 999a82ecdf..8898354baa 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -10,10 +10,10 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "object.h"
-#include "object-name.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/object.h"
+#include "odb/object-name.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "parse-options.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 10a306310c..7b8366e5cd 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -20,11 +20,11 @@
 #include "config.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
-#include "object-file.h"
-#include "object-name.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "wt-status.h"
 #include "revision.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 86933d8d7e..5ec79a4595 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -3,25 +3,25 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "commit-reach.h"
 #include "config.h"
 #include "connect.h"
 #include "connected.h"
 #include "environment.h"
 #include "exec-cmd.h"
-#include "fsck.h"
+#include "odb/fsck.h"
 #include "gettext.h"
 #include "gpg-interface.h"
 #include "hex.h"
 #include "hook.h"
 #include "lockfile.h"
-#include "object.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
-#include "oid-array.h"
-#include "oidset.h"
+#include "odb/object.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/oid-array.h"
+#include "odb/oidset.h"
 #include "pack.h"
 #include "packfile.h"
 #include "parse-options.h"
diff --git a/builtin/reflog.c b/builtin/reflog.c
index 1211c58fa4..b709cb0e3c 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -4,7 +4,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "revision.h"
 #include "reachable.h"
 #include "wildmatch.h"
diff --git a/builtin/refs.c b/builtin/refs.c
index 5cd21c25fe..37936353be 100644
--- a/builtin/refs.c
+++ b/builtin/refs.c
@@ -1,6 +1,6 @@
 #include "builtin.h"
 #include "config.h"
-#include "fsck.h"
+#include "odb/fsck.h"
 #include "pack-refs.h"
 #include "parse-options.h"
 #include "refs.h"
diff --git a/builtin/remote.c b/builtin/remote.c
index de989ea3ba..b5b54ded27 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -16,7 +16,7 @@
 #include "rebase.h"
 #include "refs.h"
 #include "refspec.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "strvec.h"
 #include "commit-reach.h"
 #include "progress.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index aed6b2c8de..793226006c 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -18,11 +18,11 @@
 #include "parse-options.h"
 #include "path.h"
 #include "run-command.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
-#include "replace-object.h"
-#include "tag.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/replace-object.h"
+#include "odb/tag.h"
 #include "wildmatch.h"
 
 static const char * const git_replace_usage[] = {
diff --git a/builtin/replay.c b/builtin/replay.c
index 39e3a86f6c..4ea7c42215 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -7,7 +7,7 @@
 #include "builtin.h"
 #include "config.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "refs.h"
 #include "replay.h"
diff --git a/builtin/repo.c b/builtin/repo.c
index 84e012f83f..473072b44d 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -1,11 +1,11 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "environment.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "parse-options.h"
 #include "path.h"
 #include "path-walk.h"
@@ -18,8 +18,8 @@
 #include "strbuf.h"
 #include "string-list.h"
 #include "shallow.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "utf8.h"
 
 #define REPO_INFO_USAGE \
diff --git a/builtin/reset.c b/builtin/reset.c
index 78e69bd84b..55539f565c 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -15,17 +15,17 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "object.h"
+#include "odb/object.h"
 #include "pretty.h"
 #include "refs.h"
 #include "diff.h"
 #include "diffcore.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "branch.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
 #include "repository.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 02818b81c6..0c55dc5b96 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -3,7 +3,7 @@
 
 #include "builtin.h"
 #include "config.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "environment.h"
 #include "gettext.h"
@@ -11,10 +11,10 @@
 #include "revision.h"
 #include "list-objects.h"
 #include "list-objects-filter-options.h"
-#include "object.h"
-#include "object-name.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object.h"
+#include "odb/object-name.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "pack-bitmap.h"
 #include "parse-options.h"
 #include "log-tree.h"
@@ -22,8 +22,8 @@
 #include "bisect.h"
 #include "progress.h"
 #include "reflog-walk.h"
-#include "oidset.h"
-#include "oidmap.h"
+#include "odb/oidset.h"
+#include "odb/oidmap.h"
 #include "packfile.h"
 #include "commit-reach.h"
 #include "quote.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 43693454d5..f3bf7831b7 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -12,14 +12,14 @@
 #include "abspath.h"
 #include "bisect.h"
 #include "config.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "refs.h"
 #include "quote.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
 #include "diff.h"
@@ -32,7 +32,7 @@
 #include "submodule.h"
 #include "commit-reach.h"
 #include "shallow.h"
-#include "object-file-convert.h"
+#include "odb/object-file-convert.h"
 
 #define DO_REVS		1
 #define DO_NOREV	2
diff --git a/builtin/rm.c b/builtin/rm.c
index 081d0bc375..c856b88d09 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -13,9 +13,9 @@
 #include "lockfile.h"
 #include "dir.h"
 #include "gettext.h"
-#include "hash.h"
-#include "tree-walk.h"
-#include "object-name.h"
+#include "odb/hash.h"
+#include "odb/tree-walk.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "read-cache.h"
 
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index d6cdbae472..2597a47bde 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -9,7 +9,7 @@
 #include "send-pack.h"
 #include "quote.h"
 #include "transport.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "gettext.h"
 #include "protocol.h"
 #include "parse-options.h"
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 4c78d2e5ba..cbcf2fb637 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -2,7 +2,7 @@
 
 #include "builtin.h"
 #include "config.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 2435e8aeda..c58abc872f 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -5,17 +5,17 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "pretty.h"
 #include "refs.h"
 #include "color.h"
 #include "strvec.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 
 #include "dir.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "date.h"
 #include "wildmatch.h"
 #include "prio-queue.h"
diff --git a/builtin/show-index.c b/builtin/show-index.c
index 24f0230967..55c3c409ae 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -3,7 +3,7 @@
 
 #include "builtin.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "pack.h"
 #include "parse-options.h"
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index d508441632..e4b186b930 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -5,9 +5,9 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs/refs-internal.h"
-#include "object-name.h"
-#include "odb.h"
-#include "object.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/object.h"
 #include "string-list.h"
 #include "parse-options.h"
 
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index cb4a037b77..e2186fdd33 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -7,8 +7,8 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
-#include "object-file.h"
-#include "object-name.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
 #include "pathspec.h"
diff --git a/builtin/stash.c b/builtin/stash.c
index 72c52571f8..2af975aaff 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -5,9 +5,9 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "refs.h"
 #include "lockfile.h"
@@ -30,8 +30,8 @@
 #include "reflog.h"
 #include "reflog-walk.h"
 #include "add-interactive.h"
-#include "oid-array.h"
-#include "commit.h"
+#include "odb/oid-array.h"
+#include "odb/commit.h"
 
 #define INCLUDE_ALL_FILES 2
 
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index e7cd3225fa..96c83476df 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -26,9 +26,9 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "odb/source.h"
 #include "advice.h"
 #include "branch.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 06c125b53c..e3eee35e88 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -17,21 +17,21 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "path.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "parse-options.h"
 #include "diff.h"
 #include "revision.h"
 #include "gpg-interface.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "column.h"
 #include "ref-filter.h"
 #include "date.h"
 #include "write-or-die.h"
-#include "object-file-convert.h"
+#include "odb/object-file-convert.h"
 #include "trailer.h"
 
 static const char * const git_tag_usage[] = {
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 387389ed49..47f43f5a87 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -3,9 +3,9 @@
 #include "config.h"
 #include "environment.h"
 #include "hex.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 
 static char *create_temp_file(struct object_id *oid)
 {
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 4263edfbec..e5891809dd 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -7,19 +7,19 @@
 #include "gettext.h"
 #include "git-zlib.h"
 #include "hex.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
 #include "odb/transaction.h"
-#include "object.h"
+#include "odb/object.h"
 #include "delta.h"
 #include "pack.h"
-#include "blob.h"
-#include "replace-object.h"
+#include "odb/blob.h"
+#include "odb/replace-object.h"
 #include "strbuf.h"
 #include "progress.h"
 #include "decorate.h"
-#include "fsck.h"
+#include "odb/fsck.h"
 #include "packfile.h"
 
 static int dry_run, quiet, recover, has_errors, strict;
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 241abd4332..992f496efd 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -11,14 +11,14 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "lockfile.h"
 #include "quote.h"
 #include "cache-tree.h"
-#include "tree-walk.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/tree-walk.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/transaction.h"
 #include "refs.h"
 #include "resolve-undo.h"
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 6355c3dd3e..e7ac68f495 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -5,10 +5,10 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "refs.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 
diff --git a/builtin/upload-pack.c b/builtin/upload-pack.c
index 32831fb879..dc37ffb70c 100644
--- a/builtin/upload-pack.c
+++ b/builtin/upload-pack.c
@@ -6,11 +6,11 @@
 #include "pkt-line.h"
 #include "parse-options.h"
 #include "protocol.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "upload-pack.h"
 #include "serve.h"
 #include "setup.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "environment.h"
 
 static const char * const upload_pack_usage[] = {
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 62398acd72..3ec03f016c 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -9,8 +9,8 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-#include "object-name.h"
-#include "commit.h"
+#include "odb/object-name.h"
+#include "odb/commit.h"
 #include "parse-options.h"
 #include "gpg-interface.h"
 
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 4a261b2369..791679a4d8 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -9,8 +9,8 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-#include "tag.h"
-#include "object-name.h"
+#include "odb/tag.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "gpg-interface.h"
 #include "ref-filter.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 654d27c3e1..7c2ed274f9 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -11,8 +11,8 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-file.h"
-#include "object-name.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
 #include "strvec.h"
diff --git a/builtin/write-tree.c b/builtin/write-tree.c
index e3bd1a40db..2e463ab394 100644
--- a/builtin/write-tree.c
+++ b/builtin/write-tree.c
@@ -9,7 +9,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "cache-tree.h"
 #include "parse-options.h"
 
diff --git a/bundle-uri.c b/bundle-uri.c
index 2bb2eb99e4..948265330b 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -14,7 +14,7 @@
 #include "fetch-pack.h"
 #include "remote.h"
 #include "trace2.h"
-#include "odb.h"
+#include "odb/odb.h"
 
 static struct {
 	enum bundle_list_heuristic heuristic;
diff --git a/bundle.c b/bundle.c
index b64716f252..81d241e6d0 100644
--- a/bundle.c
+++ b/bundle.c
@@ -7,10 +7,10 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "repository.h"
-#include "object.h"
-#include "commit.h"
+#include "odb/object.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "revision.h"
 #include "list-objects.h"
diff --git a/cache-tree.c b/cache-tree.c
index d92f513286..1c4295761a 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -5,14 +5,14 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "cache-tree.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/transaction.h"
 #include "read-cache-ll.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "repository.h"
 #include "promisor-remote.h"
 #include "trace.h"
diff --git a/cache-tree.h b/cache-tree.h
index f8bddae523..fbfa3691e1 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -1,8 +1,8 @@
 #ifndef CACHE_TREE_H
 #define CACHE_TREE_H
 
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 
 struct cache_tree;
 struct cache_tree_sub {
diff --git a/checkout.c b/checkout.c
index 1588b116ee..966a70c267 100644
--- a/checkout.c
+++ b/checkout.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "remote.h"
 #include "refspec.h"
 #include "repository.h"
diff --git a/checkout.h b/checkout.h
index 55920e7aeb..718e29080a 100644
--- a/checkout.h
+++ b/checkout.h
@@ -1,7 +1,7 @@
 #ifndef CHECKOUT_H
 #define CHECKOUT_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 /*
  * Check if the branch name uniquely matches a branch name on a remote
diff --git a/chunk-format.c b/chunk-format.c
index 51b5a2c959..08b90762d4 100644
--- a/chunk-format.c
+++ b/chunk-format.c
@@ -5,7 +5,7 @@
 #include "chunk-format.h"
 #include "csum-file.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "trace2.h"
 
 /*
diff --git a/chunk-format.h b/chunk-format.h
index 212a0a6af1..e10fcdbfcb 100644
--- a/chunk-format.h
+++ b/chunk-format.h
@@ -1,7 +1,7 @@
 #ifndef CHUNK_FORMAT_H
 #define CHUNK_FORMAT_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 struct hashfile;
 struct chunkfile;
diff --git a/combine-diff.c b/combine-diff.c
index 717d537688..1c33937f21 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -2,22 +2,22 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "odb.h"
-#include "commit.h"
+#include "odb/odb.h"
+#include "odb/commit.h"
 #include "convert.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "environment.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "quote.h"
 #include "xdiff-interface.h"
 #include "xdiff/xmacros.h"
 #include "log-tree.h"
 #include "refs.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "userdiff.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "revision.h"
 
 static int compare_paths(const struct combine_diff_path *one,
diff --git a/commit-graph.c b/commit-graph.c
index 49e8f63930..abf7c404b3 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -8,24 +8,24 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "packfile.h"
-#include "commit.h"
-#include "object.h"
+#include "odb/commit.h"
+#include "odb/object.h"
 #include "refs.h"
-#include "hash-lookup.h"
+#include "odb/hash-lookup.h"
 #include "commit-graph.h"
-#include "odb.h"
-#include "oid-array.h"
+#include "odb/odb.h"
+#include "odb/oid-array.h"
 #include "path.h"
-#include "alloc.h"
+#include "odb/alloc.h"
 #include "hashmap.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "progress.h"
 #include "bloom.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "shallow.h"
 #include "json-writer.h"
 #include "trace2.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "chunk-format.h"
 
 void git_test_write_commit_graph_or_die(struct odb_source *source)
diff --git a/commit-graph.h b/commit-graph.h
index 13ca4ff010..69ecf99feb 100644
--- a/commit-graph.h
+++ b/commit-graph.h
@@ -1,8 +1,8 @@
 #ifndef COMMIT_GRAPH_H
 #define COMMIT_GRAPH_H
 
-#include "odb.h"
-#include "oidset.h"
+#include "odb/odb.h"
+#include "odb/oidset.h"
 
 #define GIT_TEST_COMMIT_GRAPH "GIT_TEST_COMMIT_GRAPH"
 #define GIT_TEST_COMMIT_GRAPH_DIE_ON_PARSE "GIT_TEST_COMMIT_GRAPH_DIE_ON_PARSE"
diff --git a/commit-reach.c b/commit-reach.c
index b53c6b1cdf..9b4715fd65 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -1,14 +1,14 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "commit-graph.h"
 #include "decorate.h"
 #include "hex.h"
 #include "prio-queue.h"
 #include "ref-filter.h"
 #include "revision.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "commit-reach.h"
 #include "ewah/ewok.h"
 
diff --git a/commit-reach.h b/commit-reach.h
index f908d305b1..5d27ef9889 100644
--- a/commit-reach.h
+++ b/commit-reach.h
@@ -1,8 +1,8 @@
 #ifndef COMMIT_REACH_H
 #define COMMIT_REACH_H
 
-#include "commit.h"
-#include "commit-slab.h"
+#include "odb/commit.h"
+#include "odb/commit-slab.h"
 
 struct commit_list;
 struct ref_filter;
diff --git a/common-init.c b/common-init.c
index d26c9c1f20..7e6b392800 100644
--- a/common-init.c
+++ b/common-init.c
@@ -5,10 +5,10 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "attr.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "parse.h"
 #include "repository.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "setup.h"
 #include "strbuf.h"
 #include "trace2.h"
diff --git a/compat/mingw.c b/compat/mingw.c
index 4c2f26d454..785de5beb7 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -3,7 +3,7 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "alloc.h"
+#include "odb/alloc.h"
 #include "config.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/compat/sha1-chunked.c b/compat/sha1-chunked.c
index 0446f9983f..30a0d96e92 100644
--- a/compat/sha1-chunked.c
+++ b/compat/sha1-chunked.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "hash.h"
+#include "odb/hash.h"
 
 int git_SHA1_Update_Chunked(platform_SHA_CTX *c, const void *data, size_t len)
 {
diff --git a/config.c b/config.c
index 1bdd702e7a..eacc6847a2 100644
--- a/config.c
+++ b/config.c
@@ -25,8 +25,8 @@
 #include "quote.h"
 #include "hashmap.h"
 #include "string-list.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "path.h"
 #include "utf8.h"
 #include "color.h"
diff --git a/connect.c b/connect.c
index feb0420b0f..e54c88f5e2 100644
--- a/connect.c
+++ b/connect.c
@@ -13,7 +13,7 @@
 #include "connect.h"
 #include "url.h"
 #include "string-list.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "path.h"
 #include "transport.h"
 #include "trace2.h"
diff --git a/connected.c b/connected.c
index 929b9bd28d..1aafa86101 100644
--- a/connected.c
+++ b/connected.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "connected.h"
diff --git a/convert.c b/convert.c
index 036506842c..25c800eea2 100644
--- a/convert.c
+++ b/convert.c
@@ -8,7 +8,7 @@
 #include "copy.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "attr.h"
 #include "run-command.h"
 #include "quote.h"
diff --git a/convert.h b/convert.h
index 0a6e4086b8..dc6a49dc7d 100644
--- a/convert.h
+++ b/convert.h
@@ -4,7 +4,7 @@
 #ifndef CONVERT_H
 #define CONVERT_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "string-list.h"
 
 struct index_state;
diff --git a/csum-file.c b/csum-file.c
index fe18ee1de3..483608d1ec 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -11,7 +11,7 @@
 #include "git-compat-util.h"
 #include "csum-file.h"
 #include "git-zlib.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "progress.h"
 
 static void verify_buffer_or_die(struct hashfile *f,
diff --git a/csum-file.h b/csum-file.h
index 6ed74d1637..dd7aeb2813 100644
--- a/csum-file.h
+++ b/csum-file.h
@@ -1,7 +1,7 @@
 #ifndef CSUM_FILE_H
 #define CSUM_FILE_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "write-or-die.h"
 
 struct progress;
diff --git a/decorate.c b/decorate.c
index 9f24925263..262c9198eb 100644
--- a/decorate.c
+++ b/decorate.c
@@ -4,7 +4,7 @@
  */
 
 #include "git-compat-util.h"
-#include "object.h"
+#include "odb/object.h"
 #include "decorate.h"
 
 static unsigned int hash_obj(const struct object *obj, unsigned int n)
diff --git a/delta-islands.c b/delta-islands.c
index e71a7e1c05..0c0d222ab3 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -1,14 +1,14 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "object.h"
-#include "commit.h"
+#include "odb/object.h"
+#include "odb/commit.h"
 #include "gettext.h"
 #include "hex.h"
-#include "tag.h"
-#include "tree.h"
+#include "odb/tag.h"
+#include "odb/tree.h"
 #include "pack.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 #include "diff.h"
 #include "progress.h"
 #include "refs.h"
@@ -16,7 +16,7 @@
 #include "pack-bitmap.h"
 #include "pack-objects.h"
 #include "delta-islands.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "config.h"
 
 KHASH_INIT(str, const char *, void *, 1, kh_str_hash_func, kh_str_hash_equal)
diff --git a/diagnose.c b/diagnose.c
index 5092bf80d3..6858f39f45 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -7,7 +7,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "strvec.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "packfile.h"
 #include "parse-options.h"
 #include "repository.h"
diff --git a/diff-lib.c b/diff-lib.c
index 086476bd77..313b6136b1 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -6,13 +6,13 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "read-cache.h"
 #include "revision.h"
 #include "cache-tree.h"
diff --git a/diff-no-index.c b/diff-no-index.c
index f320424f05..552cd95679 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -9,7 +9,7 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "color.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "gettext.h"
diff --git a/diff.c b/diff.c
index cfe515af4e..22265895a7 100644
--- a/diff.c
+++ b/diff.c
@@ -23,7 +23,7 @@
 #include "color.h"
 #include "run-command.h"
 #include "utf8.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "userdiff.h"
 #include "submodule.h"
 #include "hashmap.h"
@@ -31,17 +31,17 @@
 #include "merge-ll.h"
 #include "string-list.h"
 #include "strvec.h"
-#include "tmp-objdir.h"
+#include "odb/tmp-objdir.h"
 #include "graph.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "packfile.h"
 #include "pager.h"
 #include "parse-options.h"
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
-#include "object-file.h"
-#include "object-name.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
 #include "read-cache-ll.h"
 #include "setup.h"
 #include "strmap.h"
diff --git a/diff.h b/diff.h
index bb5cddaf34..502bf24432 100644
--- a/diff.h
+++ b/diff.h
@@ -4,7 +4,7 @@
 #ifndef DIFF_H
 #define DIFF_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "pathspec.h"
 #include "strbuf.h"
 #include "color.h"
diff --git a/diffcore-break.c b/diffcore-break.c
index b5bcc956cc..70860c8abc 100644
--- a/diffcore-break.c
+++ b/diffcore-break.c
@@ -6,8 +6,8 @@
 
 #include "git-compat-util.h"
 #include "diffcore.h"
-#include "hash.h"
-#include "object.h"
+#include "odb/hash.h"
+#include "odb/object.h"
 #include "promisor-remote.h"
 
 static int should_break(struct repository *r,
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index b0915be86f..f7a745fb49 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -10,7 +10,7 @@
 #include "diffcore.h"
 #include "xdiff-interface.h"
 #include "kwset.h"
-#include "oidset.h"
+#include "odb/oidset.h"
 #include "pretty.h"
 #include "quote.h"
 
diff --git a/diffcore-rename.c b/diffcore-rename.c
index c797d8ed2f..68abf77c4d 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -8,10 +8,10 @@
 #include "git-compat-util.h"
 #include "diff.h"
 #include "diffcore.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "hashmap.h"
 #include "mem-pool.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "progress.h"
 #include "promisor-remote.h"
 #include "string-list.h"
diff --git a/diffcore.h b/diffcore.h
index d75038d1b3..fa6125d0bf 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -4,7 +4,7 @@
 #ifndef DIFFCORE_H
 #define DIFFCORE_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 struct diff_options;
 struct mem_pool;
diff --git a/dir.c b/dir.c
index 95d8a1cce9..c9005a0ac1 100644
--- a/dir.c
+++ b/dir.c
@@ -17,7 +17,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "name-hash.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "path.h"
 #include "refs.h"
 #include "repository.h"
@@ -34,7 +34,7 @@
 #include "submodule-config.h"
 #include "symlinks.h"
 #include "trace2.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "hex.h"
 
  /*
diff --git a/dir.h b/dir.h
index 83e0f648a8..239c7efb1e 100644
--- a/dir.h
+++ b/dir.h
@@ -1,7 +1,7 @@
 #ifndef DIR_H
 #define DIR_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "hashmap.h"
 #include "pathspec.h"
 #include "statinfo.h"
diff --git a/entry.c b/entry.c
index 1c4f0f4407..823a433539 100644
--- a/entry.c
+++ b/entry.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/environment.c b/environment.c
index 76ee65e62b..40b993ec90 100644
--- a/environment.c
+++ b/environment.c
@@ -23,12 +23,12 @@
 #include "ident.h"
 #include "lockfile.h"
 #include "mailmap.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "repository.h"
 #include "config.h"
 #include "refs.h"
 #include "fmt-merge-msg.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "strvec.h"
 #include "pager.h"
 #include "path.h"
diff --git a/fetch-object-info.c b/fetch-object-info.c
index ba7e179c44..30cf131aed 100644
--- a/fetch-object-info.c
+++ b/fetch-object-info.c
@@ -3,8 +3,8 @@
 #include "hex.h"
 #include "pkt-line.h"
 #include "connect.h"
-#include "oid-array.h"
-#include "odb.h"
+#include "odb/oid-array.h"
+#include "odb/odb.h"
 #include "fetch-object-info.h"
 #include "string-list.h"
 
diff --git a/fetch-pack.c b/fetch-pack.c
index 626f799712..b172114879 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -11,8 +11,8 @@
 #include "lockfile.h"
 #include "refs.h"
 #include "pkt-line.h"
-#include "commit.h"
-#include "tag.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
 #include "pack.h"
 #include "sideband.h"
 #include "fetch-pack.h"
@@ -21,15 +21,15 @@
 #include "connect.h"
 #include "trace2.h"
 #include "version.h"
-#include "oid-array.h"
-#include "oidset.h"
+#include "odb/oid-array.h"
+#include "odb/oidset.h"
 #include "packfile.h"
-#include "odb.h"
-#include "object-name.h"
+#include "odb/odb.h"
+#include "odb/object-name.h"
 #include "path.h"
 #include "connected.h"
 #include "fetch-negotiator.h"
-#include "fsck.h"
+#include "odb/fsck.h"
 #include "shallow.h"
 #include "commit-reach.h"
 #include "commit-graph.h"
diff --git a/fetch-pack.h b/fetch-pack.h
index 6d0dec7f41..14e4ba1079 100644
--- a/fetch-pack.h
+++ b/fetch-pack.h
@@ -4,7 +4,7 @@
 #include "string-list.h"
 #include "protocol.h"
 #include "list-objects-filter-options.h"
-#include "oidset.h"
+#include "odb/oidset.h"
 
 struct oid_array;
 
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 14441f23ae..6e11ad0fa9 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -5,13 +5,13 @@
 #include "config.h"
 #include "environment.h"
 #include "refs.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "diff.h"
 #include "diff-merges.h"
 #include "hex.h"
 #include "revision.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "string-list.h"
 #include "branch.h"
 #include "fmt-merge-msg.h"
diff --git a/fsmonitor.h b/fsmonitor.h
index 5195a8624d..59591ee49e 100644
--- a/fsmonitor.h
+++ b/fsmonitor.h
@@ -4,7 +4,7 @@
 #include "fsmonitor-ll.h"
 #include "dir.h"
 #include "fsmonitor-settings.h"
-#include "object.h"
+#include "odb/object.h"
 #include "read-cache-ll.h"
 #include "trace.h"
 
diff --git a/git.c b/git.c
index cd2d325585..619219afef 100644
--- a/git.c
+++ b/git.c
@@ -6,12 +6,12 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "help.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "pager.h"
 #include "read-cache-ll.h"
 #include "run-command.h"
 #include "alias.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "setup.h"
 #include "attr.h"
 #include "shallow.h"
diff --git a/gpg-interface.c b/gpg-interface.c
index 95abf1ef4e..034bed7aaa 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "config.h"
 #include "date.h"
 #include "gettext.h"
diff --git a/graph.c b/graph.c
index 28bef1b88f..66c2be423e 100644
--- a/graph.c
+++ b/graph.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "config.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "color.h"
 #include "graph.h"
 #include "revision.h"
diff --git a/grep.c b/grep.c
index 1d75d31421..5041c388b9 100644
--- a/grep.c
+++ b/grep.c
@@ -5,7 +5,7 @@
 #include "gettext.h"
 #include "grep.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "pretty.h"
 #include "userdiff.h"
 #include "xdiff-interface.h"
diff --git a/help.c b/help.c
index 46241492ce..ccc42f09e0 100644
--- a/help.c
+++ b/help.c
@@ -9,7 +9,7 @@
 #include "run-command.h"
 #include "levenshtein.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "help.h"
 #include "command-list.h"
 #include "string-list.h"
diff --git a/hex.c b/hex.c
index f02832140d..6aabaf45e7 100644
--- a/hex.c
+++ b/hex.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "strbuf.h"
 
diff --git a/hex.h b/hex.h
index f15c7e2220..e6dd268faf 100644
--- a/hex.h
+++ b/hex.h
@@ -1,7 +1,7 @@
 #ifndef HEX_H
 #define HEX_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex-ll.h"
 
 /*
diff --git a/http-backend.c b/http-backend.c
index c7566b1d12..9b7ae96579 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -10,8 +10,8 @@
 #include "repository.h"
 #include "refs.h"
 #include "pkt-line.h"
-#include "object.h"
-#include "tag.h"
+#include "odb/object.h"
+#include "odb/tag.h"
 #include "exec-cmd.h"
 #include "run-command.h"
 #include "string-list.h"
@@ -19,7 +19,7 @@
 #include "setup.h"
 #include "strvec.h"
 #include "packfile.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "protocol.h"
 #include "date.h"
 #include "write-or-die.h"
diff --git a/http-push.c b/http-push.c
index 786a2e9c0d..858aa9db33 100644
--- a/http-push.c
+++ b/http-push.c
@@ -4,9 +4,9 @@
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
-#include "commit.h"
-#include "tag.h"
-#include "blob.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
+#include "odb/blob.h"
 #include "http.h"
 #include "diff.h"
 #include "revision.h"
@@ -15,12 +15,12 @@
 #include "setup.h"
 #include "sigchain.h"
 #include "strvec.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "url.h"
 #include "packfile.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "commit-reach.h"
 
 #ifdef EXPAT_NEEDS_XMLPARSE_H
diff --git a/http-walker.c b/http-walker.c
index abafca84d6..dba84c0ef5 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -9,8 +9,8 @@
 #include "list.h"
 #include "transport.h"
 #include "packfile.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 
 struct alt_base {
 	char *base;
diff --git a/http.c b/http.c
index a0d399b274..81b58bd8d2 100644
--- a/http.c
+++ b/http.c
@@ -19,8 +19,8 @@
 #include "transport.h"
 #include "packfile.h"
 #include "string-list.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "tempfile.h"
 #include "date.h"
 #include "trace2.h"
diff --git a/khash.h b/khash.h
index ff88163177..665ade151f 100644
--- a/khash.h
+++ b/khash.h
@@ -26,7 +26,7 @@
 #ifndef __AC_KHASH_H
 #define __AC_KHASH_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 #define AC_VERSION_KHASH_H "0.2.8"
 
diff --git a/line-log.c b/line-log.c
index 0179f138f7..2c9c11e5d3 100644
--- a/line-log.c
+++ b/line-log.c
@@ -4,10 +4,10 @@
 #include "diffcore.h"
 #include "line-range.h"
 #include "hex.h"
-#include "tag.h"
-#include "tree.h"
+#include "odb/tag.h"
+#include "odb/tree.h"
 #include "diff.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "decorate.h"
 #include "repository.h"
 #include "revision.h"
@@ -17,7 +17,7 @@
 #include "setup.h"
 #include "strvec.h"
 #include "bloom.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 
 static void range_set_grow(struct range_set *rs, size_t extra)
 {
diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h
index 77d7bbc846..96cbe9c89b 100644
--- a/list-objects-filter-options.h
+++ b/list-objects-filter-options.h
@@ -2,7 +2,7 @@
 #define LIST_OBJECTS_FILTER_OPTIONS_H
 
 #include "gettext.h"
-#include "object.h"
+#include "odb/object.h"
 #include "strbuf.h"
 
 struct option;
diff --git a/list-objects-filter.c b/list-objects-filter.c
index c912ff3079..a34e07c061 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -4,15 +4,15 @@
 #include "dir.h"
 #include "gettext.h"
 #include "hex.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "revision.h"
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
-#include "oidmap.h"
-#include "oidset.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/oidmap.h"
+#include "odb/oidset.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 
 /* Remember to update object flag allocation in object.h */
 /*
diff --git a/list-objects.c b/list-objects.c
index 724d723c48..b8a673ed69 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -1,20 +1,20 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "tag.h"
-#include "commit.h"
+#include "odb/tag.h"
+#include "odb/commit.h"
 #include "gettext.h"
 #include "hex.h"
-#include "tree.h"
-#include "blob.h"
+#include "odb/tree.h"
+#include "odb/blob.h"
 #include "diff.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 #include "revision.h"
 #include "list-objects.h"
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
 #include "packfile.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "trace.h"
 #include "environment.h"
 
diff --git a/log-tree.c b/log-tree.c
index 83a3c4bf9b..c9fde242a1 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -3,24 +3,24 @@
 
 #include "git-compat-util.h"
 #include "commit-reach.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "config.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "environment.h"
 #include "hex.h"
-#include "object-name.h"
-#include "object-file.h"
+#include "odb/object-name.h"
+#include "odb/object-file.h"
 #include "repository.h"
-#include "tmp-objdir.h"
-#include "commit.h"
-#include "tag.h"
+#include "odb/tmp-objdir.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
 #include "graph.h"
 #include "log-tree.h"
 #include "merge-ort.h"
 #include "reflog-walk.h"
 #include "refs.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "revision.h"
 #include "string-list.h"
 #include "color.h"
@@ -30,7 +30,7 @@
 #include "help.h"
 #include "range-diff.h"
 #include "strmap.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "wildmatch.h"
 #include "write-or-die.h"
 #include "pager.h"
diff --git a/ls-refs.c b/ls-refs.c
index 9759826ca7..e29ef0947f 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "repository.h"
 #include "refs.h"
diff --git a/mailmap.c b/mailmap.c
index 1386ab208c..558b1972f8 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -2,8 +2,8 @@
 #include "environment.h"
 #include "string-list.h"
 #include "mailmap.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "setup.h"
 #include "config.h"
 
diff --git a/merge-blobs.c b/merge-blobs.c
index 16a75bd1e3..96210edd16 100644
--- a/merge-blobs.c
+++ b/merge-blobs.c
@@ -2,9 +2,9 @@
 
 #include "git-compat-util.h"
 #include "merge-ll.h"
-#include "blob.h"
+#include "odb/blob.h"
 #include "merge-blobs.h"
-#include "odb.h"
+#include "odb/odb.h"
 
 static int fill_mmfile_blob(mmfile_t *f, struct blob *obj)
 {
diff --git a/merge-ort-wrappers.c b/merge-ort-wrappers.c
index 2110844f53..846753abdf 100644
--- a/merge-ort-wrappers.c
+++ b/merge-ort-wrappers.c
@@ -1,16 +1,16 @@
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "lockfile.h"
 #include "merge-ort.h"
 #include "merge-ort-wrappers.h"
 #include "read-cache-ll.h"
 #include "repository.h"
-#include "tag.h"
-#include "tree.h"
+#include "odb/tag.h"
+#include "odb/tree.h"
 
-#include "commit.h"
+#include "odb/commit.h"
 
 static int unclean(struct merge_options *opt, struct tree *head)
 {
diff --git a/merge-ort.c b/merge-ort.c
index c410a5d353..35d30dcf06 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -20,11 +20,11 @@
 #include "git-compat-util.h"
 #include "merge-ort.h"
 
-#include "alloc.h"
+#include "odb/alloc.h"
 #include "advice.h"
 #include "attr.h"
 #include "cache-tree.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "commit-reach.h"
 #include "config.h"
 #include "diff.h"
@@ -35,12 +35,12 @@
 #include "hex.h"
 #include "entry.h"
 #include "merge-ll.h"
-#include "match-trees.h"
+#include "odb/match-trees.h"
 #include "mem-pool.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
-#include "oid-array.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/oid-array.h"
 #include "path.h"
 #include "promisor-remote.h"
 #include "read-cache-ll.h"
@@ -49,7 +49,7 @@
 #include "sparse-index.h"
 #include "strmap.h"
 #include "trace2.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "unpack-trees.h"
 #include "xdiff-interface.h"
 
diff --git a/merge-ort.h b/merge-ort.h
index 6045579825..da1d63131a 100644
--- a/merge-ort.h
+++ b/merge-ort.h
@@ -1,7 +1,7 @@
 #ifndef MERGE_ORT_H
 #define MERGE_ORT_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "strbuf.h"
 
 struct commit;
diff --git a/merge.c b/merge.c
index 0f5e823e63..f46d968b70 100644
--- a/merge.c
+++ b/merge.c
@@ -2,16 +2,16 @@
 
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "lockfile.h"
 #include "merge.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "repository.h"
 #include "run-command.h"
 #include "resolve-undo.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "unpack-trees.h"
 
 static const char *merge_argument(struct commit *commit)
diff --git a/meson.build b/meson.build
index 38ec7d4f40..6586f8ae9f 100644
--- a/meson.build
+++ b/meson.build
@@ -312,7 +312,7 @@ libgit_sources = [
   'add-patch.c',
   'advice.c',
   'alias.c',
-  'alloc.c',
+  'odb/alloc.c',
   'apply.c',
   'archive-tar.c',
   'archive-zip.c',
@@ -321,13 +321,13 @@ libgit_sources = [
   'base85.c',
   'bisect.c',
   'blame.c',
-  'blob.c',
+  'odb/blob.c',
   'bloom.c',
   'branch.c',
   'bundle-uri.c',
   'bundle.c',
   'cache-tree.c',
-  'cbtree.c',
+  'odb/cbtree.c',
   'chdir-notify.c',
   'checkout.c',
   'chunk-format.c',
@@ -336,7 +336,7 @@ libgit_sources = [
   'combine-diff.c',
   'commit-graph.c',
   'commit-reach.c',
-  'commit.c',
+  'odb/commit.c',
   'common-exit.c',
   'common-init.c',
   'compiler-tricks/not-constant.c',
@@ -377,7 +377,7 @@ libgit_sources = [
   'fetch-object-info.c',
   'fetch-pack.c',
   'fmt-merge-msg.c',
-  'fsck.c',
+  'odb/fsck.c',
   'fsmonitor.c',
   'fsmonitor-ipc.c',
   'fsmonitor-settings.c',
@@ -386,8 +386,8 @@ libgit_sources = [
   'gpg-interface.c',
   'graph.c',
   'grep.c',
-  'hash-lookup.c',
-  'hash.c',
+  'odb/hash-lookup.c',
+  'odb/hash.c',
   'hashmap.c',
   'help.c',
   'hex.c',
@@ -405,11 +405,11 @@ libgit_sources = [
   'list-objects.c',
   'lockfile.c',
   'log-tree.c',
-  'loose.c',
+  'odb/loose.c',
   'ls-refs.c',
   'mailinfo.c',
   'mailmap.c',
-  'match-trees.c',
+  'odb/match-trees.c',
   'mem-pool.c',
   'merge-blobs.c',
   'merge-ll.c',
@@ -426,11 +426,11 @@ libgit_sources = [
   'notes-merge.c',
   'notes-utils.c',
   'notes.c',
-  'object-file-convert.c',
-  'object-file.c',
-  'object-name.c',
-  'object.c',
-  'odb.c',
+  'odb/object-file-convert.c',
+  'odb/object-file.c',
+  'odb/object-name.c',
+  'odb/object.c',
+  'odb/odb.c',
   'odb/source.c',
   'odb/source-files.c',
   'odb/source-inmemory.c',
@@ -438,10 +438,10 @@ libgit_sources = [
   'odb/source-packed.c',
   'odb/streaming.c',
   'odb/transaction.c',
-  'oid-array.c',
-  'oidmap.c',
-  'oidset.c',
-  'oidtree.c',
+  'odb/oid-array.c',
+  'odb/oidmap.c',
+  'odb/oidset.c',
+  'odb/oidtree.c',
   'organize/gitorganize-format.c',
   'organize/labeler-protocol.c',
   'organize/organize.c',
@@ -515,7 +515,7 @@ libgit_sources = [
   'repack-geometry.c',
   'repack-midx.c',
   'repack-promisor.c',
-  'replace-object.c',
+  'odb/replace-object.c',
   'replay.c',
   'repo-settings.c',
   'repository.c',
@@ -544,10 +544,10 @@ libgit_sources = [
   'submodule-config.c',
   'submodule.c',
   'symlinks.c',
-  'tag.c',
+  'odb/tag.c',
   'tempfile.c',
   'thread-utils.c',
-  'tmp-objdir.c',
+  'odb/tmp-objdir.c',
   'trace.c',
   'trace2.c',
   'trace2/tr2_cfg.c',
@@ -566,8 +566,8 @@ libgit_sources = [
   'transport-helper.c',
   'transport.c',
   'tree-diff.c',
-  'tree-walk.c',
-  'tree.c',
+  'odb/tree-walk.c',
+  'odb/tree.c',
   'unpack-trees.c',
   'upload-pack.c',
   'url.c',
diff --git a/midx-write.c b/midx-write.c
index 580724d21a..bb4ceaede7 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -4,8 +4,8 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "packfile.h"
-#include "object-file.h"
-#include "hash-lookup.h"
+#include "odb/object-file.h"
+#include "odb/hash-lookup.h"
 #include "midx.h"
 #include "progress.h"
 #include "trace2.h"
diff --git a/midx.c b/midx.c
index 76c3f92cc3..47f67c4295 100644
--- a/midx.c
+++ b/midx.c
@@ -5,7 +5,7 @@
 #include "dir.h"
 #include "hex.h"
 #include "packfile.h"
-#include "hash-lookup.h"
+#include "odb/hash-lookup.h"
 #include "midx.h"
 #include "progress.h"
 #include "trace2.h"
diff --git a/name-hash.c b/name-hash.c
index 83757db874..1464b6d066 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -13,7 +13,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "name-hash.h"
-#include "object.h"
+#include "odb/object.h"
 #include "read-cache-ll.h"
 #include "thread-utils.h"
 #include "trace.h"
diff --git a/negotiator/default.c b/negotiator/default.c
index 19cdf3808c..404db17785 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -2,12 +2,12 @@
 
 #include "git-compat-util.h"
 #include "default.h"
-#include "../commit.h"
+#include "odb/commit.h"
 #include "../fetch-negotiator.h"
 #include "../prio-queue.h"
 #include "../refs.h"
 #include "../repository.h"
-#include "../tag.h"
+#include "odb/tag.h"
 
 /* Remember to update object flag allocation in object.h */
 #define COMMON		(1U << 2)
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index db90fa77b5..e1218d2a93 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -2,13 +2,13 @@
 
 #include "git-compat-util.h"
 #include "skipping.h"
-#include "../commit.h"
+#include "odb/commit.h"
 #include "../fetch-negotiator.h"
 #include "../hex.h"
 #include "../prio-queue.h"
 #include "../refs.h"
 #include "../repository.h"
-#include "../tag.h"
+#include "odb/tag.h"
 
 /* Remember to update object flag allocation in object.h */
 /*
diff --git a/notes-cache.c b/notes-cache.c
index 74cef802bd..abe0964bba 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -2,11 +2,11 @@
 
 #include "git-compat-util.h"
 #include "notes-cache.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "pretty.h"
 #include "repository.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "refs.h"
 #include "strbuf.h"
 
diff --git a/notes-merge.c b/notes-merge.c
index 118cad2518..2b025b6d3d 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -3,12 +3,12 @@
 
 #include "git-compat-util.h"
 #include "advice.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "gettext.h"
 #include "refs.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "path.h"
 #include "repository.h"
 #include "diff.h"
diff --git a/notes-utils.c b/notes-utils.c
index 5c1c75d5b8..b6275dfa26 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "config.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "environment.h"
 #include "gettext.h"
 #include "refs.h"
diff --git a/notes.c b/notes.c
index ec9c2cb150..ef44dae00d 100644
--- a/notes.c
+++ b/notes.c
@@ -6,12 +6,12 @@
 #include "environment.h"
 #include "hex.h"
 #include "notes.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "utf8.h"
 #include "strbuf.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 #include "string-list.h"
 #include "refs.h"
 
diff --git a/alloc.c b/odb/alloc.c
similarity index 95%
rename from alloc.c
rename to odb/alloc.c
index 533a045c2a..e0f0146bf8 100644
--- a/alloc.c
+++ b/odb/alloc.c
@@ -9,13 +9,13 @@
  * for the new allocation is.
  */
 #include "git-compat-util.h"
-#include "object.h"
-#include "blob.h"
-#include "tree.h"
-#include "commit.h"
+#include "odb/object.h"
+#include "odb/blob.h"
+#include "odb/tree.h"
+#include "odb/commit.h"
 #include "repository.h"
-#include "tag.h"
-#include "alloc.h"
+#include "odb/tag.h"
+#include "odb/alloc.h"
 
 #define BLOCKING 1024
 
diff --git a/alloc.h b/odb/alloc.h
similarity index 100%
rename from alloc.h
rename to odb/alloc.h
diff --git a/blob.c b/odb/blob.c
similarity index 89%
rename from blob.c
rename to odb/blob.c
index 3fb2922b1a..cd4b34a2b3 100644
--- a/blob.c
+++ b/odb/blob.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
-#include "blob.h"
-#include "alloc.h"
+#include "odb/blob.h"
+#include "odb/alloc.h"
 
 const char *blob_type = "blob";
 
diff --git a/blob.h b/odb/blob.h
similarity index 96%
rename from blob.h
rename to odb/blob.h
index 74555c90c4..cebe385c9b 100644
--- a/blob.h
+++ b/odb/blob.h
@@ -1,7 +1,7 @@
 #ifndef BLOB_H
 #define BLOB_H
 
-#include "object.h"
+#include "odb/object.h"
 
 extern const char *blob_type;
 
diff --git a/cbtree.c b/odb/cbtree.c
similarity index 99%
rename from cbtree.c
rename to odb/cbtree.c
index 8f5edbb80a..6f1699385e 100644
--- a/cbtree.c
+++ b/odb/cbtree.c
@@ -5,7 +5,7 @@
  * git clone https://github.com/agl/critbit.git
  */
 #include "git-compat-util.h"
-#include "cbtree.h"
+#include "odb/cbtree.h"
 
 static inline uint8_t *cb_node_key(struct cb_tree *t, struct cb_node *node)
 {
diff --git a/cbtree.h b/odb/cbtree.h
similarity index 100%
rename from cbtree.h
rename to odb/cbtree.h
diff --git a/commit-slab-decl.h b/odb/commit-slab-decl.h
similarity index 100%
rename from commit-slab-decl.h
rename to odb/commit-slab-decl.h
diff --git a/commit-slab-impl.h b/odb/commit-slab-impl.h
similarity index 100%
rename from commit-slab-impl.h
rename to odb/commit-slab-impl.h
diff --git a/commit-slab.h b/odb/commit-slab.h
similarity index 97%
rename from commit-slab.h
rename to odb/commit-slab.h
index 8e72a30536..8a736bdf72 100644
--- a/commit-slab.h
+++ b/odb/commit-slab.h
@@ -1,8 +1,8 @@
 #ifndef COMMIT_SLAB_H
 #define COMMIT_SLAB_H
 
-#include "commit-slab-decl.h"
-#include "commit-slab-impl.h"
+#include "odb/commit-slab-decl.h"
+#include "odb/commit-slab-impl.h"
 
 /*
  * define_commit_slab(slabname, elemtype) creates boilerplate code to define
diff --git a/commit.c b/odb/commit.c
similarity index 99%
rename from commit.c
rename to odb/commit.c
index ad26f0b40a..d0e036876c 100644
--- a/commit.c
+++ b/odb/commit.c
@@ -1,36 +1,36 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "tag.h"
-#include "commit.h"
+#include "odb/tag.h"
+#include "odb/commit.h"
 #include "commit-graph.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "repository.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "utf8.h"
 #include "diff.h"
 #include "revision.h"
 #include "notes.h"
-#include "alloc.h"
+#include "odb/alloc.h"
 #include "gpg-interface.h"
 #include "mergesort.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "prio-queue.h"
-#include "hash-lookup.h"
+#include "odb/hash-lookup.h"
 #include "wt-status.h"
 #include "advice.h"
 #include "refs.h"
 #include "commit-reach.h"
 #include "setup.h"
 #include "shallow.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "hook.h"
 #include "parse.h"
-#include "object-file.h"
-#include "object-file-convert.h"
+#include "odb/object-file.h"
+#include "odb/object-file-convert.h"
 
 static struct commit_extra_header *read_commit_extra_header_lines(const char *buf, size_t len, const char **);
 
diff --git a/commit.h b/odb/commit.h
similarity index 99%
rename from commit.h
rename to odb/commit.h
index 1061ed791b..a93c0f8d65 100644
--- a/commit.h
+++ b/odb/commit.h
@@ -1,7 +1,7 @@
 #ifndef COMMIT_H
 #define COMMIT_H
 
-#include "object.h"
+#include "odb/object.h"
 #include "add-interactive.h"
 
 struct signature_check;
diff --git a/fsck.c b/odb/fsck.c
similarity index 99%
rename from fsck.c
rename to odb/fsck.c
index 94c8651c7d..e76779109a 100644
--- a/fsck.c
+++ b/odb/fsck.c
@@ -3,21 +3,21 @@
 #include "dir.h"
 #include "environment.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "path.h"
 #include "repository.h"
-#include "object.h"
+#include "odb/object.h"
 #include "attr.h"
-#include "blob.h"
-#include "tree.h"
-#include "tree-walk.h"
-#include "commit.h"
-#include "tag.h"
-#include "fsck.h"
+#include "odb/blob.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
+#include "odb/fsck.h"
 #include "refs.h"
 #include "url.h"
 #include "utf8.h"
-#include "oidset.h"
+#include "odb/oidset.h"
 #include "packfile.h"
 #include "submodule-config.h"
 #include "config.h"
diff --git a/fsck.h b/odb/fsck.h
similarity index 99%
rename from fsck.h
rename to odb/fsck.h
index e77935c8a9..1e3fc862de 100644
--- a/fsck.h
+++ b/odb/fsck.h
@@ -1,8 +1,8 @@
 #ifndef GIT_FSCK_H
 #define GIT_FSCK_H
 
-#include "object.h"
-#include "oidset.h"
+#include "odb/object.h"
+#include "odb/oidset.h"
 
 enum fsck_msg_type {
 	/* for internal use only */
diff --git a/hash-lookup.c b/odb/hash-lookup.c
similarity index 98%
rename from hash-lookup.c
rename to odb/hash-lookup.c
index 5f808caa51..cf2d4a0245 100644
--- a/hash-lookup.c
+++ b/odb/hash-lookup.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "hash.h"
-#include "hash-lookup.h"
+#include "odb/hash.h"
+#include "odb/hash-lookup.h"
 #include "read-cache-ll.h"
 
 static uint32_t take2(const struct object_id *oid, size_t ofs)
diff --git a/hash-lookup.h b/odb/hash-lookup.h
similarity index 100%
rename from hash-lookup.h
rename to odb/hash-lookup.h
diff --git a/hash.c b/odb/hash.c
similarity index 99%
rename from hash.c
rename to odb/hash.c
index 82f7e24404..e02dcea558 100644
--- a/hash.c
+++ b/odb/hash.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 
 static const struct object_id empty_tree_oid = {
diff --git a/hash.h b/odb/hash.h
similarity index 100%
rename from hash.h
rename to odb/hash.h
diff --git a/loose.c b/odb/loose.c
similarity index 98%
rename from loose.c
rename to odb/loose.c
index aa3cb1b4fc..58af1f7910 100644
--- a/loose.c
+++ b/odb/loose.c
@@ -1,16 +1,16 @@
 #include "git-compat-util.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "path.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/source-files.h"
 #include "hex.h"
 #include "repository.h"
 #include "wrapper.h"
 #include "gettext.h"
-#include "loose.h"
+#include "odb/loose.h"
 #include "lockfile.h"
-#include "oidtree.h"
+#include "odb/oidtree.h"
 
 static const char *loose_object_header = "# loose-object-idx\n";
 
diff --git a/loose.h b/odb/loose.h
similarity index 100%
rename from loose.h
rename to odb/loose.h
diff --git a/match-trees.c b/odb/match-trees.c
similarity index 98%
rename from match-trees.c
rename to odb/match-trees.c
index 2a43c0fa1a..4062373e11 100644
--- a/match-trees.c
+++ b/odb/match-trees.c
@@ -2,12 +2,12 @@
 
 #include "git-compat-util.h"
 #include "hex.h"
-#include "match-trees.h"
+#include "odb/match-trees.h"
 #include "strbuf.h"
-#include "tree.h"
-#include "tree-walk.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "repository.h"
 
 static int score_missing(unsigned mode)
diff --git a/match-trees.h b/odb/match-trees.h
similarity index 100%
rename from match-trees.h
rename to odb/match-trees.h
diff --git a/object-file-convert.c b/odb/object-file-convert.c
similarity index 98%
rename from object-file-convert.c
rename to odb/object-file-convert.c
index 63ee18630b..cad75963f7 100644
--- a/object-file-convert.c
+++ b/odb/object-file-convert.c
@@ -5,12 +5,12 @@
 #include "strbuf.h"
 #include "hex.h"
 #include "repository.h"
-#include "hash.h"
-#include "object.h"
-#include "loose.h"
-#include "commit.h"
+#include "odb/hash.h"
+#include "odb/object.h"
+#include "odb/loose.h"
+#include "odb/commit.h"
 #include "gpg-interface.h"
-#include "object-file-convert.h"
+#include "odb/object-file-convert.h"
 
 int repo_oid_to_algop(struct repository *repo, const struct object_id *srcoid,
 		      const struct git_hash_algo *to, struct object_id *dest)
diff --git a/object-file-convert.h b/odb/object-file-convert.h
similarity index 96%
rename from object-file-convert.h
rename to odb/object-file-convert.h
index 9b3cc5e533..a9c454e76e 100644
--- a/object-file-convert.h
+++ b/odb/object-file-convert.h
@@ -5,7 +5,7 @@ struct repository;
 struct object_id;
 struct git_hash_algo;
 struct strbuf;
-#include "object.h"
+#include "odb/object.h"
 
 int repo_oid_to_algop(struct repository *repo, const struct object_id *src,
 		      const struct git_hash_algo *to, struct object_id *dest);
diff --git a/object-file.c b/odb/object-file.c
similarity index 99%
rename from object-file.c
rename to odb/object-file.c
index ec35c318bc..c4841cc289 100644
--- a/object-file.c
+++ b/odb/object-file.c
@@ -13,13 +13,13 @@
 #include "convert.h"
 #include "dir.h"
 #include "environment.h"
-#include "fsck.h"
+#include "odb/fsck.h"
 #include "gettext.h"
 #include "hex.h"
-#include "loose.h"
-#include "object-file-convert.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/loose.h"
+#include "odb/object-file-convert.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
 #include "odb/transaction.h"
 #include "pack.h"
@@ -29,7 +29,7 @@
 #include "setup.h"
 #include "strvec.h"
 #include "tempfile.h"
-#include "tmp-objdir.h"
+#include "odb/tmp-objdir.h"
 
 static int get_conv_flags(unsigned flags)
 {
diff --git a/object-file.h b/odb/object-file.h
similarity index 99%
rename from object-file.h
rename to odb/object-file.h
index 805f2cfa28..5e9b61fe17 100644
--- a/object-file.h
+++ b/odb/object-file.h
@@ -2,8 +2,8 @@
 #define OBJECT_FILE_H
 
 #include "git-zlib.h"
-#include "object.h"
-#include "odb.h"
+#include "odb/object.h"
+#include "odb/odb.h"
 #include "odb/source-loose.h"
 #include "odb/transaction.h"
 
diff --git a/object-name.c b/odb/object-name.c
similarity index 99%
rename from object-name.c
rename to odb/object-name.c
index 83efba0ba6..98c88e7337 100644
--- a/object-name.c
+++ b/odb/object-name.c
@@ -2,21 +2,21 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "tag.h"
-#include "commit.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tag.h"
+#include "odb/commit.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "refs.h"
 #include "remote.h"
 #include "dir.h"
-#include "odb.h"
-#include "oid-array.h"
+#include "odb/odb.h"
+#include "odb/oid-array.h"
 #include "pretty.h"
 #include "read-cache-ll.h"
 #include "repo-settings.h"
@@ -25,7 +25,7 @@
 #include "midx.h"
 #include "commit-reach.h"
 #include "date.h"
-#include "object-file-convert.h"
+#include "odb/object-file-convert.h"
 #include "prio-queue.h"
 
 static int get_oid_oneline(struct repository *r, const char *, struct object_id *,
diff --git a/object-name.h b/odb/object-name.h
similarity index 99%
rename from object-name.h
rename to odb/object-name.h
index 167a9154ea..ecc161a086 100644
--- a/object-name.h
+++ b/odb/object-name.h
@@ -1,7 +1,7 @@
 #ifndef OBJECT_NAME_H
 #define OBJECT_NAME_H
 
-#include "object.h"
+#include "odb/object.h"
 #include "strbuf.h"
 
 struct object_id;
diff --git a/object.c b/odb/object.c
similarity index 98%
rename from object.c
rename to odb/object.c
index 23b84aa7e2..8a34e52eca 100644
--- a/object.c
+++ b/odb/object.c
@@ -3,16 +3,16 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object.h"
-#include "replace-object.h"
-#include "object-file.h"
+#include "odb/object.h"
+#include "odb/replace-object.h"
+#include "odb/object-file.h"
 #include "odb/streaming.h"
-#include "blob.h"
+#include "odb/blob.h"
 #include "statinfo.h"
-#include "tree.h"
-#include "commit.h"
-#include "tag.h"
-#include "alloc.h"
+#include "odb/tree.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
+#include "odb/alloc.h"
 #include "commit-graph.h"
 
 unsigned int get_max_object_index(const struct repository *repo)
diff --git a/object.h b/odb/object.h
similarity index 99%
rename from object.h
rename to odb/object.h
index 8fb03ff90a..8070b40b5e 100644
--- a/object.h
+++ b/odb/object.h
@@ -1,7 +1,7 @@
 #ifndef OBJECT_H
 #define OBJECT_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 struct buffer_slab;
 struct repository;
diff --git a/odb.c b/odb/odb.c
similarity index 99%
rename from odb.c
rename to odb/odb.c
index bd02d8ad54..ffa2881e9f 100644
--- a/odb.c
+++ b/odb/odb.c
@@ -8,24 +8,24 @@
 #include "hex.h"
 #include "khash.h"
 #include "lockfile.h"
-#include "loose.h"
+#include "odb/loose.h"
 #include "midx.h"
-#include "object-file-convert.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file-convert.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "odb/source-inmemory.h"
 #include "packfile.h"
 #include "path.h"
 #include "promisor-remote.h"
 #include "quote.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 #include "run-command.h"
 #include "setup.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "submodule.h"
-#include "tmp-objdir.h"
+#include "odb/tmp-objdir.h"
 #include "trace2.h"
 #include "write-or-die.h"
 
diff --git a/odb.h b/odb/odb.h
similarity index 99%
rename from odb.h
rename to odb/odb.h
index 8eb4e85d64..476660a706 100644
--- a/odb.h
+++ b/odb/odb.h
@@ -1,9 +1,9 @@
 #ifndef ODB_H
 #define ODB_H
 
-#include "object.h"
-#include "oidset.h"
-#include "oidmap.h"
+#include "odb/object.h"
+#include "odb/oidset.h"
+#include "odb/oidmap.h"
 #include "string-list.h"
 #include "thread-utils.h"
 
diff --git a/oid-array.c b/odb/oid-array.c
similarity index 97%
rename from oid-array.c
rename to odb/oid-array.c
index 9cac974395..15425abc3f 100644
--- a/oid-array.c
+++ b/odb/oid-array.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "oid-array.h"
-#include "hash-lookup.h"
+#include "odb/oid-array.h"
+#include "odb/hash-lookup.h"
 
 void oid_array_append(struct oid_array *array, const struct object_id *oid)
 {
diff --git a/oid-array.h b/odb/oid-array.h
similarity index 99%
rename from oid-array.h
rename to odb/oid-array.h
index f60f9af674..fdde085587 100644
--- a/oid-array.h
+++ b/odb/oid-array.h
@@ -1,7 +1,7 @@
 #ifndef OID_ARRAY_H
 #define OID_ARRAY_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 /**
  * The API provides storage and manipulation of sets of object identifiers.
diff --git a/oidmap.c b/odb/oidmap.c
similarity index 97%
rename from oidmap.c
rename to odb/oidmap.c
index a1ef53577f..80c5605bb6 100644
--- a/oidmap.c
+++ b/odb/oidmap.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
-#include "hash.h"
-#include "oidmap.h"
+#include "odb/hash.h"
+#include "odb/oidmap.h"
 
 static int oidmap_neq(const void *hashmap_cmp_fn_data UNUSED,
 		      const struct hashmap_entry *e1,
diff --git a/oidmap.h b/odb/oidmap.h
similarity index 99%
rename from oidmap.h
rename to odb/oidmap.h
index acddcaecdd..f0cdebf688 100644
--- a/oidmap.h
+++ b/odb/oidmap.h
@@ -1,7 +1,7 @@
 #ifndef OIDMAP_H
 #define OIDMAP_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "hashmap.h"
 
 /*
diff --git a/oidset.c b/odb/oidset.c
similarity index 99%
rename from oidset.c
rename to odb/oidset.c
index c8ff0b385c..c37bb183eb 100644
--- a/oidset.c
+++ b/odb/oidset.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "oidset.h"
+#include "odb/oidset.h"
 #include "hex.h"
 #include "strbuf.h"
 
diff --git a/oidset.h b/odb/oidset.h
similarity index 100%
rename from oidset.h
rename to odb/oidset.h
diff --git a/oidtree.c b/odb/oidtree.c
similarity index 98%
rename from oidtree.c
rename to odb/oidtree.c
index e43f18026e..b1f4c1d232 100644
--- a/oidtree.c
+++ b/odb/oidtree.c
@@ -3,8 +3,8 @@
  * May be used to replace oid-array for prefix (abbreviation) matches
  */
 #include "git-compat-util.h"
-#include "oidtree.h"
-#include "hash.h"
+#include "odb/oidtree.h"
+#include "odb/hash.h"
 
 struct oidtree_node {
 	struct cb_node base;
diff --git a/oidtree.h b/odb/oidtree.h
similarity index 97%
rename from oidtree.h
rename to odb/oidtree.h
index baa5a436ea..41d241a5de 100644
--- a/oidtree.h
+++ b/odb/oidtree.h
@@ -1,8 +1,8 @@
 #ifndef OIDTREE_H
 #define OIDTREE_H
 
-#include "cbtree.h"
-#include "hash.h"
+#include "odb/cbtree.h"
+#include "odb/hash.h"
 #include "mem-pool.h"
 
 /*
diff --git a/replace-object.c b/odb/replace-object.c
similarity index 96%
rename from replace-object.c
rename to odb/replace-object.c
index 03d0f1f083..32d778f55e 100644
--- a/replace-object.c
+++ b/odb/replace-object.c
@@ -1,12 +1,12 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
-#include "oidmap.h"
-#include "odb.h"
-#include "replace-object.h"
+#include "odb/oidmap.h"
+#include "odb/odb.h"
+#include "odb/replace-object.h"
 #include "refs.h"
 #include "repository.h"
-#include "commit.h"
+#include "odb/commit.h"
 
 static int register_replace_ref(const struct reference *ref, void *cb_data)
 {
diff --git a/replace-object.h b/odb/replace-object.h
similarity index 97%
rename from replace-object.h
rename to odb/replace-object.h
index 4c9f2a2383..d7139028a3 100644
--- a/replace-object.h
+++ b/odb/replace-object.h
@@ -1,9 +1,9 @@
 #ifndef REPLACE_OBJECT_H
 #define REPLACE_OBJECT_H
 
-#include "oidmap.h"
+#include "odb/oidmap.h"
 #include "repository.h"
-#include "odb.h"
+#include "odb/odb.h"
 
 struct replace_object {
 	struct oidmap_entry original;
diff --git a/odb/source-files.c b/odb/source-files.c
index 4f8e7ad7e3..279a2ccab6 100644
--- a/odb/source-files.c
+++ b/odb/source-files.c
@@ -1,12 +1,12 @@
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "blob.h"
+#include "odb/blob.h"
 #include "chdir-notify.h"
 #include "config.h"
 #include "gettext.h"
 #include "lockfile.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/source.h"
 #include "odb/source-files.h"
 #include "odb/source-loose.h"
@@ -19,7 +19,7 @@
 #include "strbuf.h"
 #include "string-list.h"
 #include "strvec.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "write-or-die.h"
 
 static void odb_source_files_reparent(const char *name UNUSED,
diff --git a/odb/source-inmemory.c b/odb/source-inmemory.c
index 3e71611b8e..288b51848e 100644
--- a/odb/source-inmemory.c
+++ b/odb/source-inmemory.c
@@ -1,9 +1,9 @@
 #include "git-compat-util.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/source-inmemory.h"
 #include "odb/streaming.h"
-#include "oidtree.h"
+#include "odb/oidtree.h"
 #include "repository.h"
 
 struct inmemory_object {
diff --git a/odb/source-loose.c b/odb/source-loose.c
index a292eb7efc..2b073d2a22 100644
--- a/odb/source-loose.c
+++ b/odb/source-loose.c
@@ -3,14 +3,14 @@
 #include "chdir-notify.h"
 #include "gettext.h"
 #include "hex.h"
-#include "loose.h"
-#include "object-file.h"
-#include "object-file-convert.h"
-#include "odb.h"
+#include "odb/loose.h"
+#include "odb/object-file.h"
+#include "odb/object-file-convert.h"
+#include "odb/odb.h"
 #include "odb/source-files.h"
 #include "odb/source-loose.h"
 #include "odb/streaming.h"
-#include "oidtree.h"
+#include "odb/oidtree.h"
 #include "path.h"
 #include "repository.h"
 #include "strbuf.h"
diff --git a/odb/source.c b/odb/source.c
index 30188b806d..2a2e1d0060 100644
--- a/odb/source.c
+++ b/odb/source.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "odb/source-files.h"
 #include "odb/source.h"
 #include "packfile.h"
diff --git a/odb/source.h b/odb/source.h
index 4bc037b8d6..8f063363cb 100644
--- a/odb/source.h
+++ b/odb/source.h
@@ -1,8 +1,8 @@
 #ifndef ODB_SOURCE_H
 #define ODB_SOURCE_H
 
-#include "object.h"
-#include "odb.h"
+#include "odb/object.h"
+#include "odb/odb.h"
 #include "odb/transaction.h"
 
 enum odb_source_type {
diff --git a/odb/streaming.c b/odb/streaming.c
index 20531e864c..c3a06f5622 100644
--- a/odb/streaming.c
+++ b/odb/streaming.c
@@ -6,10 +6,10 @@
 #include "convert.h"
 #include "environment.h"
 #include "repository.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "odb/source.h"
 #include "odb/streaming.h"
-#include "replace-object.h"
+#include "odb/replace-object.h"
 
 #define FILTER_BUFFER (1024*16)
 
diff --git a/odb/streaming.h b/odb/streaming.h
index c023671780..552239e80e 100644
--- a/odb/streaming.h
+++ b/odb/streaming.h
@@ -4,8 +4,8 @@
 #ifndef STREAMING_H
 #define STREAMING_H 1
 
-#include "object.h"
-#include "odb.h"
+#include "odb/object.h"
+#include "odb/odb.h"
 
 struct object_database;
 struct odb_read_stream;
diff --git a/tag.c b/odb/tag.c
similarity index 97%
rename from tag.c
rename to odb/tag.c
index 1a00ded6eb..7be23b04c1 100644
--- a/tag.c
+++ b/odb/tag.c
@@ -2,13 +2,13 @@
 
 #include "git-compat-util.h"
 #include "environment.h"
-#include "tag.h"
-#include "object-name.h"
-#include "odb.h"
-#include "commit.h"
-#include "tree.h"
-#include "blob.h"
-#include "alloc.h"
+#include "odb/tag.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/commit.h"
+#include "odb/tree.h"
+#include "odb/blob.h"
+#include "odb/alloc.h"
 #include "gpg-interface.h"
 #include "hex.h"
 #include "packfile.h"
diff --git a/tag.h b/odb/tag.h
similarity index 96%
rename from tag.h
rename to odb/tag.h
index 534687c4ca..bfac5aa506 100644
--- a/tag.h
+++ b/odb/tag.h
@@ -1,7 +1,7 @@
 #ifndef TAG_H
 #define TAG_H
 
-#include "object.h"
+#include "odb/object.h"
 
 extern const char *tag_type;
 
diff --git a/tmp-objdir.c b/odb/tmp-objdir.c
similarity index 99%
rename from tmp-objdir.c
rename to odb/tmp-objdir.c
index d199d39e7c..b9ba5c4cd3 100644
--- a/tmp-objdir.c
+++ b/odb/tmp-objdir.c
@@ -1,16 +1,16 @@
 #include "git-compat-util.h"
-#include "tmp-objdir.h"
+#include "odb/tmp-objdir.h"
 #include "abspath.h"
 #include "chdir-notify.h"
 #include "dir.h"
 #include "environment.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "path.h"
 #include "string-list.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "quote.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "odb/source.h"
 #include "repository.h"
 
diff --git a/tmp-objdir.h b/odb/tmp-objdir.h
similarity index 100%
rename from tmp-objdir.h
rename to odb/tmp-objdir.h
diff --git a/odb/transaction.h b/odb/transaction.h
index 4cb2eafcbf..56c8bec5f9 100644
--- a/odb/transaction.h
+++ b/odb/transaction.h
@@ -2,7 +2,7 @@
 #define ODB_TRANSACTION_H
 
 #include "gettext.h"
-#include "odb.h"
+#include "odb/odb.h"
 
 /*
  * A transaction may be started for an object database prior to writing new
diff --git a/tree-walk.c b/odb/tree-walk.c
similarity index 99%
rename from tree-walk.c
rename to odb/tree-walk.c
index a67f06b9eb..51e8037ef5 100644
--- a/tree-walk.c
+++ b/odb/tree-walk.c
@@ -1,14 +1,14 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 #include "dir.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "trace2.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "pathspec.h"
 #include "json-writer.h"
 #include "environment.h"
diff --git a/tree-walk.h b/odb/tree-walk.h
similarity index 99%
rename from tree-walk.h
rename to odb/tree-walk.h
index 9646c47ac5..cada7e93c6 100644
--- a/tree-walk.h
+++ b/odb/tree-walk.h
@@ -1,7 +1,7 @@
 #ifndef TREE_WALK_H
 #define TREE_WALK_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 struct index_state;
 struct repository;
diff --git a/tree.c b/odb/tree.c
similarity index 97%
rename from tree.c
rename to odb/tree.c
index 53f7395e9f..f1a9779d1a 100644
--- a/tree.c
+++ b/odb/tree.c
@@ -1,11 +1,11 @@
 #include "git-compat-util.h"
 #include "hex.h"
-#include "tree.h"
-#include "object-name.h"
-#include "odb.h"
-#include "commit.h"
-#include "alloc.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/commit.h"
+#include "odb/alloc.h"
+#include "odb/tree-walk.h"
 #include "repository.h"
 #include "environment.h"
 
diff --git a/tree.h b/odb/tree.h
similarity index 98%
rename from tree.h
rename to odb/tree.h
index 677382eed8..cebfcfe80e 100644
--- a/tree.h
+++ b/odb/tree.h
@@ -1,7 +1,7 @@
 #ifndef TREE_H
 #define TREE_H
 
-#include "object.h"
+#include "odb/object.h"
 
 struct pathspec;
 struct repository;
diff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c
index d2a92f34d9..5b033dbd93 100644
--- a/oss-fuzz/fuzz-pack-idx.c
+++ b/oss-fuzz/fuzz-pack-idx.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "packfile.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index acbea89031..64233d6cd0 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -4,25 +4,25 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "odb.h"
-#include "commit.h"
+#include "odb/odb.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "revision.h"
 #include "progress.h"
 #include "pack.h"
 #include "pack-bitmap.h"
-#include "hash-lookup.h"
+#include "odb/hash-lookup.h"
 #include "pack-objects.h"
 #include "path.h"
 #include "commit-reach.h"
 #include "prio-queue.h"
 #include "trace2.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "pseudo-merge.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "config.h"
-#include "alloc.h"
+#include "odb/alloc.h"
 #include "refs.h"
 #include "strmap.h"
 #include "midx.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index e85bd69ba4..908a00ec0c 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1,11 +1,11 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "gettext.h"
 #include "hex.h"
 #include "strbuf.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "diff.h"
 #include "revision.h"
 #include "progress.h"
@@ -17,7 +17,7 @@
 #include "packfile.h"
 #include "repository.h"
 #include "trace2.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "list-objects-filter-options.h"
 #include "midx.h"
 #include "config.h"
diff --git a/pack-check.c b/pack-check.c
index c3b8db7c5c..358c68ef11 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -7,8 +7,8 @@
 #include "pack.h"
 #include "progress.h"
 #include "packfile.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
 
 struct idx_entry {
diff --git a/pack-mtimes.c b/pack-mtimes.c
index 8e1f2dec0e..903c1039c8 100644
--- a/pack-mtimes.c
+++ b/pack-mtimes.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-mtimes.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "packfile.h"
 #include "strbuf.h"
 
diff --git a/pack-objects.c b/pack-objects.c
index 48510dd343..35ecc8831e 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "object.h"
+#include "odb/object.h"
 #include "pack.h"
 #include "pack-objects.h"
 #include "packfile.h"
diff --git a/pack-objects.h b/pack-objects.h
index e97e84ddcb..8b9fc2e36b 100644
--- a/pack-objects.h
+++ b/pack-objects.h
@@ -1,7 +1,7 @@
 #ifndef PACK_OBJECTS_H
 #define PACK_OBJECTS_H
 
-#include "odb.h"
+#include "odb/odb.h"
 #include "thread-utils.h"
 #include "pack.h"
 #include "packfile.h"
diff --git a/pack-revindex.c b/pack-revindex.c
index 62387ae632..613d1bb897 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-revindex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "packfile.h"
 #include "strbuf.h"
 #include "trace2.h"
diff --git a/pack-write.c b/pack-write.c
index 24033a9101..86af0ac730 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -6,7 +6,7 @@
 #include "csum-file.h"
 #include "remote.h"
 #include "chunk-format.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "pack-mtimes.h"
 #include "pack-objects.h"
 #include "pack-revindex.h"
diff --git a/pack.h b/pack.h
index 1cde92082b..2b0be52ded 100644
--- a/pack.h
+++ b/pack.h
@@ -1,7 +1,7 @@
 #ifndef PACK_H
 #define PACK_H
 
-#include "object.h"
+#include "odb/object.h"
 #include "csum-file.h"
 
 struct packed_git;
diff --git a/packfile.c b/packfile.c
index 0eee45055f..2936cbf3fa 100644
--- a/packfile.c
+++ b/packfile.c
@@ -10,15 +10,15 @@
 #include "dir.h"
 #include "packfile.h"
 #include "delta.h"
-#include "hash-lookup.h"
-#include "commit.h"
-#include "object.h"
-#include "tag.h"
+#include "odb/hash-lookup.h"
+#include "odb/commit.h"
+#include "odb/object.h"
+#include "odb/tag.h"
 #include "trace.h"
-#include "tree-walk.h"
-#include "tree.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/tree-walk.h"
+#include "odb/tree.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/streaming.h"
 #include "midx.h"
 #include "commit-graph.h"
diff --git a/packfile.h b/packfile.h
index e1f77152b5..9859bfb5e0 100644
--- a/packfile.h
+++ b/packfile.h
@@ -2,11 +2,11 @@
 #define PACKFILE_H
 
 #include "list.h"
-#include "object.h"
-#include "odb.h"
+#include "odb/object.h"
+#include "odb/odb.h"
 #include "odb/source-files.h"
 #include "odb/source-packed.h"
-#include "oidset.h"
+#include "odb/oidset.h"
 #include "packfile-list.h"
 #include "repository.h"
 
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 0bf4bd6d4a..85d1c25a81 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -5,7 +5,7 @@
 #include "config.h"
 #include "entry.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "parallel-checkout.h"
 #include "pkt-line.h"
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 976cc86385..7826b8ad43 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -3,16 +3,16 @@
 #include "git-compat-util.h"
 #include "parse-options.h"
 #include "branch.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "color.h"
 #include "date.h"
 #include "environment.h"
 #include "gettext.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "setup.h"
 #include "string-list.h"
 #include "strvec.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 
 /*----- some often used options -----*/
 
diff --git a/patch-ids.c b/patch-ids.c
index 1fbc88cbec..946744e7d9 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "diff.h"
-#include "commit.h"
-#include "hash.h"
+#include "odb/commit.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "patch-ids.h"
 
diff --git a/path-walk.c b/path-walk.c
index 9ca3248ea8..ed4d3211d2 100644
--- a/path-walk.c
+++ b/path-walk.c
@@ -3,27 +3,27 @@
  */
 #include "git-compat-util.h"
 #include "path-walk.h"
-#include "blob.h"
-#include "commit.h"
+#include "odb/blob.h"
+#include "odb/commit.h"
 #include "dir.h"
 #include "hashmap.h"
 #include "hex.h"
 #include "list-objects.h"
 #include "list-objects-filter-options.h"
-#include "object-name.h"
-#include "odb.h"
-#include "object.h"
-#include "oid-array.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/object.h"
+#include "odb/oid-array.h"
 #include "path.h"
 #include "prio-queue.h"
 #include "repository.h"
 #include "revision.h"
 #include "string-list.h"
 #include "strmap.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "trace2.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 
 static const char *root_path = "";
 
diff --git a/path-walk.h b/path-walk.h
index a2652b2d46..f094610500 100644
--- a/path-walk.h
+++ b/path-walk.h
@@ -2,7 +2,7 @@
  * path-walk.h : Methods and structures for walking the object graph in batches
  * by the paths that can reach those objects.
  */
-#include "object.h" /* Required for 'enum object_type'. */
+#include "odb/object.h" /* Required for 'enum object_type'. */
 
 struct rev_info;
 struct oid_array;
diff --git a/path.c b/path.c
index c3a709a928..3a3a66155a 100644
--- a/path.c
+++ b/path.c
@@ -14,7 +14,7 @@
 #include "submodule-config.h"
 #include "path.h"
 #include "packfile.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "lockfile.h"
 #include "exec-cmd.h"
 
diff --git a/pretty.c b/pretty.c
index d8a9f370f6..461e8cd527 100644
--- a/pretty.c
+++ b/pretty.c
@@ -3,10 +3,10 @@
 
 #include "git-compat-util.h"
 #include "config.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "utf8.h"
 #include "diff.h"
@@ -21,7 +21,7 @@
 #include "gpg-interface.h"
 #include "trailer.h"
 #include "run-command.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 
 /*
  * The limit for formatting directives, which enable the caller to append
diff --git a/promisor-remote.c b/promisor-remote.c
index 43505d1e1a..b2188d34c7 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "promisor-remote.h"
 #include "config.h"
 #include "trace2.h"
diff --git a/protocol-caps.c b/protocol-caps.c
index 02261be14d..edac5dbd05 100644
--- a/protocol-caps.c
+++ b/protocol-caps.c
@@ -3,9 +3,9 @@
 #include "gettext.h"
 #include "hex.h"
 #include "pkt-line.h"
-#include "hash.h"
-#include "object.h"
-#include "odb.h"
+#include "odb/hash.h"
+#include "odb/object.h"
+#include "odb/odb.h"
 #include "repository.h"
 #include "string-list.h"
 #include "strbuf.h"
diff --git a/prune-packed.c b/prune-packed.c
index d49dc11957..f536ef1eaf 100644
--- a/prune-packed.c
+++ b/prune-packed.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "packfile.h"
 #include "progress.h"
 #include "prune-packed.h"
diff --git a/pseudo-merge.c b/pseudo-merge.c
index 22b8600d68..0809a2bcb3 100644
--- a/pseudo-merge.c
+++ b/pseudo-merge.c
@@ -4,14 +4,14 @@
 #include "git-compat-util.h"
 #include "pseudo-merge.h"
 #include "date.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "strbuf.h"
 #include "config.h"
 #include "string-list.h"
 #include "refs.h"
 #include "pack-bitmap.h"
-#include "commit.h"
-#include "alloc.h"
+#include "odb/commit.h"
+#include "odb/alloc.h"
 #include "progress.h"
 #include "hex.h"
 
diff --git a/range-diff.c b/range-diff.c
index 8e2dd2eb19..be9f872396 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -5,7 +5,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "range-diff.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "string-list.h"
 #include "run-command.h"
 #include "strvec.h"
@@ -13,7 +13,7 @@
 #include "xdiff-interface.h"
 #include "linear-assignment.h"
 #include "diffcore.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "pager.h"
 #include "pretty.h"
 #include "repository.h"
diff --git a/reachable.c b/reachable.c
index 3079d2c5f4..2a62adf7f5 100644
--- a/reachable.c
+++ b/reachable.c
@@ -4,8 +4,8 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
-#include "commit.h"
-#include "blob.h"
+#include "odb/commit.h"
+#include "odb/blob.h"
 #include "diff.h"
 #include "revision.h"
 #include "reachable.h"
@@ -14,7 +14,7 @@
 #include "list-objects.h"
 #include "packfile.h"
 #include "worktree.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "pack-bitmap.h"
 #include "pack-mtimes.h"
 #include "config.h"
diff --git a/read-cache-ll.h b/read-cache-ll.h
index 8eb266cfd1..312e65ff3c 100644
--- a/read-cache-ll.h
+++ b/read-cache-ll.h
@@ -1,7 +1,7 @@
 #ifndef READ_CACHE_LL_H
 #define READ_CACHE_LL_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "hashmap.h"
 #include "statinfo.h"
 
diff --git a/read-cache.c b/read-cache.c
index c076984858..8f6b812b5f 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -18,17 +18,17 @@
 #include "cache-tree.h"
 #include "refs.h"
 #include "dir.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "odb/transaction.h"
-#include "oid-array.h"
-#include "tree.h"
-#include "commit.h"
+#include "odb/oid-array.h"
+#include "odb/tree.h"
+#include "odb/commit.h"
 #include "environment.h"
 #include "gettext.h"
 #include "mem-pool.h"
 #include "name-hash.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "path.h"
 #include "preload-index.h"
 #include "read-cache.h"
diff --git a/read-cache.h b/read-cache.h
index ab9d40aa81..69a7118a66 100644
--- a/read-cache.h
+++ b/read-cache.h
@@ -2,7 +2,7 @@
 #define READ_CACHE_H
 
 #include "read-cache-ll.h"
-#include "object.h"
+#include "odb/object.h"
 #include "pathspec.h"
 #include "environment.h"
 
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 809f76a87b..df9c2d1275 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "editor.h"
 #include "environment.h"
 #include "gettext.h"
@@ -9,10 +9,10 @@
 #include "rebase-interactive.h"
 #include "repository.h"
 #include "strbuf.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "config.h"
 #include "dir.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 
 static const char edit_todo_list_advice[] =
 N_("You can fix this with 'git rebase --edit-todo' "
diff --git a/ref-filter.c b/ref-filter.c
index bdf54f6f59..8a3d056577 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -11,17 +11,17 @@
 #include "run-command.h"
 #include "refs.h"
 #include "wildmatch.h"
-#include "object-name.h"
-#include "odb.h"
-#include "oid-array.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/oid-array.h"
 #include "repo-settings.h"
 #include "repository.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "mailmap.h"
 #include "ident.h"
 #include "remote.h"
 #include "color.h"
-#include "tag.h"
+#include "odb/tag.h"
 #include "quote.h"
 #include "ref-filter.h"
 #include "revision.h"
@@ -29,7 +29,7 @@
 #include "versioncmp.h"
 #include "trailer.h"
 #include "wt-status.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "commit-reach.h"
 #include "worktree.h"
 #include "hashmap.h"
diff --git a/ref-filter.h b/ref-filter.h
index 9361296e2a..11180f9570 100644
--- a/ref-filter.h
+++ b/ref-filter.h
@@ -2,8 +2,8 @@
 #define REF_FILTER_H
 
 #include "gettext.h"
-#include "oid-array.h"
-#include "commit.h"
+#include "odb/oid-array.h"
+#include "odb/commit.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "commit-reach.h"
diff --git a/reflog-walk.c b/reflog-walk.c
index 4dbeaa93a7..4058cfa6df 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "refs.h"
 #include "diff.h"
 #include "repository.h"
diff --git a/reflog.c b/reflog.c
index 04edbe5670..178ef7fe44 100644
--- a/reflog.c
+++ b/reflog.c
@@ -6,12 +6,12 @@
 #include "environment.h"
 #include "gettext.h"
 #include "parse-options.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "reflog.h"
 #include "refs.h"
 #include "revision.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "wildmatch.h"
 
 static struct reflog_expire_entry_option *find_cfg_ent(struct reflog_expire_options *opts,
diff --git a/refs.c b/refs.c
index 92d5df5b71..e01163be2a 100644
--- a/refs.c
+++ b/refs.c
@@ -15,9 +15,9 @@
 #include "refs.h"
 #include "refs/refs-internal.h"
 #include "hook.h"
-#include "object-name.h"
-#include "odb.h"
-#include "object.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/object.h"
 #include "path.h"
 #include "submodule.h"
 #include "worktree.h"
@@ -25,10 +25,10 @@
 #include "repo-settings.h"
 #include "setup.h"
 #include "date.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "wildmatch.h"
 #include "ident.h"
-#include "fsck.h"
+#include "odb/fsck.h"
 
 /*
  * List of all available backends
diff --git a/refs.h b/refs.h
index 9979446d15..1746d1035c 100644
--- a/refs.h
+++ b/refs.h
@@ -1,8 +1,8 @@
 #ifndef REFS_H
 #define REFS_H
 
-#include "object-name.h"
-#include "commit.h"
+#include "odb/object-name.h"
+#include "odb/commit.h"
 #include "repository.h"
 #include "repo-settings.h"
 
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 1cc20aa486..ef7532e727 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -6,9 +6,9 @@
 #include "../copy.h"
 #include "../environment.h"
 #include "../gettext.h"
-#include "../hash.h"
+#include "odb/hash.h"
 #include "../hex.h"
-#include "../fsck.h"
+#include "odb/fsck.h"
 #include "../refs.h"
 #include "../repo-settings.h"
 #include "refs-internal.h"
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index b9b04b7010..c7005a9ecc 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -3,9 +3,9 @@
 #include "../git-compat-util.h"
 #include "../config.h"
 #include "../dir.h"
-#include "../fsck.h"
+#include "odb/fsck.h"
 #include "../gettext.h"
-#include "../hash.h"
+#include "odb/hash.h"
 #include "../hex.h"
 #include "../refs.h"
 #include "refs-internal.h"
diff --git a/refs/ref-cache.c b/refs/ref-cache.c
index ffef01a597..a4182ea57f 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -1,5 +1,5 @@
 #include "../git-compat-util.h"
-#include "../hash.h"
+#include "odb/hash.h"
 #include "../refs.h"
 #include "../repository.h"
 #include "refs-internal.h"
diff --git a/refs/ref-cache.h b/refs/ref-cache.h
index f635d2d824..7a4fe77a41 100644
--- a/refs/ref-cache.h
+++ b/refs/ref-cache.h
@@ -1,7 +1,7 @@
 #ifndef REFS_REF_CACHE_H
 #define REFS_REF_CACHE_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 struct ref_dir;
 struct ref_store;
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index 028f0211af..9d6194c4e6 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -4,9 +4,9 @@
 #include "../config.h"
 #include "../dir.h"
 #include "../environment.h"
-#include "../fsck.h"
+#include "odb/fsck.h"
 #include "../gettext.h"
-#include "../hash.h"
+#include "odb/hash.h"
 #include "../hex.h"
 #include "../ident.h"
 #include "../iterator.h"
diff --git a/refspec.c b/refspec.c
index 7cb479983b..f3cb1b0748 100644
--- a/refspec.c
+++ b/refspec.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "string-list.h"
 #include "strvec.h"
diff --git a/remote-curl.c b/remote-curl.c
index 2c35dd5240..a6a145c046 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -17,7 +17,7 @@
 #include "string-list.h"
 #include "strvec.h"
 #include "credential.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "send-pack.h"
 #include "setup.h"
 #include "protocol.h"
diff --git a/remote.c b/remote.c
index fe62068463..89dc91429a 100644
--- a/remote.c
+++ b/remote.c
@@ -12,10 +12,10 @@
 #include "urlmatch.h"
 #include "refs.h"
 #include "refspec.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "path.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "revision.h"
 #include "dir.h"
diff --git a/remote.h b/remote.h
index cca02033b9..fbf552cc2f 100644
--- a/remote.h
+++ b/remote.h
@@ -1,7 +1,7 @@
 #ifndef REMOTE_H
 #define REMOTE_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "hashmap.h"
 #include "refspec.h"
 #include "string-list.h"
diff --git a/repack-midx.c b/repack-midx.c
index 64c7f8d0f4..a9df431952 100644
--- a/repack-midx.c
+++ b/repack-midx.c
@@ -1,11 +1,11 @@
 #include "git-compat-util.h"
 #include "repack.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "lockfile.h"
 #include "midx.h"
-#include "odb.h"
-#include "oidset.h"
+#include "odb/odb.h"
+#include "odb/oidset.h"
 #include "pack-bitmap.h"
 #include "path.h"
 #include "refs.h"
diff --git a/repack.c b/repack.c
index d2aa58e134..16da2e35cb 100644
--- a/repack.c
+++ b/repack.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "dir.h"
 #include "midx.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "packfile.h"
 #include "path.h"
 #include "repack.h"
diff --git a/replay.c b/replay.c
index 463c900d6c..9e29f29ff6 100644
--- a/replay.c
+++ b/replay.c
@@ -4,13 +4,13 @@
 #include "environment.h"
 #include "hex.h"
 #include "merge-ort.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "refs.h"
 #include "replay.h"
 #include "revision.h"
 #include "sequencer.h"
 #include "strmap.h"
-#include "tree.h"
+#include "odb/tree.h"
 
 /*
  * We technically need USE_THE_REPOSITORY_VARIABLE for DEFAULT_ABBREV, but
diff --git a/replay.h b/replay.h
index 491db145e3..7ec371d6a5 100644
--- a/replay.h
+++ b/replay.h
@@ -1,7 +1,7 @@
 #ifndef REPLAY_H
 #define REPLAY_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 struct repository;
 struct rev_info;
diff --git a/repository.c b/repository.c
index db4f9d006e..72434e3a50 100644
--- a/repository.c
+++ b/repository.c
@@ -2,17 +2,17 @@
 #include "abspath.h"
 #include "repository.h"
 #include "hook.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "odb/source.h"
 #include "config.h"
 #include "gettext.h"
-#include "object.h"
+#include "odb/object.h"
 #include "lockfile.h"
 #include "path.h"
 #include "read-cache-ll.h"
 #include "remote.h"
 #include "setup.h"
-#include "loose.h"
+#include "odb/loose.h"
 #include "submodule-config.h"
 #include "sparse-index.h"
 #include "trace2.h"
diff --git a/rerere.c b/rerere.c
index 3d3bd0db16..6ff20d0692 100644
--- a/rerere.c
+++ b/rerere.c
@@ -18,8 +18,8 @@
 #include "merge-ll.h"
 #include "path.h"
 #include "pathspec.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "strmap.h"
 
 #define RESOLVED 0
diff --git a/reset.c b/reset.c
index 71254bde93..950d45d07d 100644
--- a/reset.c
+++ b/reset.c
@@ -3,11 +3,11 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "refs.h"
 #include "reset.h"
-#include "tree-walk.h"
-#include "tree.h"
+#include "odb/tree-walk.h"
+#include "odb/tree.h"
 #include "unpack-trees.h"
 #include "hook.h"
 
diff --git a/reset.h b/reset.h
index 4c992ba671..52055ad68d 100644
--- a/reset.h
+++ b/reset.h
@@ -1,7 +1,7 @@
 #ifndef RESET_H
 #define RESET_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "repository.h"
 
 #define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
diff --git a/resolve-undo.c b/resolve-undo.c
index 52c45e5a49..a54b6c0f79 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "dir.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "read-cache.h"
 #include "resolve-undo.h"
 #include "sparse-index.h"
diff --git a/resolve-undo.h b/resolve-undo.h
index 7ed11a1c59..b10c197cf0 100644
--- a/resolve-undo.h
+++ b/resolve-undo.h
@@ -6,7 +6,7 @@ struct index_state;
 struct pathspec;
 struct string_list;
 
-#include "hash.h"
+#include "odb/hash.h"
 
 struct resolve_undo_info {
 	unsigned int mode[3];
diff --git a/revision.c b/revision.c
index 50dc8b1991..9e90f909da 100644
--- a/revision.c
+++ b/revision.c
@@ -6,14 +6,14 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
-#include "object-file.h"
-#include "odb.h"
-#include "oidset.h"
-#include "tag.h"
-#include "blob.h"
-#include "tree.h"
-#include "commit.h"
+#include "odb/object-name.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
+#include "odb/oidset.h"
+#include "odb/tag.h"
+#include "odb/blob.h"
+#include "odb/tree.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "diff-merges.h"
 #include "refs.h"
@@ -28,7 +28,7 @@
 #include "line-log.h"
 #include "log-tree.h"
 #include "mailmap.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "cache-tree.h"
 #include "bisect.h"
 #include "packfile.h"
diff --git a/revision.h b/revision.h
index acf6d06b24..e0ff7aa0f2 100644
--- a/revision.h
+++ b/revision.h
@@ -1,14 +1,14 @@
 #ifndef REVISION_H
 #define REVISION_H
 
-#include "commit.h"
+#include "odb/commit.h"
 #include "grep.h"
 #include "notes.h"
-#include "object-name.h"
-#include "oidset.h"
+#include "odb/object-name.h"
+#include "odb/oidset.h"
 #include "pretty.h"
 #include "diff.h"
-#include "commit-slab-decl.h"
+#include "odb/commit-slab-decl.h"
 #include "decorate.h"
 #include "ident.h"
 #include "list-objects-filter-options.h"
diff --git a/send-pack.c b/send-pack.c
index 3bb5afc687..97dcfac586 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -1,10 +1,10 @@
 #include "git-compat-util.h"
 #include "config.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "date.h"
 #include "gettext.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "pkt-line.h"
 #include "sideband.h"
 #include "run-command.h"
@@ -13,7 +13,7 @@
 #include "send-pack.h"
 #include "transport.h"
 #include "version.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "gpg-interface.h"
 #include "shallow.h"
 #include "parse-options.h"
diff --git a/sequencer.c b/sequencer.c
index 83c3849205..67ab3cdf0d 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -11,12 +11,12 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
-#include "object.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
+#include "odb/object.h"
 #include "pager.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "sequencer.h"
 #include "run-command.h"
 #include "hook.h"
@@ -40,9 +40,9 @@
 #include "notes-utils.h"
 #include "sigchain.h"
 #include "unpack-trees.h"
-#include "oidmap.h"
-#include "oidset.h"
-#include "commit-slab.h"
+#include "odb/oidmap.h"
+#include "odb/oidset.h"
+#include "odb/commit-slab.h"
 #include "alias.h"
 #include "commit-reach.h"
 #include "rebase-interactive.h"
diff --git a/serve.c b/serve.c
index 2b07d922b3..95cf3d8ea4 100644
--- a/serve.c
+++ b/serve.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "repository.h"
 #include "config.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "pkt-line.h"
 #include "version.h"
 #include "ls-refs.h"
diff --git a/server-info.c b/server-info.c
index 4243e24edc..75ead482e1 100644
--- a/server-info.c
+++ b/server-info.c
@@ -5,13 +5,13 @@
 #include "hex.h"
 #include "repository.h"
 #include "refs.h"
-#include "object.h"
-#include "commit.h"
-#include "tag.h"
+#include "odb/object.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
 #include "packfile.h"
 #include "path.h"
-#include "object-file.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/odb.h"
 #include "server-info.h"
 #include "strbuf.h"
 #include "tempfile.h"
diff --git a/setup.c b/setup.c
index 20d29f31f4..fe8e9ffdc5 100644
--- a/setup.c
+++ b/setup.c
@@ -7,8 +7,8 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-file.h"
-#include "object-name.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
 #include "refs.h"
 #include "repository.h"
 #include "config.h"
diff --git a/shallow.c b/shallow.c
index 8e244a5669..25116d7a6e 100644
--- a/shallow.c
+++ b/shallow.c
@@ -5,16 +5,16 @@
 #include "repository.h"
 #include "tempfile.h"
 #include "lockfile.h"
-#include "odb.h"
-#include "commit.h"
-#include "tag.h"
+#include "odb/odb.h"
+#include "odb/commit.h"
+#include "odb/tag.h"
 #include "pkt-line.h"
 #include "refs.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "path.h"
 #include "diff.h"
 #include "revision.h"
-#include "commit-slab.h"
+#include "odb/commit-slab.h"
 #include "list-objects.h"
 #include "commit-reach.h"
 #include "shallow.h"
diff --git a/shallow.h b/shallow.h
index 6a64db42c9..0cb1d5ba70 100644
--- a/shallow.h
+++ b/shallow.h
@@ -1,9 +1,9 @@
 #ifndef SHALLOW_H
 #define SHALLOW_H
 
-#include "commit.h"
+#include "odb/commit.h"
 #include "lockfile.h"
-#include "object.h"
+#include "odb/object.h"
 #include "repository.h"
 #include "strbuf.h"
 
diff --git a/sparse-index.c b/sparse-index.c
index c1fa231a89..8e00862442 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -9,7 +9,7 @@
 #include "read-cache-ll.h"
 #include "repository.h"
 #include "sparse-index.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "pathspec.h"
 #include "trace2.h"
 #include "cache-tree.h"
diff --git a/split-index.c b/split-index.c
index 6ba210738c..2737cc6118 100644
--- a/split-index.c
+++ b/split-index.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "mem-pool.h"
 #include "read-cache-ll.h"
 #include "repository.h"
diff --git a/split-index.h b/split-index.h
index 1a153f47ba..6bfab742aa 100644
--- a/split-index.h
+++ b/split-index.h
@@ -1,7 +1,7 @@
 #ifndef SPLIT_INDEX_H
 #define SPLIT_INDEX_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 struct index_state;
 struct strbuf;
diff --git a/submodule-config.c b/submodule-config.c
index f75997402a..094e64d8fd 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -12,12 +12,12 @@
 #include "submodule-config.h"
 #include "submodule.h"
 #include "strbuf.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "odb/source.h"
 #include "parse-options.h"
 #include "thread-utils.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 #include "url.h"
 #include "urlmatch.h"
 
diff --git a/submodule-config.h b/submodule-config.h
index f55d4e3b61..3f4f0bf454 100644
--- a/submodule-config.h
+++ b/submodule-config.h
@@ -3,7 +3,7 @@
 
 #include "config.h"
 #include "submodule.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 
 /**
  * The submodule config cache API allows to read submodule
diff --git a/submodule.c b/submodule.c
index 5c92575888..d091b484a4 100644
--- a/submodule.c
+++ b/submodule.c
@@ -9,7 +9,7 @@
 #include "submodule.h"
 #include "dir.h"
 #include "diff.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
@@ -18,16 +18,16 @@
 #include "diffcore.h"
 #include "refs.h"
 #include "string-list.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "strvec.h"
 #include "thread-utils.h"
 #include "path.h"
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
-#include "object-file.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-file.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "commit-reach.h"
 #include "read-cache-ll.h"
 #include "setup.h"
diff --git a/t/helper/test-bitmap.c b/t/helper/test-bitmap.c
index 8547ef67e2..f1f48e973d 100644
--- a/t/helper/test-bitmap.c
+++ b/t/helper/test-bitmap.c
@@ -3,7 +3,7 @@
 #include "test-tool.h"
 #include "git-compat-util.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "pack-bitmap.h"
 #include "pseudo-merge.h"
 #include "setup.h"
diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index 0c65befbf0..48ff2c6024 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -3,7 +3,7 @@
 #include "test-tool.h"
 #include "bloom.h"
 #include "hex.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "repository.h"
 #include "setup.h"
 
diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c
index d42e260092..9f613d2911 100644
--- a/t/helper/test-cache-tree.c
+++ b/t/helper/test-cache-tree.c
@@ -4,7 +4,7 @@
 #include "test-tool.h"
 #include "gettext.h"
 #include "hex.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "cache-tree.h"
 #include "parse-options.h"
 #include "read-cache-ll.h"
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index ccb41a4239..849727d69b 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -1,9 +1,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "cache-tree.h"
 #include "read-cache-ll.h"
 #include "repository.h"
diff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c
index 28d5b1fe09..c7475ed4d9 100644
--- a/t/helper/test-find-pack.c
+++ b/t/helper/test-find-pack.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "object-name.h"
-#include "odb.h"
+#include "odb/object-name.h"
+#include "odb/odb.h"
 #include "packfile.h"
 #include "parse-options.h"
 #include "setup.h"
diff --git a/t/helper/test-hash-speed.c b/t/helper/test-hash-speed.c
index 89b0268011..4c71b04c57 100644
--- a/t/helper/test-hash-speed.c
+++ b/t/helper/test-hash-speed.c
@@ -1,5 +1,5 @@
 #include "test-tool.h"
-#include "hash.h"
+#include "odb/hash.h"
 
 #define NUM_SECONDS 3
 
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 006ce5278e..b6122af08f 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -2,11 +2,11 @@
 
 #include "test-tool.h"
 #include "hex.h"
-#include "match-trees.h"
-#include "object-name.h"
+#include "odb/match-trees.h"
+#include "odb/object-name.h"
 #include "repository.h"
 #include "setup.h"
-#include "tree.h"
+#include "odb/tree.h"
 
 int cmd__match_trees(int ac UNUSED, const char **av)
 {
diff --git a/t/helper/test-pack-deltas.c b/t/helper/test-pack-deltas.c
index 840797cf0d..7e5791c7ab 100644
--- a/t/helper/test-pack-deltas.c
+++ b/t/helper/test-pack-deltas.c
@@ -4,7 +4,7 @@
 #include "git-compat-util.h"
 #include "delta.h"
 #include "git-zlib.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "pack.h"
 #include "pack-objects.h"
diff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c
index b774056799..b915059322 100644
--- a/t/helper/test-pack-mtimes.c
+++ b/t/helper/test-pack-mtimes.c
@@ -3,7 +3,7 @@
 #include "test-tool.h"
 #include "hex.h"
 #include "strbuf.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "packfile.h"
 #include "pack-mtimes.h"
 #include "setup.h"
diff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c
index 87c59108e0..76fc0329fc 100644
--- a/t/helper/test-partial-clone.c
+++ b/t/helper/test-partial-clone.c
@@ -3,7 +3,7 @@
 #include "test-tool.h"
 #include "hex.h"
 #include "repository.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "setup.h"
 
 /*
diff --git a/t/helper/test-path-walk.c b/t/helper/test-path-walk.c
index 4233badb58..f41c6be2c6 100644
--- a/t/helper/test-path-walk.c
+++ b/t/helper/test-path-walk.c
@@ -5,15 +5,15 @@
 #include "environment.h"
 #include "hex.h"
 #include "list-objects-filter-options.h"
-#include "object-name.h"
-#include "object.h"
+#include "odb/object-name.h"
+#include "odb/object.h"
 #include "pretty.h"
 #include "revision.h"
 #include "setup.h"
 #include "parse-options.h"
 #include "strbuf.h"
 #include "path-walk.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 
 static const char * const path_walk_usage[] = {
 	N_("test-tool path-walk <options> -- <revision-options>"),
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 5d86a96c17..4151cfbe25 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -1,15 +1,15 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "commit-reach.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "ref-filter.h"
 #include "setup.h"
 #include "string-list.h"
-#include "tag.h"
+#include "odb/tag.h"
 
 static void print_sorted_commit_ids(struct commit_list *list)
 {
diff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c
index 9f07b9c25a..965700a698 100644
--- a/t/helper/test-read-graph.c
+++ b/t/helper/test-read-graph.c
@@ -3,7 +3,7 @@
 #include "test-tool.h"
 #include "commit-graph.h"
 #include "repository.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "bloom.h"
 #include "setup.h"
 
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index fb16ec0176..9be143ee6c 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -4,7 +4,7 @@
 #include "hex.h"
 #include "midx.h"
 #include "repository.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "pack-bitmap.h"
 #include "packfile.h"
 #include "setup.h"
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 5a9a3053d9..1fbdc52fc5 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -5,7 +5,7 @@
 #include "refs.h"
 #include "setup.h"
 #include "worktree.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "path.h"
 #include "repository.h"
 #include "strbuf.h"
diff --git a/t/helper/test-reftable.c b/t/helper/test-reftable.c
index fc49fafc34..e469f850ce 100644
--- a/t/helper/test-reftable.c
+++ b/t/helper/test-reftable.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "reftable/system.h"
 #include "reftable/reftable-constants.h"
diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c
index 9ba94cdffa..530e37b01d 100644
--- a/t/helper/test-repository.c
+++ b/t/helper/test-repository.c
@@ -2,13 +2,13 @@
 
 #include "test-tool.h"
 #include "commit-graph.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "environment.h"
 #include "hex.h"
-#include "object.h"
+#include "odb/object.h"
 #include "repository.h"
 #include "setup.h"
-#include "tree.h"
+#include "odb/tree.h"
 
 static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
 				       const struct object_id *commit_oid)
diff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c
index 24d7f29417..1b7f569f01 100644
--- a/t/helper/test-revision-walking.c
+++ b/t/helper/test-revision-walking.c
@@ -11,10 +11,10 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "line-log.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "repository.h"
 #include "revision.h"
 #include "setup.h"
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index 7b5ce501d9..f4f7df067d 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -5,7 +5,7 @@
 #include "read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "cache-tree.h"
 
 int cmd__scrap_cache_tree(int ac UNUSED, const char **av UNUSED)
diff --git a/t/helper/test-sha1.c b/t/helper/test-sha1.c
index 349540c4df..c45e56c23f 100644
--- a/t/helper/test-sha1.c
+++ b/t/helper/test-sha1.c
@@ -1,5 +1,5 @@
 #include "test-tool.h"
-#include "hash.h"
+#include "odb/hash.h"
 
 int cmd__sha1(int ac, const char **av)
 {
diff --git a/t/helper/test-sha256.c b/t/helper/test-sha256.c
index 7fd0aa1fcd..078ce7d78b 100644
--- a/t/helper/test-sha256.c
+++ b/t/helper/test-sha256.c
@@ -1,5 +1,5 @@
 #include "test-tool.h"
-#include "hash.h"
+#include "odb/hash.h"
 
 int cmd__sha256(int ac, const char **av)
 {
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 3f30292179..7a756d4f8d 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -2,8 +2,8 @@
 
 #include "test-tool.h"
 #include "config.h"
-#include "hash.h"
-#include "object-name.h"
+#include "odb/hash.h"
+#include "odb/object-name.h"
 #include "repository.h"
 #include "setup.h"
 #include "submodule-config.h"
diff --git a/t/helper/test-synthesize.c b/t/helper/test-synthesize.c
index fd116c87ba..57013566cc 100644
--- a/t/helper/test-synthesize.c
+++ b/t/helper/test-synthesize.c
@@ -3,10 +3,10 @@
 #include "test-tool.h"
 #include "git-compat-util.h"
 #include "git-zlib.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
-#include "object-file.h"
-#include "object.h"
+#include "odb/object-file.h"
+#include "odb/object.h"
 #include "pack.h"
 #include "parse-options.h"
 #include "parse.h"
diff --git a/t/unit-tests/lib-oid.h b/t/unit-tests/lib-oid.h
index 4031775104..4f47d1b0c3 100644
--- a/t/unit-tests/lib-oid.h
+++ b/t/unit-tests/lib-oid.h
@@ -1,7 +1,7 @@
 #ifndef LIB_OID_H
 #define LIB_OID_H
 
-#include "hash.h"
+#include "odb/hash.h"
 
 /*
  * Convert arbitrary hex string to object_id.
diff --git a/t/unit-tests/u-example-decorate.c b/t/unit-tests/u-example-decorate.c
index 9b1d1ce753..2f01340c21 100644
--- a/t/unit-tests/u-example-decorate.c
+++ b/t/unit-tests/u-example-decorate.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "unit-test.h"
-#include "object.h"
+#include "odb/object.h"
 #include "decorate.h"
 #include "repository.h"
 
diff --git a/t/unit-tests/u-odb-inmemory.c b/t/unit-tests/u-odb-inmemory.c
index 2def1b9a62..4f923f7267 100644
--- a/t/unit-tests/u-odb-inmemory.c
+++ b/t/unit-tests/u-odb-inmemory.c
@@ -1,9 +1,9 @@
 #include "unit-test.h"
 #include "hex.h"
-#include "object-file.h"
+#include "odb/object-file.h"
 #include "odb/source-inmemory.h"
 #include "odb/streaming.h"
-#include "oidset.h"
+#include "odb/oidset.h"
 #include "repository.h"
 #include "strbuf.h"
 
diff --git a/t/unit-tests/u-oid-array.c b/t/unit-tests/u-oid-array.c
index e48a433f21..71e62892f1 100644
--- a/t/unit-tests/u-oid-array.c
+++ b/t/unit-tests/u-oid-array.c
@@ -2,7 +2,7 @@
 
 #include "unit-test.h"
 #include "lib-oid.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "hex.h"
 
 static void fill_array(struct oid_array *array, const char *hexes[], size_t n)
diff --git a/t/unit-tests/u-oidmap.c b/t/unit-tests/u-oidmap.c
index 00481df63f..74417ced32 100644
--- a/t/unit-tests/u-oidmap.c
+++ b/t/unit-tests/u-oidmap.c
@@ -1,7 +1,7 @@
 #include "unit-test.h"
 #include "lib-oid.h"
-#include "oidmap.h"
-#include "hash.h"
+#include "odb/oidmap.h"
+#include "odb/hash.h"
 #include "hex.h"
 
 /*
diff --git a/t/unit-tests/u-oidtree.c b/t/unit-tests/u-oidtree.c
index f0d5ebb733..7372b87674 100644
--- a/t/unit-tests/u-oidtree.c
+++ b/t/unit-tests/u-oidtree.c
@@ -1,7 +1,7 @@
 #include "unit-test.h"
 #include "lib-oid.h"
-#include "oidtree.h"
-#include "hash.h"
+#include "odb/oidtree.h"
+#include "odb/hash.h"
 #include "hex.h"
 #include "strvec.h"
 
diff --git a/trailer.c b/trailer.c
index 6d8ec7fa8d..33fd1df188 100644
--- a/trailer.c
+++ b/trailer.c
@@ -6,7 +6,7 @@
 #include "gettext.h"
 #include "string-list.h"
 #include "run-command.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "strvec.h"
 #include "trailer.h"
 #include "list.h"
diff --git a/transport-helper.c b/transport-helper.c
index b109fbd8c3..59f61f23c6 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -4,11 +4,11 @@
 #include "transport.h"
 #include "quote.h"
 #include "run-command.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "repository.h"
 #include "remote.h"
 #include "string-list.h"
diff --git a/transport.c b/transport.c
index 42b0a2d0bd..5b83cf9e73 100644
--- a/transport.c
+++ b/transport.c
@@ -22,12 +22,12 @@
 #include "submodule.h"
 #include "strbuf.h"
 #include "string-list.h"
-#include "oid-array.h"
+#include "odb/oid-array.h"
 #include "sigchain.h"
 #include "trace2.h"
 #include "transport-internal.h"
 #include "protocol.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "color.h"
 #include "bundle-uri.h"
 #include "sideband.h"
diff --git a/tree-diff.c b/tree-diff.c
index 2f5c956d02..b33c45b696 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -7,9 +7,9 @@
 #include "git-compat-util.h"
 #include "diff.h"
 #include "diffcore.h"
-#include "hash.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/hash.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "repository.h"
 #include "dir.h"
 
diff --git a/unpack-trees.c b/unpack-trees.c
index 154d6d40a1..d6e05207a8 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -11,8 +11,8 @@
 #include "gettext.h"
 #include "hex.h"
 #include "name-hash.h"
-#include "tree.h"
-#include "tree-walk.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "progress.h"
@@ -26,7 +26,7 @@
 #include "symlinks.h"
 #include "trace2.h"
 #include "fsmonitor.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "promisor-remote.h"
 #include "entry.h"
 #include "parallel-checkout.h"
diff --git a/unpack-trees.h b/unpack-trees.h
index 5867e26e17..d9d3ce09fd 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -5,7 +5,7 @@
 #include "read-cache-ll.h"
 #include "strvec.h"
 #include "string-list.h"
-#include "tree-walk.h"
+#include "odb/tree-walk.h"
 
 #define MAX_UNPACK_TREES 8
 
diff --git a/upload-pack.c b/upload-pack.c
index a52856d869..5c12af2219 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -10,10 +10,10 @@
 #include "pkt-line.h"
 #include "sideband.h"
 #include "repository.h"
-#include "odb.h"
-#include "oid-array.h"
-#include "object.h"
-#include "commit.h"
+#include "odb/odb.h"
+#include "odb/oid-array.h"
+#include "odb/object.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "revision.h"
 #include "list-objects-filter-options.h"
diff --git a/walker.c b/walker.c
index e3de77f092..876865d20a 100644
--- a/walker.c
+++ b/walker.c
@@ -5,13 +5,13 @@
 #include "hex.h"
 #include "walker.h"
 #include "repository.h"
-#include "odb.h"
-#include "commit.h"
+#include "odb/odb.h"
+#include "odb/commit.h"
 #include "strbuf.h"
-#include "tree.h"
-#include "tree-walk.h"
-#include "tag.h"
-#include "blob.h"
+#include "odb/tree.h"
+#include "odb/tree-walk.h"
+#include "odb/tag.h"
+#include "odb/blob.h"
 #include "refs.h"
 #include "progress.h"
 #include "prio-queue.h"
diff --git a/wt-status.c b/wt-status.c
index 57772c7501..950ebc3418 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -4,15 +4,15 @@
 #include "git-compat-util.h"
 #include "advice.h"
 #include "wt-status.h"
-#include "object.h"
+#include "odb/object.h"
 #include "dir.h"
-#include "commit.h"
+#include "odb/commit.h"
 #include "diff.h"
 #include "environment.h"
 #include "gettext.h"
-#include "hash.h"
+#include "odb/hash.h"
 #include "hex.h"
-#include "object-name.h"
+#include "odb/object-name.h"
 #include "path.h"
 #include "revision.h"
 #include "diffcore.h"
@@ -29,7 +29,7 @@
 #include "strbuf.h"
 #include "trace.h"
 #include "trace2.h"
-#include "tree.h"
+#include "odb/tree.h"
 #include "utf8.h"
 #include "worktree.h"
 #include "lockfile.h"
diff --git a/xdiff-interface.c b/xdiff-interface.c
index db6938689f..af18a34ba0 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -5,7 +5,7 @@
 #include "gettext.h"
 #include "config.h"
 #include "hex.h"
-#include "odb.h"
+#include "odb/odb.h"
 #include "strbuf.h"
 #include "xdiff-interface.h"
 #include "xdiff/xtypes.h"
diff --git a/xdiff-interface.h b/xdiff-interface.h
index ce54e1c0e0..3ace6f0bc0 100644
--- a/xdiff-interface.h
+++ b/xdiff-interface.h
@@ -1,7 +1,7 @@
 #ifndef XDIFF_INTERFACE_H
 #define XDIFF_INTERFACE_H
 
-#include "hash.h"
+#include "odb/hash.h"
 #include "xdiff/xdiff.h"
 
 struct object_database;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 08/14] refs: gather the refs sources under refs/
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (6 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 07/14] odb: gather the odb sources under odb/ Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 09/14] pack: gather the pack sources under pack/ Michael Montalbo
                   ` (5 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Move the 8 refs C sources and 8 headers into refs/ as renames. Repoint
every reference to their old paths to the new ones: the #include lines
across the tree, the Makefile and meson.build build entries.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize                        | 32 ++++++++++++++---------------
 Makefile                            | 16 +++++++--------
 add-interactive.c                   |  2 +-
 archive.c                           |  2 +-
 attr.c                              |  2 +-
 bisect.c                            |  2 +-
 blame.c                             |  2 +-
 branch.c                            |  6 +++---
 builtin/am.c                        |  2 +-
 builtin/bisect.c                    |  2 +-
 builtin/blame.c                     |  2 +-
 builtin/branch.c                    |  6 +++---
 builtin/check-ref-format.c          |  2 +-
 builtin/checkout.c                  |  2 +-
 builtin/clone.c                     |  4 ++--
 builtin/config.c                    |  2 +-
 builtin/describe.c                  |  2 +-
 builtin/fast-export.c               |  4 ++--
 builtin/fast-import.c               |  2 +-
 builtin/fetch.c                     |  4 ++--
 builtin/for-each-ref.c              |  2 +-
 builtin/fsck.c                      |  4 ++--
 builtin/gc.c                        |  6 +++---
 builtin/history.c                   |  2 +-
 builtin/init-db.c                   |  2 +-
 builtin/log.c                       |  4 ++--
 builtin/ls-remote.c                 |  2 +-
 builtin/merge.c                     |  4 ++--
 builtin/name-rev.c                  |  2 +-
 builtin/notes.c                     |  4 ++--
 builtin/pack-objects.c              |  2 +-
 builtin/pack-refs.c                 |  2 +-
 builtin/pull.c                      |  4 ++--
 builtin/push.c                      |  2 +-
 builtin/rebase.c                    |  2 +-
 builtin/receive-pack.c              |  4 ++--
 builtin/reflog.c                    |  6 +++---
 builtin/refs.c                      |  6 +++---
 builtin/remote.c                    |  4 ++--
 builtin/replace.c                   |  2 +-
 builtin/replay.c                    |  2 +-
 builtin/repo.c                      |  4 ++--
 builtin/reset.c                     |  2 +-
 builtin/rev-list.c                  |  2 +-
 builtin/rev-parse.c                 |  2 +-
 builtin/show-branch.c               |  2 +-
 builtin/sparse-checkout.c           |  2 +-
 builtin/stash.c                     |  6 +++---
 builtin/submodule--helper.c         |  4 ++--
 builtin/symbolic-ref.c              |  2 +-
 builtin/tag.c                       |  4 ++--
 builtin/update-index.c              |  2 +-
 builtin/update-ref.c                |  2 +-
 builtin/var.c                       |  2 +-
 builtin/verify-tag.c                |  2 +-
 builtin/worktree.c                  |  4 ++--
 bundle-uri.c                        |  2 +-
 bundle.c                            |  2 +-
 checkout.c                          |  2 +-
 combine-diff.c                      |  2 +-
 commit-graph.c                      |  2 +-
 commit-reach.c                      |  2 +-
 config.c                            |  2 +-
 connect.c                           |  2 +-
 delta-islands.c                     |  2 +-
 diff-lib.c                          |  2 +-
 dir.c                               |  2 +-
 environment.c                       |  2 +-
 fetch-pack.c                        |  2 +-
 fmt-merge-msg.c                     |  2 +-
 help.c                              |  2 +-
 http-backend.c                      |  2 +-
 log-tree.c                          |  4 ++--
 merge-ort.c                         |  2 +-
 meson.build                         | 16 +++++++--------
 midx-write.c                        |  2 +-
 negotiator/default.c                |  2 +-
 negotiator/skipping.c               |  2 +-
 notes-cache.c                       |  2 +-
 notes-merge.c                       |  2 +-
 notes-utils.c                       |  2 +-
 notes.c                             |  2 +-
 odb/commit.c                        |  2 +-
 odb/fsck.c                          |  2 +-
 odb/object-name.c                   |  2 +-
 odb/replace-object.c                |  2 +-
 pack-bitmap-write.c                 |  2 +-
 pack-bitmap.h                       |  2 +-
 path.c                              |  2 +-
 pretty.c                            |  2 +-
 pseudo-merge.c                      |  2 +-
 reachable.c                         |  4 ++--
 read-cache.c                        |  2 +-
 refs/files-backend.c                |  4 ++--
 refs/iterator.c                     |  2 +-
 ls-refs.c => refs/ls-refs.c         |  4 ++--
 ls-refs.h => refs/ls-refs.h         |  0
 pack-refs.c => refs/pack-refs.c     |  4 ++--
 pack-refs.h => refs/pack-refs.h     |  0
 refs/packed-backend.c               |  4 ++--
 refs/ref-cache.c                    |  2 +-
 ref-filter.c => refs/ref-filter.c   |  6 +++---
 ref-filter.h => refs/ref-filter.h   |  0
 reflog-walk.c => refs/reflog-walk.c |  4 ++--
 reflog-walk.h => refs/reflog-walk.h |  0
 reflog.c => refs/reflog.c           |  4 ++--
 reflog.h => refs/reflog.h           |  2 +-
 refs/refs-internal.h                |  2 +-
 refs.c => refs/refs.c               |  4 ++--
 refs.h => refs/refs.h               |  0
 refspec.c => refs/refspec.c         |  4 ++--
 refspec.h => refs/refspec.h         |  0
 refs/reftable-backend.c             |  4 ++--
 worktree.c => refs/worktree.c       |  4 ++--
 worktree.h => refs/worktree.h       |  2 +-
 remote.c                            |  4 ++--
 remote.h                            |  2 +-
 repack-midx.c                       |  2 +-
 replay.c                            |  2 +-
 repository.c                        |  2 +-
 reset.c                             |  2 +-
 revision.c                          |  6 +++---
 scalar.c                            |  2 +-
 sequencer.c                         |  2 +-
 serve.c                             |  2 +-
 server-info.c                       |  2 +-
 setup.c                             |  4 ++--
 setup.h                             |  2 +-
 shallow.c                           |  2 +-
 submodule.c                         |  4 ++--
 t/helper/test-reach.c               |  2 +-
 t/helper/test-ref-store.c           |  4 ++--
 transport-helper.c                  |  4 ++--
 transport.c                         |  4 ++--
 unpack-trees.c                      |  2 +-
 upload-pack.c                       |  2 +-
 walker.c                            |  2 +-
 wt-status.c                         |  4 ++--
 138 files changed, 210 insertions(+), 210 deletions(-)
 rename ls-refs.c => refs/ls-refs.c (99%)
 rename ls-refs.h => refs/ls-refs.h (100%)
 rename pack-refs.c => refs/pack-refs.c (97%)
 rename pack-refs.h => refs/pack-refs.h (100%)
 rename ref-filter.c => refs/ref-filter.c (99%)
 rename ref-filter.h => refs/ref-filter.h (100%)
 rename reflog-walk.c => refs/reflog-walk.c (99%)
 rename reflog-walk.h => refs/reflog-walk.h (100%)
 rename reflog.c => refs/reflog.c (99%)
 rename reflog.h => refs/reflog.h (99%)
 rename refs.c => refs/refs.c (99%)
 rename refs.h => refs/refs.h (100%)
 rename refspec.c => refs/refspec.c (99%)
 rename refspec.h => refs/refspec.h (100%)
 rename worktree.c => refs/worktree.c (99%)
 rename worktree.h => refs/worktree.h (99%)

diff --git a/.gitorganize b/.gitorganize
index 5da6d0b2b1..e29497504a 100644
--- a/.gitorganize
+++ b/.gitorganize
@@ -201,8 +201,6 @@ lockfile.c component=? role=lib prefix=lockfile includes=setup:1 cochange=refs:1
 lockfile.h component=? role=public prefix=lockfile cochange=index:5,revision:4,diff:3,refs:3,odb:2
 log-tree.c component=revision role=lib prefix=format-patch includes=odb:8,revision:5,diff:3,setup:3,refs:2 cochange=revision:222,diff:112,odb:112,refs:31,transport:16
 log-tree.h component=revision role=header prefix=format-patch cochange=revision:64,diff:11,refs:3,odb:2,transport:2
-ls-refs.c component=refs role=lib prefix=ls-refs includes=setup:3,refs:2,odb:1,transport:1 cochange=refs:26,transport:17,pack:10,revision:5,odb:4
-ls-refs.h component=refs role=header prefix=ls-refs cochange=transport:11,refs:5,submodule:1
 mailinfo.c component=? role=lib prefix=mailinfo includes=setup:2 cochange=transport:5,index:3,notes:3,odb:3,revision:3
 mailinfo.h component=? role=public prefix=mailinfo
 mailmap.c component=? role=lib prefix=mailmap includes=setup:3,odb:2 cochange=setup:13,transport:11,refs:10,index:8,revision:5
@@ -290,8 +288,6 @@ pack-mtimes.c component=pack role=lib prefix=pack-mtimes includes=pack:2,odb:1 c
 pack-mtimes.h component=pack role=header prefix=pack-mtimes cochange=pack:4,odb:2,setup:1,transport:1
 pack-objects.c component=pack role=lib prefix=pack-objects includes=pack:3,odb:1,setup:1 cochange=pack:66,diff:17,odb:16,transport:9,index:5
 pack-objects.h component=pack role=header prefix=pack-objects includes=pack:2,odb:1 cochange=pack:44,setup:5,odb:1
-pack-refs.c component=refs role=lib prefix=pack-refs includes=refs:2,setup:2,revision:1 cochange=refs:12,transport:8,index:2,merge:2,odb:2
-pack-refs.h component=refs role=header prefix=pack-refs cochange=refs:5
 pack-revindex.c component=pack role=lib prefix=pack-revindex includes=pack:3,odb:1,setup:1 cochange=pack:94,odb:7,index:6,transport:5,setup:4
 pack-revindex.h component=pack role=header prefix=pack-revindex cochange=pack:32,odb:1
 pack-write.c component=pack role=lib prefix=pack-write includes=pack:5,setup:2,odb:1,transport:1 cochange=pack:88,odb:21,transport:21,setup:14,index:10
@@ -353,16 +349,22 @@ rebase-interactive.c component=? role=lib prefix=rebase-interactive includes=odb
 rebase-interactive.h component=? role=public prefix=rebase-interactive
 rebase.c component=? role=lib prefix=rebase cochange=index:3,pack:3,setup:2,convert:1,diff:1
 rebase.h component=? role=public prefix=pull
-ref-filter.c component=refs role=lib prefix=ref-filter includes=odb:6,setup:5,refs:3,revision:2,index:1 cochange=refs:112,revision:59,odb:41,transport:40,index:30
-ref-filter.h component=refs role=header prefix=ref-filter includes=odb:2,revision:1 cochange=refs:62,revision:7,transport:6,diff:5,index:4
-reflog-walk.c component=refs role=lib prefix=reflog-walk includes=refs:2,diff:1,odb:1,revision:1,setup:1 cochange=refs:34,revision:26,index:13,diff:9,transport:8
-reflog-walk.h component=refs role=header prefix=reflog-walk cochange=revision:23,refs:19,odb:6,archive:2,index:2
-reflog.c component=refs role=lib prefix=refs includes=odb:3,refs:2,setup:2,revision:1 cochange=refs:18,transport:13,odb:9,revision:7,diff:4
-reflog.h component=refs role=header prefix=reflog includes=refs:1 cochange=refs:8,odb:3,index:1,revision:1,transport:1
-refs.c component=refs role=lib prefix=refs includes=setup:6,odb:5,refs:2,submodule:1 cochange=refs:373,transport:133,setup:116,odb:82,revision:77
-refs.h component=refs role=header prefix=refs includes=odb:2,setup:2 cochange=refs:352,transport:55,revision:34,setup:25,odb:16
-refspec.c component=refs role=lib prefix=refspec includes=refs:2,odb:1,transport:1 cochange=refs:27,transport:26,index:2,submodule:2
-refspec.h component=refs role=header prefix=refspec cochange=transport:31,refs:29,submodule:3,index:2
+refs/ls-refs.c component=refs role=lib prefix=ls-refs includes=setup:3,refs:2,odb:1,transport:1 cochange=refs:26,transport:17,pack:10,revision:5,odb:4
+refs/ls-refs.h component=refs role=header prefix=ls-refs cochange=transport:11,refs:5,submodule:1
+refs/pack-refs.c component=refs role=lib prefix=pack-refs includes=refs:2,setup:2,revision:1 cochange=refs:12,transport:8,index:2,merge:2,odb:2
+refs/pack-refs.h component=refs role=header prefix=pack-refs cochange=refs:5
+refs/ref-filter.c component=refs role=lib prefix=ref-filter includes=odb:6,setup:5,refs:3,revision:2,index:1 cochange=refs:112,revision:59,odb:41,transport:40,index:30
+refs/ref-filter.h component=refs role=header prefix=ref-filter includes=odb:2,revision:1 cochange=refs:62,revision:7,transport:6,diff:5,index:4
+refs/reflog-walk.c component=refs role=lib prefix=reflog-walk includes=refs:2,diff:1,odb:1,revision:1,setup:1 cochange=refs:34,revision:26,index:13,diff:9,transport:8
+refs/reflog-walk.h component=refs role=header prefix=reflog-walk cochange=revision:23,refs:19,odb:6,archive:2,index:2
+refs/reflog.c component=refs role=lib prefix=refs includes=odb:3,refs:2,setup:2,revision:1 cochange=refs:18,transport:13,odb:9,revision:7,diff:4
+refs/reflog.h component=refs role=header prefix=reflog includes=refs:1 cochange=refs:8,odb:3,index:1,revision:1,transport:1
+refs/refs.c component=refs role=lib prefix=refs includes=setup:6,odb:5,refs:2,submodule:1 cochange=refs:373,transport:133,setup:116,odb:82,revision:77
+refs/refs.h component=refs role=header prefix=refs includes=odb:2,setup:2 cochange=refs:352,transport:55,revision:34,setup:25,odb:16
+refs/refspec.c component=refs role=lib prefix=refspec includes=refs:2,odb:1,transport:1 cochange=refs:27,transport:26,index:2,submodule:2
+refs/refspec.h component=refs role=header prefix=refspec cochange=transport:31,refs:29,submodule:3,index:2
+refs/worktree.c component=refs role=lib prefix=worktree includes=setup:4,index:2,refs:2 cochange=refs:73,setup:53,index:22,submodule:13,pack:11
+refs/worktree.h component=refs role=header prefix=worktree includes=refs:1 cochange=refs:61,revision:10,pack:5,setup:5,odb:4
 remote-curl.c component=transport role=lib prefix=remote-curl includes=transport:9,setup:3,odb:1 cochange=transport:226,diff:9,revision:6,setup:5,archive:4
 remote.c component=transport role=lib prefix=remote includes=odb:3,setup:3,transport:3,refs:2,revision:2 cochange=transport:272,refs:91,revision:56,index:51,odb:30
 remote.h component=transport role=header prefix=remote includes=odb:1,refs:1 cochange=transport:245,refs:24,index:12,revision:6,setup:2
@@ -480,8 +482,6 @@ walker.c component=transport role=lib prefix=refs includes=odb:6,refs:1,setup:1,
 walker.h component=transport role=header prefix=walker includes=transport:1 cochange=transport:19
 wildmatch.c component=? role=lib prefix=hex cochange=index:4,refs:3,diff:1,odb:1,revision:1
 wildmatch.h component=? role=public prefix=? cochange=index:3,refs:2,diff:1,revision:1,setup:1
-worktree.c component=refs role=lib prefix=worktree includes=setup:4,index:2,refs:2 cochange=refs:73,setup:53,index:22,submodule:13,pack:11
-worktree.h component=refs role=header prefix=worktree includes=refs:1 cochange=refs:61,revision:10,pack:5,setup:5,odb:4
 wrapper.c component=? role=lib prefix=wrapper cochange=setup:21,index:16,pack:6,transport:5,convert:4
 wrapper.h component=? role=public prefix=wrapper cochange=index:2,revision:1,setup:1
 write-or-die.c component=? role=lib prefix=write-or-die cochange=pack:6,setup:6,index:4,transport:2,convert:1
diff --git a/Makefile b/Makefile
index a95b87d970..f733ccfee0 100644
--- a/Makefile
+++ b/Makefile
@@ -1201,7 +1201,7 @@ LIB_OBJS += list-objects.o
 LIB_OBJS += lockfile.o
 LIB_OBJS += log-tree.o
 LIB_OBJS += odb/loose.o
-LIB_OBJS += ls-refs.o
+LIB_OBJS += refs/ls-refs.o
 LIB_OBJS += mailinfo.o
 LIB_OBJS += mailmap.o
 LIB_OBJS += odb/match-trees.o
@@ -1246,7 +1246,7 @@ LIB_OBJS += pack-bitmap.o
 LIB_OBJS += pack-check.o
 LIB_OBJS += pack-mtimes.o
 LIB_OBJS += pack-objects.o
-LIB_OBJS += pack-refs.o
+LIB_OBJS += refs/pack-refs.o
 LIB_OBJS += pack-revindex.o
 LIB_OBJS += pack-write.o
 LIB_OBJS += packfile.o
@@ -1278,17 +1278,17 @@ LIB_OBJS += reachable.o
 LIB_OBJS += read-cache.o
 LIB_OBJS += rebase-interactive.o
 LIB_OBJS += rebase.o
-LIB_OBJS += ref-filter.o
-LIB_OBJS += reflog-walk.o
-LIB_OBJS += reflog.o
-LIB_OBJS += refs.o
+LIB_OBJS += refs/ref-filter.o
+LIB_OBJS += refs/reflog-walk.o
+LIB_OBJS += refs/reflog.o
+LIB_OBJS += refs/refs.o
 LIB_OBJS += refs/debug.o
 LIB_OBJS += refs/files-backend.o
 LIB_OBJS += refs/reftable-backend.o
 LIB_OBJS += refs/iterator.o
 LIB_OBJS += refs/packed-backend.o
 LIB_OBJS += refs/ref-cache.o
-LIB_OBJS += refspec.o
+LIB_OBJS += refs/refspec.o
 LIB_OBJS += reftable/basics.o
 LIB_OBJS += reftable/block.o
 LIB_OBJS += reftable/blocksource.o
@@ -1377,7 +1377,7 @@ LIB_OBJS += version.o
 LIB_OBJS += versioncmp.o
 LIB_OBJS += walker.o
 LIB_OBJS += wildmatch.o
-LIB_OBJS += worktree.o
+LIB_OBJS += refs/worktree.o
 LIB_OBJS += wrapper.o
 LIB_OBJS += write-or-die.o
 LIB_OBJS += ws.o
diff --git a/add-interactive.c b/add-interactive.c
index 51ddcc4e87..67ee53f5cc 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -11,7 +11,7 @@
 #include "read-cache-ll.h"
 #include "repository.h"
 #include "revision.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "string-list.h"
 #include "lockfile.h"
 #include "dir.h"
diff --git a/archive.c b/archive.c
index c0d2e0c44b..53820bd859 100644
--- a/archive.c
+++ b/archive.c
@@ -13,7 +13,7 @@
 #include "path.h"
 #include "pretty.h"
 #include "setup.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/odb.h"
 #include "odb/commit.h"
 #include "odb/tree.h"
diff --git a/attr.c b/attr.c
index e829149cb4..e7c6562bee 100644
--- a/attr.c
+++ b/attr.c
@@ -20,7 +20,7 @@
 #include "utf8.h"
 #include "quote.h"
 #include "read-cache-ll.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "revision.h"
 #include "odb/odb.h"
 #include "setup.h"
diff --git a/bisect.c b/bisect.c
index 2dea7139ad..85c5a12ed2 100644
--- a/bisect.c
+++ b/bisect.c
@@ -9,7 +9,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "revision.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "list-objects.h"
 #include "quote.h"
 #include "run-command.h"
diff --git a/blame.c b/blame.c
index d1cba8811f..a594dc5f0e 100644
--- a/blame.c
+++ b/blame.c
@@ -2,7 +2,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/odb.h"
 #include "cache-tree.h"
 #include "mergesort.h"
diff --git a/branch.c b/branch.c
index 7593a499a9..d752e55b88 100644
--- a/branch.c
+++ b/branch.c
@@ -9,13 +9,13 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "path.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "remote.h"
 #include "repository.h"
 #include "sequencer.h"
 #include "odb/commit.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "submodule-config.h"
 #include "run-command.h"
 #include "strmap.h"
diff --git a/builtin/am.c b/builtin/am.c
index f138a8fe3d..d7e4e125d2 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -22,7 +22,7 @@
 #include "tempfile.h"
 #include "lockfile.h"
 #include "cache-tree.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/commit.h"
 #include "diff.h"
 #include "unpack-trees.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index a1b7fc9407..51e2e949cc 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -9,7 +9,7 @@
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "bisect.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "strvec.h"
 #include "run-command.h"
 #include "odb/oid-array.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index c88fc489f7..1662bd487d 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -30,7 +30,7 @@
 #include "odb/odb.h"
 #include "pager.h"
 #include "blame.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "setup.h"
 #include "odb/tag.h"
 #include "write-or-die.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index c50c28c720..7909f250aa 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -12,7 +12,7 @@
 #include "color.h"
 #include "editor.h"
 #include "environment.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/commit.h"
 #include "gettext.h"
 #include "odb/object-name.h"
@@ -24,8 +24,8 @@
 #include "strmap.h"
 #include "column.h"
 #include "utf8.h"
-#include "ref-filter.h"
-#include "worktree.h"
+#include "refs/ref-filter.h"
+#include "refs/worktree.h"
 #include "help.h"
 #include "advice.h"
 #include "commit-reach.h"
diff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c
index fd1c9c0e0c..5de8c0e6f5 100644
--- a/builtin/check-ref-format.c
+++ b/builtin/check-ref-format.c
@@ -5,7 +5,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "setup.h"
 #include "strbuf.h"
 
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 2dcebb2cb2..87c1f087b8 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -24,7 +24,7 @@
 #include "path.h"
 #include "preload-index.h"
 #include "read-cache.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "remote.h"
 #include "repo-settings.h"
 #include "resolve-undo.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 6d6a756a12..12170ae8f4 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -22,8 +22,8 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "parse-options.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/tree.h"
diff --git a/builtin/config.c b/builtin/config.c
index 0882899c3f..15782dfe64 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -15,7 +15,7 @@
 #include "quote.h"
 #include "setup.h"
 #include "strbuf.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 
 static const char *const builtin_config_usage[] = {
 	N_("git config list [<file-option>] [<display-option>] [--includes]"),
diff --git a/builtin/describe.c b/builtin/describe.c
index 75961c5945..c16a1da092 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -9,7 +9,7 @@
 #include "lockfile.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "read-cache-ll.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 472877f0e5..4a98f14d39 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -12,8 +12,8 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/commit.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 1d560d4e71..43bc72f05f 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -16,7 +16,7 @@
 #include "pack.h"
 #include "path.h"
 #include "read-cache-ll.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "csum-file.h"
 #include "quote.h"
 #include "dir.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 2089e7823e..ce46a709a6 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -11,8 +11,8 @@
 #include "gettext.h"
 #include "environment.h"
 #include "hex.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "odb/oidset.h"
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index d3399455ef..9b3f277cb8 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -6,7 +6,7 @@
 #include "gettext.h"
 #include "odb/object.h"
 #include "parse-options.h"
-#include "ref-filter.h"
+#include "refs/ref-filter.h"
 #include "strbuf.h"
 #include "strvec.h"
 
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 3176941c1d..430cf28bd8 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -6,7 +6,7 @@
 #include "odb/tree.h"
 #include "odb/blob.h"
 #include "odb/tag.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "pack.h"
 #include "cache-tree.h"
 #include "odb/fsck.h"
@@ -23,7 +23,7 @@
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "sparse-index.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "pack-revindex.h"
 #include "pack-bitmap.h"
 
diff --git a/builtin/gc.c b/builtin/gc.c
index f2fdc2c69d..1a71e6f908 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -32,17 +32,17 @@
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "path.h"
-#include "reflog.h"
+#include "refs/reflog.h"
 #include "rerere.h"
 #include "revision.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "remote.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "hook.h"
 #include "setup.h"
 #include "trace2.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 
 #define FAILED_RUN "failed to run %s"
 
diff --git a/builtin/history.c b/builtin/history.c
index a2aa224bd1..56b5015bc0 100644
--- a/builtin/history.c
+++ b/builtin/history.c
@@ -15,7 +15,7 @@
 #include "parse-options.h"
 #include "path.h"
 #include "read-cache.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "replay.h"
 #include "reset.h"
 #include "revision.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index e96b1283b7..f459635129 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -10,7 +10,7 @@
 #include "gettext.h"
 #include "parse-options.h"
 #include "path.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "setup.h"
 #include "strbuf.h"
 
diff --git a/builtin/log.c b/builtin/log.c
index ab381e529e..7099f5fcc5 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -13,7 +13,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "odb/streaming.h"
@@ -28,7 +28,7 @@
 #include "odb/oid-array.h"
 #include "odb/oidset.h"
 #include "odb/tag.h"
-#include "reflog-walk.h"
+#include "refs/reflog-walk.h"
 #include "patch-ids.h"
 #include "path.h"
 #include "shortlog.h"
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index fe77829557..1b12d6e6ec 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -4,7 +4,7 @@
 #include "hex.h"
 #include "transport.h"
 #include "pkt-line.h"
-#include "ref-filter.h"
+#include "refs/ref-filter.h"
 #include "remote.h"
 #include "parse-options.h"
 #include "wildmatch.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 56f89b2944..2369c3b6f9 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -26,8 +26,8 @@
 #include "hook.h"
 #include "diff.h"
 #include "diff-merges.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "odb/commit.h"
 #include "diffcore.h"
 #include "path.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index d2870bd37c..4e0254d70e 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -8,7 +8,7 @@
 #include "config.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/object-name.h"
 #include "pager.h"
 #include "parse-options.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 2cf1437346..6ebb5db39c 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -20,14 +20,14 @@
 #include "path.h"
 
 #include "pretty.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "exec-cmd.h"
 #include "run-command.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "notes-merge.h"
 #include "notes-utils.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "write-or-die.h"
 
 static const char *separator = "\n";
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 3e4c5442dc..69f35a727b 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -21,7 +21,7 @@
 #include "list-objects-filter-options.h"
 #include "pack-objects.h"
 #include "progress.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "thread-utils.h"
 #include "pack-bitmap.h"
 #include "delta-islands.h"
diff --git a/builtin/pack-refs.c b/builtin/pack-refs.c
index 3446b84cda..235ae2cc5a 100644
--- a/builtin/pack-refs.c
+++ b/builtin/pack-refs.c
@@ -1,6 +1,6 @@
 #include "builtin.h"
 #include "gettext.h"
-#include "pack-refs.h"
+#include "refs/pack-refs.h"
 
 int cmd_pack_refs(int argc,
 		  const char **argv,
diff --git a/builtin/pull.c b/builtin/pull.c
index cb3d76cb16..bc8dcde318 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -24,8 +24,8 @@
 #include "path.h"
 #include "read-cache-ll.h"
 #include "rebase.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "submodule.h"
 #include "submodule-config.h"
 #include "wt-status.h"
diff --git a/builtin/push.c b/builtin/push.c
index 2377b5af55..39b6ff4b8b 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -12,7 +12,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "refspec.h"
+#include "refs/refspec.h"
 #include "run-command.h"
 #include "remote.h"
 #include "transport.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 7b8366e5cd..983dbb7ce5 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -16,7 +16,7 @@
 #include "run-command.h"
 #include "strvec.h"
 #include "dir.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "config.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 5ec79a4595..88cbaed133 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -27,7 +27,7 @@
 #include "parse-options.h"
 #include "pkt-line.h"
 #include "protocol.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "remote.h"
 #include "run-command.h"
 #include "server-info.h"
@@ -40,7 +40,7 @@
 #include "trace.h"
 #include "trace2.h"
 #include "version.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 
 static const char * const receive_pack_usage[] = {
 	N_("git receive-pack <git-dir>"),
diff --git a/builtin/reflog.c b/builtin/reflog.c
index b709cb0e3c..fc0b74ed95 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -8,9 +8,9 @@
 #include "revision.h"
 #include "reachable.h"
 #include "wildmatch.h"
-#include "worktree.h"
-#include "reflog.h"
-#include "refs.h"
+#include "refs/worktree.h"
+#include "refs/reflog.h"
+#include "refs/refs.h"
 #include "parse-options.h"
 
 #define BUILTIN_REFLOG_SHOW_USAGE \
diff --git a/builtin/refs.c b/builtin/refs.c
index 37936353be..abfc0acdd2 100644
--- a/builtin/refs.c
+++ b/builtin/refs.c
@@ -1,11 +1,11 @@
 #include "builtin.h"
 #include "config.h"
 #include "odb/fsck.h"
-#include "pack-refs.h"
+#include "refs/pack-refs.h"
 #include "parse-options.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "strbuf.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "for-each-ref.h"
 #include "refs/refs-internal.h"
 
diff --git a/builtin/remote.c b/builtin/remote.c
index b5b54ded27..9a5df99c11 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -14,8 +14,8 @@
 #include "strbuf.h"
 #include "run-command.h"
 #include "rebase.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "odb/odb.h"
 #include "strvec.h"
 #include "commit-reach.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index 793226006c..83497cd974 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -14,7 +14,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "parse-options.h"
 #include "path.h"
 #include "run-command.h"
diff --git a/builtin/replay.c b/builtin/replay.c
index 4ea7c42215..83b136a13e 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -9,7 +9,7 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "replay.h"
 #include "revision.h"
 
diff --git a/builtin/repo.c b/builtin/repo.c
index 473072b44d..e052e6c0ba 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -11,8 +11,8 @@
 #include "path-walk.h"
 #include "progress.h"
 #include "quote.h"
-#include "ref-filter.h"
-#include "refs.h"
+#include "refs/ref-filter.h"
+#include "refs/refs.h"
 #include "revision.h"
 #include "setup.h"
 #include "strbuf.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 55539f565c..c3bfbab7d5 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -20,7 +20,7 @@
 #include "lockfile.h"
 #include "odb/object.h"
 #include "pretty.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "odb/tree.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 0c55dc5b96..466a0a515d 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -21,7 +21,7 @@
 #include "graph.h"
 #include "bisect.h"
 #include "progress.h"
-#include "reflog-walk.h"
+#include "refs/reflog-walk.h"
 #include "odb/oidset.h"
 #include "odb/oidmap.h"
 #include "packfile.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index f3bf7831b7..2fb682d5a2 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -17,7 +17,7 @@
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "quote.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index c58abc872f..4da3330a26 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -8,7 +8,7 @@
 #include "odb/hash.h"
 #include "hex.h"
 #include "pretty.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "color.h"
 #include "strvec.h"
 #include "odb/object-name.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index e2186fdd33..9b4cad87a5 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -19,7 +19,7 @@
 #include "quote.h"
 #include "setup.h"
 #include "sparse-index.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 
 static const char *empty_base = "";
 
diff --git a/builtin/stash.c b/builtin/stash.c
index 2af975aaff..62fec2f17f 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -9,7 +9,7 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "lockfile.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
@@ -27,8 +27,8 @@
 #include "sparse-index.h"
 #include "log-tree.h"
 #include "diffcore.h"
-#include "reflog.h"
-#include "reflog-walk.h"
+#include "refs/reflog.h"
+#include "refs/reflog-walk.h"
 #include "add-interactive.h"
 #include "odb/oid-array.h"
 #include "odb/commit.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 96c83476df..bf8b20247f 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -21,8 +21,8 @@
 #include "string-list.h"
 #include "run-command.h"
 #include "remote.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index 231e41e715..9ea9ca6500 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -3,7 +3,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "parse-options.h"
 #include "strbuf.h"
 
diff --git a/builtin/tag.c b/builtin/tag.c
index e3eee35e88..d554ae8f81 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -16,7 +16,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
@@ -28,7 +28,7 @@
 #include "gpg-interface.h"
 #include "odb/oid-array.h"
 #include "column.h"
-#include "ref-filter.h"
+#include "refs/ref-filter.h"
 #include "date.h"
 #include "write-or-die.h"
 #include "odb/object-file-convert.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 992f496efd..54741c3241 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -20,7 +20,7 @@
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/transaction.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "resolve-undo.h"
 #include "parse-options.h"
 #include "pathspec.h"
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index e7ac68f495..5bcd100e52 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -7,7 +7,7 @@
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "quote.h"
diff --git a/builtin/var.c b/builtin/var.c
index cc3a43cde2..d01c87dfa2 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -14,7 +14,7 @@
 #include "environment.h"
 #include "ident.h"
 #include "pager.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "path.h"
 #include "strbuf.h"
 #include "run-command.h"
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 791679a4d8..460244f25b 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -13,7 +13,7 @@
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "gpg-interface.h"
-#include "ref-filter.h"
+#include "refs/ref-filter.h"
 
 static const char * const verify_tag_usage[] = {
 		N_("git verify-tag [-v | --verbose] [--format=<format>] [--raw] <tag>..."),
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 7c2ed274f9..90af2193c1 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -18,14 +18,14 @@
 #include "strvec.h"
 #include "branch.h"
 #include "read-cache-ll.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "remote.h"
 #include "run-command.h"
 #include "hook.h"
 #include "sigchain.h"
 #include "submodule.h"
 #include "utf8.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "quote.h"
 
 #define BUILTIN_WORKTREE_ADD_USAGE \
diff --git a/bundle-uri.c b/bundle-uri.c
index 948265330b..96ddf92347 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -6,7 +6,7 @@
 #include "bundle.h"
 #include "copy.h"
 #include "gettext.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "run-command.h"
 #include "hashmap.h"
 #include "pkt-line.h"
diff --git a/bundle.c b/bundle.c
index 81d241e6d0..c64b14a05a 100644
--- a/bundle.c
+++ b/bundle.c
@@ -15,7 +15,7 @@
 #include "revision.h"
 #include "list-objects.h"
 #include "run-command.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "strvec.h"
 #include "list-objects-filter-options.h"
 #include "connected.h"
diff --git a/checkout.c b/checkout.c
index 966a70c267..e3b4d341da 100644
--- a/checkout.c
+++ b/checkout.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "odb/object-name.h"
 #include "remote.h"
-#include "refspec.h"
+#include "refs/refspec.h"
 #include "repository.h"
 #include "checkout.h"
 #include "config.h"
diff --git a/combine-diff.c b/combine-diff.c
index 1c33937f21..6f16e9ea38 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -14,7 +14,7 @@
 #include "xdiff-interface.h"
 #include "xdiff/xmacros.h"
 #include "log-tree.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/tree.h"
 #include "userdiff.h"
 #include "odb/oid-array.h"
diff --git a/commit-graph.c b/commit-graph.c
index abf7c404b3..7c22588c46 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -10,7 +10,7 @@
 #include "packfile.h"
 #include "odb/commit.h"
 #include "odb/object.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/hash-lookup.h"
 #include "commit-graph.h"
 #include "odb/odb.h"
diff --git a/commit-reach.c b/commit-reach.c
index 9b4715fd65..9636b5b37f 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -6,7 +6,7 @@
 #include "decorate.h"
 #include "hex.h"
 #include "prio-queue.h"
-#include "ref-filter.h"
+#include "refs/ref-filter.h"
 #include "revision.h"
 #include "odb/tag.h"
 #include "commit-reach.h"
diff --git a/config.c b/config.c
index eacc6847a2..3f335dbec1 100644
--- a/config.c
+++ b/config.c
@@ -30,7 +30,7 @@
 #include "path.h"
 #include "utf8.h"
 #include "color.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "setup.h"
 #include "strvec.h"
 #include "trace2.h"
diff --git a/connect.c b/connect.c
index e54c88f5e2..a24b019b2c 100644
--- a/connect.c
+++ b/connect.c
@@ -7,7 +7,7 @@
 #include "hex.h"
 #include "pkt-line.h"
 #include "quote.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "run-command.h"
 #include "remote.h"
 #include "connect.h"
diff --git a/delta-islands.c b/delta-islands.c
index 0c0d222ab3..1c92cdf37c 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -11,7 +11,7 @@
 #include "odb/tree-walk.h"
 #include "diff.h"
 #include "progress.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "khash.h"
 #include "pack-bitmap.h"
 #include "pack-objects.h"
diff --git a/diff-lib.c b/diff-lib.c
index 313b6136b1..a5072c5f6d 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -17,7 +17,7 @@
 #include "revision.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "repository.h"
 #include "submodule.h"
 #include "symlinks.h"
diff --git a/dir.c b/dir.c
index c9005a0ac1..d230ecdec1 100644
--- a/dir.c
+++ b/dir.c
@@ -19,7 +19,7 @@
 #include "name-hash.h"
 #include "odb/object-file.h"
 #include "path.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "repository.h"
 #include "wildmatch.h"
 #include "pathspec.h"
diff --git a/environment.c b/environment.c
index 40b993ec90..6066417b62 100644
--- a/environment.c
+++ b/environment.c
@@ -26,7 +26,7 @@
 #include "odb/object-name.h"
 #include "repository.h"
 #include "config.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "fmt-merge-msg.h"
 #include "odb/commit.h"
 #include "strvec.h"
diff --git a/fetch-pack.c b/fetch-pack.c
index b172114879..434b57e5b0 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -9,7 +9,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "pkt-line.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 6e11ad0fa9..7fa8c4cd79 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -4,7 +4,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "diff.h"
diff --git a/help.c b/help.c
index ccc42f09e0..96f98ec621 100644
--- a/help.c
+++ b/help.c
@@ -15,7 +15,7 @@
 #include "string-list.h"
 #include "column.h"
 #include "version.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "parse-options.h"
 #include "prompt.h"
 #include "fsmonitor-ipc.h"
diff --git a/http-backend.c b/http-backend.c
index 9b7ae96579..90624c3348 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -8,7 +8,7 @@
 #include "hex.h"
 #include "path.h"
 #include "repository.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "pkt-line.h"
 #include "odb/object.h"
 #include "odb/tag.h"
diff --git a/log-tree.c b/log-tree.c
index c9fde242a1..116bb7ea68 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -18,8 +18,8 @@
 #include "graph.h"
 #include "log-tree.h"
 #include "merge-ort.h"
-#include "reflog-walk.h"
-#include "refs.h"
+#include "refs/reflog-walk.h"
+#include "refs/refs.h"
 #include "odb/replace-object.h"
 #include "revision.h"
 #include "string-list.h"
diff --git a/merge-ort.c b/merge-ort.c
index 35d30dcf06..a12bf62a3d 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -44,7 +44,7 @@
 #include "path.h"
 #include "promisor-remote.h"
 #include "read-cache-ll.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "revision.h"
 #include "sparse-index.h"
 #include "strmap.h"
diff --git a/meson.build b/meson.build
index 6586f8ae9f..8dd613a8bb 100644
--- a/meson.build
+++ b/meson.build
@@ -406,7 +406,7 @@ libgit_sources = [
   'lockfile.c',
   'log-tree.c',
   'odb/loose.c',
-  'ls-refs.c',
+  'refs/ls-refs.c',
   'mailinfo.c',
   'mailmap.c',
   'odb/match-trees.c',
@@ -451,7 +451,7 @@ libgit_sources = [
   'pack-check.c',
   'pack-mtimes.c',
   'pack-objects.c',
-  'pack-refs.c',
+  'refs/pack-refs.c',
   'pack-revindex.c',
   'pack-write.c',
   'packfile.c',
@@ -483,17 +483,17 @@ libgit_sources = [
   'read-cache.c',
   'rebase-interactive.c',
   'rebase.c',
-  'ref-filter.c',
-  'reflog-walk.c',
-  'reflog.c',
-  'refs.c',
+  'refs/ref-filter.c',
+  'refs/reflog-walk.c',
+  'refs/reflog.c',
+  'refs/refs.c',
   'refs/debug.c',
   'refs/files-backend.c',
   'refs/reftable-backend.c',
   'refs/iterator.c',
   'refs/packed-backend.c',
   'refs/ref-cache.c',
-  'refspec.c',
+  'refs/refspec.c',
   'reftable/basics.c',
   'reftable/error.c',
   'reftable/block.c',
@@ -579,7 +579,7 @@ libgit_sources = [
   'versioncmp.c',
   'walker.c',
   'wildmatch.c',
-  'worktree.c',
+  'refs/worktree.c',
   'wrapper.c',
   'write-or-die.c',
   'ws.c',
diff --git a/midx-write.c b/midx-write.c
index bb4ceaede7..af4410a0b8 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -12,7 +12,7 @@
 #include "run-command.h"
 #include "chunk-format.h"
 #include "pack-bitmap.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "revision.h"
 #include "list-objects.h"
 #include "path.h"
diff --git a/negotiator/default.c b/negotiator/default.c
index 404db17785..7d67933e06 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -5,7 +5,7 @@
 #include "odb/commit.h"
 #include "../fetch-negotiator.h"
 #include "../prio-queue.h"
-#include "../refs.h"
+#include "refs/refs.h"
 #include "../repository.h"
 #include "odb/tag.h"
 
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index e1218d2a93..9e685f54a1 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -6,7 +6,7 @@
 #include "../fetch-negotiator.h"
 #include "../hex.h"
 #include "../prio-queue.h"
-#include "../refs.h"
+#include "refs/refs.h"
 #include "../repository.h"
 #include "odb/tag.h"
 
diff --git a/notes-cache.c b/notes-cache.c
index abe0964bba..02fb418c6f 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -7,7 +7,7 @@
 #include "pretty.h"
 #include "repository.h"
 #include "odb/commit.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "strbuf.h"
 
 static int notes_cache_match_validity(struct repository *r,
diff --git a/notes-merge.c b/notes-merge.c
index 2b025b6d3d..72a3b9479c 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -5,7 +5,7 @@
 #include "advice.h"
 #include "odb/commit.h"
 #include "gettext.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
diff --git a/notes-utils.c b/notes-utils.c
index b6275dfa26..491de7a7ce 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -5,7 +5,7 @@
 #include "odb/commit.h"
 #include "environment.h"
 #include "gettext.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "notes-utils.h"
 #include "strbuf.h"
 
diff --git a/notes.c b/notes.c
index ef44dae00d..5842226c68 100644
--- a/notes.c
+++ b/notes.c
@@ -13,7 +13,7 @@
 #include "strbuf.h"
 #include "odb/tree-walk.h"
 #include "string-list.h"
-#include "refs.h"
+#include "refs/refs.h"
 
 /*
  * Use a non-balancing simple 16-tree structure with struct int_node as
diff --git a/odb/commit.c b/odb/commit.c
index d0e036876c..dc98000ab2 100644
--- a/odb/commit.c
+++ b/odb/commit.c
@@ -22,7 +22,7 @@
 #include "odb/hash-lookup.h"
 #include "wt-status.h"
 #include "advice.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "commit-reach.h"
 #include "setup.h"
 #include "shallow.h"
diff --git a/odb/fsck.c b/odb/fsck.c
index e76779109a..75306dc8a3 100644
--- a/odb/fsck.c
+++ b/odb/fsck.c
@@ -14,7 +14,7 @@
 #include "odb/commit.h"
 #include "odb/tag.h"
 #include "odb/fsck.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "url.h"
 #include "utf8.h"
 #include "odb/oidset.h"
diff --git a/odb/object-name.c b/odb/object-name.c
index 98c88e7337..16b6cd8f12 100644
--- a/odb/object-name.c
+++ b/odb/object-name.c
@@ -12,7 +12,7 @@
 #include "odb/commit.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "remote.h"
 #include "dir.h"
 #include "odb/odb.h"
diff --git a/odb/replace-object.c b/odb/replace-object.c
index 32d778f55e..c69c5aa200 100644
--- a/odb/replace-object.c
+++ b/odb/replace-object.c
@@ -4,7 +4,7 @@
 #include "odb/oidmap.h"
 #include "odb/odb.h"
 #include "odb/replace-object.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "repository.h"
 #include "odb/commit.h"
 
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 64233d6cd0..b5e14b196f 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -23,7 +23,7 @@
 #include "odb/oid-array.h"
 #include "config.h"
 #include "odb/alloc.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "strmap.h"
 #include "midx.h"
 #include "pack-revindex.h"
diff --git a/pack-bitmap.h b/pack-bitmap.h
index 1385027c1f..b50ef0b4e4 100644
--- a/pack-bitmap.h
+++ b/pack-bitmap.h
@@ -5,7 +5,7 @@
 #include "khash.h"
 #include "pack.h"
 #include "pack-objects.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "string-list.h"
 
 struct commit;
diff --git a/path.c b/path.c
index 3a3a66155a..4afd1e3ffa 100644
--- a/path.c
+++ b/path.c
@@ -9,7 +9,7 @@
 #include "strbuf.h"
 #include "string-list.h"
 #include "dir.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "setup.h"
 #include "submodule-config.h"
 #include "path.h"
diff --git a/pretty.c b/pretty.c
index 461e8cd527..4575f3fde6 100644
--- a/pretty.c
+++ b/pretty.c
@@ -17,7 +17,7 @@
 #include "log-tree.h"
 #include "notes.h"
 #include "color.h"
-#include "reflog-walk.h"
+#include "refs/reflog-walk.h"
 #include "gpg-interface.h"
 #include "trailer.h"
 #include "run-command.h"
diff --git a/pseudo-merge.c b/pseudo-merge.c
index 0809a2bcb3..f87fd46b46 100644
--- a/pseudo-merge.c
+++ b/pseudo-merge.c
@@ -8,7 +8,7 @@
 #include "strbuf.h"
 #include "config.h"
 #include "string-list.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "pack-bitmap.h"
 #include "odb/commit.h"
 #include "odb/alloc.h"
diff --git a/reachable.c b/reachable.c
index 2a62adf7f5..a99699c6d8 100644
--- a/reachable.c
+++ b/reachable.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/commit.h"
 #include "odb/blob.h"
 #include "diff.h"
@@ -13,7 +13,7 @@
 #include "progress.h"
 #include "list-objects.h"
 #include "packfile.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "odb/object-file.h"
 #include "pack-bitmap.h"
 #include "pack-mtimes.h"
diff --git a/read-cache.c b/read-cache.c
index 8f6b812b5f..148a93f10e 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -16,7 +16,7 @@
 #include "tempfile.h"
 #include "lockfile.h"
 #include "cache-tree.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "dir.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index ef7532e727..35acc13ccc 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -9,7 +9,7 @@
 #include "odb/hash.h"
 #include "../hex.h"
 #include "odb/fsck.h"
-#include "../refs.h"
+#include "refs/refs.h"
 #include "../repo-settings.h"
 #include "refs-internal.h"
 #include "ref-cache.h"
@@ -22,7 +22,7 @@
 #include "../dir.h"
 #include "../chdir-notify.h"
 #include "../setup.h"
-#include "../worktree.h"
+#include "refs/worktree.h"
 #include "../wrapper.h"
 #include "../write-or-die.h"
 #include "../revision.h"
diff --git a/refs/iterator.c b/refs/iterator.c
index d5cacde51b..08c80ee818 100644
--- a/refs/iterator.c
+++ b/refs/iterator.c
@@ -6,7 +6,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "refs/refs-internal.h"
 #include "iterator.h"
 
diff --git a/ls-refs.c b/refs/ls-refs.c
similarity index 99%
rename from ls-refs.c
rename to refs/ls-refs.c
index e29ef0947f..75b9b5e620 100644
--- a/ls-refs.c
+++ b/refs/ls-refs.c
@@ -6,9 +6,9 @@
 #include "odb/hash.h"
 #include "hex.h"
 #include "repository.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "strvec.h"
-#include "ls-refs.h"
+#include "refs/ls-refs.h"
 #include "pkt-line.h"
 #include "config.h"
 #include "string-list.h"
diff --git a/ls-refs.h b/refs/ls-refs.h
similarity index 100%
rename from ls-refs.h
rename to refs/ls-refs.h
diff --git a/pack-refs.c b/refs/pack-refs.c
similarity index 97%
rename from pack-refs.c
rename to refs/pack-refs.c
index eb6b2ba2c2..c9f36872cc 100644
--- a/pack-refs.c
+++ b/refs/pack-refs.c
@@ -1,9 +1,9 @@
 #include "builtin.h"
 #include "config.h"
 #include "environment.h"
-#include "pack-refs.h"
+#include "refs/pack-refs.h"
 #include "parse-options.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "revision.h"
 
 int pack_refs_core(int argc,
diff --git a/pack-refs.h b/refs/pack-refs.h
similarity index 100%
rename from pack-refs.h
rename to refs/pack-refs.h
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index c7005a9ecc..afcb800a5f 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -7,14 +7,14 @@
 #include "../gettext.h"
 #include "odb/hash.h"
 #include "../hex.h"
-#include "../refs.h"
+#include "refs/refs.h"
 #include "refs-internal.h"
 #include "packed-backend.h"
 #include "../iterator.h"
 #include "../lockfile.h"
 #include "../chdir-notify.h"
 #include "../statinfo.h"
-#include "../worktree.h"
+#include "refs/worktree.h"
 #include "../wrapper.h"
 #include "../write-or-die.h"
 #include "../trace2.h"
diff --git a/refs/ref-cache.c b/refs/ref-cache.c
index a4182ea57f..3599199b8e 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -1,6 +1,6 @@
 #include "../git-compat-util.h"
 #include "odb/hash.h"
-#include "../refs.h"
+#include "refs/refs.h"
 #include "../repository.h"
 #include "refs-internal.h"
 #include "ref-cache.h"
diff --git a/ref-filter.c b/refs/ref-filter.c
similarity index 99%
rename from ref-filter.c
rename to refs/ref-filter.c
index 8a3d056577..e3de16b7a7 100644
--- a/ref-filter.c
+++ b/refs/ref-filter.c
@@ -9,7 +9,7 @@
 #include "hex.h"
 #include "parse-options.h"
 #include "run-command.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "wildmatch.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
@@ -23,7 +23,7 @@
 #include "color.h"
 #include "odb/tag.h"
 #include "quote.h"
-#include "ref-filter.h"
+#include "refs/ref-filter.h"
 #include "revision.h"
 #include "utf8.h"
 #include "versioncmp.h"
@@ -31,7 +31,7 @@
 #include "wt-status.h"
 #include "odb/commit-slab.h"
 #include "commit-reach.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "hashmap.h"
 
 static struct ref_msg {
diff --git a/ref-filter.h b/refs/ref-filter.h
similarity index 100%
rename from ref-filter.h
rename to refs/ref-filter.h
diff --git a/reflog-walk.c b/refs/reflog-walk.c
similarity index 99%
rename from reflog-walk.c
rename to refs/reflog-walk.c
index 4058cfa6df..711b71be66 100644
--- a/reflog-walk.c
+++ b/refs/reflog-walk.c
@@ -2,12 +2,12 @@
 
 #include "git-compat-util.h"
 #include "odb/commit.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "diff.h"
 #include "repository.h"
 #include "revision.h"
 #include "string-list.h"
-#include "reflog-walk.h"
+#include "refs/reflog-walk.h"
 
 struct complete_reflogs {
 	char *ref;
diff --git a/reflog-walk.h b/refs/reflog-walk.h
similarity index 100%
rename from reflog-walk.h
rename to refs/reflog-walk.h
diff --git a/reflog.c b/refs/reflog.c
similarity index 99%
rename from reflog.c
rename to refs/reflog.c
index 178ef7fe44..751485f885 100644
--- a/reflog.c
+++ b/refs/reflog.c
@@ -7,8 +7,8 @@
 #include "gettext.h"
 #include "parse-options.h"
 #include "odb/odb.h"
-#include "reflog.h"
-#include "refs.h"
+#include "refs/reflog.h"
+#include "refs/refs.h"
 #include "revision.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
diff --git a/reflog.h b/refs/reflog.h
similarity index 99%
rename from reflog.h
rename to refs/reflog.h
index b996712c00..ef39b0fcc5 100644
--- a/reflog.h
+++ b/refs/reflog.h
@@ -1,6 +1,6 @@
 #ifndef REFLOG_H
 #define REFLOG_H
-#include "refs.h"
+#include "refs/refs.h"
 
 #define REFLOG_EXPIRE_TOTAL   (1 << 0)
 #define REFLOG_EXPIRE_UNREACH (1 << 1)
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index c3ac7b556f..51be5be0fb 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -1,7 +1,7 @@
 #ifndef REFS_REFS_INTERNAL_H
 #define REFS_REFS_INTERNAL_H
 
-#include "refs.h"
+#include "refs/refs.h"
 #include "iterator.h"
 #include "string-list.h"
 
diff --git a/refs.c b/refs/refs.c
similarity index 99%
rename from refs.c
rename to refs/refs.c
index e01163be2a..2bc9c3cecd 100644
--- a/refs.c
+++ b/refs/refs.c
@@ -12,7 +12,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "iterator.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "refs/refs-internal.h"
 #include "hook.h"
 #include "odb/object-name.h"
@@ -20,7 +20,7 @@
 #include "odb/object.h"
 #include "path.h"
 #include "submodule.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "strvec.h"
 #include "repo-settings.h"
 #include "setup.h"
diff --git a/refs.h b/refs/refs.h
similarity index 100%
rename from refs.h
rename to refs/refs.h
diff --git a/refspec.c b/refs/refspec.c
similarity index 99%
rename from refspec.c
rename to refs/refspec.c
index f3cb1b0748..324c274bff 100644
--- a/refspec.c
+++ b/refs/refspec.c
@@ -6,8 +6,8 @@
 #include "hex.h"
 #include "string-list.h"
 #include "strvec.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "remote.h"
 #include "strbuf.h"
 
diff --git a/refspec.h b/refs/refspec.h
similarity index 100%
rename from refspec.h
rename to refs/refspec.h
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index 9d6194c4e6..120f9c947f 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -12,7 +12,7 @@
 #include "../iterator.h"
 #include "../parse.h"
 #include "../path.h"
-#include "../refs.h"
+#include "refs/refs.h"
 #include "../reftable/reftable-basics.h"
 #include "../reftable/reftable-error.h"
 #include "../reftable/reftable-fsck.h"
@@ -23,7 +23,7 @@
 #include "../setup.h"
 #include "../strmap.h"
 #include "../trace2.h"
-#include "../worktree.h"
+#include "refs/worktree.h"
 #include "../write-or-die.h"
 #include "refs-internal.h"
 
diff --git a/worktree.c b/refs/worktree.c
similarity index 99%
rename from worktree.c
rename to refs/worktree.c
index cbf95328a3..3578229534 100644
--- a/worktree.c
+++ b/refs/worktree.c
@@ -6,10 +6,10 @@
 #include "gettext.h"
 #include "path.h"
 #include "repository.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "setup.h"
 #include "strbuf.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "dir.h"
 #include "wt-status.h"
 #include "config.h"
diff --git a/worktree.h b/refs/worktree.h
similarity index 99%
rename from worktree.h
rename to refs/worktree.h
index fbb2757f5b..11cdc5f7fc 100644
--- a/worktree.h
+++ b/refs/worktree.h
@@ -1,7 +1,7 @@
 #ifndef WORKTREE_H
 #define WORKTREE_H
 
-#include "refs.h"
+#include "refs/refs.h"
 
 struct strbuf;
 
diff --git a/remote.c b/remote.c
index 89dc91429a..39e9f58cba 100644
--- a/remote.c
+++ b/remote.c
@@ -10,8 +10,8 @@
 #include "remote.h"
 #include "url.h"
 #include "urlmatch.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "path.h"
diff --git a/remote.h b/remote.h
index fbf552cc2f..e094082e03 100644
--- a/remote.h
+++ b/remote.h
@@ -3,7 +3,7 @@
 
 #include "odb/hash.h"
 #include "hashmap.h"
-#include "refspec.h"
+#include "refs/refspec.h"
 #include "string-list.h"
 #include "strvec.h"
 
diff --git a/repack-midx.c b/repack-midx.c
index a9df431952..342deb798c 100644
--- a/repack-midx.c
+++ b/repack-midx.c
@@ -8,7 +8,7 @@
 #include "odb/oidset.h"
 #include "pack-bitmap.h"
 #include "path.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "run-command.h"
 #include "tempfile.h"
 #include "trace2.h"
diff --git a/replay.c b/replay.c
index 9e29f29ff6..8dd7b99502 100644
--- a/replay.c
+++ b/replay.c
@@ -5,7 +5,7 @@
 #include "hex.h"
 #include "merge-ort.h"
 #include "odb/object-name.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "replay.h"
 #include "revision.h"
 #include "sequencer.h"
diff --git a/repository.c b/repository.c
index 72434e3a50..b5e442f9f3 100644
--- a/repository.c
+++ b/repository.c
@@ -17,7 +17,7 @@
 #include "sparse-index.h"
 #include "trace2.h"
 #include "promisor-remote.h"
-#include "refs.h"
+#include "refs/refs.h"
 
 /*
  * We do not define `USE_THE_REPOSITORY_VARIABLE` in this file because we do
diff --git a/reset.c b/reset.c
index 950d45d07d..29bbeaa9d4 100644
--- a/reset.c
+++ b/reset.c
@@ -4,7 +4,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "odb/object-name.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "reset.h"
 #include "odb/tree-walk.h"
 #include "odb/tree.h"
diff --git a/revision.c b/revision.c
index 9e90f909da..35a1893436 100644
--- a/revision.c
+++ b/revision.c
@@ -16,12 +16,12 @@
 #include "odb/commit.h"
 #include "diff.h"
 #include "diff-merges.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "revision.h"
 #include "repository.h"
 #include "graph.h"
 #include "grep.h"
-#include "reflog-walk.h"
+#include "refs/reflog-walk.h"
 #include "patch-ids.h"
 #include "decorate.h"
 #include "string-list.h"
@@ -32,7 +32,7 @@
 #include "cache-tree.h"
 #include "bisect.h"
 #include "packfile.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "path.h"
 #include "read-cache.h"
 #include "setup.h"
diff --git a/scalar.c b/scalar.c
index a80d8ee3ff..af3456b5d0 100644
--- a/scalar.c
+++ b/scalar.c
@@ -13,7 +13,7 @@
 #include "simple-ipc.h"
 #include "fsmonitor-ipc.h"
 #include "fsmonitor-settings.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "dir.h"
 #include "packfile.h"
 #include "help.h"
diff --git a/sequencer.c b/sequencer.c
index 67ab3cdf0d..d13721ab1f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -29,7 +29,7 @@
 #include "merge.h"
 #include "merge-ort.h"
 #include "merge-ort-wrappers.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "sparse-index.h"
 #include "strvec.h"
 #include "quote.h"
diff --git a/serve.c b/serve.c
index 95cf3d8ea4..df3086fb3a 100644
--- a/serve.c
+++ b/serve.c
@@ -4,7 +4,7 @@
 #include "odb/hash.h"
 #include "pkt-line.h"
 #include "version.h"
-#include "ls-refs.h"
+#include "refs/ls-refs.h"
 #include "protocol-caps.h"
 #include "serve.h"
 #include "upload-pack.h"
diff --git a/server-info.c b/server-info.c
index 75ead482e1..3021ee8926 100644
--- a/server-info.c
+++ b/server-info.c
@@ -4,7 +4,7 @@
 #include "dir.h"
 #include "hex.h"
 #include "repository.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/object.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
diff --git a/setup.c b/setup.c
index fe8e9ffdc5..925a600dba 100644
--- a/setup.c
+++ b/setup.c
@@ -9,7 +9,7 @@
 #include "hex.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "repository.h"
 #include "config.h"
 #include "dir.h"
@@ -22,7 +22,7 @@
 #include "quote.h"
 #include "trace.h"
 #include "trace2.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 
 enum allowed_bare_repo {
 	ALLOWED_BARE_REPO_EXPLICIT = 0,
diff --git a/setup.h b/setup.h
index 763fd384e8..7bfc5ce068 100644
--- a/setup.h
+++ b/setup.h
@@ -1,7 +1,7 @@
 #ifndef SETUP_H
 #define SETUP_H
 
-#include "refs.h"
+#include "refs/refs.h"
 #include "string-list.h"
 
 int is_inside_git_dir(struct repository *repo);
diff --git a/shallow.c b/shallow.c
index 25116d7a6e..daa6db8e0d 100644
--- a/shallow.c
+++ b/shallow.c
@@ -9,7 +9,7 @@
 #include "odb/commit.h"
 #include "odb/tag.h"
 #include "pkt-line.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "odb/oid-array.h"
 #include "path.h"
 #include "diff.h"
diff --git a/submodule.c b/submodule.c
index d091b484a4..32af65e6b8 100644
--- a/submodule.c
+++ b/submodule.c
@@ -16,14 +16,14 @@
 #include "revision.h"
 #include "run-command.h"
 #include "diffcore.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "string-list.h"
 #include "odb/oid-array.h"
 #include "strvec.h"
 #include "thread-utils.h"
 #include "path.h"
 #include "remote.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "parse-options.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 4151cfbe25..df1c677b9f 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -6,7 +6,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
-#include "ref-filter.h"
+#include "refs/ref-filter.h"
 #include "setup.h"
 #include "string-list.h"
 #include "odb/tag.h"
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 1fbdc52fc5..8c2fb0aad7 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -2,9 +2,9 @@
 
 #include "test-tool.h"
 #include "hex.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "setup.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "odb/odb.h"
 #include "path.h"
 #include "repository.h"
diff --git a/transport-helper.c b/transport-helper.c
index 59f61f23c6..55bd9291db 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -15,8 +15,8 @@
 #include "thread-utils.h"
 #include "sigchain.h"
 #include "strvec.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "transport-internal.h"
 #include "protocol.h"
 #include "packfile.h"
diff --git a/transport.c b/transport.c
index 5b83cf9e73..38915e5466 100644
--- a/transport.c
+++ b/transport.c
@@ -15,8 +15,8 @@
 #include "send-pack.h"
 #include "bundle.h"
 #include "gettext.h"
-#include "refs.h"
-#include "refspec.h"
+#include "refs/refs.h"
+#include "refs/refspec.h"
 #include "branch.h"
 #include "url.h"
 #include "submodule.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index d6e05207a8..b911700d74 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -16,7 +16,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "progress.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "attr.h"
 #include "read-cache.h"
 #include "split-index.h"
diff --git a/upload-pack.c b/upload-pack.c
index 5c12af2219..80d2c95c9b 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -6,7 +6,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "pkt-line.h"
 #include "sideband.h"
 #include "repository.h"
diff --git a/walker.c b/walker.c
index 876865d20a..83f980c1f3 100644
--- a/walker.c
+++ b/walker.c
@@ -12,7 +12,7 @@
 #include "odb/tree-walk.h"
 #include "odb/tag.h"
 #include "odb/blob.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "progress.h"
 #include "prio-queue.h"
 
diff --git a/wt-status.c b/wt-status.c
index 950ebc3418..708366b973 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -21,7 +21,7 @@
 #include "run-command.h"
 #include "strvec.h"
 #include "remote.h"
-#include "refs.h"
+#include "refs/refs.h"
 #include "submodule.h"
 #include "column.h"
 #include "read-cache.h"
@@ -31,7 +31,7 @@
 #include "trace2.h"
 #include "odb/tree.h"
 #include "utf8.h"
-#include "worktree.h"
+#include "refs/worktree.h"
 #include "lockfile.h"
 #include "sequencer.h"
 #include "fsmonitor-settings.h"
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 09/14] pack: gather the pack sources under pack/
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (7 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 08/14] refs: gather the refs sources under refs/ Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 10/14] diff: gather the diff sources under diff/ Michael Montalbo
                   ` (4 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Move the 27 pack C sources and 18 headers into pack/ as renames. Repoint
every reference to their old paths to the new ones: the #include lines
across the tree, the Makefile and meson.build build entries.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize                                  | 90 +++++++++----------
 Makefile                                      | 56 ++++++------
 apply.c                                       |  2 +-
 blame.c                                       |  4 +-
 builtin/backfill.c                            |  2 +-
 builtin/cat-file.c                            |  2 +-
 builtin/clone.c                               |  2 +-
 builtin/commit-graph.c                        |  2 +-
 builtin/commit.c                              |  2 +-
 builtin/count-objects.c                       |  2 +-
 builtin/fast-import.c                         |  6 +-
 builtin/fetch.c                               |  2 +-
 builtin/fsck.c                                |  8 +-
 builtin/gc.c                                  |  4 +-
 builtin/index-pack.c                          |  8 +-
 builtin/last-modified.c                       |  4 +-
 builtin/merge.c                               |  2 +-
 builtin/multi-pack-index.c                    |  2 +-
 builtin/name-rev.c                            |  2 +-
 builtin/pack-objects.c                        | 20 ++---
 builtin/pack-redundant.c                      |  2 +-
 builtin/prune-packed.c                        |  2 +-
 builtin/prune.c                               |  4 +-
 builtin/receive-pack.c                        |  6 +-
 builtin/reflog.c                              |  2 +-
 builtin/repack.c                              | 10 +--
 builtin/rev-list.c                            |  4 +-
 builtin/show-index.c                          |  2 +-
 builtin/unpack-objects.c                      |  6 +-
 builtin/update-server-info.c                  |  2 +-
 commit-reach.c                                |  2 +-
 connected.c                                   |  2 +-
 diagnose.c                                    |  2 +-
 diff.c                                        |  4 +-
 fetch-pack.c                                  |  6 +-
 http-backend.c                                |  2 +-
 http-push.c                                   |  2 +-
 http-walker.c                                 |  2 +-
 http.c                                        |  4 +-
 line-log.c                                    |  2 +-
 list-objects.c                                |  2 +-
 meson.build                                   | 54 +++++------
 odb/commit.c                                  |  2 +-
 odb/fsck.c                                    |  2 +-
 odb/object-file.c                             |  4 +-
 odb/object-name.c                             |  2 +-
 odb/object.c                                  |  2 +-
 odb/odb.c                                     |  6 +-
 odb/source-files.c                            |  6 +-
 odb/source-packed.c                           |  6 +-
 odb/source-packed.h                           |  2 +-
 odb/source.c                                  |  2 +-
 odb/tag.c                                     |  2 +-
 oss-fuzz/fuzz-commit-graph.c                  |  2 +-
 oss-fuzz/fuzz-pack-headers.c                  |  2 +-
 oss-fuzz/fuzz-pack-idx.c                      |  2 +-
 bloom.c => pack/bloom.c                       |  4 +-
 bloom.h => pack/bloom.h                       |  0
 chunk-format.c => pack/chunk-format.c         |  2 +-
 chunk-format.h => pack/chunk-format.h         |  0
 commit-graph.c => pack/commit-graph.c         |  8 +-
 commit-graph.h => pack/commit-graph.h         |  0
 delta-islands.c => pack/delta-islands.c       |  8 +-
 delta-islands.h => pack/delta-islands.h       |  0
 delta.h => pack/delta.h                       |  0
 diff-delta.c => pack/diff-delta.c             |  2 +-
 midx-write.c => pack/midx-write.c             | 10 +--
 midx.c => pack/midx.c                         | 10 +--
 midx.h => pack/midx.h                         |  0
 .../pack-bitmap-write.c                       | 12 +--
 pack-bitmap.c => pack/pack-bitmap.c           | 14 +--
 pack-bitmap.h => pack/pack-bitmap.h           |  4 +-
 pack-check.c => pack/pack-check.c             |  4 +-
 pack-mtimes.c => pack/pack-mtimes.c           |  4 +-
 pack-mtimes.h => pack/pack-mtimes.h           |  0
 pack-objects.c => pack/pack-objects.c         |  6 +-
 pack-objects.h => pack/pack-objects.h         |  4 +-
 pack-revindex.c => pack/pack-revindex.c       |  6 +-
 pack-revindex.h => pack/pack-revindex.h       |  0
 pack-write.c => pack/pack-write.c             | 10 +--
 pack.h => pack/pack.h                         |  0
 packfile-list.c => pack/packfile-list.c       |  4 +-
 packfile-list.h => pack/packfile-list.h       |  0
 packfile.c => pack/packfile.c                 | 14 +--
 packfile.h => pack/packfile.h                 |  2 +-
 patch-delta.c => pack/patch-delta.c           |  2 +-
 prune-packed.c => pack/prune-packed.c         |  4 +-
 prune-packed.h => pack/prune-packed.h         |  0
 pseudo-merge.c => pack/pseudo-merge.c         |  4 +-
 pseudo-merge.h => pack/pseudo-merge.h         |  0
 reachable.c => pack/reachable.c               |  8 +-
 reachable.h => pack/reachable.h               |  0
 repack-cruft.c => pack/repack-cruft.c         |  4 +-
 repack-filtered.c => pack/repack-filtered.c   |  2 +-
 repack-geometry.c => pack/repack-geometry.c   |  6 +-
 repack-midx.c => pack/repack-midx.c           |  6 +-
 repack-promisor.c => pack/repack-promisor.c   |  6 +-
 repack.c => pack/repack.c                     |  6 +-
 repack.h => pack/repack.h                     |  0
 server-info.c => pack/server-info.c           |  4 +-
 server-info.h => pack/server-info.h           |  0
 path.c                                        |  2 +-
 promisor-remote.c                             |  2 +-
 repo-settings.c                               |  4 +-
 revision.c                                    |  6 +-
 run-command.c                                 |  2 +-
 scalar.c                                      |  2 +-
 t/helper/test-bitmap.c                        |  4 +-
 t/helper/test-bloom.c                         |  2 +-
 t/helper/test-delta.c                         |  2 +-
 t/helper/test-find-pack.c                     |  2 +-
 t/helper/test-name-hash.c                     |  2 +-
 t/helper/test-pack-deltas.c                   |  6 +-
 t/helper/test-pack-mtimes.c                   |  4 +-
 t/helper/test-read-graph.c                    |  4 +-
 t/helper/test-read-midx.c                     |  8 +-
 t/helper/test-repository.c                    |  2 +-
 t/helper/test-synthesize.c                    |  2 +-
 transport-helper.c                            |  2 +-
 upload-pack.c                                 |  2 +-
 120 files changed, 314 insertions(+), 314 deletions(-)
 rename bloom.c => pack/bloom.c (99%)
 rename bloom.h => pack/bloom.h (100%)
 rename chunk-format.c => pack/chunk-format.c (99%)
 rename chunk-format.h => pack/chunk-format.h (100%)
 rename commit-graph.c => pack/commit-graph.c (99%)
 rename commit-graph.h => pack/commit-graph.h (100%)
 rename delta-islands.c => pack/delta-islands.c (99%)
 rename delta-islands.h => pack/delta-islands.h (100%)
 rename delta.h => pack/delta.h (100%)
 rename diff-delta.c => pack/diff-delta.c (99%)
 rename midx-write.c => pack/midx-write.c (99%)
 rename midx.c => pack/midx.c (99%)
 rename midx.h => pack/midx.h (100%)
 rename pack-bitmap-write.c => pack/pack-bitmap-write.c (99%)
 rename pack-bitmap.c => pack/pack-bitmap.c (99%)
 rename pack-bitmap.h => pack/pack-bitmap.h (99%)
 rename pack-check.c => pack/pack-check.c (99%)
 rename pack-mtimes.c => pack/pack-mtimes.c (98%)
 rename pack-mtimes.h => pack/pack-mtimes.h (100%)
 rename pack-objects.c => pack/pack-objects.c (98%)
 rename pack-objects.h => pack/pack-objects.h (99%)
 rename pack-revindex.c => pack/pack-revindex.c (99%)
 rename pack-revindex.h => pack/pack-revindex.h (100%)
 rename pack-write.c => pack/pack-write.c (99%)
 rename pack.h => pack/pack.h (100%)
 rename packfile-list.c => pack/packfile-list.c (96%)
 rename packfile-list.h => pack/packfile-list.h (100%)
 rename packfile.c => pack/packfile.c (99%)
 rename packfile.h => pack/packfile.h (99%)
 rename patch-delta.c => pack/patch-delta.c (98%)
 rename prune-packed.c => pack/prune-packed.c (94%)
 rename prune-packed.h => pack/prune-packed.h (100%)
 rename pseudo-merge.c => pack/pseudo-merge.c (99%)
 rename pseudo-merge.h => pack/pseudo-merge.h (100%)
 rename reachable.c => pack/reachable.c (98%)
 rename reachable.h => pack/reachable.h (100%)
 rename repack-cruft.c => pack/repack-cruft.c (98%)
 rename repack-filtered.c => pack/repack-filtered.c (98%)
 rename repack-geometry.c => pack/repack-geometry.c (99%)
 rename repack-midx.c => pack/repack-midx.c (99%)
 rename repack-promisor.c => pack/repack-promisor.c (98%)
 rename repack.c => pack/repack.c (99%)
 rename repack.h => pack/repack.h (100%)
 rename server-info.c => pack/server-info.c (99%)
 rename server-info.h => pack/server-info.h (100%)

diff --git a/.gitorganize b/.gitorganize
index e29497504a..533d50ed89 100644
--- a/.gitorganize
+++ b/.gitorganize
@@ -45,8 +45,6 @@ bisect.c component=revision role=lib prefix=bisect includes=odb:5,revision:5,set
 bisect.h component=revision role=header prefix=bisect cochange=revision:29,odb:2
 blame.c component=revision role=lib prefix=blame includes=odb:5,diff:2,index:2,pack:2,revision:2 cochange=diff:68,revision:66,odb:56,index:29,pack:22
 blame.h component=revision role=header prefix=blame includes=diff:1,odb:1 cochange=revision:19,odb:7,diff:4,archive:1,index:1
-bloom.c component=pack role=lib prefix=bloom includes=odb:4,diff:2,pack:2,setup:2 cochange=pack:38,revision:25,diff:15,odb:6,index:2
-bloom.h component=pack role=header prefix=bloom cochange=pack:28,revision:12,odb:1
 branch.c component=? role=lib prefix=branch includes=refs:3,setup:3,odb:2,submodule:1,transport:1 cochange=refs:62,transport:41,setup:28,index:19,revision:12
 branch.h component=? role=public prefix=branch cochange=setup:8,refs:4,submodule:4
 builtin.h component=? role=public prefix=builtin includes=setup:1 cochange=diff:15,index:15,transport:12,odb:6,notes:5
@@ -60,15 +58,11 @@ chdir-notify.c component=? role=lib prefix=chdir-notify includes=revision:1 coch
 chdir-notify.h component=? role=public prefix=chdir-notify
 checkout.c component=index role=lib prefix=checkout includes=setup:2,index:1,odb:1,refs:1,transport:1 cochange=transport:16,refs:6,setup:5,index:3,odb:2
 checkout.h component=index role=header prefix=checkout includes=odb:1 cochange=index:4,diff:1,odb:1,refs:1,revision:1
-chunk-format.c component=pack role=lib prefix=chunk-format includes=odb:1,pack:1 cochange=pack:20,odb:1,transport:1
-chunk-format.h component=pack role=header prefix=chunk-format includes=odb:1 cochange=pack:15,odb:2,setup:1,transport:1
 color.c component=? role=lib prefix=color includes=setup:1 cochange=diff:21,index:14,revision:13,setup:7,transport:7
 color.h component=? role=public prefix=color cochange=diff:18,index:12,revision:12,transport:2,odb:1
 column.c component=? role=lib prefix=column includes=setup:1 cochange=transport:6,setup:5,diff:4,revision:3,index:2
 column.h component=? role=public prefix=column
 combine-diff.c component=diff role=lib prefix=combine-diff includes=odb:5,diff:4,revision:2,convert:1,refs:1 cochange=diff:198,revision:67,index:35,odb:16,transport:16
-commit-graph.c component=pack role=lib prefix=commit-graph includes=odb:9,pack:4,setup:2,refs:1,revision:1 cochange=pack:206,odb:125,revision:47,transport:34,setup:22
-commit-graph.h component=pack role=header prefix=commit-graph includes=odb:2 cochange=pack:92,odb:14,setup:9,revision:8,transport:5
 commit-reach.c component=revision role=lib prefix=commit-reach includes=revision:3,odb:2,pack:1,refs:1 cochange=revision:38,odb:17,pack:15,transport:9,index:5
 commit-reach.h component=revision role=header prefix=commit-reach includes=odb:2 cochange=revision:32,odb:9,transport:8,pack:3,refs:3
 common-exit.c component=? role=lib prefix=common-main
@@ -95,12 +89,8 @@ date.c component=? role=lib prefix=date cochange=revision:17,odb:16,refs:14,setu
 date.h component=? role=public prefix=date cochange=refs:7,revision:4,setup:2,archive:1,odb:1
 decorate.c component=revision role=lib prefix=decorate includes=odb:1,revision:1 cochange=diff:6,odb:5,revision:5,pack:2,transport:2
 decorate.h component=revision role=header prefix=decorate cochange=revision:4,odb:1
-delta-islands.c component=pack role=lib prefix=delta-islands includes=odb:6,pack:4,diff:1,refs:1,setup:1 cochange=pack:20,odb:17,revision:7,transport:7,diff:5
-delta-islands.h component=pack role=header prefix=delta-islands cochange=pack:6
-delta.h component=pack role=header prefix=diff-delta cochange=pack:27,odb:19,diff:5,transport:3,convert:1
 diagnose.c component=? role=lib prefix=diagnose includes=archive:1,index:1,odb:1,pack:1,setup:1 cochange=index:4,revision:4,odb:3,pack:3,transport:3
 diagnose.h component=? role=public prefix=diagnose cochange=revision:2,refs:1,transport:1
-diff-delta.c component=pack role=lib prefix=diff-delta includes=pack:1 cochange=pack:24,diff:7,index:2,odb:2,transport:2
 diff-lib.c component=diff role=lib prefix=diff includes=index:6,odb:3,diff:2,revision:2,refs:1 cochange=diff:150,index:124,revision:47,submodule:18,odb:8
 diff-merges.c component=diff role=lib prefix=diff-merges includes=diff:1,revision:1 cochange=revision:18,diff:17,odb:4,refs:3,index:2
 diff-merges.h component=diff role=header prefix=diff-merges cochange=diff:11,revision:4,merge:1
@@ -218,9 +208,6 @@ merge-ort.h component=merge role=header prefix=merge-ort includes=odb:1 cochange
 merge.c component=merge role=lib prefix=merge includes=odb:4,index:2,merge:1,setup:1 cochange=index:22,merge:6,setup:4,diff:2,odb:2
 merge.h component=merge role=header prefix=merge cochange=merge:1
 mergesort.h component=? role=public prefix=mergesort cochange=odb:1
-midx-write.c component=pack role=lib prefix=midx-write includes=pack:5,odb:2,revision:2,refs:1,setup:1 cochange=pack:100,odb:20,refs:7,transport:6,setup:4
-midx.c component=pack role=lib prefix=midx includes=pack:5,index:1,odb:1,setup:1 cochange=pack:220,odb:34,transport:11,index:6,setup:4
-midx.h component=pack role=header prefix=midx cochange=pack:134,odb:5,setup:2,transport:2,refs:1
 name-hash.c component=index role=lib prefix=name-hash includes=index:3,odb:1,setup:1 cochange=diff:43,index:39,revision:18,setup:14,refs:12
 name-hash.h component=index role=header prefix=name-hash cochange=index:7
 notes-cache.c component=notes role=lib prefix=notes includes=odb:3,notes:1,refs:1,revision:1,setup:1 cochange=notes:37,odb:29,diff:10,index:10,revision:9
@@ -280,22 +267,51 @@ odb/tree-walk.c component=odb role=lib prefix=tree-walk includes=odb:4,index:3,s
 odb/tree-walk.h component=odb role=header prefix=tree-walk includes=odb:1 cochange=odb:64,diff:23,index:23,revision:21,notes:7
 odb/tree.c component=odb role=lib prefix=tree includes=odb:6,setup:2 cochange=odb:212,revision:45,index:36,pack:25,transport:21
 odb/tree.h component=odb role=header prefix=tree includes=odb:1 cochange=odb:75,revision:12,archive:8,index:6,pack:5
-pack-bitmap-write.c component=pack role=lib prefix=pack-bitmap-write includes=odb:7,pack:6,revision:2,setup:2,diff:1 cochange=pack:132,odb:32,revision:27,transport:10,diff:4
-pack-bitmap.c component=pack role=lib prefix=pack-bitmap includes=pack:7,odb:3,revision:3,setup:2,diff:1 cochange=pack:232,revision:30,odb:18,transport:14,refs:7
-pack-bitmap.h component=pack role=header prefix=pack-bitmap includes=pack:2,refs:1 cochange=pack:117,refs:5,odb:2,setup:2,revision:1
-pack-check.c component=pack role=lib prefix=pack-check includes=odb:2,pack:2,setup:2 cochange=pack:59,odb:26,transport:23,diff:11,index:10
-pack-mtimes.c component=pack role=lib prefix=pack-mtimes includes=pack:2,odb:1 cochange=pack:10,odb:3,transport:2,notes:1
-pack-mtimes.h component=pack role=header prefix=pack-mtimes cochange=pack:4,odb:2,setup:1,transport:1
-pack-objects.c component=pack role=lib prefix=pack-objects includes=pack:3,odb:1,setup:1 cochange=pack:66,diff:17,odb:16,transport:9,index:5
-pack-objects.h component=pack role=header prefix=pack-objects includes=pack:2,odb:1 cochange=pack:44,setup:5,odb:1
-pack-revindex.c component=pack role=lib prefix=pack-revindex includes=pack:3,odb:1,setup:1 cochange=pack:94,odb:7,index:6,transport:5,setup:4
-pack-revindex.h component=pack role=header prefix=pack-revindex cochange=pack:32,odb:1
-pack-write.c component=pack role=lib prefix=pack-write includes=pack:5,setup:2,odb:1,transport:1 cochange=pack:88,odb:21,transport:21,setup:14,index:10
-pack.h component=pack role=header prefix=pack-write includes=odb:1 cochange=pack:72,odb:13,transport:9,setup:5,revision:1
-packfile-list.c component=pack role=lib prefix=packfile includes=pack:2 cochange=pack:3
-packfile-list.h component=pack role=header prefix=packfile cochange=pack:3
-packfile.c component=pack role=lib prefix=packfile includes=odb:8,pack:7,setup:2,index:1,revision:1 cochange=pack:317,odb:134,transport:52,revision:36,index:27
-packfile.h component=pack role=header prefix=packfile includes=odb:3,pack:1,revision:1,setup:1 cochange=pack:234,odb:66,transport:32,revision:9,setup:7
+pack/bloom.c component=pack role=lib prefix=bloom includes=odb:4,diff:2,pack:2,setup:2 cochange=pack:38,revision:25,diff:15,odb:6,index:2
+pack/bloom.h component=pack role=header prefix=bloom cochange=pack:28,revision:12,odb:1
+pack/chunk-format.c component=pack role=lib prefix=chunk-format includes=odb:1,pack:1 cochange=pack:20,odb:1,transport:1
+pack/chunk-format.h component=pack role=header prefix=chunk-format includes=odb:1 cochange=pack:15,odb:2,setup:1,transport:1
+pack/commit-graph.c component=pack role=lib prefix=commit-graph includes=odb:9,pack:4,setup:2,refs:1,revision:1 cochange=pack:206,odb:125,revision:47,transport:34,setup:22
+pack/commit-graph.h component=pack role=header prefix=commit-graph includes=odb:2 cochange=pack:92,odb:14,setup:9,revision:8,transport:5
+pack/delta-islands.c component=pack role=lib prefix=delta-islands includes=odb:6,pack:4,diff:1,refs:1,setup:1 cochange=pack:20,odb:17,revision:7,transport:7,diff:5
+pack/delta-islands.h component=pack role=header prefix=delta-islands cochange=pack:6
+pack/delta.h component=pack role=header prefix=diff-delta cochange=pack:27,odb:19,diff:5,transport:3,convert:1
+pack/diff-delta.c component=pack role=lib prefix=diff-delta includes=pack:1 cochange=pack:24,diff:7,index:2,odb:2,transport:2
+pack/midx-write.c component=pack role=lib prefix=midx-write includes=pack:5,odb:2,revision:2,refs:1,setup:1 cochange=pack:100,odb:20,refs:7,transport:6,setup:4
+pack/midx.c component=pack role=lib prefix=midx includes=pack:5,index:1,odb:1,setup:1 cochange=pack:220,odb:34,transport:11,index:6,setup:4
+pack/midx.h component=pack role=header prefix=midx cochange=pack:134,odb:5,setup:2,transport:2,refs:1
+pack/pack-bitmap-write.c component=pack role=lib prefix=pack-bitmap-write includes=odb:7,pack:6,revision:2,setup:2,diff:1 cochange=pack:132,odb:32,revision:27,transport:10,diff:4
+pack/pack-bitmap.c component=pack role=lib prefix=pack-bitmap includes=pack:7,odb:3,revision:3,setup:2,diff:1 cochange=pack:232,revision:30,odb:18,transport:14,refs:7
+pack/pack-bitmap.h component=pack role=header prefix=pack-bitmap includes=pack:2,refs:1 cochange=pack:117,refs:5,odb:2,setup:2,revision:1
+pack/pack-check.c component=pack role=lib prefix=pack-check includes=odb:2,pack:2,setup:2 cochange=pack:59,odb:26,transport:23,diff:11,index:10
+pack/pack-mtimes.c component=pack role=lib prefix=pack-mtimes includes=pack:2,odb:1 cochange=pack:10,odb:3,transport:2,notes:1
+pack/pack-mtimes.h component=pack role=header prefix=pack-mtimes cochange=pack:4,odb:2,setup:1,transport:1
+pack/pack-objects.c component=pack role=lib prefix=pack-objects includes=pack:3,odb:1,setup:1 cochange=pack:66,diff:17,odb:16,transport:9,index:5
+pack/pack-objects.h component=pack role=header prefix=pack-objects includes=pack:2,odb:1 cochange=pack:44,setup:5,odb:1
+pack/pack-revindex.c component=pack role=lib prefix=pack-revindex includes=pack:3,odb:1,setup:1 cochange=pack:94,odb:7,index:6,transport:5,setup:4
+pack/pack-revindex.h component=pack role=header prefix=pack-revindex cochange=pack:32,odb:1
+pack/pack-write.c component=pack role=lib prefix=pack-write includes=pack:5,setup:2,odb:1,transport:1 cochange=pack:88,odb:21,transport:21,setup:14,index:10
+pack/pack.h component=pack role=header prefix=pack-write includes=odb:1 cochange=pack:72,odb:13,transport:9,setup:5,revision:1
+pack/packfile-list.c component=pack role=lib prefix=packfile includes=pack:2 cochange=pack:3
+pack/packfile-list.h component=pack role=header prefix=packfile cochange=pack:3
+pack/packfile.c component=pack role=lib prefix=packfile includes=odb:8,pack:7,setup:2,index:1,revision:1 cochange=pack:317,odb:134,transport:52,revision:36,index:27
+pack/packfile.h component=pack role=header prefix=packfile includes=odb:3,pack:1,revision:1,setup:1 cochange=pack:234,odb:66,transport:32,revision:9,setup:7
+pack/patch-delta.c component=pack role=lib prefix=patch-delta includes=pack:1 cochange=pack:23,diff:2,odb:2,transport:2,convert:1
+pack/prune-packed.c component=pack role=lib prefix=environment includes=pack:2,odb:1,setup:1 cochange=pack:13,odb:7,setup:5,diff:3,revision:3
+pack/prune-packed.h component=pack role=header prefix=? cochange=pack:1
+pack/pseudo-merge.c component=pack role=lib prefix=pseudo-merge includes=odb:3,pack:2,refs:1,setup:1 cochange=pack:21,refs:3
+pack/pseudo-merge.h component=pack role=header prefix=pseudo-merge cochange=pack:17
+pack/reachable.c component=pack role=lib prefix=reachable includes=pack:4,odb:3,refs:2,revision:2,diff:1 cochange=odb:60,pack:57,revision:47,transport:17,refs:14
+pack/reachable.h component=pack role=header prefix=prune cochange=pack:5
+pack/repack-cruft.c component=pack role=lib prefix=repack includes=pack:2,setup:1 cochange=pack:8,transport:2,odb:1
+pack/repack-filtered.c component=pack role=lib prefix=repack includes=pack:1,setup:1 cochange=pack:1
+pack/repack-geometry.c component=pack role=lib prefix=repack includes=pack:3,setup:1 cochange=pack:25,transport:2,odb:1
+pack/repack-midx.c component=pack role=lib prefix=repack includes=odb:3,pack:3,refs:1 cochange=pack:23,refs:3,setup:2,merge:1,odb:1
+pack/repack-promisor.c component=pack role=lib prefix=repack-promisor includes=pack:3,setup:1 cochange=pack:8,odb:3,revision:2
+pack/repack.c component=pack role=lib prefix=repack includes=pack:3,index:1,odb:1,setup:1 cochange=pack:31,transport:2,odb:1
+pack/repack.h component=pack role=header prefix=repack includes=revision:1 cochange=pack:28
+pack/server-info.c component=pack role=lib prefix=server-info includes=odb:5,pack:2,index:1,refs:1,setup:1 cochange=pack:40,transport:34,odb:33,setup:13,refs:10
+pack/server-info.h component=pack role=header prefix=server-info cochange=pack:2
 pager.c component=? role=lib prefix=pager includes=setup:4 cochange=setup:23,diff:9,transport:7,revision:3,submodule:3
 pager.h component=? role=public prefix=pager cochange=diff:3,setup:2,revision:1
 parallel-checkout.c component=index role=lib prefix=parallel-checkout includes=index:4,odb:1,setup:1,transport:1 cochange=index:26,transport:7,odb:6,diff:3,merge:3
@@ -305,7 +321,6 @@ parse-options.c component=? role=lib prefix=parse-options cochange=index:14,diff
 parse-options.h component=? role=public prefix=parse-options cochange=diff:7,merge:4,archive:3,index:3,refs:3
 parse.c component=? role=lib prefix=parse cochange=setup:6,index:3,pack:2,convert:1
 parse.h component=? role=public prefix=config cochange=setup:6,index:3,pack:2,convert:1
-patch-delta.c component=pack role=lib prefix=patch-delta includes=pack:1 cochange=pack:23,diff:2,odb:2,transport:2,convert:1
 patch-ids.c component=diff role=lib prefix=patch-ids includes=diff:2,odb:2 cochange=diff:73,revision:34,index:14,odb:13,refs:12
 patch-ids.h component=diff role=header prefix=patch-ids includes=diff:1 cochange=diff:15,revision:3,index:1
 path-walk.c component=? role=lib prefix=path-walk includes=odb:9,revision:3,index:1,setup:1 cochange=index:2,revision:2,transport:2,odb:1,pack:1
@@ -332,16 +347,10 @@ protocol-caps.c component=transport role=lib prefix=protocol-caps includes=odb:3
 protocol-caps.h component=transport role=header prefix=protocol-caps cochange=transport:6,refs:2
 protocol.c component=transport role=lib prefix=protocol includes=setup:2,transport:1 cochange=transport:21,index:4,setup:4,refs:2,diff:1
 protocol.h component=transport role=header prefix=protocol cochange=transport:5
-prune-packed.c component=pack role=lib prefix=environment includes=pack:2,odb:1,setup:1 cochange=pack:13,odb:7,setup:5,diff:3,revision:3
-prune-packed.h component=pack role=header prefix=? cochange=pack:1
-pseudo-merge.c component=pack role=lib prefix=pseudo-merge includes=odb:3,pack:2,refs:1,setup:1 cochange=pack:21,refs:3
-pseudo-merge.h component=pack role=header prefix=pseudo-merge cochange=pack:17
 quote.c component=? role=lib prefix=quote cochange=index:15,diff:12,transport:7,odb:6,revision:6
 quote.h component=? role=public prefix=quote cochange=diff:8,transport:6,index:5,odb:5,refs:5
 range-diff.c component=diff role=lib prefix=range-diff includes=diff:4,odb:2,revision:2,setup:2 cochange=diff:49,revision:26,index:9,submodule:8,setup:7
 range-diff.h component=diff role=header prefix=range-diff includes=diff:1 cochange=diff:13,revision:4
-reachable.c component=pack role=lib prefix=reachable includes=pack:4,odb:3,refs:2,revision:2,diff:1 cochange=odb:60,pack:57,revision:47,transport:17,refs:14
-reachable.h component=pack role=header prefix=prune cochange=pack:5
 read-cache-ll.h component=index role=header prefix=read-cache includes=index:1,odb:1 cochange=index:8,diff:1,odb:1,revision:1
 read-cache.c component=index role=lib prefix=read-cache includes=index:10,odb:6,setup:4,diff:2,submodule:2 cochange=index:240,odb:81,setup:79,diff:67,pack:46
 read-cache.h component=index role=header prefix=read-cache includes=index:2,odb:1,setup:1 cochange=index:4,setup:4,diff:2
@@ -368,13 +377,6 @@ refs/worktree.h component=refs role=header prefix=worktree includes=refs:1 cocha
 remote-curl.c component=transport role=lib prefix=remote-curl includes=transport:9,setup:3,odb:1 cochange=transport:226,diff:9,revision:6,setup:5,archive:4
 remote.c component=transport role=lib prefix=remote includes=odb:3,setup:3,transport:3,refs:2,revision:2 cochange=transport:272,refs:91,revision:56,index:51,odb:30
 remote.h component=transport role=header prefix=remote includes=odb:1,refs:1 cochange=transport:245,refs:24,index:12,revision:6,setup:2
-repack-cruft.c component=pack role=lib prefix=repack includes=pack:2,setup:1 cochange=pack:8,transport:2,odb:1
-repack-filtered.c component=pack role=lib prefix=repack includes=pack:1,setup:1 cochange=pack:1
-repack-geometry.c component=pack role=lib prefix=repack includes=pack:3,setup:1 cochange=pack:25,transport:2,odb:1
-repack-midx.c component=pack role=lib prefix=repack includes=odb:3,pack:3,refs:1 cochange=pack:23,refs:3,setup:2,merge:1,odb:1
-repack-promisor.c component=pack role=lib prefix=repack-promisor includes=pack:3,setup:1 cochange=pack:8,odb:3,revision:2
-repack.c component=pack role=lib prefix=repack includes=pack:3,index:1,odb:1,setup:1 cochange=pack:31,transport:2,odb:1
-repack.h component=pack role=header prefix=repack includes=revision:1 cochange=pack:28
 replay.c component=? role=lib prefix=replay includes=odb:2,merge:1,refs:1,revision:1,setup:1 cochange=transport:1
 replay.h component=? role=public prefix=replay includes=odb:1
 repo-settings.c component=setup role=lib prefix=repo-settings includes=setup:4,pack:2 cochange=setup:65,pack:17,index:8,transport:8,odb:6
@@ -399,8 +401,6 @@ sequencer.c component=? role=lib prefix=sequencer includes=odb:8,index:5,merge:4
 sequencer.h component=? role=public prefix=sequencer includes=index:1 cochange=revision:5,index:4,notes:3,odb:3,transport:3
 serve.c component=transport role=lib prefix=serve includes=transport:6,setup:3,odb:1,refs:1 cochange=transport:53,refs:7,odb:4,setup:3,index:1
 serve.h component=transport role=header prefix=serve cochange=transport:9,refs:3,submodule:1
-server-info.c component=pack role=lib prefix=server-info includes=odb:5,pack:2,index:1,refs:1,setup:1 cochange=pack:40,transport:34,odb:33,setup:13,refs:10
-server-info.h component=pack role=header prefix=server-info cochange=pack:2
 setup.c component=setup role=lib prefix=setup includes=setup:4,odb:2,refs:2,index:1,revision:1 cochange=setup:177,refs:47,transport:44,index:39,odb:24
 setup.h component=setup role=header prefix=setup includes=refs:1 cochange=setup:70,refs:8,index:5,revision:4,submodule:4
 sh-i18n--envsubst.c component=? role=program prefix=sh-i18n--envsubst cochange=index:3,diff:1,transport:1
diff --git a/Makefile b/Makefile
index f733ccfee0..85d2a620a7 100644
--- a/Makefile
+++ b/Makefile
@@ -1113,7 +1113,7 @@ LIB_OBJS += base85.o
 LIB_OBJS += bisect.o
 LIB_OBJS += blame.o
 LIB_OBJS += odb/blob.o
-LIB_OBJS += bloom.o
+LIB_OBJS += pack/bloom.o
 LIB_OBJS += branch.o
 LIB_OBJS += bundle-uri.o
 LIB_OBJS += bundle.o
@@ -1121,11 +1121,11 @@ LIB_OBJS += cache-tree.o
 LIB_OBJS += odb/cbtree.o
 LIB_OBJS += chdir-notify.o
 LIB_OBJS += checkout.o
-LIB_OBJS += chunk-format.o
+LIB_OBJS += pack/chunk-format.o
 LIB_OBJS += color.o
 LIB_OBJS += column.o
 LIB_OBJS += combine-diff.o
-LIB_OBJS += commit-graph.o
+LIB_OBJS += pack/commit-graph.o
 LIB_OBJS += commit-reach.o
 LIB_OBJS += odb/commit.o
 LIB_OBJS += common-exit.o
@@ -1145,9 +1145,9 @@ LIB_OBJS += csum-file.o
 LIB_OBJS += ctype.o
 LIB_OBJS += date.o
 LIB_OBJS += decorate.o
-LIB_OBJS += delta-islands.o
+LIB_OBJS += pack/delta-islands.o
 LIB_OBJS += diagnose.o
-LIB_OBJS += diff-delta.o
+LIB_OBJS += pack/diff-delta.o
 LIB_OBJS += diff-merges.o
 LIB_OBJS += diff-lib.o
 LIB_OBJS += diff-no-index.o
@@ -1211,8 +1211,8 @@ LIB_OBJS += merge-ll.o
 LIB_OBJS += merge-ort.o
 LIB_OBJS += merge-ort-wrappers.o
 LIB_OBJS += merge.o
-LIB_OBJS += midx.o
-LIB_OBJS += midx-write.o
+LIB_OBJS += pack/midx.o
+LIB_OBJS += pack/midx-write.o
 LIB_OBJS += name-hash.o
 LIB_OBJS += negotiator/default.o
 LIB_OBJS += negotiator/noop.o
@@ -1241,22 +1241,22 @@ LIB_OBJS += organize/gitorganize-format.o
 LIB_OBJS += organize/labeler-protocol.o
 LIB_OBJS += organize/organize.o
 LIB_OBJS += organize/organizer-protocol.o
-LIB_OBJS += pack-bitmap-write.o
-LIB_OBJS += pack-bitmap.o
-LIB_OBJS += pack-check.o
-LIB_OBJS += pack-mtimes.o
-LIB_OBJS += pack-objects.o
+LIB_OBJS += pack/pack-bitmap-write.o
+LIB_OBJS += pack/pack-bitmap.o
+LIB_OBJS += pack/pack-check.o
+LIB_OBJS += pack/pack-mtimes.o
+LIB_OBJS += pack/pack-objects.o
 LIB_OBJS += refs/pack-refs.o
-LIB_OBJS += pack-revindex.o
-LIB_OBJS += pack-write.o
-LIB_OBJS += packfile.o
-LIB_OBJS += packfile-list.o
+LIB_OBJS += pack/pack-revindex.o
+LIB_OBJS += pack/pack-write.o
+LIB_OBJS += pack/packfile.o
+LIB_OBJS += pack/packfile-list.o
 LIB_OBJS += pager.o
 LIB_OBJS += parallel-checkout.o
 LIB_OBJS += parse.o
 LIB_OBJS += parse-options-cb.o
 LIB_OBJS += parse-options.o
-LIB_OBJS += patch-delta.o
+LIB_OBJS += pack/patch-delta.o
 LIB_OBJS += patch-ids.o
 LIB_OBJS += path.o
 LIB_OBJS += path-walk.o
@@ -1270,11 +1270,11 @@ LIB_OBJS += promisor-remote.o
 LIB_OBJS += prompt.o
 LIB_OBJS += protocol.o
 LIB_OBJS += protocol-caps.o
-LIB_OBJS += prune-packed.o
-LIB_OBJS += pseudo-merge.o
+LIB_OBJS += pack/prune-packed.o
+LIB_OBJS += pack/pseudo-merge.o
 LIB_OBJS += quote.o
 LIB_OBJS += range-diff.o
-LIB_OBJS += reachable.o
+LIB_OBJS += pack/reachable.o
 LIB_OBJS += read-cache.o
 LIB_OBJS += rebase-interactive.o
 LIB_OBJS += rebase.o
@@ -1304,12 +1304,12 @@ LIB_OBJS += reftable/table.o
 LIB_OBJS += reftable/tree.o
 LIB_OBJS += reftable/writer.o
 LIB_OBJS += remote.o
-LIB_OBJS += repack.o
-LIB_OBJS += repack-cruft.o
-LIB_OBJS += repack-filtered.o
-LIB_OBJS += repack-geometry.o
-LIB_OBJS += repack-midx.o
-LIB_OBJS += repack-promisor.o
+LIB_OBJS += pack/repack.o
+LIB_OBJS += pack/repack-cruft.o
+LIB_OBJS += pack/repack-filtered.o
+LIB_OBJS += pack/repack-geometry.o
+LIB_OBJS += pack/repack-midx.o
+LIB_OBJS += pack/repack-promisor.o
 LIB_OBJS += odb/replace-object.o
 LIB_OBJS += replay.o
 LIB_OBJS += repo-settings.o
@@ -1322,7 +1322,7 @@ LIB_OBJS += run-command.o
 LIB_OBJS += send-pack.o
 LIB_OBJS += sequencer.o
 LIB_OBJS += serve.o
-LIB_OBJS += server-info.o
+LIB_OBJS += pack/server-info.o
 LIB_OBJS += setup.o
 LIB_OBJS += shallow.o
 LIB_OBJS += sideband.o
@@ -2992,7 +2992,7 @@ gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
 http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp: SP_EXTRA_FLAGS += \
 	-DCURL_DISABLE_TYPECHECK
 
-pack-revindex.sp: SP_EXTRA_FLAGS += -Wno-memcpy-max-count
+pack/pack-revindex.sp: SP_EXTRA_FLAGS += -Wno-memcpy-max-count
 
 ifdef NO_EXPAT
 http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
diff --git a/apply.c b/apply.c
index ba486ab51d..dbfb891b4c 100644
--- a/apply.c
+++ b/apply.c
@@ -15,7 +15,7 @@
 #include "base85.h"
 #include "config.h"
 #include "odb/odb.h"
-#include "delta.h"
+#include "pack/delta.h"
 #include "diff.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/blame.c b/blame.c
index a594dc5f0e..cd18c09a3c 100644
--- a/blame.c
+++ b/blame.c
@@ -21,8 +21,8 @@
 #include "blame.h"
 #include "odb/alloc.h"
 #include "odb/commit-slab.h"
-#include "bloom.h"
-#include "commit-graph.h"
+#include "pack/bloom.h"
+#include "pack/commit-graph.h"
 
 define_commit_slab(blame_suspects, struct blame_origin *);
 static struct blame_suspects blame_suspects;
diff --git a/builtin/backfill.c b/builtin/backfill.c
index 3685713205..c42226d3e8 100644
--- a/builtin/backfill.c
+++ b/builtin/backfill.c
@@ -22,7 +22,7 @@
 #include "revision.h"
 #include "trace2.h"
 #include "progress.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "path-walk.h"
 
 static const char * const builtin_backfill_usage[] = {
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index ccd6b33827..a59aa00cea 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -19,7 +19,7 @@
 #include "parse-options.h"
 #include "userdiff.h"
 #include "odb/oid-array.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 12170ae8f4..7b5274e884 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -40,7 +40,7 @@
 #include "run-command.h"
 #include "setup.h"
 #include "connected.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "path.h"
 #include "pkt-line.h"
 #include "list-objects-filter-options.h"
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 0758af3b64..2de897402e 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -6,7 +6,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "parse-options.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "odb/odb.h"
 #include "progress.h"
 #include "odb/replace-object.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index e5a6c0b889..39271d720e 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -40,7 +40,7 @@
 #include "mailmap.h"
 #include "help.h"
 #include "commit-reach.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "pretty.h"
 #include "trailer.h"
 
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index e256779b1f..45a7a61cd3 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -12,7 +12,7 @@
 #include "path.h"
 #include "parse-options.h"
 #include "quote.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 
 static unsigned long garbage;
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 43bc72f05f..3b7d650e24 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -12,8 +12,8 @@
 #include "odb/blob.h"
 #include "odb/tree.h"
 #include "odb/commit.h"
-#include "delta.h"
-#include "pack.h"
+#include "pack/delta.h"
+#include "pack/pack.h"
 #include "path.h"
 #include "read-cache-ll.h"
 #include "refs/refs.h"
@@ -21,7 +21,7 @@
 #include "quote.h"
 #include "dir.h"
 #include "run-command.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index ce46a709a6..b14b96ce5c 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -36,7 +36,7 @@
 #include "commit-reach.h"
 #include "branch.h"
 #include "promisor-remote.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "shallow.h"
 #include "trace.h"
 #include "trace2.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 430cf28bd8..a00ca35703 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -7,12 +7,12 @@
 #include "odb/blob.h"
 #include "odb/tag.h"
 #include "refs/refs.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "cache-tree.h"
 #include "odb/fsck.h"
 #include "parse-options.h"
 #include "progress.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
@@ -24,8 +24,8 @@
 #include "run-command.h"
 #include "sparse-index.h"
 #include "refs/worktree.h"
-#include "pack-revindex.h"
-#include "pack-bitmap.h"
+#include "pack/pack-revindex.h"
+#include "pack/pack-bitmap.h"
 
 #define REACHABLE 0x0001
 #define SEEN      0x0002
diff --git a/builtin/gc.c b/builtin/gc.c
index 1a71e6f908..bdf3d43108 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -27,8 +27,8 @@
 #include "sigchain.h"
 #include "strvec.h"
 #include "odb/commit.h"
-#include "commit-graph.h"
-#include "packfile.h"
+#include "pack/commit-graph.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "path.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index aa0e04eeee..23d7e68020 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -3,11 +3,11 @@
 
 #include "builtin.h"
 #include "config.h"
-#include "delta.h"
+#include "pack/delta.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "csum-file.h"
 #include "odb/blob.h"
 #include "odb/commit.h"
@@ -17,8 +17,8 @@
 #include "odb/fsck.h"
 #include "strbuf.h"
 #include "thread-utils.h"
-#include "packfile.h"
-#include "pack-revindex.h"
+#include "pack/packfile.h"
+#include "pack/pack-revindex.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/streaming.h"
diff --git a/builtin/last-modified.c b/builtin/last-modified.c
index e8827b5dc6..83c5d66f36 100644
--- a/builtin/last-modified.c
+++ b/builtin/last-modified.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
-#include "bloom.h"
+#include "pack/bloom.h"
 #include "builtin.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "odb/commit-slab.h"
 #include "odb/commit.h"
 #include "config.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 2369c3b6f9..ad0c984d4b 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -50,7 +50,7 @@
 #include "branch.h"
 #include "commit-reach.h"
 #include "wt-status.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 
 #define DEFAULT_TWOHEAD (1<<0)
 #define DEFAULT_OCTOPUS (1<<1)
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index 10af1beb5c..81401e37d5 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -5,7 +5,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "parse-options.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "strbuf.h"
 #include "trace2.h"
 #include "odb/odb.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 4e0254d70e..f3f4714c1d 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -14,7 +14,7 @@
 #include "parse-options.h"
 #include "odb/hash-lookup.h"
 #include "odb/commit-slab.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "wildmatch.h"
 #include "mem-pool.h"
 #include "pretty.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 69f35a727b..37c379d3d8 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -10,38 +10,38 @@
 #include "odb/object.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
-#include "delta.h"
-#include "pack.h"
-#include "pack-revindex.h"
+#include "pack/delta.h"
+#include "pack/pack.h"
+#include "pack/pack-revindex.h"
 #include "csum-file.h"
 #include "odb/tree-walk.h"
 #include "diff.h"
 #include "revision.h"
 #include "list-objects.h"
 #include "list-objects-filter-options.h"
-#include "pack-objects.h"
+#include "pack/pack-objects.h"
 #include "progress.h"
 #include "refs/refs.h"
 #include "thread-utils.h"
-#include "pack-bitmap.h"
-#include "delta-islands.h"
-#include "reachable.h"
+#include "pack/pack-bitmap.h"
+#include "pack/delta-islands.h"
+#include "pack/reachable.h"
 #include "odb/oid-array.h"
 #include "strvec.h"
 #include "strmap.h"
 #include "list.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/object-file-convert.h"
 #include "odb/odb.h"
 #include "odb/streaming.h"
 #include "odb/replace-object.h"
 #include "dir.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "trace2.h"
 #include "shallow.h"
 #include "promisor-remote.h"
-#include "pack-mtimes.h"
+#include "pack/pack-mtimes.h"
 #include "parse-options.h"
 #include "pkt-line.h"
 #include "odb/blob.h"
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index 10e1ce6ab5..5396e2bc10 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -12,7 +12,7 @@
 #include "gettext.h"
 #include "hex.h"
 
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/odb.h"
 #include "strbuf.h"
 
diff --git a/builtin/prune-packed.c b/builtin/prune-packed.c
index 4d63f26b0a..5d4a72abb4 100644
--- a/builtin/prune-packed.c
+++ b/builtin/prune-packed.c
@@ -1,7 +1,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
-#include "prune-packed.h"
+#include "pack/prune-packed.h"
 
 static const char * const prune_packed_usage[] = {
 	"git prune-packed [-n | --dry-run] [-q | --quiet]",
diff --git a/builtin/prune.c b/builtin/prune.c
index 301f59e897..ae3505c5e5 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -8,11 +8,11 @@
 #include "gettext.h"
 #include "hex.h"
 #include "revision.h"
-#include "reachable.h"
+#include "pack/reachable.h"
 #include "parse-options.h"
 #include "path.h"
 #include "progress.h"
-#include "prune-packed.h"
+#include "pack/prune-packed.h"
 #include "odb/replace-object.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 88cbaed133..f01cc1a188 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -22,15 +22,15 @@
 #include "odb/odb.h"
 #include "odb/oid-array.h"
 #include "odb/oidset.h"
-#include "pack.h"
-#include "packfile.h"
+#include "pack/pack.h"
+#include "pack/packfile.h"
 #include "parse-options.h"
 #include "pkt-line.h"
 #include "protocol.h"
 #include "refs/refs.h"
 #include "remote.h"
 #include "run-command.h"
-#include "server-info.h"
+#include "pack/server-info.h"
 #include "setup.h"
 #include "shallow.h"
 #include "sideband.h"
diff --git a/builtin/reflog.c b/builtin/reflog.c
index fc0b74ed95..d227104063 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -6,7 +6,7 @@
 #include "hex.h"
 #include "odb/odb.h"
 #include "revision.h"
-#include "reachable.h"
+#include "pack/reachable.h"
 #include "wildmatch.h"
 #include "refs/worktree.h"
 #include "refs/reflog.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index db504d673f..5927a0dfdb 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -6,13 +6,13 @@
 #include "parse-options.h"
 #include "path.h"
 #include "run-command.h"
-#include "server-info.h"
+#include "pack/server-info.h"
 #include "string-list.h"
-#include "midx.h"
-#include "packfile.h"
-#include "prune-packed.h"
+#include "pack/midx.h"
+#include "pack/packfile.h"
+#include "pack/prune-packed.h"
 #include "promisor-remote.h"
-#include "repack.h"
+#include "pack/repack.h"
 #include "shallow.h"
 
 #define ALL_INTO_ONE 1
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 466a0a515d..d6bddda9d4 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -15,7 +15,7 @@
 #include "odb/object-name.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
-#include "pack-bitmap.h"
+#include "pack/pack-bitmap.h"
 #include "parse-options.h"
 #include "log-tree.h"
 #include "graph.h"
@@ -24,7 +24,7 @@
 #include "refs/reflog-walk.h"
 #include "odb/oidset.h"
 #include "odb/oidmap.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "commit-reach.h"
 #include "quote.h"
 #include "strbuf.h"
diff --git a/builtin/show-index.c b/builtin/show-index.c
index 55c3c409ae..86dacb1a1e 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -5,7 +5,7 @@
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "parse-options.h"
 
 static const char *const show_index_usage[] = {
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index e5891809dd..93caca20ef 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -12,15 +12,15 @@
 #include "odb/streaming.h"
 #include "odb/transaction.h"
 #include "odb/object.h"
-#include "delta.h"
-#include "pack.h"
+#include "pack/delta.h"
+#include "pack/pack.h"
 #include "odb/blob.h"
 #include "odb/replace-object.h"
 #include "strbuf.h"
 #include "progress.h"
 #include "decorate.h"
 #include "odb/fsck.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 
 static int dry_run, quiet, recover, has_errors, strict;
 static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict]";
diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c
index 4c12968a83..41bbd0114f 100644
--- a/builtin/update-server-info.c
+++ b/builtin/update-server-info.c
@@ -3,7 +3,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "parse-options.h"
-#include "server-info.h"
+#include "pack/server-info.h"
 
 static const char * const update_server_info_usage[] = {
 	"git update-server-info [-f | --force]",
diff --git a/commit-reach.c b/commit-reach.c
index 9636b5b37f..0b59c9ba29 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "odb/commit.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "decorate.h"
 #include "hex.h"
 #include "prio-queue.h"
diff --git a/connected.c b/connected.c
index 1aafa86101..1884614b80 100644
--- a/connected.c
+++ b/connected.c
@@ -8,7 +8,7 @@
 #include "sigchain.h"
 #include "connected.h"
 #include "transport.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "promisor-remote.h"
 
 static int promised_object_cb(const struct object_id *oid UNUSED,
diff --git a/diagnose.c b/diagnose.c
index 6858f39f45..716dabf05c 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -8,7 +8,7 @@
 #include "hex.h"
 #include "strvec.h"
 #include "odb/odb.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "parse-options.h"
 #include "repository.h"
 #include "write-or-die.h"
diff --git a/diff.c b/diff.c
index 22265895a7..91addcdab7 100644
--- a/diff.c
+++ b/diff.c
@@ -17,7 +17,7 @@
 #include "quote.h"
 #include "diff.h"
 #include "diffcore.h"
-#include "delta.h"
+#include "pack/delta.h"
 #include "hex.h"
 #include "xdiff-interface.h"
 #include "color.h"
@@ -34,7 +34,7 @@
 #include "odb/tmp-objdir.h"
 #include "graph.h"
 #include "odb/oid-array.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "pager.h"
 #include "parse-options.h"
 #include "help.h"
diff --git a/fetch-pack.c b/fetch-pack.c
index 434b57e5b0..b19cb3239e 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -13,7 +13,7 @@
 #include "pkt-line.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "sideband.h"
 #include "fetch-pack.h"
 #include "remote.h"
@@ -23,7 +23,7 @@
 #include "version.h"
 #include "odb/oid-array.h"
 #include "odb/oidset.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/odb.h"
 #include "odb/object-name.h"
 #include "path.h"
@@ -32,7 +32,7 @@
 #include "odb/fsck.h"
 #include "shallow.h"
 #include "commit-reach.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "sigchain.h"
 #include "mergesort.h"
 #include "prio-queue.h"
diff --git a/http-backend.c b/http-backend.c
index 90624c3348..57589cc127 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -18,7 +18,7 @@
 #include "url.h"
 #include "setup.h"
 #include "strvec.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/odb.h"
 #include "protocol.h"
 #include "date.h"
diff --git a/http-push.c b/http-push.c
index 858aa9db33..88a8417ea4 100644
--- a/http-push.c
+++ b/http-push.c
@@ -18,7 +18,7 @@
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
 #include "url.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "commit-reach.h"
diff --git a/http-walker.c b/http-walker.c
index dba84c0ef5..e73c3677d1 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -8,7 +8,7 @@
 #include "http.h"
 #include "list.h"
 #include "transport.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 
diff --git a/http.c b/http.c
index 81b58bd8d2..24a6b30ab3 100644
--- a/http.c
+++ b/http.c
@@ -7,7 +7,7 @@
 #include "hex.h"
 #include "http.h"
 #include "config.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "run-command.h"
 #include "url.h"
 #include "urlmatch.h"
@@ -17,7 +17,7 @@
 #include "gettext.h"
 #include "trace.h"
 #include "transport.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "string-list.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
diff --git a/line-log.c b/line-log.c
index 2c9c11e5d3..343159d90a 100644
--- a/line-log.c
+++ b/line-log.c
@@ -16,7 +16,7 @@
 #include "line-log.h"
 #include "setup.h"
 #include "strvec.h"
-#include "bloom.h"
+#include "pack/bloom.h"
 #include "odb/tree-walk.h"
 
 static void range_set_grow(struct range_set *rs, size_t extra)
diff --git a/list-objects.c b/list-objects.c
index b8a673ed69..1db5ba29b5 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -13,7 +13,7 @@
 #include "list-objects.h"
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/odb.h"
 #include "trace.h"
 #include "environment.h"
diff --git a/meson.build b/meson.build
index 8dd613a8bb..238beb0dfd 100644
--- a/meson.build
+++ b/meson.build
@@ -322,7 +322,7 @@ libgit_sources = [
   'bisect.c',
   'blame.c',
   'odb/blob.c',
-  'bloom.c',
+  'pack/bloom.c',
   'branch.c',
   'bundle-uri.c',
   'bundle.c',
@@ -330,11 +330,11 @@ libgit_sources = [
   'odb/cbtree.c',
   'chdir-notify.c',
   'checkout.c',
-  'chunk-format.c',
+  'pack/chunk-format.c',
   'color.c',
   'column.c',
   'combine-diff.c',
-  'commit-graph.c',
+  'pack/commit-graph.c',
   'commit-reach.c',
   'odb/commit.c',
   'common-exit.c',
@@ -350,9 +350,9 @@ libgit_sources = [
   'ctype.c',
   'date.c',
   'decorate.c',
-  'delta-islands.c',
+  'pack/delta-islands.c',
   'diagnose.c',
-  'diff-delta.c',
+  'pack/diff-delta.c',
   'diff-merges.c',
   'diff-lib.c',
   'diff-no-index.c',
@@ -416,8 +416,8 @@ libgit_sources = [
   'merge-ort.c',
   'merge-ort-wrappers.c',
   'merge.c',
-  'midx.c',
-  'midx-write.c',
+  'pack/midx.c',
+  'pack/midx-write.c',
   'name-hash.c',
   'negotiator/default.c',
   'negotiator/noop.c',
@@ -446,22 +446,22 @@ libgit_sources = [
   'organize/labeler-protocol.c',
   'organize/organize.c',
   'organize/organizer-protocol.c',
-  'pack-bitmap-write.c',
-  'pack-bitmap.c',
-  'pack-check.c',
-  'pack-mtimes.c',
-  'pack-objects.c',
+  'pack/pack-bitmap-write.c',
+  'pack/pack-bitmap.c',
+  'pack/pack-check.c',
+  'pack/pack-mtimes.c',
+  'pack/pack-objects.c',
   'refs/pack-refs.c',
-  'pack-revindex.c',
-  'pack-write.c',
-  'packfile.c',
-  'packfile-list.c',
+  'pack/pack-revindex.c',
+  'pack/pack-write.c',
+  'pack/packfile.c',
+  'pack/packfile-list.c',
   'pager.c',
   'parallel-checkout.c',
   'parse.c',
   'parse-options-cb.c',
   'parse-options.c',
-  'patch-delta.c',
+  'pack/patch-delta.c',
   'patch-ids.c',
   'path.c',
   'path-walk.c',
@@ -475,11 +475,11 @@ libgit_sources = [
   'prompt.c',
   'protocol.c',
   'protocol-caps.c',
-  'prune-packed.c',
-  'pseudo-merge.c',
+  'pack/prune-packed.c',
+  'pack/pseudo-merge.c',
   'quote.c',
   'range-diff.c',
-  'reachable.c',
+  'pack/reachable.c',
   'read-cache.c',
   'rebase-interactive.c',
   'rebase.c',
@@ -509,12 +509,12 @@ libgit_sources = [
   'reftable/tree.c',
   'reftable/writer.c',
   'remote.c',
-  'repack.c',
-  'repack-cruft.c',
-  'repack-filtered.c',
-  'repack-geometry.c',
-  'repack-midx.c',
-  'repack-promisor.c',
+  'pack/repack.c',
+  'pack/repack-cruft.c',
+  'pack/repack-filtered.c',
+  'pack/repack-geometry.c',
+  'pack/repack-midx.c',
+  'pack/repack-promisor.c',
   'odb/replace-object.c',
   'replay.c',
   'repo-settings.c',
@@ -527,7 +527,7 @@ libgit_sources = [
   'send-pack.c',
   'sequencer.c',
   'serve.c',
-  'server-info.c',
+  'pack/server-info.c',
   'setup.c',
   'shallow.c',
   'sideband.c',
diff --git a/odb/commit.c b/odb/commit.c
index dc98000ab2..06daa8c6a0 100644
--- a/odb/commit.c
+++ b/odb/commit.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "odb/tag.h"
 #include "odb/commit.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/odb/fsck.c b/odb/fsck.c
index 75306dc8a3..8c953f61a4 100644
--- a/odb/fsck.c
+++ b/odb/fsck.c
@@ -18,7 +18,7 @@
 #include "url.h"
 #include "utf8.h"
 #include "odb/oidset.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "submodule-config.h"
 #include "config.h"
 #include "help.h"
diff --git a/odb/object-file.c b/odb/object-file.c
index c4841cc289..41ee67abb6 100644
--- a/odb/object-file.c
+++ b/odb/object-file.c
@@ -22,8 +22,8 @@
 #include "odb/odb.h"
 #include "odb/streaming.h"
 #include "odb/transaction.h"
-#include "pack.h"
-#include "packfile.h"
+#include "pack/pack.h"
+#include "pack/packfile.h"
 #include "path.h"
 #include "read-cache-ll.h"
 #include "setup.h"
diff --git a/odb/object-name.c b/odb/object-name.c
index 16b6cd8f12..ff61d55590 100644
--- a/odb/object-name.c
+++ b/odb/object-name.c
@@ -22,7 +22,7 @@
 #include "repo-settings.h"
 #include "repository.h"
 #include "setup.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "commit-reach.h"
 #include "date.h"
 #include "odb/object-file-convert.h"
diff --git a/odb/object.c b/odb/object.c
index 8a34e52eca..7c2f920d3f 100644
--- a/odb/object.c
+++ b/odb/object.c
@@ -13,7 +13,7 @@
 #include "odb/commit.h"
 #include "odb/tag.h"
 #include "odb/alloc.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 
 unsigned int get_max_object_index(const struct repository *repo)
 {
diff --git a/odb/odb.c b/odb/odb.c
index ffa2881e9f..e942149d91 100644
--- a/odb/odb.c
+++ b/odb/odb.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "config.h"
 #include "dir.h"
 #include "environment.h"
@@ -9,13 +9,13 @@
 #include "khash.h"
 #include "lockfile.h"
 #include "odb/loose.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "odb/object-file-convert.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "odb/source-inmemory.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "path.h"
 #include "promisor-remote.h"
 #include "quote.h"
diff --git a/odb/source-files.c b/odb/source-files.c
index 279a2ccab6..b526e5c219 100644
--- a/odb/source-files.c
+++ b/odb/source-files.c
@@ -10,11 +10,11 @@
 #include "odb/source.h"
 #include "odb/source-files.h"
 #include "odb/source-loose.h"
-#include "pack-objects.h"
-#include "packfile.h"
+#include "pack/pack-objects.h"
+#include "pack/packfile.h"
 #include "path.h"
 #include "promisor-remote.h"
-#include "repack.h"
+#include "pack/repack.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/odb/source-packed.c b/odb/source-packed.c
index 0890704e76..0e391f6fcf 100644
--- a/odb/source-packed.c
+++ b/odb/source-packed.c
@@ -5,11 +5,11 @@
 #include "git-zlib.h"
 #include "list-objects-filter-options.h"
 #include "mergesort.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "odb/source-packed.h"
 #include "odb/streaming.h"
-#include "packfile.h"
-#include "pack-bitmap.h"
+#include "pack/packfile.h"
+#include "pack/pack-bitmap.h"
 
 static int find_pack_entry(struct odb_source_packed *store,
 			   const struct object_id *oid,
diff --git a/odb/source-packed.h b/odb/source-packed.h
index a0f6b5096d..619e28179e 100644
--- a/odb/source-packed.h
+++ b/odb/source-packed.h
@@ -2,7 +2,7 @@
 #define ODB_SOURCE_PACKED_H
 
 #include "odb/source.h"
-#include "packfile-list.h"
+#include "pack/packfile-list.h"
 #include "strmap.h"
 
 /*
diff --git a/odb/source.c b/odb/source.c
index 2a2e1d0060..95f4362327 100644
--- a/odb/source.c
+++ b/odb/source.c
@@ -2,7 +2,7 @@
 #include "odb/object-file.h"
 #include "odb/source-files.h"
 #include "odb/source.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 
 static const char * const odb_source_names_by_type[] = {
 	[ODB_SOURCE_UNKNOWN] = "unknown",
diff --git a/odb/tag.c b/odb/tag.c
index 7be23b04c1..36cb7732a8 100644
--- a/odb/tag.c
+++ b/odb/tag.c
@@ -11,7 +11,7 @@
 #include "odb/alloc.h"
 #include "gpg-interface.h"
 #include "hex.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "repository.h"
 
 const char *tag_type = "tag";
diff --git a/oss-fuzz/fuzz-commit-graph.c b/oss-fuzz/fuzz-commit-graph.c
index 59bbb849d1..e0ef2ef871 100644
--- a/oss-fuzz/fuzz-commit-graph.c
+++ b/oss-fuzz/fuzz-commit-graph.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "repository.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
diff --git a/oss-fuzz/fuzz-pack-headers.c b/oss-fuzz/fuzz-pack-headers.c
index ef61ab577c..81dc1d556b 100644
--- a/oss-fuzz/fuzz-pack-headers.c
+++ b/oss-fuzz/fuzz-pack-headers.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
 
diff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c
index 5b033dbd93..599b12b9bf 100644
--- a/oss-fuzz/fuzz-pack-idx.c
+++ b/oss-fuzz/fuzz-pack-idx.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "odb/odb.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
 
diff --git a/bloom.c b/pack/bloom.c
similarity index 99%
rename from bloom.c
rename to pack/bloom.c
index e61cb05246..874e011530 100644
--- a/bloom.c
+++ b/pack/bloom.c
@@ -1,11 +1,11 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "bloom.h"
+#include "pack/bloom.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "hashmap.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "odb/commit.h"
 #include "odb/commit-slab.h"
 #include "odb/tree.h"
diff --git a/bloom.h b/pack/bloom.h
similarity index 100%
rename from bloom.h
rename to pack/bloom.h
diff --git a/chunk-format.c b/pack/chunk-format.c
similarity index 99%
rename from chunk-format.c
rename to pack/chunk-format.c
index 08b90762d4..31468dcc6e 100644
--- a/chunk-format.c
+++ b/pack/chunk-format.c
@@ -2,7 +2,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "chunk-format.h"
+#include "pack/chunk-format.h"
 #include "csum-file.h"
 #include "gettext.h"
 #include "odb/hash.h"
diff --git a/chunk-format.h b/pack/chunk-format.h
similarity index 100%
rename from chunk-format.h
rename to pack/chunk-format.h
diff --git a/commit-graph.c b/pack/commit-graph.c
similarity index 99%
rename from commit-graph.c
rename to pack/commit-graph.c
index 7c22588c46..afc04d74a5 100644
--- a/commit-graph.c
+++ b/pack/commit-graph.c
@@ -7,12 +7,12 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/commit.h"
 #include "odb/object.h"
 #include "refs/refs.h"
 #include "odb/hash-lookup.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "odb/odb.h"
 #include "odb/oid-array.h"
 #include "path.h"
@@ -20,13 +20,13 @@
 #include "hashmap.h"
 #include "odb/replace-object.h"
 #include "progress.h"
-#include "bloom.h"
+#include "pack/bloom.h"
 #include "odb/commit-slab.h"
 #include "shallow.h"
 #include "json-writer.h"
 #include "trace2.h"
 #include "odb/tree.h"
-#include "chunk-format.h"
+#include "pack/chunk-format.h"
 
 void git_test_write_commit_graph_or_die(struct odb_source *source)
 {
diff --git a/commit-graph.h b/pack/commit-graph.h
similarity index 100%
rename from commit-graph.h
rename to pack/commit-graph.h
diff --git a/delta-islands.c b/pack/delta-islands.c
similarity index 99%
rename from delta-islands.c
rename to pack/delta-islands.c
index 1c92cdf37c..3d015719a5 100644
--- a/delta-islands.c
+++ b/pack/delta-islands.c
@@ -7,15 +7,15 @@
 #include "hex.h"
 #include "odb/tag.h"
 #include "odb/tree.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "odb/tree-walk.h"
 #include "diff.h"
 #include "progress.h"
 #include "refs/refs.h"
 #include "khash.h"
-#include "pack-bitmap.h"
-#include "pack-objects.h"
-#include "delta-islands.h"
+#include "pack/pack-bitmap.h"
+#include "pack/pack-objects.h"
+#include "pack/delta-islands.h"
 #include "odb/oid-array.h"
 #include "config.h"
 
diff --git a/delta-islands.h b/pack/delta-islands.h
similarity index 100%
rename from delta-islands.h
rename to pack/delta-islands.h
diff --git a/delta.h b/pack/delta.h
similarity index 100%
rename from delta.h
rename to pack/delta.h
diff --git a/diff-delta.c b/pack/diff-delta.c
similarity index 99%
rename from diff-delta.c
rename to pack/diff-delta.c
index 43c339f010..0800ce4607 100644
--- a/diff-delta.c
+++ b/pack/diff-delta.c
@@ -14,7 +14,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "delta.h"
+#include "pack/delta.h"
 
 /* maximum hash entry list for the same hash bucket */
 #define HASH_LIMIT 64
diff --git a/midx-write.c b/pack/midx-write.c
similarity index 99%
rename from midx-write.c
rename to pack/midx-write.c
index af4410a0b8..1f8f24410a 100644
--- a/midx-write.c
+++ b/pack/midx-write.c
@@ -3,20 +3,20 @@
 #include "config.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/hash-lookup.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "progress.h"
 #include "trace2.h"
 #include "run-command.h"
-#include "chunk-format.h"
-#include "pack-bitmap.h"
+#include "pack/chunk-format.h"
+#include "pack/pack-bitmap.h"
 #include "refs/refs.h"
 #include "revision.h"
 #include "list-objects.h"
 #include "path.h"
-#include "pack-revindex.h"
+#include "pack/pack-revindex.h"
 
 #define PACK_EXPIRED UINT_MAX
 #define BITMAP_POS_UNKNOWN (~((uint32_t)0))
diff --git a/midx.c b/pack/midx.c
similarity index 99%
rename from midx.c
rename to pack/midx.c
index 47f67c4295..2608e99468 100644
--- a/midx.c
+++ b/pack/midx.c
@@ -4,14 +4,14 @@
 #include "config.h"
 #include "dir.h"
 #include "hex.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/hash-lookup.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "progress.h"
 #include "trace2.h"
-#include "chunk-format.h"
-#include "pack-bitmap.h"
-#include "pack-revindex.h"
+#include "pack/chunk-format.h"
+#include "pack/pack-bitmap.h"
+#include "pack/pack-revindex.h"
 #include "strvec.h"
 
 #define MIDX_PACK_ERROR ((void *)(intptr_t)-1)
diff --git a/midx.h b/pack/midx.h
similarity index 100%
rename from midx.h
rename to pack/midx.h
diff --git a/pack-bitmap-write.c b/pack/pack-bitmap-write.c
similarity index 99%
rename from pack-bitmap-write.c
rename to pack/pack-bitmap-write.c
index b5e14b196f..6ef5fb4629 100644
--- a/pack-bitmap-write.c
+++ b/pack/pack-bitmap-write.c
@@ -9,24 +9,24 @@
 #include "diff.h"
 #include "revision.h"
 #include "progress.h"
-#include "pack.h"
-#include "pack-bitmap.h"
+#include "pack/pack.h"
+#include "pack/pack-bitmap.h"
 #include "odb/hash-lookup.h"
-#include "pack-objects.h"
+#include "pack/pack-objects.h"
 #include "path.h"
 #include "commit-reach.h"
 #include "prio-queue.h"
 #include "trace2.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "pseudo-merge.h"
+#include "pack/pseudo-merge.h"
 #include "odb/oid-array.h"
 #include "config.h"
 #include "odb/alloc.h"
 #include "refs/refs.h"
 #include "strmap.h"
-#include "midx.h"
-#include "pack-revindex.h"
+#include "pack/midx.h"
+#include "pack/pack-revindex.h"
 
 struct bitmapped_commit {
 	struct commit *commit;
diff --git a/pack-bitmap.c b/pack/pack-bitmap.c
similarity index 99%
rename from pack-bitmap.c
rename to pack/pack-bitmap.c
index 908a00ec0c..80f853f355 100644
--- a/pack-bitmap.c
+++ b/pack/pack-bitmap.c
@@ -10,18 +10,18 @@
 #include "revision.h"
 #include "progress.h"
 #include "list-objects.h"
-#include "pack.h"
-#include "pack-bitmap.h"
-#include "pack-revindex.h"
-#include "pack-objects.h"
-#include "packfile.h"
+#include "pack/pack.h"
+#include "pack/pack-bitmap.h"
+#include "pack/pack-revindex.h"
+#include "pack/pack-objects.h"
+#include "pack/packfile.h"
 #include "repository.h"
 #include "trace2.h"
 #include "odb/odb.h"
 #include "list-objects-filter-options.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "config.h"
-#include "pseudo-merge.h"
+#include "pack/pseudo-merge.h"
 
 /*
  * An entry on the bitmap index, representing the bitmap for a given
diff --git a/pack-bitmap.h b/pack/pack-bitmap.h
similarity index 99%
rename from pack-bitmap.h
rename to pack/pack-bitmap.h
index b50ef0b4e4..6f6fc1cb50 100644
--- a/pack-bitmap.h
+++ b/pack/pack-bitmap.h
@@ -3,8 +3,8 @@
 
 #include "ewah/ewok.h"
 #include "khash.h"
-#include "pack.h"
-#include "pack-objects.h"
+#include "pack/pack.h"
+#include "pack/pack-objects.h"
 #include "refs/refs.h"
 #include "string-list.h"
 
diff --git a/pack-check.c b/pack/pack-check.c
similarity index 99%
rename from pack-check.c
rename to pack/pack-check.c
index 358c68ef11..e66ef8f1b7 100644
--- a/pack-check.c
+++ b/pack/pack-check.c
@@ -4,9 +4,9 @@
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "progress.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/streaming.h"
diff --git a/pack-mtimes.c b/pack/pack-mtimes.c
similarity index 98%
rename from pack-mtimes.c
rename to pack/pack-mtimes.c
index 903c1039c8..1dbc072bb0 100644
--- a/pack-mtimes.c
+++ b/pack/pack-mtimes.c
@@ -1,8 +1,8 @@
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "pack-mtimes.h"
+#include "pack/pack-mtimes.h"
 #include "odb/odb.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "strbuf.h"
 
 static char *pack_mtimes_filename(struct packed_git *p)
diff --git a/pack-mtimes.h b/pack/pack-mtimes.h
similarity index 100%
rename from pack-mtimes.h
rename to pack/pack-mtimes.h
diff --git a/pack-objects.c b/pack/pack-objects.c
similarity index 98%
rename from pack-objects.c
rename to pack/pack-objects.c
index 35ecc8831e..aa1d5bb1c9 100644
--- a/pack-objects.c
+++ b/pack/pack-objects.c
@@ -1,8 +1,8 @@
 #include "git-compat-util.h"
 #include "odb/object.h"
-#include "pack.h"
-#include "pack-objects.h"
-#include "packfile.h"
+#include "pack/pack.h"
+#include "pack/pack-objects.h"
+#include "pack/packfile.h"
 #include "parse.h"
 #include "repository.h"
 
diff --git a/pack-objects.h b/pack/pack-objects.h
similarity index 99%
rename from pack-objects.h
rename to pack/pack-objects.h
index 8b9fc2e36b..dbd07d3913 100644
--- a/pack-objects.h
+++ b/pack/pack-objects.h
@@ -3,8 +3,8 @@
 
 #include "odb/odb.h"
 #include "thread-utils.h"
-#include "pack.h"
-#include "packfile.h"
+#include "pack/pack.h"
+#include "pack/packfile.h"
 
 struct repository;
 
diff --git a/pack-revindex.c b/pack/pack-revindex.c
similarity index 99%
rename from pack-revindex.c
rename to pack/pack-revindex.c
index 613d1bb897..51cf1f82c6 100644
--- a/pack-revindex.c
+++ b/pack/pack-revindex.c
@@ -1,13 +1,13 @@
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "pack-revindex.h"
+#include "pack/pack-revindex.h"
 #include "odb/odb.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "strbuf.h"
 #include "trace2.h"
 #include "parse.h"
 #include "repository.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "csum-file.h"
 
 struct revindex_entry {
diff --git a/pack-revindex.h b/pack/pack-revindex.h
similarity index 100%
rename from pack-revindex.h
rename to pack/pack-revindex.h
diff --git a/pack-write.c b/pack/pack-write.c
similarity index 99%
rename from pack-write.c
rename to pack/pack-write.c
index 86af0ac730..3ced89d932 100644
--- a/pack-write.c
+++ b/pack/pack-write.c
@@ -2,14 +2,14 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "csum-file.h"
 #include "remote.h"
-#include "chunk-format.h"
+#include "pack/chunk-format.h"
 #include "odb/object-file.h"
-#include "pack-mtimes.h"
-#include "pack-objects.h"
-#include "pack-revindex.h"
+#include "pack/pack-mtimes.h"
+#include "pack/pack-objects.h"
+#include "pack/pack-revindex.h"
 #include "path.h"
 #include "repository.h"
 #include "strbuf.h"
diff --git a/pack.h b/pack/pack.h
similarity index 100%
rename from pack.h
rename to pack/pack.h
diff --git a/packfile-list.c b/pack/packfile-list.c
similarity index 96%
rename from packfile-list.c
rename to pack/packfile-list.c
index 01fb913abf..4e041d4fed 100644
--- a/packfile-list.c
+++ b/pack/packfile-list.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
-#include "packfile.h"
-#include "packfile-list.h"
+#include "pack/packfile.h"
+#include "pack/packfile-list.h"
 
 void packfile_list_clear(struct packfile_list *list)
 {
diff --git a/packfile-list.h b/pack/packfile-list.h
similarity index 100%
rename from packfile-list.h
rename to pack/packfile-list.h
diff --git a/packfile.c b/pack/packfile.c
similarity index 99%
rename from packfile.c
rename to pack/packfile.c
index 2936cbf3fa..0426bee827 100644
--- a/packfile.c
+++ b/pack/packfile.c
@@ -5,11 +5,11 @@
 #include "gettext.h"
 #include "hex.h"
 #include "list.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "repository.h"
 #include "dir.h"
-#include "packfile.h"
-#include "delta.h"
+#include "pack/packfile.h"
+#include "pack/delta.h"
 #include "odb/hash-lookup.h"
 #include "odb/commit.h"
 #include "odb/object.h"
@@ -20,11 +20,11 @@
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/streaming.h"
-#include "midx.h"
-#include "commit-graph.h"
-#include "pack-revindex.h"
+#include "pack/midx.h"
+#include "pack/commit-graph.h"
+#include "pack/pack-revindex.h"
 #include "promisor-remote.h"
-#include "pack-mtimes.h"
+#include "pack/pack-mtimes.h"
 
 char *odb_pack_name(struct repository *r, struct strbuf *buf,
 		    const unsigned char *hash, const char *ext)
diff --git a/packfile.h b/pack/packfile.h
similarity index 99%
rename from packfile.h
rename to pack/packfile.h
index 9859bfb5e0..55dc02539b 100644
--- a/packfile.h
+++ b/pack/packfile.h
@@ -7,7 +7,7 @@
 #include "odb/source-files.h"
 #include "odb/source-packed.h"
 #include "odb/oidset.h"
-#include "packfile-list.h"
+#include "pack/packfile-list.h"
 #include "repository.h"
 
 /* in odb.h */
diff --git a/patch-delta.c b/pack/patch-delta.c
similarity index 98%
rename from patch-delta.c
rename to pack/patch-delta.c
index 42199fa956..77c1e278b7 100644
--- a/patch-delta.c
+++ b/pack/patch-delta.c
@@ -10,7 +10,7 @@
  */
 
 #include "git-compat-util.h"
-#include "delta.h"
+#include "pack/delta.h"
 
 void *patch_delta(const void *src_buf, size_t src_size,
 		  const void *delta_buf, size_t delta_size,
diff --git a/prune-packed.c b/pack/prune-packed.c
similarity index 94%
rename from prune-packed.c
rename to pack/prune-packed.c
index f536ef1eaf..52473c6bf9 100644
--- a/prune-packed.c
+++ b/pack/prune-packed.c
@@ -3,9 +3,9 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "odb/object-file.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "progress.h"
-#include "prune-packed.h"
+#include "pack/prune-packed.h"
 #include "repository.h"
 
 static struct progress *progress;
diff --git a/prune-packed.h b/pack/prune-packed.h
similarity index 100%
rename from prune-packed.h
rename to pack/prune-packed.h
diff --git a/pseudo-merge.c b/pack/pseudo-merge.c
similarity index 99%
rename from pseudo-merge.c
rename to pack/pseudo-merge.c
index f87fd46b46..07c6ebea05 100644
--- a/pseudo-merge.c
+++ b/pack/pseudo-merge.c
@@ -2,14 +2,14 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "pseudo-merge.h"
+#include "pack/pseudo-merge.h"
 #include "date.h"
 #include "odb/oid-array.h"
 #include "strbuf.h"
 #include "config.h"
 #include "string-list.h"
 #include "refs/refs.h"
-#include "pack-bitmap.h"
+#include "pack/pack-bitmap.h"
 #include "odb/commit.h"
 #include "odb/alloc.h"
 #include "progress.h"
diff --git a/pseudo-merge.h b/pack/pseudo-merge.h
similarity index 100%
rename from pseudo-merge.h
rename to pack/pseudo-merge.h
diff --git a/reachable.c b/pack/reachable.c
similarity index 98%
rename from reachable.c
rename to pack/reachable.c
index a99699c6d8..51c13b552f 100644
--- a/reachable.c
+++ b/pack/reachable.c
@@ -8,15 +8,15 @@
 #include "odb/blob.h"
 #include "diff.h"
 #include "revision.h"
-#include "reachable.h"
+#include "pack/reachable.h"
 #include "cache-tree.h"
 #include "progress.h"
 #include "list-objects.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "refs/worktree.h"
 #include "odb/object-file.h"
-#include "pack-bitmap.h"
-#include "pack-mtimes.h"
+#include "pack/pack-bitmap.h"
+#include "pack/pack-mtimes.h"
 #include "config.h"
 #include "run-command.h"
 #include "sequencer.h"
diff --git a/reachable.h b/pack/reachable.h
similarity index 100%
rename from reachable.h
rename to pack/reachable.h
diff --git a/repack-cruft.c b/pack/repack-cruft.c
similarity index 98%
rename from repack-cruft.c
rename to pack/repack-cruft.c
index 0653e88792..0f49a59ca7 100644
--- a/repack-cruft.c
+++ b/pack/repack-cruft.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
-#include "repack.h"
-#include "packfile.h"
+#include "pack/repack.h"
+#include "pack/packfile.h"
 #include "repository.h"
 #include "run-command.h"
 
diff --git a/repack-filtered.c b/pack/repack-filtered.c
similarity index 98%
rename from repack-filtered.c
rename to pack/repack-filtered.c
index edcf7667c5..2a77018951 100644
--- a/repack-filtered.c
+++ b/pack/repack-filtered.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "repack.h"
+#include "pack/repack.h"
 #include "repository.h"
 #include "run-command.h"
 #include "string-list.h"
diff --git a/repack-geometry.c b/pack/repack-geometry.c
similarity index 99%
rename from repack-geometry.c
rename to pack/repack-geometry.c
index 15b3412950..1ae2e8be9f 100644
--- a/repack-geometry.c
+++ b/pack/repack-geometry.c
@@ -1,11 +1,11 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "repack.h"
+#include "pack/repack.h"
 #include "repository.h"
 #include "hex.h"
-#include "midx.h"
-#include "packfile.h"
+#include "pack/midx.h"
+#include "pack/packfile.h"
 
 static uint32_t pack_geometry_weight(struct packed_git *p)
 {
diff --git a/repack-midx.c b/pack/repack-midx.c
similarity index 99%
rename from repack-midx.c
rename to pack/repack-midx.c
index 342deb798c..d1b563e90c 100644
--- a/repack-midx.c
+++ b/pack/repack-midx.c
@@ -1,12 +1,12 @@
 #include "git-compat-util.h"
-#include "repack.h"
+#include "pack/repack.h"
 #include "odb/hash.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "odb/odb.h"
 #include "odb/oidset.h"
-#include "pack-bitmap.h"
+#include "pack/pack-bitmap.h"
 #include "path.h"
 #include "refs/refs.h"
 #include "run-command.h"
diff --git a/repack-promisor.c b/pack/repack-promisor.c
similarity index 98%
rename from repack-promisor.c
rename to pack/repack-promisor.c
index 90318ce150..628903244c 100644
--- a/repack-promisor.c
+++ b/pack/repack-promisor.c
@@ -1,8 +1,8 @@
 #include "git-compat-util.h"
-#include "repack.h"
+#include "pack/repack.h"
 #include "hex.h"
-#include "pack.h"
-#include "packfile.h"
+#include "pack/pack.h"
+#include "pack/packfile.h"
 #include "path.h"
 #include "repository.h"
 #include "run-command.h"
diff --git a/repack.c b/pack/repack.c
similarity index 99%
rename from repack.c
rename to pack/repack.c
index 16da2e35cb..91dde13b29 100644
--- a/repack.c
+++ b/pack/repack.c
@@ -1,10 +1,10 @@
 #include "git-compat-util.h"
 #include "dir.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "odb/odb.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "path.h"
-#include "repack.h"
+#include "pack/repack.h"
 #include "repository.h"
 #include "run-command.h"
 #include "tempfile.h"
diff --git a/repack.h b/pack/repack.h
similarity index 100%
rename from repack.h
rename to pack/repack.h
diff --git a/server-info.c b/pack/server-info.c
similarity index 99%
rename from server-info.c
rename to pack/server-info.c
index 3021ee8926..627d2e3c98 100644
--- a/server-info.c
+++ b/pack/server-info.c
@@ -8,11 +8,11 @@
 #include "odb/object.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "path.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
-#include "server-info.h"
+#include "pack/server-info.h"
 #include "strbuf.h"
 #include "tempfile.h"
 
diff --git a/server-info.h b/pack/server-info.h
similarity index 100%
rename from server-info.h
rename to pack/server-info.h
diff --git a/path.c b/path.c
index 4afd1e3ffa..516abb3f82 100644
--- a/path.c
+++ b/path.c
@@ -13,7 +13,7 @@
 #include "setup.h"
 #include "submodule-config.h"
 #include "path.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "odb/odb.h"
 #include "lockfile.h"
 #include "exec-cmd.h"
diff --git a/promisor-remote.c b/promisor-remote.c
index b2188d34c7..da6b1225dd 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -9,7 +9,7 @@
 #include "trace2.h"
 #include "transport.h"
 #include "strvec.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "environment.h"
 #include "url.h"
 #include "urlmatch.h"
diff --git a/repo-settings.c b/repo-settings.c
index f3be3b8c5a..f40d1436a9 100644
--- a/repo-settings.c
+++ b/repo-settings.c
@@ -2,8 +2,8 @@
 #include "config.h"
 #include "repo-settings.h"
 #include "repository.h"
-#include "midx.h"
-#include "pack-objects.h"
+#include "pack/midx.h"
+#include "pack/pack-objects.h"
 #include "setup.h"
 
 static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
diff --git a/revision.c b/revision.c
index 35a1893436..f92a6482f1 100644
--- a/revision.c
+++ b/revision.c
@@ -31,7 +31,7 @@
 #include "odb/commit-slab.h"
 #include "cache-tree.h"
 #include "bisect.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "refs/worktree.h"
 #include "path.h"
 #include "read-cache.h"
@@ -40,11 +40,11 @@
 #include "strvec.h"
 #include "trace2.h"
 #include "commit-reach.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "prio-queue.h"
 #include "hashmap.h"
 #include "utf8.h"
-#include "bloom.h"
+#include "pack/bloom.h"
 #include "json-writer.h"
 #include "list-objects-filter-options.h"
 #include "resolve-undo.h"
diff --git a/run-command.c b/run-command.c
index ce84db8782..e0c4325900 100644
--- a/run-command.c
+++ b/run-command.c
@@ -15,7 +15,7 @@
 #include "trace2.h"
 #include "quote.h"
 #include "config.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "compat/nonblock.h"
 
 void child_process_init(struct child_process *child)
diff --git a/scalar.c b/scalar.c
index af3456b5d0..2cb09af1a5 100644
--- a/scalar.c
+++ b/scalar.c
@@ -15,7 +15,7 @@
 #include "fsmonitor-settings.h"
 #include "refs/refs.h"
 #include "dir.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "help.h"
 #include "setup.h"
 #include "trace2.h"
diff --git a/t/helper/test-bitmap.c b/t/helper/test-bitmap.c
index f1f48e973d..59beba76d2 100644
--- a/t/helper/test-bitmap.c
+++ b/t/helper/test-bitmap.c
@@ -4,8 +4,8 @@
 #include "git-compat-util.h"
 #include "hex.h"
 #include "odb/odb.h"
-#include "pack-bitmap.h"
-#include "pseudo-merge.h"
+#include "pack/pack-bitmap.h"
+#include "pack/pseudo-merge.h"
 #include "setup.h"
 
 static int bitmap_list_commits(void)
diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index 48ff2c6024..5c469af08d 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "bloom.h"
+#include "pack/bloom.h"
 #include "hex.h"
 #include "odb/commit.h"
 #include "repository.h"
diff --git a/t/helper/test-delta.c b/t/helper/test-delta.c
index 8223a60229..291c2eb291 100644
--- a/t/helper/test-delta.c
+++ b/t/helper/test-delta.c
@@ -10,7 +10,7 @@
 
 #include "test-tool.h"
 #include "git-compat-util.h"
-#include "delta.h"
+#include "pack/delta.h"
 #include "strbuf.h"
 
 static const char usage_str[] =
diff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c
index c7475ed4d9..216e7abb9a 100644
--- a/t/helper/test-find-pack.c
+++ b/t/helper/test-find-pack.c
@@ -3,7 +3,7 @@
 #include "test-tool.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 #include "parse-options.h"
 #include "setup.h"
 
diff --git a/t/helper/test-name-hash.c b/t/helper/test-name-hash.c
index af1d52de10..13e8996b66 100644
--- a/t/helper/test-name-hash.c
+++ b/t/helper/test-name-hash.c
@@ -5,7 +5,7 @@
 
 #include "test-tool.h"
 #include "git-compat-util.h"
-#include "pack-objects.h"
+#include "pack/pack-objects.h"
 #include "strbuf.h"
 
 int cmd__name_hash(int argc UNUSED, const char **argv UNUSED)
diff --git a/t/helper/test-pack-deltas.c b/t/helper/test-pack-deltas.c
index 7e5791c7ab..a3117ca6fc 100644
--- a/t/helper/test-pack-deltas.c
+++ b/t/helper/test-pack-deltas.c
@@ -2,12 +2,12 @@
 
 #include "test-tool.h"
 #include "git-compat-util.h"
-#include "delta.h"
+#include "pack/delta.h"
 #include "git-zlib.h"
 #include "odb/hash.h"
 #include "hex.h"
-#include "pack.h"
-#include "pack-objects.h"
+#include "pack/pack.h"
+#include "pack/pack-objects.h"
 #include "parse-options.h"
 #include "setup.h"
 #include "strbuf.h"
diff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c
index b915059322..4750a33140 100644
--- a/t/helper/test-pack-mtimes.c
+++ b/t/helper/test-pack-mtimes.c
@@ -4,8 +4,8 @@
 #include "hex.h"
 #include "strbuf.h"
 #include "odb/odb.h"
-#include "packfile.h"
-#include "pack-mtimes.h"
+#include "pack/packfile.h"
+#include "pack/pack-mtimes.h"
 #include "setup.h"
 
 static void dump_mtimes(struct packed_git *p)
diff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c
index 965700a698..c80df07586 100644
--- a/t/helper/test-read-graph.c
+++ b/t/helper/test-read-graph.c
@@ -1,10 +1,10 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "repository.h"
 #include "odb/odb.h"
-#include "bloom.h"
+#include "pack/bloom.h"
 #include "setup.h"
 
 static void dump_graph_info(struct commit_graph *graph)
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index 9be143ee6c..1e3db8cd81 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -2,14 +2,14 @@
 
 #include "test-tool.h"
 #include "hex.h"
-#include "midx.h"
+#include "pack/midx.h"
 #include "repository.h"
 #include "odb/odb.h"
-#include "pack-bitmap.h"
-#include "packfile.h"
+#include "pack/pack-bitmap.h"
+#include "pack/packfile.h"
 #include "setup.h"
 #include "gettext.h"
-#include "pack-revindex.h"
+#include "pack/pack-revindex.h"
 
 static struct multi_pack_index *setup_midx(const char *object_dir)
 {
diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c
index 530e37b01d..58f486a471 100644
--- a/t/helper/test-repository.c
+++ b/t/helper/test-repository.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "odb/commit.h"
 #include "environment.h"
 #include "hex.h"
diff --git a/t/helper/test-synthesize.c b/t/helper/test-synthesize.c
index 57013566cc..1997141691 100644
--- a/t/helper/test-synthesize.c
+++ b/t/helper/test-synthesize.c
@@ -7,7 +7,7 @@
 #include "hex.h"
 #include "odb/object-file.h"
 #include "odb/object.h"
-#include "pack.h"
+#include "pack/pack.h"
 #include "parse-options.h"
 #include "parse.h"
 #include "repository.h"
diff --git a/transport-helper.c b/transport-helper.c
index 55bd9291db..6721209d46 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -19,7 +19,7 @@
 #include "refs/refspec.h"
 #include "transport-internal.h"
 #include "protocol.h"
-#include "packfile.h"
+#include "pack/packfile.h"
 
 static int debug;
 
diff --git a/upload-pack.c b/upload-pack.c
index 80d2c95c9b..d145a89c7b 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -26,7 +26,7 @@
 #include "trace2.h"
 #include "protocol.h"
 #include "upload-pack.h"
-#include "commit-graph.h"
+#include "pack/commit-graph.h"
 #include "commit-reach.h"
 #include "shallow.h"
 #include "trace.h"
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 10/14] diff: gather the diff sources under diff/
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (8 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 09/14] pack: gather the pack sources under pack/ Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 11/14] revision: gather the revision sources under revision/ Michael Montalbo
                   ` (3 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Move the 16 diff C sources and 7 headers into diff/ as renames. Repoint
every reference to their old paths to the new ones: the #include lines
across the tree, the Makefile and meson.build build entries.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize                                  | 46 +++++++++----------
 Makefile                                      | 32 ++++++-------
 add-interactive.c                             |  2 +-
 add-patch.c                                   |  2 +-
 apply.c                                       |  4 +-
 archive-zip.c                                 |  4 +-
 bisect.c                                      |  2 +-
 blame.c                                       |  4 +-
 blame.h                                       |  2 +-
 builtin/add.c                                 |  2 +-
 builtin/am.c                                  |  2 +-
 builtin/blame.c                               |  4 +-
 builtin/cat-file.c                            |  4 +-
 builtin/checkout.c                            |  4 +-
 builtin/commit.c                              |  2 +-
 builtin/describe.c                            |  2 +-
 builtin/diff-files.c                          |  4 +-
 builtin/diff-index.c                          |  4 +-
 builtin/diff-pairs.c                          |  4 +-
 builtin/diff-tree.c                           |  2 +-
 builtin/diff.c                                |  6 +--
 builtin/fast-export.c                         |  4 +-
 builtin/last-modified.c                       |  4 +-
 builtin/log.c                                 | 12 ++---
 builtin/merge-file.c                          |  4 +-
 builtin/merge-ours.c                          |  2 +-
 builtin/merge-tree.c                          |  2 +-
 builtin/merge.c                               |  6 +--
 builtin/pack-objects.c                        |  2 +-
 builtin/patch-id.c                            |  2 +-
 builtin/prune.c                               |  2 +-
 builtin/range-diff.c                          |  2 +-
 builtin/rebase.c                              |  2 +-
 builtin/rerere.c                              |  2 +-
 builtin/reset.c                               |  4 +-
 builtin/rev-list.c                            |  2 +-
 builtin/rev-parse.c                           |  2 +-
 builtin/revert.c                              |  2 +-
 builtin/shortlog.c                            |  2 +-
 builtin/stash.c                               |  2 +-
 builtin/submodule--helper.c                   |  4 +-
 builtin/tag.c                                 |  2 +-
 bundle.c                                      |  2 +-
 combine-diff.c => diff/combine-diff.c         |  8 ++--
 diff-lib.c => diff/diff-lib.c                 |  4 +-
 diff-merges.c => diff/diff-merges.c           |  2 +-
 diff-merges.h => diff/diff-merges.h           |  0
 diff-no-index.c => diff/diff-no-index.c       |  4 +-
 diff.c => diff/diff.c                         |  8 ++--
 diff.h => diff/diff.h                         |  0
 diffcore-break.c => diff/diffcore-break.c     |  2 +-
 diffcore-delta.c => diff/diffcore-delta.c     |  2 +-
 diffcore-order.c => diff/diffcore-order.c     |  4 +-
 diffcore-pickaxe.c => diff/diffcore-pickaxe.c |  6 +--
 diffcore-rename.c => diff/diffcore-rename.c   |  4 +-
 diffcore-rotate.c => diff/diffcore-rotate.c   |  4 +-
 diffcore.h => diff/diffcore.h                 |  0
 patch-ids.c => diff/patch-ids.c               |  4 +-
 patch-ids.h => diff/patch-ids.h               |  2 +-
 range-diff.c => diff/range-diff.c             |  8 ++--
 range-diff.h => diff/range-diff.h             |  2 +-
 tree-diff.c => diff/tree-diff.c               |  4 +-
 userdiff.c => diff/userdiff.c                 |  2 +-
 userdiff.h => diff/userdiff.h                 |  0
 xdiff-interface.c => diff/xdiff-interface.c   |  2 +-
 xdiff-interface.h => diff/xdiff-interface.h   |  0
 fmt-merge-msg.c                               |  4 +-
 graph.h                                       |  2 +-
 grep.c                                        |  8 ++--
 grep.h                                        |  2 +-
 http-push.c                                   |  2 +-
 line-log.c                                    |  6 +--
 line-log.h                                    |  2 +-
 line-range.c                                  |  4 +-
 list-objects-filter.c                         |  2 +-
 list-objects.c                                |  2 +-
 log-tree.c                                    |  6 +--
 merge-ll.c                                    |  2 +-
 merge-ort.c                                   |  6 +--
 meson.build                                   | 32 ++++++-------
 notes-merge.c                                 |  6 +--
 odb/commit.c                                  |  2 +-
 pack/bloom.c                                  |  4 +-
 pack/delta-islands.c                          |  2 +-
 pack/pack-bitmap-write.c                      |  2 +-
 pack/pack-bitmap.c                            |  2 +-
 pack/reachable.c                              |  2 +-
 pretty.c                                      |  2 +-
 read-cache.c                                  |  4 +-
 refs/reflog-walk.c                            |  2 +-
 remote.c                                      |  2 +-
 rerere.c                                      |  2 +-
 revision.c                                    |  6 +--
 revision.h                                    |  2 +-
 sequencer.c                                   |  2 +-
 shallow.c                                     |  2 +-
 submodule.c                                   |  4 +-
 t/helper/test-revision-walking.c              |  2 +-
 t/helper/test-userdiff.c                      |  2 +-
 upload-pack.c                                 |  2 +-
 wt-status.c                                   |  4 +-
 101 files changed, 208 insertions(+), 208 deletions(-)
 rename combine-diff.c => diff/combine-diff.c (99%)
 rename diff-lib.c => diff/diff-lib.c (99%)
 rename diff-merges.c => diff/diff-merges.c (99%)
 rename diff-merges.h => diff/diff-merges.h (100%)
 rename diff-no-index.c => diff/diff-no-index.c (99%)
 rename diff.c => diff/diff.c (99%)
 rename diff.h => diff/diff.h (100%)
 rename diffcore-break.c => diff/diffcore-break.c (99%)
 rename diffcore-delta.c => diff/diffcore-delta.c (99%)
 rename diffcore-order.c => diff/diffcore-order.c (97%)
 rename diffcore-pickaxe.c => diff/diffcore-pickaxe.c (98%)
 rename diffcore-rename.c => diff/diffcore-rename.c (99%)
 rename diffcore-rotate.c => diff/diffcore-rotate.c (95%)
 rename diffcore.h => diff/diffcore.h (100%)
 rename patch-ids.c => diff/patch-ids.c (98%)
 rename patch-ids.h => diff/patch-ids.h (98%)
 rename range-diff.c => diff/range-diff.c (99%)
 rename range-diff.h => diff/range-diff.h (98%)
 rename tree-diff.c => diff/tree-diff.c (99%)
 rename userdiff.c => diff/userdiff.c (99%)
 rename userdiff.h => diff/userdiff.h (100%)
 rename xdiff-interface.c => diff/xdiff-interface.c (99%)
 rename xdiff-interface.h => diff/xdiff-interface.h (100%)

diff --git a/.gitorganize b/.gitorganize
index 533d50ed89..160365fbca 100644
--- a/.gitorganize
+++ b/.gitorganize
@@ -62,7 +62,6 @@ color.c component=? role=lib prefix=color includes=setup:1 cochange=diff:21,inde
 color.h component=? role=public prefix=color cochange=diff:18,index:12,revision:12,transport:2,odb:1
 column.c component=? role=lib prefix=column includes=setup:1 cochange=transport:6,setup:5,diff:4,revision:3,index:2
 column.h component=? role=public prefix=column
-combine-diff.c component=diff role=lib prefix=combine-diff includes=odb:5,diff:4,revision:2,convert:1,refs:1 cochange=diff:198,revision:67,index:35,odb:16,transport:16
 commit-reach.c component=revision role=lib prefix=commit-reach includes=revision:3,odb:2,pack:1,refs:1 cochange=revision:38,odb:17,pack:15,transport:9,index:5
 commit-reach.h component=revision role=header prefix=commit-reach includes=odb:2 cochange=revision:32,odb:9,transport:8,pack:3,refs:3
 common-exit.c component=? role=lib prefix=common-main
@@ -91,19 +90,29 @@ decorate.c component=revision role=lib prefix=decorate includes=odb:1,revision:1
 decorate.h component=revision role=header prefix=decorate cochange=revision:4,odb:1
 diagnose.c component=? role=lib prefix=diagnose includes=archive:1,index:1,odb:1,pack:1,setup:1 cochange=index:4,revision:4,odb:3,pack:3,transport:3
 diagnose.h component=? role=public prefix=diagnose cochange=revision:2,refs:1,transport:1
-diff-lib.c component=diff role=lib prefix=diff includes=index:6,odb:3,diff:2,revision:2,refs:1 cochange=diff:150,index:124,revision:47,submodule:18,odb:8
-diff-merges.c component=diff role=lib prefix=diff-merges includes=diff:1,revision:1 cochange=revision:18,diff:17,odb:4,refs:3,index:2
-diff-merges.h component=diff role=header prefix=diff-merges cochange=diff:11,revision:4,merge:1
-diff-no-index.c component=diff role=lib prefix=diff includes=diff:2,index:2,odb:1,revision:1 cochange=diff:76,revision:21,index:19,refs:8,notes:7
-diff.c component=diff role=lib prefix=diff includes=odb:5,diff:4,setup:3,convert:2,index:2 cochange=diff:610,revision:121,index:100,transport:71,setup:69
-diff.h component=diff role=header prefix=diff includes=index:1,odb:1 cochange=diff:471,revision:83,index:29,submodule:18,odb:14
-diffcore-break.c component=diff role=lib prefix=diffcore-break includes=odb:2,diff:1,transport:1 cochange=diff:71,pack:8,revision:7,index:5,merge:3
-diffcore-delta.c component=diff role=lib prefix=diffcore-delta includes=diff:1 cochange=diff:26,revision:7,odb:4,index:2,refs:2
-diffcore-order.c component=diff role=lib prefix=diffcore-order includes=diff:2 cochange=diff:19,index:8,refs:7,revision:7,pack:5
-diffcore-pickaxe.c component=diff role=lib prefix=pickaxe includes=diff:3,odb:1,revision:1 cochange=diff:97,revision:15,notes:3,odb:3,merge:2
-diffcore-rename.c component=diff role=lib prefix=diffcore-rename includes=diff:2,odb:2,transport:1 cochange=diff:188,index:38,revision:37,odb:21,pack:17
-diffcore-rotate.c component=diff role=lib prefix=diff includes=diff:2 cochange=diff:14,revision:5,pack:2,merge:1,refs:1
-diffcore.h component=diff role=header prefix=diff includes=odb:1 cochange=diff:175,revision:11,merge:10,submodule:4,odb:2
+diff/combine-diff.c component=diff role=lib prefix=combine-diff includes=odb:5,diff:4,revision:2,convert:1,refs:1 cochange=diff:198,revision:67,index:35,odb:16,transport:16
+diff/diff-lib.c component=diff role=lib prefix=diff includes=index:6,odb:3,diff:2,revision:2,refs:1 cochange=diff:150,index:124,revision:47,submodule:18,odb:8
+diff/diff-merges.c component=diff role=lib prefix=diff-merges includes=diff:1,revision:1 cochange=revision:18,diff:17,odb:4,refs:3,index:2
+diff/diff-merges.h component=diff role=header prefix=diff-merges cochange=diff:11,revision:4,merge:1
+diff/diff-no-index.c component=diff role=lib prefix=diff includes=diff:2,index:2,odb:1,revision:1 cochange=diff:76,revision:21,index:19,refs:8,notes:7
+diff/diff.c component=diff role=lib prefix=diff includes=odb:5,diff:4,setup:3,convert:2,index:2 cochange=diff:610,revision:121,index:100,transport:71,setup:69
+diff/diff.h component=diff role=header prefix=diff includes=index:1,odb:1 cochange=diff:471,revision:83,index:29,submodule:18,odb:14
+diff/diffcore-break.c component=diff role=lib prefix=diffcore-break includes=odb:2,diff:1,transport:1 cochange=diff:71,pack:8,revision:7,index:5,merge:3
+diff/diffcore-delta.c component=diff role=lib prefix=diffcore-delta includes=diff:1 cochange=diff:26,revision:7,odb:4,index:2,refs:2
+diff/diffcore-order.c component=diff role=lib prefix=diffcore-order includes=diff:2 cochange=diff:19,index:8,refs:7,revision:7,pack:5
+diff/diffcore-pickaxe.c component=diff role=lib prefix=pickaxe includes=diff:3,odb:1,revision:1 cochange=diff:97,revision:15,notes:3,odb:3,merge:2
+diff/diffcore-rename.c component=diff role=lib prefix=diffcore-rename includes=diff:2,odb:2,transport:1 cochange=diff:188,index:38,revision:37,odb:21,pack:17
+diff/diffcore-rotate.c component=diff role=lib prefix=diff includes=diff:2 cochange=diff:14,revision:5,pack:2,merge:1,refs:1
+diff/diffcore.h component=diff role=header prefix=diff includes=odb:1 cochange=diff:175,revision:11,merge:10,submodule:4,odb:2
+diff/patch-ids.c component=diff role=lib prefix=patch-ids includes=diff:2,odb:2 cochange=diff:73,revision:34,index:14,odb:13,refs:12
+diff/patch-ids.h component=diff role=header prefix=patch-ids includes=diff:1 cochange=diff:15,revision:3,index:1
+diff/range-diff.c component=diff role=lib prefix=range-diff includes=diff:4,odb:2,revision:2,setup:2 cochange=diff:49,revision:26,index:9,submodule:8,setup:7
+diff/range-diff.h component=diff role=header prefix=range-diff includes=diff:1 cochange=diff:13,revision:4
+diff/tree-diff.c component=diff role=lib prefix=tree-diff includes=odb:3,diff:2,index:1,setup:1 cochange=diff:115,odb:56,revision:53,index:36,notes:12
+diff/userdiff.c component=diff role=lib prefix=userdiff includes=setup:2,convert:1,diff:1 cochange=diff:41,convert:34,archive:11,index:7,transport:6
+diff/userdiff.h component=diff role=header prefix=diff includes=notes:1 cochange=diff:40,notes:2,archive:1,merge:1,revision:1
+diff/xdiff-interface.c component=diff role=lib prefix=xdiff-interface includes=setup:2,diff:1,odb:1 cochange=diff:73,index:5,merge:3,notes:3,refs:3
+diff/xdiff-interface.h component=diff role=header prefix=xdiff-interface includes=odb:1 cochange=diff:62,index:2,notes:2,merge:1,odb:1
 dir-iterator.c component=index role=lib prefix=dir-iterator includes=index:2 cochange=index:7,refs:1
 dir-iterator.h component=index role=header prefix=dir-iterator cochange=index:7,refs:1
 dir.c component=index role=lib prefix=dir includes=index:7,setup:4,odb:2,convert:1,refs:1 cochange=index:343,diff:61,setup:49,odb:37,convert:29
@@ -321,8 +330,6 @@ parse-options.c component=? role=lib prefix=parse-options cochange=index:14,diff
 parse-options.h component=? role=public prefix=parse-options cochange=diff:7,merge:4,archive:3,index:3,refs:3
 parse.c component=? role=lib prefix=parse cochange=setup:6,index:3,pack:2,convert:1
 parse.h component=? role=public prefix=config cochange=setup:6,index:3,pack:2,convert:1
-patch-ids.c component=diff role=lib prefix=patch-ids includes=diff:2,odb:2 cochange=diff:73,revision:34,index:14,odb:13,refs:12
-patch-ids.h component=diff role=header prefix=patch-ids includes=diff:1 cochange=diff:15,revision:3,index:1
 path-walk.c component=? role=lib prefix=path-walk includes=odb:9,revision:3,index:1,setup:1 cochange=index:2,revision:2,transport:2,odb:1,pack:1
 path-walk.h component=? role=public prefix=path-walk includes=odb:1 cochange=index:2
 path.c component=? role=lib prefix=path includes=setup:2,index:1,odb:1,pack:1,refs:1 cochange=setup:78,refs:29,index:26,transport:15,odb:12
@@ -349,8 +356,6 @@ protocol.c component=transport role=lib prefix=protocol includes=setup:2,transpo
 protocol.h component=transport role=header prefix=protocol cochange=transport:5
 quote.c component=? role=lib prefix=quote cochange=index:15,diff:12,transport:7,odb:6,revision:6
 quote.h component=? role=public prefix=quote cochange=diff:8,transport:6,index:5,odb:5,refs:5
-range-diff.c component=diff role=lib prefix=range-diff includes=diff:4,odb:2,revision:2,setup:2 cochange=diff:49,revision:26,index:9,submodule:8,setup:7
-range-diff.h component=diff role=header prefix=range-diff includes=diff:1 cochange=diff:13,revision:4
 read-cache-ll.h component=index role=header prefix=read-cache includes=index:1,odb:1 cochange=index:8,diff:1,odb:1,revision:1
 read-cache.c component=index role=lib prefix=read-cache includes=index:10,odb:6,setup:4,diff:2,submodule:2 cochange=index:240,odb:81,setup:79,diff:67,pack:46
 read-cache.h component=index role=header prefix=read-cache includes=index:2,odb:1,setup:1 cochange=index:4,setup:4,diff:2
@@ -453,7 +458,6 @@ transport-helper.c component=transport role=lib prefix=transport-helper includes
 transport-internal.h component=transport role=header prefix=transport includes=transport:1 cochange=transport:42,refs:3,odb:1,submodule:1
 transport.c component=transport role=lib prefix=transport includes=transport:12,setup:3,odb:2,refs:2,submodule:1 cochange=transport:482,refs:35,setup:31,submodule:29,revision:21
 transport.h component=transport role=header prefix=transport includes=transport:2,revision:1 cochange=transport:249,submodule:6,odb:4,revision:2,diff:1
-tree-diff.c component=diff role=lib prefix=tree-diff includes=odb:3,diff:2,index:1,setup:1 cochange=diff:115,odb:56,revision:53,index:36,notes:12
 unicode-width.h component=? role=public prefix=unicode
 unix-socket.c component=? role=lib prefix=unix-socket cochange=diff:3,revision:2,setup:1
 unix-socket.h component=? role=public prefix=unix-socket
@@ -468,8 +472,6 @@ url.h component=? role=public prefix=url cochange=transport:9,revision:4,submodu
 urlmatch.c component=? role=lib prefix=urlmatch cochange=diff:3,odb:2,revision:2,setup:2,transport:2
 urlmatch.h component=? role=public prefix=urlmatch includes=setup:1 cochange=transport:1
 usage.c component=? role=lib prefix=usage cochange=index:3,odb:2,diff:1,revision:1,setup:1
-userdiff.c component=diff role=lib prefix=userdiff includes=setup:2,convert:1,diff:1 cochange=diff:41,convert:34,archive:11,index:7,transport:6
-userdiff.h component=diff role=header prefix=diff includes=notes:1 cochange=diff:40,notes:2,archive:1,merge:1,revision:1
 utf8.c component=? role=lib prefix=utf8 cochange=revision:6,index:3,setup:3,transport:2,convert:1
 utf8.h component=? role=public prefix=utf8 cochange=revision:6,index:2,setup:2,transport:2,convert:1
 varint.c component=? role=lib prefix=varint cochange=index:2,transport:1
@@ -490,5 +492,3 @@ ws.c component=convert role=lib prefix=whitespace includes=convert:2 cochange=co
 ws.h component=convert role=header prefix=whitespace cochange=diff:5,convert:2,setup:2
 wt-status.c component=index role=lib prefix=wt-status includes=odb:5,index:4,setup:3,diff:2,refs:2 cochange=index:149,diff:83,transport:55,refs:45,revision:45
 wt-status.h component=index role=header prefix=wt-status includes=index:1,transport:1 cochange=index:89,diff:10,refs:9,revision:4,transport:4
-xdiff-interface.c component=diff role=lib prefix=xdiff-interface includes=setup:2,diff:1,odb:1 cochange=diff:73,index:5,merge:3,notes:3,refs:3
-xdiff-interface.h component=diff role=header prefix=xdiff-interface includes=odb:1 cochange=diff:62,index:2,notes:2,merge:1,odb:1
diff --git a/Makefile b/Makefile
index 85d2a620a7..b96345ba0c 100644
--- a/Makefile
+++ b/Makefile
@@ -1124,7 +1124,7 @@ LIB_OBJS += checkout.o
 LIB_OBJS += pack/chunk-format.o
 LIB_OBJS += color.o
 LIB_OBJS += column.o
-LIB_OBJS += combine-diff.o
+LIB_OBJS += diff/combine-diff.o
 LIB_OBJS += pack/commit-graph.o
 LIB_OBJS += commit-reach.o
 LIB_OBJS += odb/commit.o
@@ -1148,16 +1148,16 @@ LIB_OBJS += decorate.o
 LIB_OBJS += pack/delta-islands.o
 LIB_OBJS += diagnose.o
 LIB_OBJS += pack/diff-delta.o
-LIB_OBJS += diff-merges.o
-LIB_OBJS += diff-lib.o
-LIB_OBJS += diff-no-index.o
-LIB_OBJS += diff.o
-LIB_OBJS += diffcore-break.o
-LIB_OBJS += diffcore-delta.o
-LIB_OBJS += diffcore-order.o
-LIB_OBJS += diffcore-pickaxe.o
-LIB_OBJS += diffcore-rename.o
-LIB_OBJS += diffcore-rotate.o
+LIB_OBJS += diff/diff-merges.o
+LIB_OBJS += diff/diff-lib.o
+LIB_OBJS += diff/diff-no-index.o
+LIB_OBJS += diff/diff.o
+LIB_OBJS += diff/diffcore-break.o
+LIB_OBJS += diff/diffcore-delta.o
+LIB_OBJS += diff/diffcore-order.o
+LIB_OBJS += diff/diffcore-pickaxe.o
+LIB_OBJS += diff/diffcore-rename.o
+LIB_OBJS += diff/diffcore-rotate.o
 LIB_OBJS += dir-iterator.o
 LIB_OBJS += dir.o
 LIB_OBJS += editor.o
@@ -1257,7 +1257,7 @@ LIB_OBJS += parse.o
 LIB_OBJS += parse-options-cb.o
 LIB_OBJS += parse-options.o
 LIB_OBJS += pack/patch-delta.o
-LIB_OBJS += patch-ids.o
+LIB_OBJS += diff/patch-ids.o
 LIB_OBJS += path.o
 LIB_OBJS += path-walk.o
 LIB_OBJS += pathspec.o
@@ -1273,7 +1273,7 @@ LIB_OBJS += protocol-caps.o
 LIB_OBJS += pack/prune-packed.o
 LIB_OBJS += pack/pseudo-merge.o
 LIB_OBJS += quote.o
-LIB_OBJS += range-diff.o
+LIB_OBJS += diff/range-diff.o
 LIB_OBJS += pack/reachable.o
 LIB_OBJS += read-cache.o
 LIB_OBJS += rebase-interactive.o
@@ -1360,7 +1360,7 @@ LIB_OBJS += trace2/tr2_tmr.o
 LIB_OBJS += trailer.o
 LIB_OBJS += transport-helper.o
 LIB_OBJS += transport.o
-LIB_OBJS += tree-diff.o
+LIB_OBJS += diff/tree-diff.o
 LIB_OBJS += odb/tree-walk.o
 LIB_OBJS += odb/tree.o
 LIB_OBJS += unpack-trees.o
@@ -1368,7 +1368,7 @@ LIB_OBJS += upload-pack.o
 LIB_OBJS += url.o
 LIB_OBJS += urlmatch.o
 LIB_OBJS += usage.o
-LIB_OBJS += userdiff.o
+LIB_OBJS += diff/userdiff.o
 LIB_OBJS += utf8.o
 ifdef NO_RUST
 LIB_OBJS += varint.o
@@ -1382,7 +1382,7 @@ LIB_OBJS += wrapper.o
 LIB_OBJS += write-or-die.o
 LIB_OBJS += ws.o
 LIB_OBJS += wt-status.o
-LIB_OBJS += xdiff-interface.o
+LIB_OBJS += diff/xdiff-interface.o
 LIB_OBJS += xdiff/xdiffi.o
 LIB_OBJS += xdiff/xemit.o
 LIB_OBJS += xdiff/xhistogram.o
diff --git a/add-interactive.c b/add-interactive.c
index 67ee53f5cc..f656db231c 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "add-interactive.h"
 #include "color.h"
-#include "diffcore.h"
+#include "diff/diffcore.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
diff --git a/add-patch.c b/add-patch.c
index 1b4c53e4ce..c6860310c1 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -6,7 +6,7 @@
 #include "advice.h"
 #include "odb/commit.h"
 #include "config.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "editor.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/apply.c b/apply.c
index dbfb891b4c..b8d97d140d 100644
--- a/apply.c
+++ b/apply.c
@@ -16,12 +16,12 @@
 #include "config.h"
 #include "odb/odb.h"
 #include "pack/delta.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "merge-ll.h"
 #include "lockfile.h"
 #include "name-hash.h"
diff --git a/archive-zip.c b/archive-zip.c
index 53c50ebc44..df1edadd33 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -14,9 +14,9 @@
 #include "odb/odb.h"
 #include "odb/streaming.h"
 #include "strbuf.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 #include "write-or-die.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "date.h"
 
 static int zip_date;
diff --git a/bisect.c b/bisect.c
index 85c5a12ed2..1f8d81b894 100644
--- a/bisect.c
+++ b/bisect.c
@@ -4,7 +4,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/blame.c b/blame.c
index cd18c09a3c..c736441f18 100644
--- a/blame.c
+++ b/blame.c
@@ -8,8 +8,8 @@
 #include "mergesort.h"
 #include "odb/commit.h"
 #include "convert.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "gettext.h"
 #include "hex.h"
 #include "path.h"
diff --git a/blame.h b/blame.h
index 97137099e3..30aeae2d4e 100644
--- a/blame.h
+++ b/blame.h
@@ -2,7 +2,7 @@
 #define BLAME_H
 
 #include "odb/oidset.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "prio-queue.h"
 
 #define PICKAXE_BLAME_MOVE		01
diff --git a/builtin/add.c b/builtin/add.c
index 5d6dd91f70..dd5e33c7b0 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -20,7 +20,7 @@
 #include "parse-options.h"
 #include "path.h"
 #include "preload-index.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "read-cache.h"
 #include "revision.h"
 #include "strvec.h"
diff --git a/builtin/am.c b/builtin/am.c
index d7e4e125d2..7bd7fde14b 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -24,7 +24,7 @@
 #include "cache-tree.h"
 #include "refs/refs.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "unpack-trees.h"
 #include "branch.h"
 #include "odb/object-name.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index 1662bd487d..cb9f8b4ff0 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -14,7 +14,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "quote.h"
 #include "string-list.h"
@@ -22,7 +22,7 @@
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "utf8.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 #include "line-range.h"
 #include "line-log.h"
 #include "progress.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index a59aa00cea..4fd1999f80 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -10,14 +10,14 @@
 #include "builtin.h"
 #include "config.h"
 #include "convert.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "ident.h"
 #include "list-objects-filter-options.h"
 #include "parse-options.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 #include "odb/oid-array.h"
 #include "pack/packfile.h"
 #include "odb/object-file.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 87c1f087b8..c35c3d92d1 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -8,7 +8,7 @@
 #include "checkout.h"
 #include "odb/commit.h"
 #include "config.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
@@ -40,7 +40,7 @@
 #include "odb/tree-walk.h"
 #include "unpack-trees.h"
 #include "wt-status.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "entry.h"
 #include "parallel-checkout.h"
 #include "add-interactive.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 39271d720e..d2b4ecbd40 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -17,7 +17,7 @@
 #include "dir.h"
 #include "editor.h"
 #include "environment.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "odb/commit.h"
 #include "add-interactive.h"
 #include "gettext.h"
diff --git a/builtin/describe.c b/builtin/describe.c
index c16a1da092..ff44b55e9e 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -14,7 +14,7 @@
 #include "parse-options.h"
 #include "read-cache-ll.h"
 #include "revision.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "hashmap.h"
 #include "setup.h"
 #include "strvec.h"
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index c5b7548e55..39eaf9cfce 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -9,8 +9,8 @@
 
 #include "builtin.h"
 #include "config.h"
-#include "diff.h"
-#include "diff-merges.h"
+#include "diff/diff.h"
+#include "diff/diff-merges.h"
 #include "odb/commit.h"
 #include "preload-index.h"
 #include "revision.h"
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index a23f444348..799f5533ad 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -3,8 +3,8 @@
 
 #include "builtin.h"
 #include "config.h"
-#include "diff.h"
-#include "diff-merges.h"
+#include "diff/diff.h"
+#include "diff/diff-merges.h"
 #include "odb/commit.h"
 #include "preload-index.h"
 #include "revision.h"
diff --git a/builtin/diff-pairs.c b/builtin/diff-pairs.c
index 315fc7357a..e3350b2915 100644
--- a/builtin/diff-pairs.c
+++ b/builtin/diff-pairs.c
@@ -1,7 +1,7 @@
 #include "builtin.h"
 #include "config.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index a3e1e5e020..8f2103013c 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -2,7 +2,7 @@
 
 #include "builtin.h"
 #include "config.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "odb/commit.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/diff.c b/builtin/diff.c
index c9ccc7e6c5..774c12cea6 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -15,9 +15,9 @@
 #include "odb/commit.h"
 #include "gettext.h"
 #include "odb/tag.h"
-#include "diff.h"
-#include "diff-merges.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diff-merges.h"
+#include "diff/diffcore.h"
 #include "preload-index.h"
 #include "read-cache-ll.h"
 #include "revision.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 4a98f14d39..6683d49660 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -19,8 +19,8 @@
 #include "odb/commit.h"
 #include "odb/object.h"
 #include "odb/tag.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "log-tree.h"
 #include "revision.h"
 #include "decorate.h"
diff --git a/builtin/last-modified.c b/builtin/last-modified.c
index 83c5d66f36..911441a321 100644
--- a/builtin/last-modified.c
+++ b/builtin/last-modified.c
@@ -5,8 +5,8 @@
 #include "odb/commit-slab.h"
 #include "odb/commit.h"
 #include "config.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "environment.h"
 #include "ewah/ewok.h"
 #include "hashmap.h"
diff --git a/builtin/log.c b/builtin/log.c
index 7099f5fcc5..a93b97858b 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -20,16 +20,16 @@
 #include "pager.h"
 #include "color.h"
 #include "odb/commit.h"
-#include "diff.h"
-#include "diffcore.h"
-#include "diff-merges.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
+#include "diff/diff-merges.h"
 #include "revision.h"
 #include "log-tree.h"
 #include "odb/oid-array.h"
 #include "odb/oidset.h"
 #include "odb/tag.h"
 #include "refs/reflog-walk.h"
-#include "patch-ids.h"
+#include "diff/patch-ids.h"
 #include "path.h"
 #include "shortlog.h"
 #include "remote.h"
@@ -46,10 +46,10 @@
 
 #include "commit-reach.h"
 #include "promisor-remote.h"
-#include "range-diff.h"
+#include "diff/range-diff.h"
 #include "odb/tmp-objdir.h"
 #include "odb/tree.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 #include "write-or-die.h"
 
 #define MAIL_DEFAULT_WRAP 72
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 22a6862a13..12701b1d81 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -3,7 +3,7 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "hex.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
@@ -12,7 +12,7 @@
 #include "gettext.h"
 #include "setup.h"
 #include "xdiff/xdiff.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "parse-options.h"
 
 static const char *const merge_file_usage[] = {
diff --git a/builtin/merge-ours.c b/builtin/merge-ours.c
index 405b2989f7..c33e176c65 100644
--- a/builtin/merge-ours.c
+++ b/builtin/merge-ours.c
@@ -12,7 +12,7 @@
 #include "builtin.h"
 #include "config.h"
 #include "environment.h"
-#include "diff.h"
+#include "diff/diff.h"
 
 static const char builtin_merge_ours_usage[] =
 	"git merge-ours <base>... -- HEAD <remote>...";
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 27f2944ece..8217938d86 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -3,7 +3,7 @@
 #include "builtin.h"
 #include "environment.h"
 #include "odb/tree-walk.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "help.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index ad0c984d4b..7ec4554b0b 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -24,12 +24,12 @@
 #include "repository.h"
 #include "run-command.h"
 #include "hook.h"
-#include "diff.h"
-#include "diff-merges.h"
+#include "diff/diff.h"
+#include "diff/diff-merges.h"
 #include "refs/refs.h"
 #include "refs/refspec.h"
 #include "odb/commit.h"
-#include "diffcore.h"
+#include "diff/diffcore.h"
 #include "path.h"
 #include "revision.h"
 #include "unpack-trees.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 37c379d3d8..17721f13ac 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -15,7 +15,7 @@
 #include "pack/pack-revindex.h"
 #include "csum-file.h"
 #include "odb/tree-walk.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "list-objects.h"
 #include "list-objects-filter-options.h"
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index e2c1375b41..7207279cef 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -2,7 +2,7 @@
 
 #include "builtin.h"
 #include "config.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index ae3505c5e5..0adf0f02d1 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -2,7 +2,7 @@
 
 #include "builtin.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index 7e37a00d9e..323046c696 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -4,7 +4,7 @@
 #include "gettext.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
-#include "range-diff.h"
+#include "diff/range-diff.h"
 #include "config.h"
 #include "parse.h"
 #include "color.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 983dbb7ce5..8f9fdcc79b 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -25,7 +25,7 @@
 #include "parse-options.h"
 #include "path.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "wt-status.h"
 #include "revision.h"
 #include "commit-reach.h"
diff --git a/builtin/rerere.c b/builtin/rerere.c
index a056cb791b..545ffe2715 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -8,7 +8,7 @@
 #include "strbuf.h"
 #include "string-list.h"
 #include "xdiff/xdiff.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "pathspec.h"
 
 static const char * const rerere_usage[] = {
diff --git a/builtin/reset.c b/builtin/reset.c
index c3bfbab7d5..f843bab823 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -21,8 +21,8 @@
 #include "odb/object.h"
 #include "pretty.h"
 #include "refs/refs.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "odb/tree.h"
 #include "branch.h"
 #include "odb/object-name.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index d6bddda9d4..c0e0769aab 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -4,7 +4,7 @@
 #include "builtin.h"
 #include "config.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 2fb682d5a2..b95cdac85e 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -22,7 +22,7 @@
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "read-cache-ll.h"
 #include "repo-settings.h"
 #include "repository.h"
diff --git a/builtin/revert.c b/builtin/revert.c
index bedc40f368..a939c590fb 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "builtin.h"
 #include "parse-options.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "environment.h"
 #include "gettext.h"
 #include "revision.h"
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index cbcf2fb637..59be73a372 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -3,7 +3,7 @@
 #include "builtin.h"
 #include "config.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "environment.h"
 #include "gettext.h"
 #include "string-list.h"
diff --git a/builtin/stash.c b/builtin/stash.c
index 62fec2f17f..c5e100746d 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -26,7 +26,7 @@
 #include "setup.h"
 #include "sparse-index.h"
 #include "log-tree.h"
-#include "diffcore.h"
+#include "diff/diffcore.h"
 #include "refs/reflog.h"
 #include "refs/reflog-walk.h"
 #include "add-interactive.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index bf8b20247f..5711a79428 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -24,8 +24,8 @@
 #include "refs/refs.h"
 #include "refs/refspec.h"
 #include "revision.h"
-#include "diffcore.h"
-#include "diff.h"
+#include "diff/diffcore.h"
+#include "diff/diff.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index d554ae8f81..c04c2cc207 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -23,7 +23,7 @@
 #include "path.h"
 #include "odb/tag.h"
 #include "parse-options.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "gpg-interface.h"
 #include "odb/oid-array.h"
diff --git a/bundle.c b/bundle.c
index c64b14a05a..54ec76866b 100644
--- a/bundle.c
+++ b/bundle.c
@@ -11,7 +11,7 @@
 #include "repository.h"
 #include "odb/object.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "list-objects.h"
 #include "run-command.h"
diff --git a/combine-diff.c b/diff/combine-diff.c
similarity index 99%
rename from combine-diff.c
rename to diff/combine-diff.c
index 6f16e9ea38..44f0eb5442 100644
--- a/combine-diff.c
+++ b/diff/combine-diff.c
@@ -5,18 +5,18 @@
 #include "odb/odb.h"
 #include "odb/commit.h"
 #include "convert.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "environment.h"
 #include "hex.h"
 #include "odb/object-name.h"
 #include "quote.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "xdiff/xmacros.h"
 #include "log-tree.h"
 #include "refs/refs.h"
 #include "odb/tree.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 #include "odb/oid-array.h"
 #include "revision.h"
 
diff --git a/diff-lib.c b/diff/diff-lib.c
similarity index 99%
rename from diff-lib.c
rename to diff/diff-lib.c
index a5072c5f6d..fb0514dcb0 100644
--- a/diff-lib.c
+++ b/diff/diff-lib.c
@@ -7,8 +7,8 @@
 
 #include "git-compat-util.h"
 #include "odb/commit.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
diff --git a/diff-merges.c b/diff/diff-merges.c
similarity index 99%
rename from diff-merges.c
rename to diff/diff-merges.c
index 45507588a2..ca3cbf7767 100644
--- a/diff-merges.c
+++ b/diff/diff-merges.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "diff-merges.h"
+#include "diff/diff-merges.h"
 
 #include "gettext.h"
 #include "revision.h"
diff --git a/diff-merges.h b/diff/diff-merges.h
similarity index 100%
rename from diff-merges.h
rename to diff/diff-merges.h
diff --git a/diff-no-index.c b/diff/diff-no-index.c
similarity index 99%
rename from diff-no-index.c
rename to diff/diff-no-index.c
index 552cd95679..5712e5474d 100644
--- a/diff-no-index.c
+++ b/diff/diff-no-index.c
@@ -10,8 +10,8 @@
 #include "abspath.h"
 #include "color.h"
 #include "odb/commit.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "gettext.h"
 #include "revision.h"
 #include "parse-options.h"
diff --git a/diff.c b/diff/diff.c
similarity index 99%
rename from diff.c
rename to diff/diff.c
index 91addcdab7..9062f96b7b 100644
--- a/diff.c
+++ b/diff/diff.c
@@ -15,16 +15,16 @@
 #include "tempfile.h"
 #include "revision.h"
 #include "quote.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "pack/delta.h"
 #include "hex.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "color.h"
 #include "run-command.h"
 #include "utf8.h"
 #include "odb/odb.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 #include "submodule.h"
 #include "hashmap.h"
 #include "mem-pool.h"
diff --git a/diff.h b/diff/diff.h
similarity index 100%
rename from diff.h
rename to diff/diff.h
diff --git a/diffcore-break.c b/diff/diffcore-break.c
similarity index 99%
rename from diffcore-break.c
rename to diff/diffcore-break.c
index 70860c8abc..c822a0d56d 100644
--- a/diffcore-break.c
+++ b/diff/diffcore-break.c
@@ -5,7 +5,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "diffcore.h"
+#include "diff/diffcore.h"
 #include "odb/hash.h"
 #include "odb/object.h"
 #include "promisor-remote.h"
diff --git a/diffcore-delta.c b/diff/diffcore-delta.c
similarity index 99%
rename from diffcore-delta.c
rename to diff/diffcore-delta.c
index 2b7db39983..4291662274 100644
--- a/diffcore-delta.c
+++ b/diff/diffcore-delta.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "diffcore.h"
+#include "diff/diffcore.h"
 
 /*
  * Idea here is very simple.
diff --git a/diffcore-order.c b/diff/diffcore-order.c
similarity index 97%
rename from diffcore-order.c
rename to diff/diffcore-order.c
index f91ef22471..e6a6a23aca 100644
--- a/diffcore-order.c
+++ b/diff/diffcore-order.c
@@ -4,8 +4,8 @@
 
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "wildmatch.h"
 
 static char **order;
diff --git a/diffcore-pickaxe.c b/diff/diffcore-pickaxe.c
similarity index 98%
rename from diffcore-pickaxe.c
rename to diff/diffcore-pickaxe.c
index f7a745fb49..e7289d9a26 100644
--- a/diffcore-pickaxe.c
+++ b/diff/diffcore-pickaxe.c
@@ -6,9 +6,9 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "diff.h"
-#include "diffcore.h"
-#include "xdiff-interface.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
+#include "diff/xdiff-interface.h"
 #include "kwset.h"
 #include "odb/oidset.h"
 #include "pretty.h"
diff --git a/diffcore-rename.c b/diff/diffcore-rename.c
similarity index 99%
rename from diffcore-rename.c
rename to diff/diffcore-rename.c
index 68abf77c4d..16746444d8 100644
--- a/diffcore-rename.c
+++ b/diff/diffcore-rename.c
@@ -6,8 +6,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "odb/object-file.h"
 #include "hashmap.h"
 #include "mem-pool.h"
diff --git a/diffcore-rotate.c b/diff/diffcore-rotate.c
similarity index 95%
rename from diffcore-rotate.c
rename to diff/diffcore-rotate.c
index 67b591261a..a55d954092 100644
--- a/diffcore-rotate.c
+++ b/diff/diffcore-rotate.c
@@ -5,8 +5,8 @@
 
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 
 void diffcore_rotate(struct diff_options *opt)
 {
diff --git a/diffcore.h b/diff/diffcore.h
similarity index 100%
rename from diffcore.h
rename to diff/diffcore.h
diff --git a/patch-ids.c b/diff/patch-ids.c
similarity index 98%
rename from patch-ids.c
rename to diff/patch-ids.c
index 946744e7d9..de4e5702ed 100644
--- a/patch-ids.c
+++ b/diff/patch-ids.c
@@ -1,9 +1,9 @@
 #include "git-compat-util.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "odb/commit.h"
 #include "odb/hash.h"
 #include "hex.h"
-#include "patch-ids.h"
+#include "diff/patch-ids.h"
 
 static int patch_id_defined(struct commit *commit)
 {
diff --git a/patch-ids.h b/diff/patch-ids.h
similarity index 98%
rename from patch-ids.h
rename to diff/patch-ids.h
index 57534ee722..47291160ec 100644
--- a/patch-ids.h
+++ b/diff/patch-ids.h
@@ -1,7 +1,7 @@
 #ifndef PATCH_IDS_H
 #define PATCH_IDS_H
 
-#include "diff.h"
+#include "diff/diff.h"
 #include "hashmap.h"
 
 struct commit;
diff --git a/range-diff.c b/diff/range-diff.c
similarity index 99%
rename from range-diff.c
rename to diff/range-diff.c
index be9f872396..2177b8ba2d 100644
--- a/range-diff.c
+++ b/diff/range-diff.c
@@ -4,20 +4,20 @@
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
-#include "range-diff.h"
+#include "diff/range-diff.h"
 #include "odb/object-name.h"
 #include "string-list.h"
 #include "run-command.h"
 #include "strvec.h"
 #include "hashmap.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "linear-assignment.h"
-#include "diffcore.h"
+#include "diff/diffcore.h"
 #include "odb/commit.h"
 #include "pager.h"
 #include "pretty.h"
 #include "repository.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 #include "apply.h"
 #include "revision.h"
 
diff --git a/range-diff.h b/diff/range-diff.h
similarity index 98%
rename from range-diff.h
rename to diff/range-diff.h
index 9b70a80009..23aae59192 100644
--- a/range-diff.h
+++ b/diff/range-diff.h
@@ -1,7 +1,7 @@
 #ifndef RANGE_DIFF_H
 #define RANGE_DIFF_H
 
-#include "diff.h"
+#include "diff/diff.h"
 #include "strvec.h"
 
 #define RANGE_DIFF_CREATION_FACTOR_DEFAULT 60
diff --git a/tree-diff.c b/diff/tree-diff.c
similarity index 99%
rename from tree-diff.c
rename to diff/tree-diff.c
index b33c45b696..4b7c90f6db 100644
--- a/tree-diff.c
+++ b/diff/tree-diff.c
@@ -5,8 +5,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "odb/hash.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
diff --git a/userdiff.c b/diff/userdiff.c
similarity index 99%
rename from userdiff.c
rename to diff/userdiff.c
index 7129bf1482..8993b622c1 100644
--- a/userdiff.c
+++ b/diff/userdiff.c
@@ -3,7 +3,7 @@
 
 #include "git-compat-util.h"
 #include "config.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 #include "attr.h"
 #include "strbuf.h"
 #include "environment.h"
diff --git a/userdiff.h b/diff/userdiff.h
similarity index 100%
rename from userdiff.h
rename to diff/userdiff.h
diff --git a/xdiff-interface.c b/diff/xdiff-interface.c
similarity index 99%
rename from xdiff-interface.c
rename to diff/xdiff-interface.c
index af18a34ba0..2c87316caa 100644
--- a/xdiff-interface.c
+++ b/diff/xdiff-interface.c
@@ -7,7 +7,7 @@
 #include "hex.h"
 #include "odb/odb.h"
 #include "strbuf.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "xdiff/xtypes.h"
 #include "xdiff/xdiffi.h"
 #include "xdiff/xutils.h"
diff --git a/xdiff-interface.h b/diff/xdiff-interface.h
similarity index 100%
rename from xdiff-interface.h
rename to diff/xdiff-interface.h
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 7fa8c4cd79..34f769ae9f 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -7,8 +7,8 @@
 #include "refs/refs.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
-#include "diff.h"
-#include "diff-merges.h"
+#include "diff/diff.h"
+#include "diff/diff-merges.h"
 #include "hex.h"
 #include "revision.h"
 #include "odb/tag.h"
diff --git a/graph.h b/graph.h
index 1193711fb8..84a5a4b822 100644
--- a/graph.h
+++ b/graph.h
@@ -1,6 +1,6 @@
 #ifndef GRAPH_H
 #define GRAPH_H
-#include "diff.h"
+#include "diff/diff.h"
 
 /**
  * The graph API is used to draw a text-based representation of the commit
diff --git a/grep.c b/grep.c
index 5041c388b9..88c87ba1c9 100644
--- a/grep.c
+++ b/grep.c
@@ -7,10 +7,10 @@
 #include "hex.h"
 #include "odb/odb.h"
 #include "pretty.h"
-#include "userdiff.h"
-#include "xdiff-interface.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/userdiff.h"
+#include "diff/xdiff-interface.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "quote.h"
 #include "help.h"
 
diff --git a/grep.h b/grep.h
index 13e26a9318..7881f28587 100644
--- a/grep.h
+++ b/grep.h
@@ -24,7 +24,7 @@ typedef int pcre2_general_context;
 #define PCRE2_MATCH_INVALID_UTF 0
 #endif
 #include "thread-utils.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 
 struct repository;
 
diff --git a/http-push.c b/http-push.c
index 88a8417ea4..6d38410ccb 100644
--- a/http-push.c
+++ b/http-push.c
@@ -8,7 +8,7 @@
 #include "odb/tag.h"
 #include "odb/blob.h"
 #include "http.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "remote.h"
 #include "list-objects.h"
diff --git a/line-log.c b/line-log.c
index 343159d90a..78697cb377 100644
--- a/line-log.c
+++ b/line-log.c
@@ -1,17 +1,17 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "diffcore.h"
+#include "diff/diffcore.h"
 #include "line-range.h"
 #include "hex.h"
 #include "odb/tag.h"
 #include "odb/tree.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "odb/commit.h"
 #include "decorate.h"
 #include "repository.h"
 #include "revision.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "strbuf.h"
 #include "line-log.h"
 #include "setup.h"
diff --git a/line-log.h b/line-log.h
index 99e1755ce3..3a72d84698 100644
--- a/line-log.h
+++ b/line-log.h
@@ -1,7 +1,7 @@
 #ifndef LINE_LOG_H
 #define LINE_LOG_H
 
-#include "diffcore.h" /* struct range, struct range_set */
+#include "diff/diffcore.h" /* struct range, struct range_set */
 
 struct rev_info;
 struct commit;
diff --git a/line-range.c b/line-range.c
index b99f0d9895..1dbf761ecc 100644
--- a/line-range.c
+++ b/line-range.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "line-range.h"
-#include "xdiff-interface.h"
-#include "userdiff.h"
+#include "diff/xdiff-interface.h"
+#include "diff/userdiff.h"
 
 /*
  * Parse one item in the -L option
diff --git a/list-objects-filter.c b/list-objects-filter.c
index a34e07c061..a011cef0b5 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -5,7 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
diff --git a/list-objects.c b/list-objects.c
index 1db5ba29b5..6b67f0f927 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -7,7 +7,7 @@
 #include "hex.h"
 #include "odb/tree.h"
 #include "odb/blob.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "odb/tree-walk.h"
 #include "revision.h"
 #include "list-objects.h"
diff --git a/log-tree.c b/log-tree.c
index 116bb7ea68..ddeafedb45 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -5,8 +5,8 @@
 #include "commit-reach.h"
 #include "odb/commit-slab.h"
 #include "config.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "environment.h"
 #include "hex.h"
 #include "odb/object-name.h"
@@ -28,7 +28,7 @@
 #include "sequencer.h"
 #include "line-log.h"
 #include "help.h"
-#include "range-diff.h"
+#include "diff/range-diff.h"
 #include "strmap.h"
 #include "odb/tree.h"
 #include "wildmatch.h"
diff --git a/merge-ll.c b/merge-ll.c
index ef5287dee8..2aa45bfa90 100644
--- a/merge-ll.c
+++ b/merge-ll.c
@@ -11,7 +11,7 @@
 #include "config.h"
 #include "convert.h"
 #include "attr.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "run-command.h"
 #include "merge-ll.h"
 #include "quote.h"
diff --git a/merge-ort.c b/merge-ort.c
index a12bf62a3d..61fb855500 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -27,8 +27,8 @@
 #include "odb/commit.h"
 #include "commit-reach.h"
 #include "config.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
@@ -51,7 +51,7 @@
 #include "trace2.h"
 #include "odb/tree.h"
 #include "unpack-trees.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 
 /*
  * We technically need USE_THE_REPOSITORY_VARIABLE above for DEFAULT_ABBREV,
diff --git a/meson.build b/meson.build
index 238beb0dfd..87060ff883 100644
--- a/meson.build
+++ b/meson.build
@@ -333,7 +333,7 @@ libgit_sources = [
   'pack/chunk-format.c',
   'color.c',
   'column.c',
-  'combine-diff.c',
+  'diff/combine-diff.c',
   'pack/commit-graph.c',
   'commit-reach.c',
   'odb/commit.c',
@@ -353,16 +353,16 @@ libgit_sources = [
   'pack/delta-islands.c',
   'diagnose.c',
   'pack/diff-delta.c',
-  'diff-merges.c',
-  'diff-lib.c',
-  'diff-no-index.c',
-  'diff.c',
-  'diffcore-break.c',
-  'diffcore-delta.c',
-  'diffcore-order.c',
-  'diffcore-pickaxe.c',
-  'diffcore-rename.c',
-  'diffcore-rotate.c',
+  'diff/diff-merges.c',
+  'diff/diff-lib.c',
+  'diff/diff-no-index.c',
+  'diff/diff.c',
+  'diff/diffcore-break.c',
+  'diff/diffcore-delta.c',
+  'diff/diffcore-order.c',
+  'diff/diffcore-pickaxe.c',
+  'diff/diffcore-rename.c',
+  'diff/diffcore-rotate.c',
   'dir-iterator.c',
   'dir.c',
   'editor.c',
@@ -462,7 +462,7 @@ libgit_sources = [
   'parse-options-cb.c',
   'parse-options.c',
   'pack/patch-delta.c',
-  'patch-ids.c',
+  'diff/patch-ids.c',
   'path.c',
   'path-walk.c',
   'pathspec.c',
@@ -478,7 +478,7 @@ libgit_sources = [
   'pack/prune-packed.c',
   'pack/pseudo-merge.c',
   'quote.c',
-  'range-diff.c',
+  'diff/range-diff.c',
   'pack/reachable.c',
   'read-cache.c',
   'rebase-interactive.c',
@@ -565,7 +565,7 @@ libgit_sources = [
   'trailer.c',
   'transport-helper.c',
   'transport.c',
-  'tree-diff.c',
+  'diff/tree-diff.c',
   'odb/tree-walk.c',
   'odb/tree.c',
   'unpack-trees.c',
@@ -573,7 +573,7 @@ libgit_sources = [
   'url.c',
   'urlmatch.c',
   'usage.c',
-  'userdiff.c',
+  'diff/userdiff.c',
   'utf8.c',
   'version.c',
   'versioncmp.c',
@@ -584,7 +584,7 @@ libgit_sources = [
   'write-or-die.c',
   'ws.c',
   'wt-status.c',
-  'xdiff-interface.c',
+  'diff/xdiff-interface.c',
   'xdiff/xdiffi.c',
   'xdiff/xemit.c',
   'xdiff/xhistogram.c',
diff --git a/notes-merge.c b/notes-merge.c
index 72a3b9479c..ff14b7dfcc 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -11,10 +11,10 @@
 #include "odb/odb.h"
 #include "path.h"
 #include "repository.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "hex.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "merge-ll.h"
 #include "dir.h"
 #include "notes.h"
diff --git a/odb/commit.c b/odb/commit.c
index 06daa8c6a0..b78cd28013 100644
--- a/odb/commit.c
+++ b/odb/commit.c
@@ -11,7 +11,7 @@
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "utf8.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "notes.h"
 #include "odb/alloc.h"
diff --git a/pack/bloom.c b/pack/bloom.c
index 874e011530..3fdbbf3aba 100644
--- a/pack/bloom.c
+++ b/pack/bloom.c
@@ -2,8 +2,8 @@
 
 #include "git-compat-util.h"
 #include "pack/bloom.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "hashmap.h"
 #include "pack/commit-graph.h"
 #include "odb/commit.h"
diff --git a/pack/delta-islands.c b/pack/delta-islands.c
index 3d015719a5..7c48204384 100644
--- a/pack/delta-islands.c
+++ b/pack/delta-islands.c
@@ -9,7 +9,7 @@
 #include "odb/tree.h"
 #include "pack/pack.h"
 #include "odb/tree-walk.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "progress.h"
 #include "refs/refs.h"
 #include "khash.h"
diff --git a/pack/pack-bitmap-write.c b/pack/pack-bitmap-write.c
index 6ef5fb4629..22ee370bde 100644
--- a/pack/pack-bitmap-write.c
+++ b/pack/pack-bitmap-write.c
@@ -6,7 +6,7 @@
 #include "hex.h"
 #include "odb/odb.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "progress.h"
 #include "pack/pack.h"
diff --git a/pack/pack-bitmap.c b/pack/pack-bitmap.c
index 80f853f355..3adb5d0563 100644
--- a/pack/pack-bitmap.c
+++ b/pack/pack-bitmap.c
@@ -6,7 +6,7 @@
 #include "hex.h"
 #include "strbuf.h"
 #include "odb/tag.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "progress.h"
 #include "list-objects.h"
diff --git a/pack/reachable.c b/pack/reachable.c
index 51c13b552f..7989f7327a 100644
--- a/pack/reachable.c
+++ b/pack/reachable.c
@@ -6,7 +6,7 @@
 #include "refs/refs.h"
 #include "odb/commit.h"
 #include "odb/blob.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "pack/reachable.h"
 #include "cache-tree.h"
diff --git a/pretty.c b/pretty.c
index 4575f3fde6..3444617506 100644
--- a/pretty.c
+++ b/pretty.c
@@ -9,7 +9,7 @@
 #include "odb/hash.h"
 #include "hex.h"
 #include "utf8.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "pager.h"
 #include "revision.h"
 #include "string-list.h"
diff --git a/read-cache.c b/read-cache.c
index 148a93f10e..5bca3fda12 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -10,8 +10,8 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "date.h"
-#include "diff.h"
-#include "diffcore.h"
+#include "diff/diff.h"
+#include "diff/diffcore.h"
 #include "hex.h"
 #include "tempfile.h"
 #include "lockfile.h"
diff --git a/refs/reflog-walk.c b/refs/reflog-walk.c
index 711b71be66..f9eee9a76f 100644
--- a/refs/reflog-walk.c
+++ b/refs/reflog-walk.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "odb/commit.h"
 #include "refs/refs.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "repository.h"
 #include "revision.h"
 #include "string-list.h"
diff --git a/remote.c b/remote.c
index 39e9f58cba..c619009d30 100644
--- a/remote.c
+++ b/remote.c
@@ -16,7 +16,7 @@
 #include "odb/odb.h"
 #include "path.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "dir.h"
 #include "setup.h"
diff --git a/rerere.c b/rerere.c
index 6ff20d0692..3055989a41 100644
--- a/rerere.c
+++ b/rerere.c
@@ -12,7 +12,7 @@
 #include "string-list.h"
 #include "read-cache-ll.h"
 #include "rerere.h"
-#include "xdiff-interface.h"
+#include "diff/xdiff-interface.h"
 #include "dir.h"
 #include "resolve-undo.h"
 #include "merge-ll.h"
diff --git a/revision.c b/revision.c
index f92a6482f1..249a1736fd 100644
--- a/revision.c
+++ b/revision.c
@@ -14,15 +14,15 @@
 #include "odb/blob.h"
 #include "odb/tree.h"
 #include "odb/commit.h"
-#include "diff.h"
-#include "diff-merges.h"
+#include "diff/diff.h"
+#include "diff/diff-merges.h"
 #include "refs/refs.h"
 #include "revision.h"
 #include "repository.h"
 #include "graph.h"
 #include "grep.h"
 #include "refs/reflog-walk.h"
-#include "patch-ids.h"
+#include "diff/patch-ids.h"
 #include "decorate.h"
 #include "string-list.h"
 #include "line-log.h"
diff --git a/revision.h b/revision.h
index e0ff7aa0f2..64d9a47091 100644
--- a/revision.h
+++ b/revision.h
@@ -7,7 +7,7 @@
 #include "odb/object-name.h"
 #include "odb/oidset.h"
 #include "pretty.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "odb/commit-slab-decl.h"
 #include "decorate.h"
 #include "ident.h"
diff --git a/sequencer.c b/sequencer.c
index d13721ab1f..551e4529c4 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -22,7 +22,7 @@
 #include "hook.h"
 #include "utf8.h"
 #include "cache-tree.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "path.h"
 #include "revision.h"
 #include "rerere.h"
diff --git a/shallow.c b/shallow.c
index daa6db8e0d..fa16834aff 100644
--- a/shallow.c
+++ b/shallow.c
@@ -12,7 +12,7 @@
 #include "refs/refs.h"
 #include "odb/oid-array.h"
 #include "path.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "odb/commit-slab.h"
 #include "list-objects.h"
diff --git a/submodule.c b/submodule.c
index 32af65e6b8..a9137aa180 100644
--- a/submodule.c
+++ b/submodule.c
@@ -8,14 +8,14 @@
 #include "submodule-config.h"
 #include "submodule.h"
 #include "dir.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "odb/commit.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "revision.h"
 #include "run-command.h"
-#include "diffcore.h"
+#include "diff/diffcore.h"
 #include "refs/refs.h"
 #include "string-list.h"
 #include "odb/oid-array.h"
diff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c
index 1b7f569f01..7c66b8566f 100644
--- a/t/helper/test-revision-walking.c
+++ b/t/helper/test-revision-walking.c
@@ -12,7 +12,7 @@
 
 #include "test-tool.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "line-log.h"
 #include "odb/object-name.h"
 #include "repository.h"
diff --git a/t/helper/test-userdiff.c b/t/helper/test-userdiff.c
index fc34c589b3..ee829e0868 100644
--- a/t/helper/test-userdiff.c
+++ b/t/helper/test-userdiff.c
@@ -2,7 +2,7 @@
 
 #include "test-tool.h"
 #include "setup.h"
-#include "userdiff.h"
+#include "diff/userdiff.h"
 #include "config.h"
 
 static int driver_cb(struct userdiff_driver *driver,
diff --git a/upload-pack.c b/upload-pack.c
index d145a89c7b..acd381ebf1 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -14,7 +14,7 @@
 #include "odb/oid-array.h"
 #include "odb/object.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "revision.h"
 #include "list-objects-filter-options.h"
 #include "run-command.h"
diff --git a/wt-status.c b/wt-status.c
index 708366b973..28a0c72a51 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -7,7 +7,7 @@
 #include "odb/object.h"
 #include "dir.h"
 #include "odb/commit.h"
-#include "diff.h"
+#include "diff/diff.h"
 #include "environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
@@ -15,7 +15,7 @@
 #include "odb/object-name.h"
 #include "path.h"
 #include "revision.h"
-#include "diffcore.h"
+#include "diff/diffcore.h"
 #include "quote.h"
 #include "repository.h"
 #include "run-command.h"
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 11/14] revision: gather the revision sources under revision/
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (9 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 10/14] diff: gather the diff sources under diff/ Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 12/14] index: gather the index sources under index/ Michael Montalbo
                   ` (2 subsequent siblings)
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Move the 14 revision C sources and 15 headers into revision/ as renames.
Repoint every reference to their old paths to the new ones: the #include
lines across the tree, the Makefile and meson.build build entries, and
the tutorial #include examples.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize                                  | 58 +++++++++----------
 Documentation/MyFirstContribution.adoc        |  2 +-
 Documentation/MyFirstObjectWalk.adoc          |  6 +-
 Makefile                                      | 28 ++++-----
 add-interactive.c                             |  2 +-
 archive.c                                     |  2 +-
 attr.c                                        |  2 +-
 builtin/add.c                                 |  2 +-
 builtin/am.c                                  |  6 +-
 builtin/backfill.c                            |  2 +-
 builtin/bisect.c                              |  4 +-
 builtin/blame.c                               |  8 +--
 builtin/branch.c                              |  2 +-
 builtin/cat-file.c                            |  2 +-
 builtin/checkout.c                            |  2 +-
 builtin/clone.c                               |  2 +-
 builtin/commit.c                              |  6 +-
 builtin/describe.c                            |  4 +-
 builtin/diff-files.c                          |  2 +-
 builtin/diff-index.c                          |  2 +-
 builtin/diff-pairs.c                          |  2 +-
 builtin/diff-tree.c                           |  4 +-
 builtin/diff.c                                |  4 +-
 builtin/fast-export.c                         |  6 +-
 builtin/fast-import.c                         |  2 +-
 builtin/fetch.c                               |  6 +-
 builtin/gc.c                                  |  2 +-
 builtin/history.c                             |  4 +-
 builtin/last-modified.c                       |  2 +-
 builtin/log.c                                 |  8 +--
 builtin/merge-base.c                          |  2 +-
 builtin/merge-tree.c                          |  2 +-
 builtin/merge.c                               |  4 +-
 builtin/name-rev.c                            |  4 +-
 builtin/notes.c                               |  2 +-
 builtin/pack-objects.c                        | 10 ++--
 builtin/prune.c                               |  4 +-
 builtin/pull.c                                |  2 +-
 builtin/rebase.c                              |  4 +-
 builtin/receive-pack.c                        |  4 +-
 builtin/reflog.c                              |  2 +-
 builtin/remote.c                              |  2 +-
 builtin/repack.c                              |  2 +-
 builtin/replay.c                              |  2 +-
 builtin/repo.c                                |  4 +-
 builtin/reset.c                               |  2 +-
 builtin/rev-list.c                            | 14 ++---
 builtin/rev-parse.c                           |  8 +--
 builtin/revert.c                              |  2 +-
 builtin/shortlog.c                            |  2 +-
 builtin/show-branch.c                         |  2 +-
 builtin/stash.c                               |  4 +-
 builtin/submodule--helper.c                   |  4 +-
 builtin/tag.c                                 |  2 +-
 builtin/unpack-objects.c                      |  2 +-
 bundle.c                                      |  6 +-
 bundle.h                                      |  2 +-
 chdir-notify.c                                |  2 +-
 diff/combine-diff.c                           |  4 +-
 diff/diff-lib.c                               |  4 +-
 diff/diff-merges.c                            |  2 +-
 diff/diff-no-index.c                          |  2 +-
 diff/diff.c                                   |  4 +-
 diff/diffcore-pickaxe.c                       |  2 +-
 diff/range-diff.c                             |  4 +-
 fetch-pack.c                                  |  4 +-
 fetch-pack.h                                  |  2 +-
 fmt-merge-msg.c                               |  4 +-
 git.c                                         |  2 +-
 grep.c                                        |  2 +-
 http-push.c                                   |  6 +-
 http-walker.c                                 |  2 +-
 merge-ort.c                                   |  4 +-
 meson.build                                   | 28 ++++-----
 notes-cache.c                                 |  2 +-
 notes-merge.c                                 |  2 +-
 odb/commit.c                                  |  6 +-
 odb/object-name.c                             |  4 +-
 odb/source-packed.c                           |  2 +-
 pack/commit-graph.c                           |  2 +-
 pack/midx-write.c                             |  4 +-
 pack/pack-bitmap-write.c                      |  4 +-
 pack/pack-bitmap.c                            |  6 +-
 pack/packfile.c                               |  2 +-
 pack/packfile.h                               |  2 +-
 pack/reachable.c                              |  4 +-
 pack/repack.h                                 |  2 +-
 path-walk.c                                   |  6 +-
 read-cache.c                                  |  2 +-
 refs/files-backend.c                          |  2 +-
 refs/pack-refs.c                              |  2 +-
 refs/ref-filter.c                             |  4 +-
 refs/ref-filter.h                             |  2 +-
 refs/reflog-walk.c                            |  2 +-
 refs/reflog.c                                 |  2 +-
 remote.c                                      |  4 +-
 replay.c                                      |  2 +-
 bisect.c => revision/bisect.c                 | 10 ++--
 bisect.h => revision/bisect.h                 |  0
 blame.c => revision/blame.c                   |  4 +-
 blame.h => revision/blame.h                   |  0
 commit-reach.c => revision/commit-reach.c     |  6 +-
 commit-reach.h => revision/commit-reach.h     |  0
 decorate.c => revision/decorate.c             |  2 +-
 decorate.h => revision/decorate.h             |  0
 graph.c => revision/graph.c                   |  4 +-
 graph.h => revision/graph.h                   |  0
 line-log.c => revision/line-log.c             |  8 +--
 line-log.h => revision/line-log.h             |  0
 line-range.c => revision/line-range.c         |  2 +-
 line-range.h => revision/line-range.h         |  0
 .../list-objects-filter-options.c             |  2 +-
 .../list-objects-filter-options.h             |  0
 .../list-objects-filter.c                     |  6 +-
 .../list-objects-filter.h                     |  0
 list-objects.c => revision/list-objects.c     |  8 +--
 list-objects.h => revision/list-objects.h     |  0
 list.h => revision/list.h                     |  0
 log-tree.c => revision/log-tree.c             | 10 ++--
 log-tree.h => revision/log-tree.h             |  0
 pretty.c => revision/pretty.c                 |  4 +-
 pretty.h => revision/pretty.h                 |  0
 revision.c => revision/revision.c             | 16 ++---
 revision.h => revision/revision.h             |  6 +-
 shallow.c => revision/shallow.c               |  8 +--
 shallow.h => revision/shallow.h               |  0
 send-pack.c                                   |  2 +-
 sequencer.c                                   |  6 +-
 setup.c                                       |  2 +-
 submodule.c                                   |  4 +-
 t/helper/test-path-walk.c                     |  6 +-
 t/helper/test-reach.c                         |  2 +-
 t/helper/test-ref-store.c                     |  2 +-
 t/helper/test-revision-walking.c              |  4 +-
 t/unit-tests/u-example-decorate.c             |  2 +-
 t/unit-tests/u-list-objects-filter-options.c  |  2 +-
 tempfile.h                                    |  2 +-
 trailer.c                                     |  2 +-
 trailer.h                                     |  2 +-
 transport.h                                   |  2 +-
 upload-pack.c                                 |  8 +--
 wt-status.c                                   |  2 +-
 142 files changed, 289 insertions(+), 289 deletions(-)
 rename bisect.c => revision/bisect.c (99%)
 rename bisect.h => revision/bisect.h (100%)
 rename blame.c => revision/blame.c (99%)
 rename blame.h => revision/blame.h (100%)
 rename commit-reach.c => revision/commit-reach.c (99%)
 rename commit-reach.h => revision/commit-reach.h (100%)
 rename decorate.c => revision/decorate.c (98%)
 rename decorate.h => revision/decorate.h (100%)
 rename graph.c => revision/graph.c (99%)
 rename graph.h => revision/graph.h (100%)
 rename line-log.c => revision/line-log.c (99%)
 rename line-log.h => revision/line-log.h (100%)
 rename line-range.c => revision/line-range.c (99%)
 rename line-range.h => revision/line-range.h (100%)
 rename list-objects-filter-options.c => revision/list-objects-filter-options.c (99%)
 rename list-objects-filter-options.h => revision/list-objects-filter-options.h (100%)
 rename list-objects-filter.c => revision/list-objects-filter.c (99%)
 rename list-objects-filter.h => revision/list-objects-filter.h (100%)
 rename list-objects.c => revision/list-objects.c (98%)
 rename list-objects.h => revision/list-objects.h (100%)
 rename list.h => revision/list.h (100%)
 rename log-tree.c => revision/log-tree.c (99%)
 rename log-tree.h => revision/log-tree.h (100%)
 rename pretty.c => revision/pretty.c (99%)
 rename pretty.h => revision/pretty.h (100%)
 rename revision.c => revision/revision.c (99%)
 rename revision.h => revision/revision.h (99%)
 rename shallow.c => revision/shallow.c (99%)
 rename shallow.h => revision/shallow.h (100%)

diff --git a/.gitorganize b/.gitorganize
index 160365fbca..d62d0a2240 100644
--- a/.gitorganize
+++ b/.gitorganize
@@ -41,10 +41,6 @@ attr.h component=convert role=header prefix=attr cochange=convert:50,index:13,di
 banned.h component=? role=public prefix=banned
 base85.c component=? role=lib prefix=base85 cochange=diff:4,pack:2,convert:1,transport:1
 base85.h component=? role=public prefix=base85 cochange=diff:1
-bisect.c component=revision role=lib prefix=bisect includes=odb:5,revision:5,setup:2,diff:1,index:1 cochange=revision:61,odb:32,transport:31,refs:13,diff:9
-bisect.h component=revision role=header prefix=bisect cochange=revision:29,odb:2
-blame.c component=revision role=lib prefix=blame includes=odb:5,diff:2,index:2,pack:2,revision:2 cochange=diff:68,revision:66,odb:56,index:29,pack:22
-blame.h component=revision role=header prefix=blame includes=diff:1,odb:1 cochange=revision:19,odb:7,diff:4,archive:1,index:1
 branch.c component=? role=lib prefix=branch includes=refs:3,setup:3,odb:2,submodule:1,transport:1 cochange=refs:62,transport:41,setup:28,index:19,revision:12
 branch.h component=? role=public prefix=branch cochange=setup:8,refs:4,submodule:4
 builtin.h component=? role=public prefix=builtin includes=setup:1 cochange=diff:15,index:15,transport:12,odb:6,notes:5
@@ -62,8 +58,6 @@ color.c component=? role=lib prefix=color includes=setup:1 cochange=diff:21,inde
 color.h component=? role=public prefix=color cochange=diff:18,index:12,revision:12,transport:2,odb:1
 column.c component=? role=lib prefix=column includes=setup:1 cochange=transport:6,setup:5,diff:4,revision:3,index:2
 column.h component=? role=public prefix=column
-commit-reach.c component=revision role=lib prefix=commit-reach includes=revision:3,odb:2,pack:1,refs:1 cochange=revision:38,odb:17,pack:15,transport:9,index:5
-commit-reach.h component=revision role=header prefix=commit-reach includes=odb:2 cochange=revision:32,odb:9,transport:8,pack:3,refs:3
 common-exit.c component=? role=lib prefix=common-main
 common-init.c component=? role=lib prefix=common-main includes=odb:2,setup:2,convert:1 cochange=setup:1
 common-init.h component=? role=public prefix=common-main
@@ -86,8 +80,6 @@ ctype.c component=? role=lib prefix=ctype cochange=setup:3,index:2,odb:1,pack:1,
 daemon.c component=? role=program prefix=daemon includes=setup:3,transport:2 cochange=transport:77,index:14,setup:13,diff:7,refs:5
 date.c component=? role=lib prefix=date cochange=revision:17,odb:16,refs:14,setup:9,diff:7
 date.h component=? role=public prefix=date cochange=refs:7,revision:4,setup:2,archive:1,odb:1
-decorate.c component=revision role=lib prefix=decorate includes=odb:1,revision:1 cochange=diff:6,odb:5,revision:5,pack:2,transport:2
-decorate.h component=revision role=header prefix=decorate cochange=revision:4,odb:1
 diagnose.c component=? role=lib prefix=diagnose includes=archive:1,index:1,odb:1,pack:1,setup:1 cochange=index:4,revision:4,odb:3,pack:3,transport:3
 diagnose.h component=? role=public prefix=diagnose cochange=revision:2,refs:1,transport:1
 diff/combine-diff.c component=diff role=lib prefix=combine-diff includes=odb:5,diff:4,revision:2,convert:1,refs:1 cochange=diff:198,revision:67,index:35,odb:16,transport:16
@@ -152,8 +144,6 @@ git-zlib.h component=? role=public prefix=git-zlib cochange=archive:3,setup:2,od
 git.c component=? role=lib prefix=git includes=setup:4,odb:2,convert:1,index:1,revision:1 cochange=setup:70,revision:54,transport:47,index:28,diff:25
 gpg-interface.c component=? role=lib prefix=gpg-interface includes=setup:3,index:1,odb:1 cochange=revision:25,odb:22,setup:13,transport:11,diff:8
 gpg-interface.h component=? role=public prefix=gpg-interface cochange=odb:22,revision:15,merge:4,transport:3,refs:1
-graph.c component=revision role=lib prefix=graph includes=revision:2,odb:1,setup:1 cochange=revision:38,diff:23,index:4,odb:3,transport:3
-graph.h component=revision role=header prefix=graph includes=diff:1 cochange=revision:19,diff:2,odb:1
 grep.c component=? role=lib prefix=grep includes=diff:4,odb:1,revision:1,setup:1 cochange=diff:40,revision:28,transport:10,index:7,refs:7
 grep.h component=? role=public prefix=grep includes=diff:1 cochange=revision:23,diff:10,transport:4,index:2,refs:2
 hashmap.c component=? role=lib prefix=hashmap cochange=diff:33,revision:19,index:17,refs:13,submodule:13
@@ -183,23 +173,10 @@ kwset.c component=? role=lib prefix=kwset cochange=convert:2,diff:1,pack:1,revis
 kwset.h component=? role=public prefix=kwset
 levenshtein.c component=? role=lib prefix=? cochange=diff:2,revision:2,odb:1
 levenshtein.h component=? role=public prefix=? cochange=transport:2,diff:1,refs:1,setup:1
-line-log.c component=revision role=lib prefix=line-log includes=odb:4,revision:4,diff:3,setup:2,pack:1 cochange=revision:52,diff:48,odb:23,pack:15,notes:8
-line-log.h component=revision role=header prefix=line-log includes=diff:1 cochange=revision:20,odb:3,diff:2,setup:1,submodule:1
-line-range.c component=revision role=lib prefix=line-range includes=diff:2,revision:1 cochange=revision:14,diff:8,archive:1,odb:1,pack:1
-line-range.h component=revision role=header prefix=line-range cochange=revision:13
 linear-assignment.c component=? role=lib prefix=linear-assignment cochange=diff:1,revision:1
 linear-assignment.h component=? role=public prefix=linear-assignment
-list-objects-filter-options.c component=revision role=lib prefix=list-objects-filter-options includes=revision:1,setup:1,transport:1 cochange=revision:39,transport:21,setup:9,diff:6,index:4
-list-objects-filter-options.h component=revision role=header prefix=list-objects-filter includes=odb:1 cochange=revision:40,transport:17,odb:4,diff:3,refs:2
-list-objects-filter.c component=revision role=lib prefix=list-objects-filter includes=odb:5,revision:3,diff:1,index:1 cochange=revision:32,odb:13,index:10,diff:6,pack:3
-list-objects-filter.h component=revision role=header prefix=list-objects cochange=revision:16,odb:1
-list-objects.c component=revision role=lib prefix=list-objects includes=odb:6,revision:4,diff:1,pack:1,setup:1 cochange=revision:91,odb:68,pack:40,transport:28,index:15
-list-objects.h component=revision role=header prefix=list-objects cochange=revision:32,pack:13,transport:4,odb:1
-list.h component=revision role=header prefix=list cochange=submodule:2,transport:2,index:1,revision:1
 lockfile.c component=? role=lib prefix=lockfile includes=setup:1 cochange=refs:18,index:13,setup:9,diff:8,merge:3
 lockfile.h component=? role=public prefix=lockfile cochange=index:5,revision:4,diff:3,refs:3,odb:2
-log-tree.c component=revision role=lib prefix=format-patch includes=odb:8,revision:5,diff:3,setup:3,refs:2 cochange=revision:222,diff:112,odb:112,refs:31,transport:16
-log-tree.h component=revision role=header prefix=format-patch cochange=revision:64,diff:11,refs:3,odb:2,transport:2
 mailinfo.c component=? role=lib prefix=mailinfo includes=setup:2 cochange=transport:5,index:3,notes:3,odb:3,revision:3
 mailinfo.h component=? role=public prefix=mailinfo
 mailmap.c component=? role=lib prefix=mailmap includes=setup:3,odb:2 cochange=setup:13,transport:11,refs:10,index:8,revision:5
@@ -340,8 +317,6 @@ pkt-line.c component=transport role=lib prefix=pkt-line includes=transport:2 coc
 pkt-line.h component=transport role=header prefix=pkt-line cochange=transport:94,pack:5,convert:4,odb:2,diff:1
 preload-index.c component=index role=lib prefix=preload-index includes=index:6,setup:3 cochange=index:52,setup:15,diff:12,revision:5,merge:3
 preload-index.h component=index role=header prefix=preload-index cochange=index:2,setup:1
-pretty.c component=revision role=lib prefix=pretty includes=odb:3,revision:2,setup:2,diff:1,notes:1 cochange=revision:115,odb:72,refs:29,notes:23,transport:19
-pretty.h component=revision role=header prefix=pretty cochange=revision:26,refs:7,diff:5,odb:5,archive:4
 prio-queue.c component=? role=lib prefix=prio-queue cochange=odb:5,revision:5,diff:2,pack:2,transport:2
 prio-queue.h component=? role=public prefix=prio-queue cochange=odb:3,revision:2,transport:2,pack:1
 progress.c component=? role=lib prefix=progress includes=setup:1 cochange=index:11,diff:6,setup:6,pack:4,revision:2
@@ -394,8 +369,35 @@ reset.c component=? role=lib prefix=reset includes=odb:3,index:2,refs:1,setup:1
 reset.h component=? role=public prefix=reset includes=odb:1,setup:1
 resolve-undo.c component=index role=lib prefix=resolve-undo includes=index:4,odb:1 cochange=index:33,merge:5,revision:4,diff:3,notes:2
 resolve-undo.h component=index role=header prefix=resolve-undo includes=odb:1 cochange=index:12,merge:3,archive:1,revision:1
-revision.c component=revision role=lib prefix=revision includes=odb:9,revision:8,index:4,setup:4,diff:3 cochange=revision:379,diff:194,odb:181,refs:109,pack:101
-revision.h component=revision role=header prefix=revision includes=odb:4,revision:3,diff:1,notes:1,setup:1 cochange=revision:304,odb:48,diff:24,pack:19,refs:15
+revision/bisect.c component=revision role=lib prefix=bisect includes=odb:5,revision:5,setup:2,diff:1,index:1 cochange=revision:61,odb:32,transport:31,refs:13,diff:9
+revision/bisect.h component=revision role=header prefix=bisect cochange=revision:29,odb:2
+revision/blame.c component=revision role=lib prefix=blame includes=odb:5,diff:2,index:2,pack:2,revision:2 cochange=diff:68,revision:66,odb:56,index:29,pack:22
+revision/blame.h component=revision role=header prefix=blame includes=diff:1,odb:1 cochange=revision:19,odb:7,diff:4,archive:1,index:1
+revision/commit-reach.c component=revision role=lib prefix=commit-reach includes=revision:3,odb:2,pack:1,refs:1 cochange=revision:38,odb:17,pack:15,transport:9,index:5
+revision/commit-reach.h component=revision role=header prefix=commit-reach includes=odb:2 cochange=revision:32,odb:9,transport:8,pack:3,refs:3
+revision/decorate.c component=revision role=lib prefix=decorate includes=odb:1,revision:1 cochange=diff:6,odb:5,revision:5,pack:2,transport:2
+revision/decorate.h component=revision role=header prefix=decorate cochange=revision:4,odb:1
+revision/graph.c component=revision role=lib prefix=graph includes=revision:2,odb:1,setup:1 cochange=revision:38,diff:23,index:4,odb:3,transport:3
+revision/graph.h component=revision role=header prefix=graph includes=diff:1 cochange=revision:19,diff:2,odb:1
+revision/line-log.c component=revision role=lib prefix=line-log includes=odb:4,revision:4,diff:3,setup:2,pack:1 cochange=revision:52,diff:48,odb:23,pack:15,notes:8
+revision/line-log.h component=revision role=header prefix=line-log includes=diff:1 cochange=revision:20,odb:3,diff:2,setup:1,submodule:1
+revision/line-range.c component=revision role=lib prefix=line-range includes=diff:2,revision:1 cochange=revision:14,diff:8,archive:1,odb:1,pack:1
+revision/line-range.h component=revision role=header prefix=line-range cochange=revision:13
+revision/list-objects-filter-options.c component=revision role=lib prefix=list-objects-filter-options includes=revision:1,setup:1,transport:1 cochange=revision:39,transport:21,setup:9,diff:6,index:4
+revision/list-objects-filter-options.h component=revision role=header prefix=list-objects-filter includes=odb:1 cochange=revision:40,transport:17,odb:4,diff:3,refs:2
+revision/list-objects-filter.c component=revision role=lib prefix=list-objects-filter includes=odb:5,revision:3,diff:1,index:1 cochange=revision:32,odb:13,index:10,diff:6,pack:3
+revision/list-objects-filter.h component=revision role=header prefix=list-objects cochange=revision:16,odb:1
+revision/list-objects.c component=revision role=lib prefix=list-objects includes=odb:6,revision:4,diff:1,pack:1,setup:1 cochange=revision:91,odb:68,pack:40,transport:28,index:15
+revision/list-objects.h component=revision role=header prefix=list-objects cochange=revision:32,pack:13,transport:4,odb:1
+revision/list.h component=revision role=header prefix=list cochange=submodule:2,transport:2,index:1,revision:1
+revision/log-tree.c component=revision role=lib prefix=format-patch includes=odb:8,revision:5,diff:3,setup:3,refs:2 cochange=revision:222,diff:112,odb:112,refs:31,transport:16
+revision/log-tree.h component=revision role=header prefix=format-patch cochange=revision:64,diff:11,refs:3,odb:2,transport:2
+revision/pretty.c component=revision role=lib prefix=pretty includes=odb:3,revision:2,setup:2,diff:1,notes:1 cochange=revision:115,odb:72,refs:29,notes:23,transport:19
+revision/pretty.h component=revision role=header prefix=pretty cochange=revision:26,refs:7,diff:5,odb:5,archive:4
+revision/revision.c component=revision role=lib prefix=revision includes=odb:9,revision:8,index:4,setup:4,diff:3 cochange=revision:379,diff:194,odb:181,refs:109,pack:101
+revision/revision.h component=revision role=header prefix=revision includes=odb:4,revision:3,diff:1,notes:1,setup:1 cochange=revision:304,odb:48,diff:24,pack:19,refs:15
+revision/shallow.c component=revision role=lib prefix=shallow includes=odb:5,revision:4,diff:1,index:1,refs:1 cochange=odb:83,transport:73,revision:31,index:20,refs:14
+revision/shallow.h component=revision role=header prefix=shallow includes=odb:2,setup:1 cochange=revision:10,transport:7,odb:5,diff:3,index:2
 run-command.c component=? role=lib prefix=run-command includes=setup:2,index:1,pack:1 cochange=transport:27,index:21,setup:14,odb:8,submodule:6
 run-command.h component=? role=public prefix=run-command cochange=transport:21,setup:8,odb:6,submodule:5,refs:4
 sane-ctype.h component=? role=public prefix=sane-ctype
@@ -411,8 +413,6 @@ setup.h component=setup role=header prefix=setup includes=refs:1 cochange=setup:
 sh-i18n--envsubst.c component=? role=program prefix=sh-i18n--envsubst cochange=index:3,diff:1,transport:1
 sha1dc_git.c component=? role=lib prefix=sha1dc cochange=diff:3,odb:2,revision:2,setup:1
 sha1dc_git.h component=? role=public prefix=sha1dc cochange=odb:2
-shallow.c component=revision role=lib prefix=shallow includes=odb:5,revision:4,diff:1,index:1,refs:1 cochange=odb:83,transport:73,revision:31,index:20,refs:14
-shallow.h component=revision role=header prefix=shallow includes=odb:2,setup:1 cochange=revision:10,transport:7,odb:5,diff:3,index:2
 shell.c component=? role=program prefix=shell includes=setup:1 cochange=transport:10,setup:4,revision:2
 shortlog.h component=? role=public prefix=shortlog cochange=revision:2
 sideband.c component=transport role=lib prefix=sideband includes=transport:2,setup:1 cochange=transport:51,revision:6,diff:5,index:5,refs:4
diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
index 4b50aaa40e..2da56ca8fc 100644
--- a/Documentation/MyFirstContribution.adoc
+++ b/Documentation/MyFirstContribution.adoc
@@ -429,7 +429,7 @@ Add the following includes:
 
 ----
 #include "odb/commit.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "strbuf.h"
 ----
 
diff --git a/Documentation/MyFirstObjectWalk.adoc b/Documentation/MyFirstObjectWalk.adoc
index 87b2433b2c..7fb63e6861 100644
--- a/Documentation/MyFirstObjectWalk.adoc
+++ b/Documentation/MyFirstObjectWalk.adoc
@@ -259,7 +259,7 @@ Add the `struct rev_info` and the `repo_init_revisions()` call.
 We'll also need to include the `revision.h` header:
 
 ----
-#include "revision.h"
+#include "revision/revision.h"
 
 ...
 
@@ -359,7 +359,7 @@ the walk loop below the `prepare_revision_walk()` call within your
 `walken_commit_walk()`:
 
 ----
-#include "pretty.h"
+#include "revision/pretty.h"
 
 ...
 
@@ -668,7 +668,7 @@ Complete your implementation of `walken_object_walk()`.
 We'll also need to include the `list-objects.h` header.
 
 ----
-#include "list-objects.h"
+#include "revision/list-objects.h"
 
 ...
 
diff --git a/Makefile b/Makefile
index b96345ba0c..74013e8380 100644
--- a/Makefile
+++ b/Makefile
@@ -1110,8 +1110,8 @@ LIB_OBJS += archive-zip.o
 LIB_OBJS += archive.o
 LIB_OBJS += attr.o
 LIB_OBJS += base85.o
-LIB_OBJS += bisect.o
-LIB_OBJS += blame.o
+LIB_OBJS += revision/bisect.o
+LIB_OBJS += revision/blame.o
 LIB_OBJS += odb/blob.o
 LIB_OBJS += pack/bloom.o
 LIB_OBJS += branch.o
@@ -1126,7 +1126,7 @@ LIB_OBJS += color.o
 LIB_OBJS += column.o
 LIB_OBJS += diff/combine-diff.o
 LIB_OBJS += pack/commit-graph.o
-LIB_OBJS += commit-reach.o
+LIB_OBJS += revision/commit-reach.o
 LIB_OBJS += odb/commit.o
 LIB_OBJS += common-exit.o
 LIB_OBJS += common-init.o
@@ -1144,7 +1144,7 @@ LIB_OBJS += credential.o
 LIB_OBJS += csum-file.o
 LIB_OBJS += ctype.o
 LIB_OBJS += date.o
-LIB_OBJS += decorate.o
+LIB_OBJS += revision/decorate.o
 LIB_OBJS += pack/delta-islands.o
 LIB_OBJS += diagnose.o
 LIB_OBJS += pack/diff-delta.o
@@ -1179,7 +1179,7 @@ LIB_OBJS += fsmonitor-settings.o
 LIB_OBJS += gettext.o
 LIB_OBJS += git-zlib.o
 LIB_OBJS += gpg-interface.o
-LIB_OBJS += graph.o
+LIB_OBJS += revision/graph.o
 LIB_OBJS += grep.o
 LIB_OBJS += odb/hash-lookup.o
 LIB_OBJS += odb/hash.o
@@ -1192,14 +1192,14 @@ LIB_OBJS += ident.o
 LIB_OBJS += json-writer.o
 LIB_OBJS += kwset.o
 LIB_OBJS += levenshtein.o
-LIB_OBJS += line-log.o
-LIB_OBJS += line-range.o
+LIB_OBJS += revision/line-log.o
+LIB_OBJS += revision/line-range.o
 LIB_OBJS += linear-assignment.o
-LIB_OBJS += list-objects-filter-options.o
-LIB_OBJS += list-objects-filter.o
-LIB_OBJS += list-objects.o
+LIB_OBJS += revision/list-objects-filter-options.o
+LIB_OBJS += revision/list-objects-filter.o
+LIB_OBJS += revision/list-objects.o
 LIB_OBJS += lockfile.o
-LIB_OBJS += log-tree.o
+LIB_OBJS += revision/log-tree.o
 LIB_OBJS += odb/loose.o
 LIB_OBJS += refs/ls-refs.o
 LIB_OBJS += mailinfo.o
@@ -1263,7 +1263,7 @@ LIB_OBJS += path-walk.o
 LIB_OBJS += pathspec.o
 LIB_OBJS += pkt-line.o
 LIB_OBJS += preload-index.o
-LIB_OBJS += pretty.o
+LIB_OBJS += revision/pretty.o
 LIB_OBJS += prio-queue.o
 LIB_OBJS += progress.o
 LIB_OBJS += promisor-remote.o
@@ -1317,14 +1317,14 @@ LIB_OBJS += repository.o
 LIB_OBJS += rerere.o
 LIB_OBJS += reset.o
 LIB_OBJS += resolve-undo.o
-LIB_OBJS += revision.o
+LIB_OBJS += revision/revision.o
 LIB_OBJS += run-command.o
 LIB_OBJS += send-pack.o
 LIB_OBJS += sequencer.o
 LIB_OBJS += serve.o
 LIB_OBJS += pack/server-info.o
 LIB_OBJS += setup.o
-LIB_OBJS += shallow.o
+LIB_OBJS += revision/shallow.o
 LIB_OBJS += sideband.o
 LIB_OBJS += sigchain.o
 LIB_OBJS += sparse-index.o
diff --git a/add-interactive.c b/add-interactive.c
index f656db231c..7bfc410361 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -10,7 +10,7 @@
 #include "preload-index.h"
 #include "read-cache-ll.h"
 #include "repository.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "refs/refs.h"
 #include "string-list.h"
 #include "lockfile.h"
diff --git a/archive.c b/archive.c
index 53820bd859..a2402fb7e6 100644
--- a/archive.c
+++ b/archive.c
@@ -11,7 +11,7 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "path.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "setup.h"
 #include "refs/refs.h"
 #include "odb/odb.h"
diff --git a/attr.c b/attr.c
index e7c6562bee..e7d364d490 100644
--- a/attr.c
+++ b/attr.c
@@ -21,7 +21,7 @@
 #include "quote.h"
 #include "read-cache-ll.h"
 #include "refs/refs.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "odb/odb.h"
 #include "setup.h"
 #include "thread-utils.h"
diff --git a/builtin/add.c b/builtin/add.c
index dd5e33c7b0..4dbdccd928 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -22,7 +22,7 @@
 #include "preload-index.h"
 #include "diff/diff.h"
 #include "read-cache.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "strvec.h"
 #include "submodule.h"
 #include "add-interactive.h"
diff --git a/builtin/am.c b/builtin/am.c
index 7bd7fde14b..5dbe1f171b 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -30,9 +30,9 @@
 #include "odb/object-name.h"
 #include "preload-index.h"
 #include "sequencer.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "merge-ort-wrappers.h"
-#include "log-tree.h"
+#include "revision/log-tree.h"
 #include "notes-utils.h"
 #include "rerere.h"
 #include "mailinfo.h"
@@ -40,7 +40,7 @@
 #include "string-list.h"
 #include "pager.h"
 #include "path.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 
 /**
  * Returns the length of the first line of msg.
diff --git a/builtin/backfill.c b/builtin/backfill.c
index c42226d3e8..d2ef39bc58 100644
--- a/builtin/backfill.c
+++ b/builtin/backfill.c
@@ -19,7 +19,7 @@
 #include "promisor-remote.h"
 #include "strmap.h"
 #include "string-list.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "trace2.h"
 #include "progress.h"
 #include "pack/packfile.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 51e2e949cc..cfb0741d22 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -8,7 +8,7 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
-#include "bisect.h"
+#include "revision/bisect.h"
 #include "refs/refs.h"
 #include "strvec.h"
 #include "run-command.h"
@@ -16,7 +16,7 @@
 #include "path.h"
 #include "prompt.h"
 #include "quote.h"
-#include "revision.h"
+#include "revision/revision.h"
 
 static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
 static GIT_PATH_FUNC(git_path_bisect_ancestors_ok, "BISECT_ANCESTORS_OK")
diff --git a/builtin/blame.c b/builtin/blame.c
index cb9f8b4ff0..9e5776e31b 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -15,7 +15,7 @@
 #include "hex.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "quote.h"
 #include "string-list.h"
 #include "mailmap.h"
@@ -23,13 +23,13 @@
 #include "prio-queue.h"
 #include "utf8.h"
 #include "diff/userdiff.h"
-#include "line-range.h"
-#include "line-log.h"
+#include "revision/line-range.h"
+#include "revision/line-log.h"
 #include "progress.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "pager.h"
-#include "blame.h"
+#include "revision/blame.h"
 #include "refs/refs.h"
 #include "setup.h"
 #include "odb/tag.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index 7909f250aa..c80df76d36 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -28,7 +28,7 @@
 #include "refs/worktree.h"
 #include "help.h"
 #include "advice.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 
 static const char * const builtin_branch_usage[] = {
 	N_("git branch [<options>] [-r | -a] [--merged] [--no-merged] [(--forked <branch>)...]"),
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 4fd1999f80..94979a2683 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -15,7 +15,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "ident.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "parse-options.h"
 #include "diff/userdiff.h"
 #include "odb/oid-array.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index c35c3d92d1..286fcdc1ba 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -28,7 +28,7 @@
 #include "remote.h"
 #include "repo-settings.h"
 #include "resolve-undo.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "sequencer.h"
 #include "setup.h"
 #include "sparse-index.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 7b5274e884..8ed07e1a15 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -43,7 +43,7 @@
 #include "pack/packfile.h"
 #include "path.h"
 #include "pkt-line.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "hook.h"
 #include "bundle.h"
 #include "bundle-uri.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index d2b4ecbd40..aa89e0dc52 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -21,7 +21,7 @@
 #include "odb/commit.h"
 #include "add-interactive.h"
 #include "gettext.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "wt-status.h"
 #include "run-command.h"
 #include "strbuf.h"
@@ -39,9 +39,9 @@
 #include "sparse-index.h"
 #include "mailmap.h"
 #include "help.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "pack/commit-graph.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "trailer.h"
 
 static const char * const builtin_commit_usage[] = {
diff --git a/builtin/describe.c b/builtin/describe.c
index ff44b55e9e..bbeba1e465 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -13,14 +13,14 @@
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "read-cache-ll.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "diff/diff.h"
 #include "hashmap.h"
 #include "setup.h"
 #include "strvec.h"
 #include "run-command.h"
 #include "odb/odb.h"
-#include "list-objects.h"
+#include "revision/list-objects.h"
 #include "odb/commit-slab.h"
 #include "wildmatch.h"
 #include "prio-queue.h"
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index 39eaf9cfce..d1e8d2b462 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -13,7 +13,7 @@
 #include "diff/diff-merges.h"
 #include "odb/commit.h"
 #include "preload-index.h"
-#include "revision.h"
+#include "revision/revision.h"
 
 static const char diff_files_usage[] =
 "git diff-files [-q] [-0 | -1 | -2 | -3 | -c | --cc] [<common-diff-options>] [<path>...]"
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index 799f5533ad..f3b2eadda0 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -7,7 +7,7 @@
 #include "diff/diff-merges.h"
 #include "odb/commit.h"
 #include "preload-index.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "setup.h"
 
 static const char diff_cache_usage[] =
diff --git a/builtin/diff-pairs.c b/builtin/diff-pairs.c
index e3350b2915..df5630be47 100644
--- a/builtin/diff-pairs.c
+++ b/builtin/diff-pairs.c
@@ -7,7 +7,7 @@
 #include "hex.h"
 #include "odb/object.h"
 #include "parse-options.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "strbuf.h"
 
 static unsigned parse_mode_or_die(const char *mode, const char **end)
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 8f2103013c..2bd5ed4004 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -6,9 +6,9 @@
 #include "odb/commit.h"
 #include "gettext.h"
 #include "hex.h"
-#include "log-tree.h"
+#include "revision/log-tree.h"
 #include "read-cache-ll.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "odb/tmp-objdir.h"
 #include "odb/tree.h"
 
diff --git a/builtin/diff.c b/builtin/diff.c
index 774c12cea6..e4487901d3 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -20,8 +20,8 @@
 #include "diff/diffcore.h"
 #include "preload-index.h"
 #include "read-cache-ll.h"
-#include "revision.h"
-#include "log-tree.h"
+#include "revision/revision.h"
+#include "revision/log-tree.h"
 #include "setup.h"
 #include "odb/oid-array.h"
 #include "odb/tree.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 6683d49660..565cdccb40 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -21,9 +21,9 @@
 #include "odb/tag.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
-#include "log-tree.h"
-#include "revision.h"
-#include "decorate.h"
+#include "revision/log-tree.h"
+#include "revision/revision.h"
+#include "revision/decorate.h"
 #include "string-list.h"
 #include "utf8.h"
 #include "parse-options.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 3b7d650e24..f3af94307f 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -26,7 +26,7 @@
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "mem-pool.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "khash.h"
 #include "date.h"
 #include "gpg-interface.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index b14b96ce5c..2f744ac8b8 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -32,12 +32,12 @@
 #include "pager.h"
 #include "path.h"
 #include "pkt-line.h"
-#include "list-objects-filter-options.h"
-#include "commit-reach.h"
+#include "revision/list-objects-filter-options.h"
+#include "revision/commit-reach.h"
 #include "branch.h"
 #include "promisor-remote.h"
 #include "pack/commit-graph.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 #include "trace.h"
 #include "trace2.h"
 #include "bundle-uri.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index bdf3d43108..c340489c64 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -34,7 +34,7 @@
 #include "path.h"
 #include "refs/reflog.h"
 #include "rerere.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "refs/refs.h"
 #include "remote.h"
 #include "exec-cmd.h"
diff --git a/builtin/history.c b/builtin/history.c
index 56b5015bc0..73a31ce152 100644
--- a/builtin/history.c
+++ b/builtin/history.c
@@ -3,7 +3,7 @@
 #include "builtin.h"
 #include "cache-tree.h"
 #include "odb/commit.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "config.h"
 #include "editor.h"
 #include "environment.h"
@@ -18,7 +18,7 @@
 #include "refs/refs.h"
 #include "replay.h"
 #include "reset.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "sequencer.h"
 #include "strvec.h"
 #include "odb/tree.h"
diff --git a/builtin/last-modified.c b/builtin/last-modified.c
index 911441a321..88e122db9b 100644
--- a/builtin/last-modified.c
+++ b/builtin/last-modified.c
@@ -17,7 +17,7 @@
 #include "prio-queue.h"
 #include "quote.h"
 #include "repository.h"
-#include "revision.h"
+#include "revision/revision.h"
 
 /* Remember to update object flag allocation in object.h */
 #define PARENT1 (1u<<16) /* used instead of SEEN */
diff --git a/builtin/log.c b/builtin/log.c
index a93b97858b..82144cf2b6 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -23,8 +23,8 @@
 #include "diff/diff.h"
 #include "diff/diffcore.h"
 #include "diff/diff-merges.h"
-#include "revision.h"
-#include "log-tree.h"
+#include "revision/revision.h"
+#include "revision/log-tree.h"
 #include "odb/oid-array.h"
 #include "odb/oidset.h"
 #include "odb/tag.h"
@@ -35,7 +35,7 @@
 #include "remote.h"
 #include "string-list.h"
 #include "parse-options.h"
-#include "line-log.h"
+#include "revision/line-log.h"
 #include "branch.h"
 #include "version.h"
 #include "mailmap.h"
@@ -44,7 +44,7 @@
 #include "advice.h"
 #include "utf8.h"
 
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "promisor-remote.h"
 #include "diff/range-diff.h"
 #include "odb/tmp-objdir.h"
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 191e4e7fa0..7eec05ae7b 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -7,7 +7,7 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 
 static int show_merge_base(struct commit **rev, size_t rev_nr, int show_all)
 {
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 8217938d86..41d8bbcbc1 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -8,7 +8,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/commit.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "merge-ort.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 7ec4554b0b..268ffc4855 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -31,7 +31,7 @@
 #include "odb/commit.h"
 #include "diff/diffcore.h"
 #include "path.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "unpack-trees.h"
 #include "cache-tree.h"
 #include "dir.h"
@@ -48,7 +48,7 @@
 #include "odb/tag.h"
 #include "alias.h"
 #include "branch.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "wt-status.h"
 #include "pack/commit-graph.h"
 
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index f3f4714c1d..31bc960b34 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -17,8 +17,8 @@
 #include "pack/commit-graph.h"
 #include "wildmatch.h"
 #include "mem-pool.h"
-#include "pretty.h"
-#include "revision.h"
+#include "revision/pretty.h"
+#include "revision/revision.h"
 #include "notes.h"
 #include "write-or-die.h"
 
diff --git a/builtin/notes.c b/builtin/notes.c
index 6ebb5db39c..61087b0fa5 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -19,7 +19,7 @@
 #include "odb/odb.h"
 #include "path.h"
 
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "refs/refs.h"
 #include "exec-cmd.h"
 #include "run-command.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 17721f13ac..3b025a08e9 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -16,9 +16,9 @@
 #include "csum-file.h"
 #include "odb/tree-walk.h"
 #include "diff/diff.h"
-#include "revision.h"
-#include "list-objects.h"
-#include "list-objects-filter-options.h"
+#include "revision/revision.h"
+#include "revision/list-objects.h"
+#include "revision/list-objects-filter-options.h"
 #include "pack/pack-objects.h"
 #include "progress.h"
 #include "refs/refs.h"
@@ -29,7 +29,7 @@
 #include "odb/oid-array.h"
 #include "strvec.h"
 #include "strmap.h"
-#include "list.h"
+#include "revision/list.h"
 #include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/object-file-convert.h"
@@ -39,7 +39,7 @@
 #include "dir.h"
 #include "pack/midx.h"
 #include "trace2.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 #include "promisor-remote.h"
 #include "pack/pack-mtimes.h"
 #include "parse-options.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index 0adf0f02d1..ba7b1303b3 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -7,7 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "pack/reachable.h"
 #include "parse-options.h"
 #include "path.h"
@@ -17,7 +17,7 @@
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 
 static const char * const prune_usage[] = {
 	N_("git prune [-n] [-v] [--progress] [--expire <time>] [--] [<head>...]"),
diff --git a/builtin/pull.c b/builtin/pull.c
index bc8dcde318..af120a7e1b 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -29,7 +29,7 @@
 #include "submodule.h"
 #include "submodule-config.h"
 #include "wt-status.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "sequencer.h"
 
 /**
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 8f9fdcc79b..a14a31d60e 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -27,8 +27,8 @@
 #include "odb/commit.h"
 #include "diff/diff.h"
 #include "wt-status.h"
-#include "revision.h"
-#include "commit-reach.h"
+#include "revision/revision.h"
+#include "revision/commit-reach.h"
 #include "rerere.h"
 #include "branch.h"
 #include "sequencer.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index f01cc1a188..9a816f1e86 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -4,7 +4,7 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "odb/commit.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "config.h"
 #include "connect.h"
 #include "connected.h"
@@ -32,7 +32,7 @@
 #include "run-command.h"
 #include "pack/server-info.h"
 #include "setup.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 #include "sideband.h"
 #include "sigchain.h"
 #include "string-list.h"
diff --git a/builtin/reflog.c b/builtin/reflog.c
index d227104063..d8d1cb2c6a 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -5,7 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/odb.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "pack/reachable.h"
 #include "wildmatch.h"
 #include "refs/worktree.h"
diff --git a/builtin/remote.c b/builtin/remote.c
index 9a5df99c11..3f6cee14ff 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -18,7 +18,7 @@
 #include "refs/refspec.h"
 #include "odb/odb.h"
 #include "strvec.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "progress.h"
 
 static const char * const builtin_remote_usage[] = {
diff --git a/builtin/repack.c b/builtin/repack.c
index 5927a0dfdb..aa74f2161a 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -13,7 +13,7 @@
 #include "pack/prune-packed.h"
 #include "promisor-remote.h"
 #include "pack/repack.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 
 #define ALL_INTO_ONE 1
 #define LOOSEN_UNREACHABLE 2
diff --git a/builtin/replay.c b/builtin/replay.c
index 83b136a13e..4f5515a314 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -11,7 +11,7 @@
 #include "parse-options.h"
 #include "refs/refs.h"
 #include "replay.h"
-#include "revision.h"
+#include "revision/revision.h"
 
 enum ref_action_mode {
 	REF_ACTION_UPDATE,
diff --git a/builtin/repo.c b/builtin/repo.c
index e052e6c0ba..b296e2cda7 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -13,11 +13,11 @@
 #include "quote.h"
 #include "refs/ref-filter.h"
 #include "refs/refs.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "setup.h"
 #include "strbuf.h"
 #include "string-list.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
 #include "utf8.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index f843bab823..eed0d0ea0b 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -19,7 +19,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "odb/object.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "refs/refs.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index c0e0769aab..21d7b8aa81 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -8,24 +8,24 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "revision.h"
-#include "list-objects.h"
-#include "list-objects-filter-options.h"
+#include "revision/revision.h"
+#include "revision/list-objects.h"
+#include "revision/list-objects-filter-options.h"
 #include "odb/object.h"
 #include "odb/object-name.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "pack/pack-bitmap.h"
 #include "parse-options.h"
-#include "log-tree.h"
-#include "graph.h"
-#include "bisect.h"
+#include "revision/log-tree.h"
+#include "revision/graph.h"
+#include "revision/bisect.h"
 #include "progress.h"
 #include "refs/reflog-walk.h"
 #include "odb/oidset.h"
 #include "odb/oidmap.h"
 #include "pack/packfile.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "quote.h"
 #include "strbuf.h"
 
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index b95cdac85e..ef4b6795dd 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -10,7 +10,7 @@
 #include "builtin.h"
 
 #include "abspath.h"
-#include "bisect.h"
+#include "revision/bisect.h"
 #include "config.h"
 #include "odb/commit.h"
 #include "environment.h"
@@ -26,12 +26,12 @@
 #include "read-cache-ll.h"
 #include "repo-settings.h"
 #include "repository.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "setup.h"
 #include "split-index.h"
 #include "submodule.h"
-#include "commit-reach.h"
-#include "shallow.h"
+#include "revision/commit-reach.h"
+#include "revision/shallow.h"
 #include "odb/object-file-convert.h"
 
 #define DO_REVS		1
diff --git a/builtin/revert.c b/builtin/revert.c
index a939c590fb..ae3f186f12 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -6,7 +6,7 @@
 #include "diff/diff.h"
 #include "environment.h"
 #include "gettext.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "rerere.h"
 #include "sequencer.h"
 #include "branch.h"
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 59be73a372..2fe86d6f46 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -7,7 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "string-list.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "utf8.h"
 #include "mailmap.h"
 #include "setup.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 4da3330a26..8db11f6e4c 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -7,7 +7,7 @@
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "refs/refs.h"
 #include "color.h"
 #include "strvec.h"
diff --git a/builtin/stash.c b/builtin/stash.c
index c5e100746d..6458e3a2d6 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -22,10 +22,10 @@
 #include "read-cache.h"
 #include "repository.h"
 #include "rerere.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "setup.h"
 #include "sparse-index.h"
-#include "log-tree.h"
+#include "revision/log-tree.h"
 #include "diff/diffcore.h"
 #include "refs/reflog.h"
 #include "refs/reflog-walk.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 5711a79428..0e061827f9 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -23,7 +23,7 @@
 #include "remote.h"
 #include "refs/refs.h"
 #include "refs/refspec.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "diff/diffcore.h"
 #include "diff/diff.h"
 #include "odb/object-file.h"
@@ -32,7 +32,7 @@
 #include "odb/source.h"
 #include "advice.h"
 #include "branch.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "wildmatch.h"
 #include "strbuf.h"
 #include "url.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index c04c2cc207..46df0f7c27 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -24,7 +24,7 @@
 #include "odb/tag.h"
 #include "parse-options.h"
 #include "diff/diff.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "gpg-interface.h"
 #include "odb/oid-array.h"
 #include "column.h"
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 93caca20ef..fb724e46ea 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -18,7 +18,7 @@
 #include "odb/replace-object.h"
 #include "strbuf.h"
 #include "progress.h"
-#include "decorate.h"
+#include "revision/decorate.h"
 #include "odb/fsck.h"
 #include "pack/packfile.h"
 
diff --git a/bundle.c b/bundle.c
index 54ec76866b..dc50661bdd 100644
--- a/bundle.c
+++ b/bundle.c
@@ -12,12 +12,12 @@
 #include "odb/object.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "revision.h"
-#include "list-objects.h"
+#include "revision/revision.h"
+#include "revision/list-objects.h"
 #include "run-command.h"
 #include "refs/refs.h"
 #include "strvec.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "connected.h"
 #include "write-or-die.h"
 
diff --git a/bundle.h b/bundle.h
index d664b2f2d6..fc78766902 100644
--- a/bundle.h
+++ b/bundle.h
@@ -3,7 +3,7 @@
 
 #include "strvec.h"
 #include "string-list.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 
 struct bundle_header {
 	unsigned version;
diff --git a/chdir-notify.c b/chdir-notify.c
index 1237a45e2e..3d1d5ee3d2 100644
--- a/chdir-notify.c
+++ b/chdir-notify.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "chdir-notify.h"
-#include "list.h"
+#include "revision/list.h"
 #include "path.h"
 #include "strbuf.h"
 #include "trace.h"
diff --git a/diff/combine-diff.c b/diff/combine-diff.c
index 44f0eb5442..8e03062f39 100644
--- a/diff/combine-diff.c
+++ b/diff/combine-diff.c
@@ -13,12 +13,12 @@
 #include "quote.h"
 #include "diff/xdiff-interface.h"
 #include "xdiff/xmacros.h"
-#include "log-tree.h"
+#include "revision/log-tree.h"
 #include "refs/refs.h"
 #include "odb/tree.h"
 #include "diff/userdiff.h"
 #include "odb/oid-array.h"
-#include "revision.h"
+#include "revision/revision.h"
 
 static int compare_paths(const struct combine_diff_path *one,
 			  const struct diff_filespec *two)
diff --git a/diff/diff-lib.c b/diff/diff-lib.c
index fb0514dcb0..d48196f7c7 100644
--- a/diff/diff-lib.c
+++ b/diff/diff-lib.c
@@ -14,7 +14,7 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "read-cache.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "refs/refs.h"
@@ -24,7 +24,7 @@
 #include "trace.h"
 #include "dir.h"
 #include "fsmonitor.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 
 /*
  * diff-files
diff --git a/diff/diff-merges.c b/diff/diff-merges.c
index ca3cbf7767..8300d21a4f 100644
--- a/diff/diff-merges.c
+++ b/diff/diff-merges.c
@@ -2,7 +2,7 @@
 #include "diff/diff-merges.h"
 
 #include "gettext.h"
-#include "revision.h"
+#include "revision/revision.h"
 
 typedef void (*diff_merges_setup_func_t)(struct rev_info *);
 static void set_separate(struct rev_info *revs);
diff --git a/diff/diff-no-index.c b/diff/diff-no-index.c
index 5712e5474d..19cb90d121 100644
--- a/diff/diff-no-index.c
+++ b/diff/diff-no-index.c
@@ -13,7 +13,7 @@
 #include "diff/diff.h"
 #include "diff/diffcore.h"
 #include "gettext.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "parse-options.h"
 #include "pathspec.h"
 #include "string-list.h"
diff --git a/diff/diff.c b/diff/diff.c
index 9062f96b7b..2b87f27238 100644
--- a/diff/diff.c
+++ b/diff/diff.c
@@ -13,7 +13,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "tempfile.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "quote.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
@@ -32,7 +32,7 @@
 #include "string-list.h"
 #include "strvec.h"
 #include "odb/tmp-objdir.h"
-#include "graph.h"
+#include "revision/graph.h"
 #include "odb/oid-array.h"
 #include "pack/packfile.h"
 #include "pager.h"
diff --git a/diff/diffcore-pickaxe.c b/diff/diffcore-pickaxe.c
index e7289d9a26..d851afe3db 100644
--- a/diff/diffcore-pickaxe.c
+++ b/diff/diffcore-pickaxe.c
@@ -11,7 +11,7 @@
 #include "diff/xdiff-interface.h"
 #include "kwset.h"
 #include "odb/oidset.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "quote.h"
 
 typedef int (*pickaxe_fn)(mmfile_t *one, mmfile_t *two,
diff --git a/diff/range-diff.c b/diff/range-diff.c
index 2177b8ba2d..281c043480 100644
--- a/diff/range-diff.c
+++ b/diff/range-diff.c
@@ -15,11 +15,11 @@
 #include "diff/diffcore.h"
 #include "odb/commit.h"
 #include "pager.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "repository.h"
 #include "diff/userdiff.h"
 #include "apply.h"
-#include "revision.h"
+#include "revision/revision.h"
 
 struct patch_util {
 	/* For the search for an exact match */
diff --git a/fetch-pack.c b/fetch-pack.c
index b19cb3239e..d27a28502f 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -30,8 +30,8 @@
 #include "connected.h"
 #include "fetch-negotiator.h"
 #include "odb/fsck.h"
-#include "shallow.h"
-#include "commit-reach.h"
+#include "revision/shallow.h"
+#include "revision/commit-reach.h"
 #include "pack/commit-graph.h"
 #include "sigchain.h"
 #include "mergesort.h"
diff --git a/fetch-pack.h b/fetch-pack.h
index 14e4ba1079..42922616be 100644
--- a/fetch-pack.h
+++ b/fetch-pack.h
@@ -3,7 +3,7 @@
 
 #include "string-list.h"
 #include "protocol.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "odb/oidset.h"
 
 struct oid_array;
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 34f769ae9f..4993cc4a02 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -10,12 +10,12 @@
 #include "diff/diff.h"
 #include "diff/diff-merges.h"
 #include "hex.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "odb/tag.h"
 #include "string-list.h"
 #include "branch.h"
 #include "fmt-merge-msg.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "gpg-interface.h"
 #include "wildmatch.h"
 
diff --git a/git.c b/git.c
index 619219afef..9dace05858 100644
--- a/git.c
+++ b/git.c
@@ -14,7 +14,7 @@
 #include "odb/replace-object.h"
 #include "setup.h"
 #include "attr.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 #include "trace.h"
 #include "trace2.h"
 
diff --git a/grep.c b/grep.c
index 88c87ba1c9..c4eb18ccd7 100644
--- a/grep.c
+++ b/grep.c
@@ -6,7 +6,7 @@
 #include "grep.h"
 #include "hex.h"
 #include "odb/odb.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "diff/userdiff.h"
 #include "diff/xdiff-interface.h"
 #include "diff/diff.h"
diff --git a/http-push.c b/http-push.c
index 6d38410ccb..d45daee9e0 100644
--- a/http-push.c
+++ b/http-push.c
@@ -9,9 +9,9 @@
 #include "odb/blob.h"
 #include "http.h"
 #include "diff/diff.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "remote.h"
-#include "list-objects.h"
+#include "revision/list-objects.h"
 #include "setup.h"
 #include "sigchain.h"
 #include "strvec.h"
@@ -21,7 +21,7 @@
 #include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 
 #ifdef EXPAT_NEEDS_XMLPARSE_H
 #include <xmlparse.h>
diff --git a/http-walker.c b/http-walker.c
index e73c3677d1..8df0c5329b 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -6,7 +6,7 @@
 #include "hex.h"
 #include "walker.h"
 #include "http.h"
-#include "list.h"
+#include "revision/list.h"
 #include "transport.h"
 #include "pack/packfile.h"
 #include "odb/object-file.h"
diff --git a/merge-ort.c b/merge-ort.c
index 61fb855500..71274c24bf 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -25,7 +25,7 @@
 #include "attr.h"
 #include "cache-tree.h"
 #include "odb/commit.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "config.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
@@ -45,7 +45,7 @@
 #include "promisor-remote.h"
 #include "read-cache-ll.h"
 #include "refs/refs.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "sparse-index.h"
 #include "strmap.h"
 #include "trace2.h"
diff --git a/meson.build b/meson.build
index 87060ff883..65be53078d 100644
--- a/meson.build
+++ b/meson.build
@@ -319,8 +319,8 @@ libgit_sources = [
   'archive.c',
   'attr.c',
   'base85.c',
-  'bisect.c',
-  'blame.c',
+  'revision/bisect.c',
+  'revision/blame.c',
   'odb/blob.c',
   'pack/bloom.c',
   'branch.c',
@@ -335,7 +335,7 @@ libgit_sources = [
   'column.c',
   'diff/combine-diff.c',
   'pack/commit-graph.c',
-  'commit-reach.c',
+  'revision/commit-reach.c',
   'odb/commit.c',
   'common-exit.c',
   'common-init.c',
@@ -349,7 +349,7 @@ libgit_sources = [
   'csum-file.c',
   'ctype.c',
   'date.c',
-  'decorate.c',
+  'revision/decorate.c',
   'pack/delta-islands.c',
   'diagnose.c',
   'pack/diff-delta.c',
@@ -384,7 +384,7 @@ libgit_sources = [
   'gettext.c',
   'git-zlib.c',
   'gpg-interface.c',
-  'graph.c',
+  'revision/graph.c',
   'grep.c',
   'odb/hash-lookup.c',
   'odb/hash.c',
@@ -397,14 +397,14 @@ libgit_sources = [
   'json-writer.c',
   'kwset.c',
   'levenshtein.c',
-  'line-log.c',
-  'line-range.c',
+  'revision/line-log.c',
+  'revision/line-range.c',
   'linear-assignment.c',
-  'list-objects-filter-options.c',
-  'list-objects-filter.c',
-  'list-objects.c',
+  'revision/list-objects-filter-options.c',
+  'revision/list-objects-filter.c',
+  'revision/list-objects.c',
   'lockfile.c',
-  'log-tree.c',
+  'revision/log-tree.c',
   'odb/loose.c',
   'refs/ls-refs.c',
   'mailinfo.c',
@@ -468,7 +468,7 @@ libgit_sources = [
   'pathspec.c',
   'pkt-line.c',
   'preload-index.c',
-  'pretty.c',
+  'revision/pretty.c',
   'prio-queue.c',
   'progress.c',
   'promisor-remote.c',
@@ -522,14 +522,14 @@ libgit_sources = [
   'rerere.c',
   'reset.c',
   'resolve-undo.c',
-  'revision.c',
+  'revision/revision.c',
   'run-command.c',
   'send-pack.c',
   'sequencer.c',
   'serve.c',
   'pack/server-info.c',
   'setup.c',
-  'shallow.c',
+  'revision/shallow.c',
   'sideband.c',
   'sigchain.c',
   'sparse-index.c',
diff --git a/notes-cache.c b/notes-cache.c
index 02fb418c6f..1e734c5c19 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -4,7 +4,7 @@
 #include "notes-cache.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "repository.h"
 #include "odb/commit.h"
 #include "refs/refs.h"
diff --git a/notes-merge.c b/notes-merge.c
index ff14b7dfcc..53f42ba863 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -22,7 +22,7 @@
 #include "strbuf.h"
 #include "trace.h"
 #include "notes-utils.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 
 struct notes_merge_pair {
 	struct object_id obj, base, local, remote;
diff --git a/odb/commit.c b/odb/commit.c
index b78cd28013..1b0703a9ef 100644
--- a/odb/commit.c
+++ b/odb/commit.c
@@ -12,7 +12,7 @@
 #include "odb/odb.h"
 #include "utf8.h"
 #include "diff/diff.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "notes.h"
 #include "odb/alloc.h"
 #include "gpg-interface.h"
@@ -23,9 +23,9 @@
 #include "wt-status.h"
 #include "advice.h"
 #include "refs/refs.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "setup.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 #include "odb/tree.h"
 #include "hook.h"
 #include "parse.h"
diff --git a/odb/object-name.c b/odb/object-name.c
index ff61d55590..825fc717bf 100644
--- a/odb/object-name.c
+++ b/odb/object-name.c
@@ -17,13 +17,13 @@
 #include "dir.h"
 #include "odb/odb.h"
 #include "odb/oid-array.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "read-cache-ll.h"
 #include "repo-settings.h"
 #include "repository.h"
 #include "setup.h"
 #include "pack/midx.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "date.h"
 #include "odb/object-file-convert.h"
 #include "prio-queue.h"
diff --git a/odb/source-packed.c b/odb/source-packed.c
index 0e391f6fcf..c1e2756471 100644
--- a/odb/source-packed.c
+++ b/odb/source-packed.c
@@ -3,7 +3,7 @@
 #include "chdir-notify.h"
 #include "dir.h"
 #include "git-zlib.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "mergesort.h"
 #include "pack/midx.h"
 #include "odb/source-packed.h"
diff --git a/pack/commit-graph.c b/pack/commit-graph.c
index afc04d74a5..d5537a9ee8 100644
--- a/pack/commit-graph.c
+++ b/pack/commit-graph.c
@@ -22,7 +22,7 @@
 #include "progress.h"
 #include "pack/bloom.h"
 #include "odb/commit-slab.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 #include "json-writer.h"
 #include "trace2.h"
 #include "odb/tree.h"
diff --git a/pack/midx-write.c b/pack/midx-write.c
index 1f8f24410a..1d5a6525a6 100644
--- a/pack/midx-write.c
+++ b/pack/midx-write.c
@@ -13,8 +13,8 @@
 #include "pack/chunk-format.h"
 #include "pack/pack-bitmap.h"
 #include "refs/refs.h"
-#include "revision.h"
-#include "list-objects.h"
+#include "revision/revision.h"
+#include "revision/list-objects.h"
 #include "path.h"
 #include "pack/pack-revindex.h"
 
diff --git a/pack/pack-bitmap-write.c b/pack/pack-bitmap-write.c
index 22ee370bde..3b7b41c5d7 100644
--- a/pack/pack-bitmap-write.c
+++ b/pack/pack-bitmap-write.c
@@ -7,14 +7,14 @@
 #include "odb/odb.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "progress.h"
 #include "pack/pack.h"
 #include "pack/pack-bitmap.h"
 #include "odb/hash-lookup.h"
 #include "pack/pack-objects.h"
 #include "path.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "prio-queue.h"
 #include "trace2.h"
 #include "odb/tree.h"
diff --git a/pack/pack-bitmap.c b/pack/pack-bitmap.c
index 3adb5d0563..7cd24a37f5 100644
--- a/pack/pack-bitmap.c
+++ b/pack/pack-bitmap.c
@@ -7,9 +7,9 @@
 #include "strbuf.h"
 #include "odb/tag.h"
 #include "diff/diff.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "progress.h"
-#include "list-objects.h"
+#include "revision/list-objects.h"
 #include "pack/pack.h"
 #include "pack/pack-bitmap.h"
 #include "pack/pack-revindex.h"
@@ -18,7 +18,7 @@
 #include "repository.h"
 #include "trace2.h"
 #include "odb/odb.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "pack/midx.h"
 #include "config.h"
 #include "pack/pseudo-merge.h"
diff --git a/pack/packfile.c b/pack/packfile.c
index 0426bee827..72252faffe 100644
--- a/pack/packfile.c
+++ b/pack/packfile.c
@@ -4,7 +4,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "list.h"
+#include "revision/list.h"
 #include "pack/pack.h"
 #include "repository.h"
 #include "dir.h"
diff --git a/pack/packfile.h b/pack/packfile.h
index 55dc02539b..1e6e69fb77 100644
--- a/pack/packfile.h
+++ b/pack/packfile.h
@@ -1,7 +1,7 @@
 #ifndef PACKFILE_H
 #define PACKFILE_H
 
-#include "list.h"
+#include "revision/list.h"
 #include "odb/object.h"
 #include "odb/odb.h"
 #include "odb/source-files.h"
diff --git a/pack/reachable.c b/pack/reachable.c
index 7989f7327a..f61525308e 100644
--- a/pack/reachable.c
+++ b/pack/reachable.c
@@ -7,11 +7,11 @@
 #include "odb/commit.h"
 #include "odb/blob.h"
 #include "diff/diff.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "pack/reachable.h"
 #include "cache-tree.h"
 #include "progress.h"
-#include "list-objects.h"
+#include "revision/list-objects.h"
 #include "pack/packfile.h"
 #include "refs/worktree.h"
 #include "odb/object-file.h"
diff --git a/pack/repack.h b/pack/repack.h
index f9fbc895f0..6248e7deac 100644
--- a/pack/repack.h
+++ b/pack/repack.h
@@ -1,7 +1,7 @@
 #ifndef REPACK_H
 #define REPACK_H
 
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "string-list.h"
 
 struct pack_objects_args {
diff --git a/path-walk.c b/path-walk.c
index ed4d3211d2..4b8ddb2a28 100644
--- a/path-walk.c
+++ b/path-walk.c
@@ -8,8 +8,8 @@
 #include "dir.h"
 #include "hashmap.h"
 #include "hex.h"
-#include "list-objects.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects.h"
+#include "revision/list-objects-filter-options.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "odb/object.h"
@@ -17,7 +17,7 @@
 #include "path.h"
 #include "prio-queue.h"
 #include "repository.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "string-list.h"
 #include "strmap.h"
 #include "odb/tag.h"
diff --git a/read-cache.c b/read-cache.c
index 5bca3fda12..a970eb1b6a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -34,7 +34,7 @@
 #include "read-cache.h"
 #include "repository.h"
 #include "resolve-undo.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "strbuf.h"
 #include "trace2.h"
 #include "varint.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 35acc13ccc..a792297d8f 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -25,7 +25,7 @@
 #include "refs/worktree.h"
 #include "../wrapper.h"
 #include "../write-or-die.h"
-#include "../revision.h"
+#include "revision/revision.h"
 #include <wildmatch.h>
 
 /* So that we can drop `USE_THE_REPOSITORY_VARIABLE`. */
diff --git a/refs/pack-refs.c b/refs/pack-refs.c
index c9f36872cc..d6c41d64f1 100644
--- a/refs/pack-refs.c
+++ b/refs/pack-refs.c
@@ -4,7 +4,7 @@
 #include "refs/pack-refs.h"
 #include "parse-options.h"
 #include "refs/refs.h"
-#include "revision.h"
+#include "revision/revision.h"
 
 int pack_refs_core(int argc,
 		   const char **argv,
diff --git a/refs/ref-filter.c b/refs/ref-filter.c
index e3de16b7a7..7635e13f88 100644
--- a/refs/ref-filter.c
+++ b/refs/ref-filter.c
@@ -24,13 +24,13 @@
 #include "odb/tag.h"
 #include "quote.h"
 #include "refs/ref-filter.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "utf8.h"
 #include "versioncmp.h"
 #include "trailer.h"
 #include "wt-status.h"
 #include "odb/commit-slab.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "refs/worktree.h"
 #include "hashmap.h"
 
diff --git a/refs/ref-filter.h b/refs/ref-filter.h
index 11180f9570..0f4f80ec20 100644
--- a/refs/ref-filter.h
+++ b/refs/ref-filter.h
@@ -6,7 +6,7 @@
 #include "odb/commit.h"
 #include "string-list.h"
 #include "strvec.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 
 /* Quoting styles */
 #define QUOTE_NONE 0
diff --git a/refs/reflog-walk.c b/refs/reflog-walk.c
index f9eee9a76f..4c321fb3a8 100644
--- a/refs/reflog-walk.c
+++ b/refs/reflog-walk.c
@@ -5,7 +5,7 @@
 #include "refs/refs.h"
 #include "diff/diff.h"
 #include "repository.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "string-list.h"
 #include "refs/reflog-walk.h"
 
diff --git a/refs/reflog.c b/refs/reflog.c
index 751485f885..1050ae6301 100644
--- a/refs/reflog.c
+++ b/refs/reflog.c
@@ -9,7 +9,7 @@
 #include "odb/odb.h"
 #include "refs/reflog.h"
 #include "refs/refs.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
 #include "wildmatch.h"
diff --git a/remote.c b/remote.c
index c619009d30..8a65967fb0 100644
--- a/remote.c
+++ b/remote.c
@@ -17,12 +17,12 @@
 #include "path.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "dir.h"
 #include "setup.h"
 #include "string-list.h"
 #include "strvec.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "advice.h"
 #include "connect.h"
 #include "parse-options.h"
diff --git a/replay.c b/replay.c
index 8dd7b99502..6922a1f137 100644
--- a/replay.c
+++ b/replay.c
@@ -7,7 +7,7 @@
 #include "odb/object-name.h"
 #include "refs/refs.h"
 #include "replay.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "sequencer.h"
 #include "strmap.h"
 #include "odb/tree.h"
diff --git a/bisect.c b/revision/bisect.c
similarity index 99%
rename from bisect.c
rename to revision/bisect.c
index 1f8d81b894..696e365310 100644
--- a/bisect.c
+++ b/revision/bisect.c
@@ -8,17 +8,17 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "refs/refs.h"
-#include "list-objects.h"
+#include "revision/list-objects.h"
 #include "quote.h"
 #include "run-command.h"
-#include "log-tree.h"
-#include "bisect.h"
+#include "revision/log-tree.h"
+#include "revision/bisect.h"
 #include "odb/oid-array.h"
 #include "strvec.h"
 #include "odb/commit-slab.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "path.h"
diff --git a/bisect.h b/revision/bisect.h
similarity index 100%
rename from bisect.h
rename to revision/bisect.h
diff --git a/blame.c b/revision/blame.c
similarity index 99%
rename from blame.c
rename to revision/blame.c
index c736441f18..54284ed8da 100644
--- a/blame.c
+++ b/revision/blame.c
@@ -14,11 +14,11 @@
 #include "hex.h"
 #include "path.h"
 #include "read-cache.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "setup.h"
 #include "odb/tag.h"
 #include "trace2.h"
-#include "blame.h"
+#include "revision/blame.h"
 #include "odb/alloc.h"
 #include "odb/commit-slab.h"
 #include "pack/bloom.h"
diff --git a/blame.h b/revision/blame.h
similarity index 100%
rename from blame.h
rename to revision/blame.h
diff --git a/commit-reach.c b/revision/commit-reach.c
similarity index 99%
rename from commit-reach.c
rename to revision/commit-reach.c
index 0b59c9ba29..e1e1b71819 100644
--- a/commit-reach.c
+++ b/revision/commit-reach.c
@@ -3,13 +3,13 @@
 #include "git-compat-util.h"
 #include "odb/commit.h"
 #include "pack/commit-graph.h"
-#include "decorate.h"
+#include "revision/decorate.h"
 #include "hex.h"
 #include "prio-queue.h"
 #include "refs/ref-filter.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "odb/tag.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "ewah/ewok.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/commit-reach.h b/revision/commit-reach.h
similarity index 100%
rename from commit-reach.h
rename to revision/commit-reach.h
diff --git a/decorate.c b/revision/decorate.c
similarity index 98%
rename from decorate.c
rename to revision/decorate.c
index 262c9198eb..eeba03ec83 100644
--- a/decorate.c
+++ b/revision/decorate.c
@@ -5,7 +5,7 @@
 
 #include "git-compat-util.h"
 #include "odb/object.h"
-#include "decorate.h"
+#include "revision/decorate.h"
 
 static unsigned int hash_obj(const struct object *obj, unsigned int n)
 {
diff --git a/decorate.h b/revision/decorate.h
similarity index 100%
rename from decorate.h
rename to revision/decorate.h
diff --git a/graph.c b/revision/graph.c
similarity index 99%
rename from graph.c
rename to revision/graph.c
index 66c2be423e..c6f10398a2 100644
--- a/graph.c
+++ b/revision/graph.c
@@ -5,8 +5,8 @@
 #include "config.h"
 #include "odb/commit.h"
 #include "color.h"
-#include "graph.h"
-#include "revision.h"
+#include "revision/graph.h"
+#include "revision/revision.h"
 #include "strvec.h"
 
 /* Internal API */
diff --git a/graph.h b/revision/graph.h
similarity index 100%
rename from graph.h
rename to revision/graph.h
diff --git a/line-log.c b/revision/line-log.c
similarity index 99%
rename from line-log.c
rename to revision/line-log.c
index 78697cb377..3da7af2340 100644
--- a/line-log.c
+++ b/revision/line-log.c
@@ -2,18 +2,18 @@
 
 #include "git-compat-util.h"
 #include "diff/diffcore.h"
-#include "line-range.h"
+#include "revision/line-range.h"
 #include "hex.h"
 #include "odb/tag.h"
 #include "odb/tree.h"
 #include "diff/diff.h"
 #include "odb/commit.h"
-#include "decorate.h"
+#include "revision/decorate.h"
 #include "repository.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "diff/xdiff-interface.h"
 #include "strbuf.h"
-#include "line-log.h"
+#include "revision/line-log.h"
 #include "setup.h"
 #include "strvec.h"
 #include "pack/bloom.h"
diff --git a/line-log.h b/revision/line-log.h
similarity index 100%
rename from line-log.h
rename to revision/line-log.h
diff --git a/line-range.c b/revision/line-range.c
similarity index 99%
rename from line-range.c
rename to revision/line-range.c
index 1dbf761ecc..419d90d863 100644
--- a/line-range.c
+++ b/revision/line-range.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "line-range.h"
+#include "revision/line-range.h"
 #include "diff/xdiff-interface.h"
 #include "diff/userdiff.h"
 
diff --git a/line-range.h b/revision/line-range.h
similarity index 100%
rename from line-range.h
rename to revision/line-range.h
diff --git a/list-objects-filter-options.c b/revision/list-objects-filter-options.c
similarity index 99%
rename from list-objects-filter-options.c
rename to revision/list-objects-filter-options.c
index bc5d98f9e6..6730808896 100644
--- a/list-objects-filter-options.c
+++ b/revision/list-objects-filter-options.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "gettext.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "promisor-remote.h"
 #include "trace.h"
 #include "url.h"
diff --git a/list-objects-filter-options.h b/revision/list-objects-filter-options.h
similarity index 100%
rename from list-objects-filter-options.h
rename to revision/list-objects-filter-options.h
diff --git a/list-objects-filter.c b/revision/list-objects-filter.c
similarity index 99%
rename from list-objects-filter.c
rename to revision/list-objects-filter.c
index a011cef0b5..0ea4cb826e 100644
--- a/list-objects-filter.c
+++ b/revision/list-objects-filter.c
@@ -6,9 +6,9 @@
 #include "hex.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "revision.h"
-#include "list-objects-filter.h"
-#include "list-objects-filter-options.h"
+#include "revision/revision.h"
+#include "revision/list-objects-filter.h"
+#include "revision/list-objects-filter-options.h"
 #include "odb/oidmap.h"
 #include "odb/oidset.h"
 #include "odb/object-name.h"
diff --git a/list-objects-filter.h b/revision/list-objects-filter.h
similarity index 100%
rename from list-objects-filter.h
rename to revision/list-objects-filter.h
diff --git a/list-objects.c b/revision/list-objects.c
similarity index 98%
rename from list-objects.c
rename to revision/list-objects.c
index 6b67f0f927..fdf98b629f 100644
--- a/list-objects.c
+++ b/revision/list-objects.c
@@ -9,10 +9,10 @@
 #include "odb/blob.h"
 #include "diff/diff.h"
 #include "odb/tree-walk.h"
-#include "revision.h"
-#include "list-objects.h"
-#include "list-objects-filter.h"
-#include "list-objects-filter-options.h"
+#include "revision/revision.h"
+#include "revision/list-objects.h"
+#include "revision/list-objects-filter.h"
+#include "revision/list-objects-filter-options.h"
 #include "pack/packfile.h"
 #include "odb/odb.h"
 #include "trace.h"
diff --git a/list-objects.h b/revision/list-objects.h
similarity index 100%
rename from list-objects.h
rename to revision/list-objects.h
diff --git a/list.h b/revision/list.h
similarity index 100%
rename from list.h
rename to revision/list.h
diff --git a/log-tree.c b/revision/log-tree.c
similarity index 99%
rename from log-tree.c
rename to revision/log-tree.c
index ddeafedb45..e555d07072 100644
--- a/log-tree.c
+++ b/revision/log-tree.c
@@ -2,7 +2,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "odb/commit-slab.h"
 #include "config.h"
 #include "diff/diff.h"
@@ -15,18 +15,18 @@
 #include "odb/tmp-objdir.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
-#include "graph.h"
-#include "log-tree.h"
+#include "revision/graph.h"
+#include "revision/log-tree.h"
 #include "merge-ort.h"
 #include "refs/reflog-walk.h"
 #include "refs/refs.h"
 #include "odb/replace-object.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "string-list.h"
 #include "color.h"
 #include "gpg-interface.h"
 #include "sequencer.h"
-#include "line-log.h"
+#include "revision/line-log.h"
 #include "help.h"
 #include "diff/range-diff.h"
 #include "strmap.h"
diff --git a/log-tree.h b/revision/log-tree.h
similarity index 100%
rename from log-tree.h
rename to revision/log-tree.h
diff --git a/pretty.c b/revision/pretty.c
similarity index 99%
rename from pretty.c
rename to revision/pretty.c
index 3444617506..cdf63ded49 100644
--- a/pretty.c
+++ b/revision/pretty.c
@@ -11,10 +11,10 @@
 #include "utf8.h"
 #include "diff/diff.h"
 #include "pager.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "string-list.h"
 #include "mailmap.h"
-#include "log-tree.h"
+#include "revision/log-tree.h"
 #include "notes.h"
 #include "color.h"
 #include "refs/reflog-walk.h"
diff --git a/pretty.h b/revision/pretty.h
similarity index 100%
rename from pretty.h
rename to revision/pretty.h
diff --git a/revision.c b/revision/revision.c
similarity index 99%
rename from revision.c
rename to revision/revision.c
index 249a1736fd..9a19a5654a 100644
--- a/revision.c
+++ b/revision/revision.c
@@ -17,20 +17,20 @@
 #include "diff/diff.h"
 #include "diff/diff-merges.h"
 #include "refs/refs.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "repository.h"
-#include "graph.h"
+#include "revision/graph.h"
 #include "grep.h"
 #include "refs/reflog-walk.h"
 #include "diff/patch-ids.h"
-#include "decorate.h"
+#include "revision/decorate.h"
 #include "string-list.h"
-#include "line-log.h"
-#include "log-tree.h"
+#include "revision/line-log.h"
+#include "revision/log-tree.h"
 #include "mailmap.h"
 #include "odb/commit-slab.h"
 #include "cache-tree.h"
-#include "bisect.h"
+#include "revision/bisect.h"
 #include "pack/packfile.h"
 #include "refs/worktree.h"
 #include "path.h"
@@ -39,14 +39,14 @@
 #include "sparse-index.h"
 #include "strvec.h"
 #include "trace2.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "pack/commit-graph.h"
 #include "prio-queue.h"
 #include "hashmap.h"
 #include "utf8.h"
 #include "pack/bloom.h"
 #include "json-writer.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "resolve-undo.h"
 #include "parse-options.h"
 #include "wildmatch.h"
diff --git a/revision.h b/revision/revision.h
similarity index 99%
rename from revision.h
rename to revision/revision.h
index 64d9a47091..9cb9419b22 100644
--- a/revision.h
+++ b/revision/revision.h
@@ -6,12 +6,12 @@
 #include "notes.h"
 #include "odb/object-name.h"
 #include "odb/oidset.h"
-#include "pretty.h"
+#include "revision/pretty.h"
 #include "diff/diff.h"
 #include "odb/commit-slab-decl.h"
-#include "decorate.h"
+#include "revision/decorate.h"
 #include "ident.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "prio-queue.h"
 #include "strvec.h"
 
diff --git a/shallow.c b/revision/shallow.c
similarity index 99%
rename from shallow.c
rename to revision/shallow.c
index fa16834aff..51ba602971 100644
--- a/shallow.c
+++ b/revision/shallow.c
@@ -13,11 +13,11 @@
 #include "odb/oid-array.h"
 #include "path.h"
 #include "diff/diff.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "odb/commit-slab.h"
-#include "list-objects.h"
-#include "commit-reach.h"
-#include "shallow.h"
+#include "revision/list-objects.h"
+#include "revision/commit-reach.h"
+#include "revision/shallow.h"
 #include "statinfo.h"
 #include "trace.h"
 
diff --git a/shallow.h b/revision/shallow.h
similarity index 100%
rename from shallow.h
rename to revision/shallow.h
diff --git a/send-pack.c b/send-pack.c
index 97dcfac586..f59686f971 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -15,7 +15,7 @@
 #include "version.h"
 #include "odb/oid-array.h"
 #include "gpg-interface.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 #include "parse-options.h"
 #include "trace2.h"
 #include "write-or-die.h"
diff --git a/sequencer.c b/sequencer.c
index 551e4529c4..d5b1eb9719 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -24,7 +24,7 @@
 #include "cache-tree.h"
 #include "diff/diff.h"
 #include "path.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "rerere.h"
 #include "merge.h"
 #include "merge-ort.h"
@@ -34,7 +34,7 @@
 #include "strvec.h"
 #include "quote.h"
 #include "trailer.h"
-#include "log-tree.h"
+#include "revision/log-tree.h"
 #include "wt-status.h"
 #include "hashmap.h"
 #include "notes-utils.h"
@@ -44,7 +44,7 @@
 #include "odb/oidset.h"
 #include "odb/commit-slab.h"
 #include "alias.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "rebase-interactive.h"
 #include "reset.h"
 #include "branch.h"
diff --git a/setup.c b/setup.c
index 925a600dba..62fbda948d 100644
--- a/setup.c
+++ b/setup.c
@@ -14,7 +14,7 @@
 #include "config.h"
 #include "dir.h"
 #include "setup.h"
-#include "shallow.h"
+#include "revision/shallow.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "chdir-notify.h"
diff --git a/submodule.c b/submodule.c
index a9137aa180..16f4d30b82 100644
--- a/submodule.c
+++ b/submodule.c
@@ -13,7 +13,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "run-command.h"
 #include "diff/diffcore.h"
 #include "refs/refs.h"
@@ -28,7 +28,7 @@
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "read-cache-ll.h"
 #include "setup.h"
 #include "advice.h"
diff --git a/t/helper/test-path-walk.c b/t/helper/test-path-walk.c
index f41c6be2c6..71d052d504 100644
--- a/t/helper/test-path-walk.c
+++ b/t/helper/test-path-walk.c
@@ -4,11 +4,11 @@
 #include "dir.h"
 #include "environment.h"
 #include "hex.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "odb/object-name.h"
 #include "odb/object.h"
-#include "pretty.h"
-#include "revision.h"
+#include "revision/pretty.h"
+#include "revision/revision.h"
 #include "setup.h"
 #include "parse-options.h"
 #include "strbuf.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index df1c677b9f..7f00cc7d9c 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -2,7 +2,7 @@
 
 #include "test-tool.h"
 #include "odb/commit.h"
-#include "commit-reach.h"
+#include "revision/commit-reach.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 8c2fb0aad7..582e8b4d97 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -9,7 +9,7 @@
 #include "path.h"
 #include "repository.h"
 #include "strbuf.h"
-#include "revision.h"
+#include "revision/revision.h"
 
 struct flag_definition {
 	const char *name;
diff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c
index 7c66b8566f..57e0bcea63 100644
--- a/t/helper/test-revision-walking.c
+++ b/t/helper/test-revision-walking.c
@@ -13,10 +13,10 @@
 #include "test-tool.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "line-log.h"
+#include "revision/line-log.h"
 #include "odb/object-name.h"
 #include "repository.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "setup.h"
 #include "string-list.h"
 
diff --git a/t/unit-tests/u-example-decorate.c b/t/unit-tests/u-example-decorate.c
index 2f01340c21..85d0277ee2 100644
--- a/t/unit-tests/u-example-decorate.c
+++ b/t/unit-tests/u-example-decorate.c
@@ -2,7 +2,7 @@
 
 #include "unit-test.h"
 #include "odb/object.h"
-#include "decorate.h"
+#include "revision/decorate.h"
 #include "repository.h"
 
 struct test_vars {
diff --git a/t/unit-tests/u-list-objects-filter-options.c b/t/unit-tests/u-list-objects-filter-options.c
index f7d73701b5..cbcae66fa5 100644
--- a/t/unit-tests/u-list-objects-filter-options.c
+++ b/t/unit-tests/u-list-objects-filter-options.c
@@ -1,5 +1,5 @@
 #include "unit-test.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "strbuf.h"
 
 /* Helper to test gently_parse_list_objects_filter() */
diff --git a/tempfile.h b/tempfile.h
index f571f3c609..40d8d230de 100644
--- a/tempfile.h
+++ b/tempfile.h
@@ -1,7 +1,7 @@
 #ifndef TEMPFILE_H
 #define TEMPFILE_H
 
-#include "list.h"
+#include "revision/list.h"
 #include "strbuf.h"
 
 struct repository;
diff --git a/trailer.c b/trailer.c
index 33fd1df188..7723c5cf52 100644
--- a/trailer.c
+++ b/trailer.c
@@ -9,7 +9,7 @@
 #include "odb/commit.h"
 #include "strvec.h"
 #include "trailer.h"
-#include "list.h"
+#include "revision/list.h"
 #include "tempfile.h"
 
 /*
diff --git a/trailer.h b/trailer.h
index b49338858c..5afc1775f2 100644
--- a/trailer.h
+++ b/trailer.h
@@ -1,7 +1,7 @@
 #ifndef TRAILER_H
 #define TRAILER_H
 
-#include "list.h"
+#include "revision/list.h"
 #include "strbuf.h"
 
 struct trailer_block;
diff --git a/transport.h b/transport.h
index a7869d18e0..064f4192cf 100644
--- a/transport.h
+++ b/transport.h
@@ -3,7 +3,7 @@
 
 #include "run-command.h"
 #include "remote.h"
-#include "list-objects-filter-options.h"
+#include "revision/list-objects-filter-options.h"
 #include "string-list.h"
 #include "connect.h"
 
diff --git a/upload-pack.c b/upload-pack.c
index acd381ebf1..09a986e486 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -15,8 +15,8 @@
 #include "odb/object.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "revision.h"
-#include "list-objects-filter-options.h"
+#include "revision/revision.h"
+#include "revision/list-objects-filter-options.h"
 #include "run-command.h"
 #include "connect.h"
 #include "sigchain.h"
@@ -27,8 +27,8 @@
 #include "protocol.h"
 #include "upload-pack.h"
 #include "pack/commit-graph.h"
-#include "commit-reach.h"
-#include "shallow.h"
+#include "revision/commit-reach.h"
+#include "revision/shallow.h"
 #include "trace.h"
 #include "write-or-die.h"
 #include "json-writer.h"
diff --git a/wt-status.c b/wt-status.c
index 28a0c72a51..83fdf5334f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -14,7 +14,7 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "path.h"
-#include "revision.h"
+#include "revision/revision.h"
 #include "diff/diffcore.h"
 #include "quote.h"
 #include "repository.h"
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 12/14] index: gather the index sources under index/
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (10 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 11/14] revision: gather the revision sources under revision/ Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 13/14] setup: gather the setup sources under setup/ Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 14/14] transport: gather the transport sources under transport/ Michael Montalbo
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Move the 20 index C sources and 24 headers into index/ as renames.
Repoint every reference to their old paths to the new ones: the #include
lines across the tree, the Makefile and meson.build build entries, and
the tutorial #include examples.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize                                  | 88 +++++++++----------
 Documentation/MyFirstContribution.adoc        |  2 +-
 Makefile                                      | 42 ++++-----
 add-interactive.c                             |  6 +-
 add-patch.c                                   |  4 +-
 apply.c                                       | 10 +--
 archive.c                                     |  2 +-
 archive.h                                     |  2 +-
 attr.c                                        |  4 +-
 builtin/add.c                                 |  8 +-
 builtin/am.c                                  |  8 +-
 builtin/backfill.c                            |  2 +-
 builtin/check-ignore.c                        |  4 +-
 builtin/checkout--worker.c                    |  6 +-
 builtin/checkout-index.c                      | 10 +--
 builtin/checkout.c                            | 24 ++---
 builtin/clean.c                               |  6 +-
 builtin/clone.c                               |  6 +-
 builtin/commit.c                              | 14 +--
 builtin/count-objects.c                       |  2 +-
 builtin/describe.c                            |  2 +-
 builtin/diff-files.c                          |  2 +-
 builtin/diff-index.c                          |  2 +-
 builtin/diff-tree.c                           |  2 +-
 builtin/diff.c                                |  4 +-
 builtin/difftool.c                            |  8 +-
 builtin/fast-import.c                         |  4 +-
 builtin/fsck.c                                |  8 +-
 builtin/fsmonitor--daemon.c                   | 10 +--
 builtin/gc.c                                  |  2 +-
 builtin/grep.c                                |  6 +-
 builtin/history.c                             |  8 +-
 builtin/ls-files.c                            | 10 +--
 builtin/ls-tree.c                             |  2 +-
 builtin/merge-index.c                         |  4 +-
 builtin/merge.c                               | 10 +--
 builtin/mv.c                                  | 12 +--
 builtin/pack-objects.c                        |  2 +-
 builtin/prune.c                               |  2 +-
 builtin/pull.c                                |  6 +-
 builtin/push.c                                |  2 +-
 builtin/read-tree.c                           |  8 +-
 builtin/rebase.c                              |  6 +-
 builtin/rerere.c                              |  2 +-
 builtin/reset.c                               |  8 +-
 builtin/rev-parse.c                           |  4 +-
 builtin/rm.c                                  |  8 +-
 builtin/show-branch.c                         |  2 +-
 builtin/sparse-checkout.c                     |  8 +-
 builtin/stash.c                               | 14 +--
 builtin/submodule--helper.c                   | 10 +--
 builtin/update-index.c                        | 18 ++--
 builtin/worktree.c                            |  6 +-
 builtin/write-tree.c                          |  2 +-
 compat/fsmonitor/fsm-health-darwin.c          |  4 +-
 compat/fsmonitor/fsm-health-linux.c           |  4 +-
 compat/fsmonitor/fsm-health-win32.c           |  4 +-
 compat/fsmonitor/fsm-ipc-unix.c               |  6 +-
 compat/fsmonitor/fsm-ipc-win32.c              |  2 +-
 compat/fsmonitor/fsm-listen-darwin.c          |  6 +-
 compat/fsmonitor/fsm-listen-linux.c           |  8 +-
 compat/fsmonitor/fsm-listen-win32.c           |  4 +-
 compat/fsmonitor/fsm-path-utils-darwin.c      |  4 +-
 compat/fsmonitor/fsm-path-utils-linux.c       |  4 +-
 compat/fsmonitor/fsm-path-utils-win32.c       |  4 +-
 compat/fsmonitor/fsm-settings-unix.c          |  8 +-
 compat/fsmonitor/fsm-settings-win32.c         |  6 +-
 compat/mingw.c                                |  4 +-
 config.c                                      |  2 +-
 convert.c                                     |  2 +-
 diagnose.c                                    |  2 +-
 diff/diff-lib.c                               | 12 +--
 diff/diff-no-index.c                          |  4 +-
 diff/diff.c                                   |  4 +-
 diff/diff.h                                   |  2 +-
 diff/tree-diff.c                              |  2 +-
 git.c                                         |  2 +-
 gpg-interface.c                               |  2 +-
 help.c                                        |  2 +-
 cache-tree.c => index/cache-tree.c            |  4 +-
 cache-tree.h => index/cache-tree.h            |  0
 checkout.c => index/checkout.c                |  2 +-
 checkout.h => index/checkout.h                |  0
 dir-iterator.c => index/dir-iterator.c        |  4 +-
 dir-iterator.h => index/dir-iterator.h        |  0
 dir.c => index/dir.c                          | 14 +--
 dir.h => index/dir.h                          |  4 +-
 entry.c => index/entry.c                      | 14 +--
 entry.h => index/entry.h                      |  0
 .../fsmonitor--daemon.h                       |  2 +-
 fsmonitor-ipc.c => index/fsmonitor-ipc.c      |  2 +-
 fsmonitor-ipc.h => index/fsmonitor-ipc.h      |  0
 fsmonitor-ll.h => index/fsmonitor-ll.h        |  0
 .../fsmonitor-path-utils.h                    |  0
 .../fsmonitor-settings.c                      |  6 +-
 .../fsmonitor-settings.h                      |  0
 fsmonitor.c => index/fsmonitor.c              |  8 +-
 fsmonitor.h => index/fsmonitor.h              |  8 +-
 name-hash.c => index/name-hash.c              |  6 +-
 name-hash.h => index/name-hash.h              |  0
 .../parallel-checkout.c                       |  8 +-
 .../parallel-checkout.h                       |  0
 pathspec.c => index/pathspec.c                |  8 +-
 pathspec.h => index/pathspec.h                |  0
 preload-index.c => index/preload-index.c      | 12 +--
 preload-index.h => index/preload-index.h      |  0
 read-cache-ll.h => index/read-cache-ll.h      |  2 +-
 read-cache.c => index/read-cache.c            | 20 ++---
 read-cache.h => index/read-cache.h            |  4 +-
 resolve-undo.c => index/resolve-undo.c        |  8 +-
 resolve-undo.h => index/resolve-undo.h        |  0
 sparse-index.c => index/sparse-index.c        | 14 +--
 sparse-index.h => index/sparse-index.h        |  0
 split-index.c => index/split-index.c          |  4 +-
 split-index.h => index/split-index.h          |  0
 statinfo.c => index/statinfo.c                |  2 +-
 statinfo.h => index/statinfo.h                |  0
 symlinks.c => index/symlinks.c                |  2 +-
 symlinks.h => index/symlinks.h                |  0
 unpack-trees.c => index/unpack-trees.c        | 22 ++---
 unpack-trees.h => index/unpack-trees.h        |  2 +-
 wt-status.c => index/wt-status.c              |  8 +-
 wt-status.h => index/wt-status.h              |  2 +-
 merge-ort-wrappers.c                          |  2 +-
 merge-ort.c                                   | 12 +--
 merge.c                                       |  4 +-
 meson.build                                   | 40 ++++-----
 notes-merge.c                                 |  2 +-
 odb/commit.c                                  |  2 +-
 odb/fsck.c                                    |  2 +-
 odb/hash-lookup.c                             |  2 +-
 odb/object-file.c                             |  4 +-
 odb/object-name.c                             |  4 +-
 odb/object.c                                  |  2 +-
 odb/odb.c                                     |  2 +-
 odb/source-packed.c                           |  2 +-
 odb/tmp-objdir.c                              |  2 +-
 odb/tree-walk.c                               |  6 +-
 organize/gitorganize-format.c                 |  2 +-
 organize/organize.c                           |  6 +-
 pack/midx.c                                   |  2 +-
 pack/packfile.c                               |  2 +-
 pack/reachable.c                              |  2 +-
 pack/repack.c                                 |  2 +-
 pack/server-info.c                            |  2 +-
 path-walk.c                                   |  2 +-
 path.c                                        |  2 +-
 rebase-interactive.c                          |  2 +-
 refs/files-backend.c                          |  4 +-
 refs/packed-backend.c                         |  4 +-
 refs/ref-filter.c                             |  2 +-
 refs/reftable-backend.c                       |  2 +-
 refs/worktree.c                               |  4 +-
 remote.c                                      |  2 +-
 repository.c                                  |  4 +-
 rerere.c                                      |  8 +-
 reset.c                                       |  4 +-
 revision/bisect.c                             |  2 +-
 revision/blame.c                              |  4 +-
 revision/list-objects-filter.c                |  2 +-
 revision/revision.c                           |  8 +-
 revision/shallow.c                            |  2 +-
 run-command.c                                 |  2 +-
 scalar.c                                      |  6 +-
 sequencer.c                                   | 10 +--
 sequencer.h                                   |  2 +-
 setup.c                                       |  2 +-
 submodule-config.c                            |  2 +-
 submodule.c                                   |  4 +-
 t/helper/test-cache-tree.c                    |  4 +-
 t/helper/test-dir-iterator.c                  |  2 +-
 t/helper/test-dump-cache-tree.c               |  4 +-
 t/helper/test-dump-fsmonitor.c                |  2 +-
 t/helper/test-dump-split-index.c              |  4 +-
 t/helper/test-dump-untracked-cache.c          |  4 +-
 t/helper/test-fsmonitor-client.c              |  4 +-
 t/helper/test-lazy-init-name-hash.c           |  4 +-
 t/helper/test-parse-pathspec-file.c           |  2 +-
 t/helper/test-path-utils.c                    |  2 +-
 t/helper/test-path-walk.c                     |  2 +-
 t/helper/test-read-cache.c                    |  2 +-
 t/helper/test-scrap-cache-tree.c              |  4 +-
 t/helper/test-write-cache.c                   |  2 +-
 t/unit-tests/test-lib.c                       |  2 +-
 t/unit-tests/u-dir.c                          |  2 +-
 t/unit-tests/u-reftable-stack.c               |  2 +-
 t/unit-tests/u-strcmp-offset.c                |  2 +-
 trace2/tr2_sysenv.c                           |  2 +-
 188 files changed, 497 insertions(+), 497 deletions(-)
 rename cache-tree.c => index/cache-tree.c (99%)
 rename cache-tree.h => index/cache-tree.h (100%)
 rename checkout.c => index/checkout.c (98%)
 rename checkout.h => index/checkout.h (100%)
 rename dir-iterator.c => index/dir-iterator.c (99%)
 rename dir-iterator.h => index/dir-iterator.h (100%)
 rename dir.c => index/dir.c (99%)
 rename dir.h => index/dir.h (99%)
 rename entry.c => index/entry.c (98%)
 rename entry.h => index/entry.h (100%)
 rename fsmonitor--daemon.h => index/fsmonitor--daemon.h (99%)
 rename fsmonitor-ipc.c => index/fsmonitor-ipc.c (99%)
 rename fsmonitor-ipc.h => index/fsmonitor-ipc.h (100%)
 rename fsmonitor-ll.h => index/fsmonitor-ll.h (100%)
 rename fsmonitor-path-utils.h => index/fsmonitor-path-utils.h (100%)
 rename fsmonitor-settings.c => index/fsmonitor-settings.c (98%)
 rename fsmonitor-settings.h => index/fsmonitor-settings.h (100%)
 rename fsmonitor.c => index/fsmonitor.c (99%)
 rename fsmonitor.h => index/fsmonitor.h (95%)
 rename name-hash.c => index/name-hash.c (99%)
 rename name-hash.h => index/name-hash.h (100%)
 rename parallel-checkout.c => index/parallel-checkout.c (99%)
 rename parallel-checkout.h => index/parallel-checkout.h (100%)
 rename pathspec.c => index/pathspec.c (99%)
 rename pathspec.h => index/pathspec.h (100%)
 rename preload-index.c => index/preload-index.c (96%)
 rename preload-index.h => index/preload-index.h (100%)
 rename read-cache-ll.h => index/read-cache-ll.h (99%)
 rename read-cache.c => index/read-cache.c (99%)
 rename read-cache.h => index/read-cache.h (95%)
 rename resolve-undo.c => index/resolve-undo.c (97%)
 rename resolve-undo.h => index/resolve-undo.h (100%)
 rename sparse-index.c => index/sparse-index.c (99%)
 rename sparse-index.h => index/sparse-index.h (100%)
 rename split-index.c => index/split-index.c (99%)
 rename split-index.h => index/split-index.h (100%)
 rename statinfo.c => index/statinfo.c (99%)
 rename statinfo.h => index/statinfo.h (100%)
 rename symlinks.c => index/symlinks.c (99%)
 rename symlinks.h => index/symlinks.h (100%)
 rename unpack-trees.c => index/unpack-trees.c (99%)
 rename unpack-trees.h => index/unpack-trees.h (99%)
 rename wt-status.c => index/wt-status.c (99%)
 rename wt-status.h => index/wt-status.h (99%)

diff --git a/.gitorganize b/.gitorganize
index d62d0a2240..fe81c40f09 100644
--- a/.gitorganize
+++ b/.gitorganize
@@ -48,12 +48,8 @@ bundle-uri.c component=transport role=lib prefix=bundle-uri includes=transport:5
 bundle-uri.h component=transport role=header prefix=bundle-uri cochange=transport:14
 bundle.c component=transport role=lib prefix=bundle includes=odb:3,revision:3,setup:2,transport:2,diff:1 cochange=transport:63,odb:24,revision:21,refs:17,pack:10
 bundle.h component=transport role=header prefix=bundle includes=revision:1 cochange=transport:37,revision:5
-cache-tree.c component=index role=lib prefix=cache-tree includes=odb:5,index:2,setup:1,transport:1 cochange=index:94,odb:69,revision:27,transport:21,diff:20
-cache-tree.h component=index role=header prefix=cache-tree includes=odb:2 cochange=index:42,diff:4,revision:4,odb:3,refs:1
 chdir-notify.c component=? role=lib prefix=chdir-notify includes=revision:1 cochange=index:2,archive:1,merge:1,revision:1
 chdir-notify.h component=? role=public prefix=chdir-notify
-checkout.c component=index role=lib prefix=checkout includes=setup:2,index:1,odb:1,refs:1,transport:1 cochange=transport:16,refs:6,setup:5,index:3,odb:2
-checkout.h component=index role=header prefix=checkout includes=odb:1 cochange=index:4,diff:1,odb:1,refs:1,revision:1
 color.c component=? role=lib prefix=color includes=setup:1 cochange=diff:21,index:14,revision:13,setup:7,transport:7
 color.h component=? role=public prefix=color cochange=diff:18,index:12,revision:12,transport:2,odb:1
 column.c component=? role=lib prefix=column includes=setup:1 cochange=transport:6,setup:5,diff:4,revision:3,index:2
@@ -105,14 +101,8 @@ diff/userdiff.c component=diff role=lib prefix=userdiff includes=setup:2,convert
 diff/userdiff.h component=diff role=header prefix=diff includes=notes:1 cochange=diff:40,notes:2,archive:1,merge:1,revision:1
 diff/xdiff-interface.c component=diff role=lib prefix=xdiff-interface includes=setup:2,diff:1,odb:1 cochange=diff:73,index:5,merge:3,notes:3,refs:3
 diff/xdiff-interface.h component=diff role=header prefix=xdiff-interface includes=odb:1 cochange=diff:62,index:2,notes:2,merge:1,odb:1
-dir-iterator.c component=index role=lib prefix=dir-iterator includes=index:2 cochange=index:7,refs:1
-dir-iterator.h component=index role=header prefix=dir-iterator cochange=index:7,refs:1
-dir.c component=index role=lib prefix=dir includes=index:7,setup:4,odb:2,convert:1,refs:1 cochange=index:343,diff:61,setup:49,odb:37,convert:29
-dir.h component=index role=header prefix=dir includes=index:2,odb:1 cochange=index:236,odb:13,setup:12,submodule:11,convert:10
 editor.c component=? role=lib prefix=editor includes=setup:2 cochange=transport:20,setup:12,index:8,odb:4,submodule:4
 editor.h component=? role=public prefix=editor cochange=transport:1
-entry.c component=index role=lib prefix=entry includes=index:7,odb:1,setup:1,submodule:1 cochange=index:96,diff:28,convert:20,setup:17,odb:10
-entry.h component=index role=header prefix=entry includes=convert:1 cochange=index:18,submodule:4,revision:3,transport:2,convert:1
 environment.c component=setup role=lib prefix=environment includes=setup:5,convert:3,odb:2,merge:1,refs:1 cochange=setup:281,index:77,odb:48,refs:36,transport:28
 environment.h component=setup role=header prefix=environment includes=setup:1 cochange=setup:135,index:37,odb:15,refs:11,pack:9
 exec-cmd.c component=? role=lib prefix=strvec includes=setup:1
@@ -126,15 +116,6 @@ fetch-pack.h component=transport role=header prefix=fetch-pack includes=odb:1,re
 fmt-merge-msg.c component=merge role=lib prefix=fmt-merge-msg includes=odb:3,diff:2,revision:2,setup:2,merge:1 cochange=revision:10,odb:7,index:6,diff:4,setup:4
 fmt-merge-msg.h component=merge role=header prefix=fmt-merge-msg cochange=merge:3,setup:2
 for-each-ref.h component=? role=public prefix=?
-fsmonitor--daemon.h component=index role=header prefix=fsmonitor--daemon includes=index:1 cochange=index:1
-fsmonitor-ipc.c component=index role=lib prefix=fsmonitor includes=index:1,setup:1 cochange=index:6,transport:2,merge:1,notes:1,pack:1
-fsmonitor-ipc.h component=index role=header prefix=fsmonitor cochange=index:2
-fsmonitor-ll.h component=index role=header prefix=fsmonitor-ll cochange=index:4
-fsmonitor-path-utils.h component=index role=header prefix=fsmonitor cochange=index:2
-fsmonitor-settings.c component=index role=lib prefix=fsmonitor includes=index:3,setup:2 cochange=index:17,setup:10,transport:2,diff:1,odb:1
-fsmonitor-settings.h component=index role=header prefix=fsmonitor-settings cochange=index:11,setup:4
-fsmonitor.c component=index role=lib prefix=fsmonitor includes=index:4,setup:3 cochange=index:37,setup:16,transport:4,merge:2,refs:2
-fsmonitor.h component=index role=header prefix=fsmonitor includes=index:4,odb:1 cochange=index:24,setup:7,diff:3,submodule:1
 gettext.c component=? role=lib prefix=gettext includes=setup:1 cochange=pack:5,refs:3,setup:2,transport:2,merge:1
 gettext.h component=? role=public prefix=i18n cochange=transport:2,setup:1
 git-compat-util.h component=? role=public prefix=git-compat-util cochange=setup:48,index:35,odb:22,pack:21,diff:17
@@ -165,6 +146,50 @@ http.h component=transport role=header prefix=http includes=transport:1 cochange
 ident.c component=setup role=lib prefix=ident includes=setup:2 cochange=setup:19,revision:10,odb:6,refs:6,pack:4
 ident.h component=setup role=header prefix=ident cochange=setup:3,revision:1
 imap-send.c component=? role=program prefix=imap-send includes=setup:3,transport:1 cochange=transport:47,diff:16,index:16,refs:9,odb:8
+index/cache-tree.c component=index role=lib prefix=cache-tree includes=odb:5,index:2,setup:1,transport:1 cochange=index:94,odb:69,revision:27,transport:21,diff:20
+index/cache-tree.h component=index role=header prefix=cache-tree includes=odb:2 cochange=index:42,diff:4,revision:4,odb:3,refs:1
+index/checkout.c component=index role=lib prefix=checkout includes=setup:2,index:1,odb:1,refs:1,transport:1 cochange=transport:16,refs:6,setup:5,index:3,odb:2
+index/checkout.h component=index role=header prefix=checkout includes=odb:1 cochange=index:4,diff:1,odb:1,refs:1,revision:1
+index/dir-iterator.c component=index role=lib prefix=dir-iterator includes=index:2 cochange=index:7,refs:1
+index/dir-iterator.h component=index role=header prefix=dir-iterator cochange=index:7,refs:1
+index/dir.c component=index role=lib prefix=dir includes=index:7,setup:4,odb:2,convert:1,refs:1 cochange=index:343,diff:61,setup:49,odb:37,convert:29
+index/dir.h component=index role=header prefix=dir includes=index:2,odb:1 cochange=index:236,odb:13,setup:12,submodule:11,convert:10
+index/entry.c component=index role=lib prefix=entry includes=index:7,odb:1,setup:1,submodule:1 cochange=index:96,diff:28,convert:20,setup:17,odb:10
+index/entry.h component=index role=header prefix=entry includes=convert:1 cochange=index:18,submodule:4,revision:3,transport:2,convert:1
+index/fsmonitor--daemon.h component=index role=header prefix=fsmonitor--daemon includes=index:1 cochange=index:1
+index/fsmonitor-ipc.c component=index role=lib prefix=fsmonitor includes=index:1,setup:1 cochange=index:6,transport:2,merge:1,notes:1,pack:1
+index/fsmonitor-ipc.h component=index role=header prefix=fsmonitor cochange=index:2
+index/fsmonitor-ll.h component=index role=header prefix=fsmonitor-ll cochange=index:4
+index/fsmonitor-path-utils.h component=index role=header prefix=fsmonitor cochange=index:2
+index/fsmonitor-settings.c component=index role=lib prefix=fsmonitor includes=index:3,setup:2 cochange=index:17,setup:10,transport:2,diff:1,odb:1
+index/fsmonitor-settings.h component=index role=header prefix=fsmonitor-settings cochange=index:11,setup:4
+index/fsmonitor.c component=index role=lib prefix=fsmonitor includes=index:4,setup:3 cochange=index:37,setup:16,transport:4,merge:2,refs:2
+index/fsmonitor.h component=index role=header prefix=fsmonitor includes=index:4,odb:1 cochange=index:24,setup:7,diff:3,submodule:1
+index/name-hash.c component=index role=lib prefix=name-hash includes=index:3,odb:1,setup:1 cochange=diff:43,index:39,revision:18,setup:14,refs:12
+index/name-hash.h component=index role=header prefix=name-hash cochange=index:7
+index/parallel-checkout.c component=index role=lib prefix=parallel-checkout includes=index:4,odb:1,setup:1,transport:1 cochange=index:26,transport:7,odb:6,diff:3,merge:3
+index/parallel-checkout.h component=index role=header prefix=parallel-checkout includes=convert:1 cochange=index:12,convert:1
+index/pathspec.c component=index role=lib prefix=pathspec includes=index:4,setup:3,convert:1 cochange=index:89,setup:23,convert:16,diff:16,revision:9
+index/pathspec.h component=index role=header prefix=pathspec cochange=index:67,diff:11,odb:9,convert:6,submodule:4
+index/preload-index.c component=index role=lib prefix=preload-index includes=index:6,setup:3 cochange=index:52,setup:15,diff:12,revision:5,merge:3
+index/preload-index.h component=index role=header prefix=preload-index cochange=index:2,setup:1
+index/read-cache-ll.h component=index role=header prefix=read-cache includes=index:1,odb:1 cochange=index:8,diff:1,odb:1,revision:1
+index/read-cache.c component=index role=lib prefix=read-cache includes=index:10,odb:6,setup:4,diff:2,submodule:2 cochange=index:240,odb:81,setup:79,diff:67,pack:46
+index/read-cache.h component=index role=header prefix=read-cache includes=index:2,odb:1,setup:1 cochange=index:4,setup:4,diff:2
+index/resolve-undo.c component=index role=lib prefix=resolve-undo includes=index:4,odb:1 cochange=index:33,merge:5,revision:4,diff:3,notes:2
+index/resolve-undo.h component=index role=header prefix=resolve-undo includes=odb:1 cochange=index:12,merge:3,archive:1,revision:1
+index/sparse-index.c component=index role=lib prefix=sparse-index includes=index:7,setup:3,odb:1 cochange=index:42,setup:17,diff:2,odb:2,revision:1
+index/sparse-index.h component=index role=header prefix=sparse-index cochange=index:16,setup:4,merge:1,revision:1
+index/split-index.c component=index role=lib prefix=split-index includes=index:2,odb:1,setup:1 cochange=index:46,odb:5,revision:4,pack:3,merge:2
+index/split-index.h component=index role=header prefix=split-index includes=odb:1 cochange=index:21,archive:1,merge:1,revision:1
+index/statinfo.c component=index role=lib prefix=environment includes=setup:2,index:1 cochange=index:9,setup:6,diff:2,odb:1,revision:1
+index/statinfo.h component=index role=header prefix=statinfo cochange=index:8,odb:1,revision:1
+index/symlinks.c component=index role=lib prefix=symlinks includes=index:1,setup:1 cochange=index:23,diff:3,archive:2,convert:1,revision:1
+index/symlinks.h component=index role=header prefix=symlinks cochange=index:9,diff:1
+index/unpack-trees.c component=index role=lib prefix=unpack-trees includes=index:11,odb:3,setup:3,submodule:2,convert:1 cochange=index:262,odb:49,diff:41,transport:19,revision:18
+index/unpack-trees.h component=index role=header prefix=unpack-trees includes=convert:1,index:1,odb:1 cochange=index:75,diff:9,odb:6,setup:5,merge:4
+index/wt-status.c component=index role=lib prefix=wt-status includes=odb:5,index:4,setup:3,diff:2,refs:2 cochange=index:149,diff:83,transport:55,refs:45,revision:45
+index/wt-status.h component=index role=header prefix=wt-status includes=index:1,transport:1 cochange=index:89,diff:10,refs:9,revision:4,transport:4
 iterator.h component=? role=public prefix=refs cochange=index:2,refs:2
 json-writer.c component=? role=lib prefix=json-writer
 json-writer.h component=? role=public prefix=json-writer cochange=transport:1
@@ -194,8 +219,6 @@ merge-ort.h component=merge role=header prefix=merge-ort includes=odb:1 cochange
 merge.c component=merge role=lib prefix=merge includes=odb:4,index:2,merge:1,setup:1 cochange=index:22,merge:6,setup:4,diff:2,odb:2
 merge.h component=merge role=header prefix=merge cochange=merge:1
 mergesort.h component=? role=public prefix=mergesort cochange=odb:1
-name-hash.c component=index role=lib prefix=name-hash includes=index:3,odb:1,setup:1 cochange=diff:43,index:39,revision:18,setup:14,refs:12
-name-hash.h component=index role=header prefix=name-hash cochange=index:7
 notes-cache.c component=notes role=lib prefix=notes includes=odb:3,notes:1,refs:1,revision:1,setup:1 cochange=notes:37,odb:29,diff:10,index:10,revision:9
 notes-cache.h component=notes role=header prefix=notes-cache includes=notes:1 cochange=diff:7,notes:3
 notes-merge.c component=notes role=lib prefix=notes-merge includes=odb:4,diff:3,notes:3,index:1,merge:1 cochange=diff:54,revision:41,odb:37,notes:36,index:30
@@ -300,8 +323,6 @@ pack/server-info.c component=pack role=lib prefix=server-info includes=odb:5,pac
 pack/server-info.h component=pack role=header prefix=server-info cochange=pack:2
 pager.c component=? role=lib prefix=pager includes=setup:4 cochange=setup:23,diff:9,transport:7,revision:3,submodule:3
 pager.h component=? role=public prefix=pager cochange=diff:3,setup:2,revision:1
-parallel-checkout.c component=index role=lib prefix=parallel-checkout includes=index:4,odb:1,setup:1,transport:1 cochange=index:26,transport:7,odb:6,diff:3,merge:3
-parallel-checkout.h component=index role=header prefix=parallel-checkout includes=convert:1 cochange=index:12,convert:1
 parse-options-cb.c component=? role=lib prefix=parse-options includes=odb:3,setup:2 cochange=revision:10,transport:10,diff:7,odb:4,refs:3
 parse-options.c component=? role=lib prefix=parse-options cochange=index:14,diff:12,setup:10,transport:10,odb:6
 parse-options.h component=? role=public prefix=parse-options cochange=diff:7,merge:4,archive:3,index:3,refs:3
@@ -311,12 +332,8 @@ path-walk.c component=? role=lib prefix=path-walk includes=odb:9,revision:3,inde
 path-walk.h component=? role=public prefix=path-walk includes=odb:1 cochange=index:2
 path.c component=? role=lib prefix=path includes=setup:2,index:1,odb:1,pack:1,refs:1 cochange=setup:78,refs:29,index:26,transport:15,odb:12
 path.h component=? role=public prefix=path includes=setup:1 cochange=setup:23,refs:13,odb:11,index:10,pack:8
-pathspec.c component=index role=lib prefix=pathspec includes=index:4,setup:3,convert:1 cochange=index:89,setup:23,convert:16,diff:16,revision:9
-pathspec.h component=index role=header prefix=pathspec cochange=index:67,diff:11,odb:9,convert:6,submodule:4
 pkt-line.c component=transport role=lib prefix=pkt-line includes=transport:2 cochange=transport:102,pack:6,convert:5,diff:5,odb:3
 pkt-line.h component=transport role=header prefix=pkt-line cochange=transport:94,pack:5,convert:4,odb:2,diff:1
-preload-index.c component=index role=lib prefix=preload-index includes=index:6,setup:3 cochange=index:52,setup:15,diff:12,revision:5,merge:3
-preload-index.h component=index role=header prefix=preload-index cochange=index:2,setup:1
 prio-queue.c component=? role=lib prefix=prio-queue cochange=odb:5,revision:5,diff:2,pack:2,transport:2
 prio-queue.h component=? role=public prefix=prio-queue cochange=odb:3,revision:2,transport:2,pack:1
 progress.c component=? role=lib prefix=progress includes=setup:1 cochange=index:11,diff:6,setup:6,pack:4,revision:2
@@ -331,9 +348,6 @@ protocol.c component=transport role=lib prefix=protocol includes=setup:2,transpo
 protocol.h component=transport role=header prefix=protocol cochange=transport:5
 quote.c component=? role=lib prefix=quote cochange=index:15,diff:12,transport:7,odb:6,revision:6
 quote.h component=? role=public prefix=quote cochange=diff:8,transport:6,index:5,odb:5,refs:5
-read-cache-ll.h component=index role=header prefix=read-cache includes=index:1,odb:1 cochange=index:8,diff:1,odb:1,revision:1
-read-cache.c component=index role=lib prefix=read-cache includes=index:10,odb:6,setup:4,diff:2,submodule:2 cochange=index:240,odb:81,setup:79,diff:67,pack:46
-read-cache.h component=index role=header prefix=read-cache includes=index:2,odb:1,setup:1 cochange=index:4,setup:4,diff:2
 rebase-interactive.c component=? role=lib prefix=rebase-interactive includes=odb:3,setup:3,index:1 cochange=revision:4,transport:4,index:3,odb:3,merge:2
 rebase-interactive.h component=? role=public prefix=rebase-interactive
 rebase.c component=? role=lib prefix=rebase cochange=index:3,pack:3,setup:2,convert:1,diff:1
@@ -367,8 +381,6 @@ rerere.c component=merge role=lib prefix=rerere includes=index:4,merge:2,odb:2,s
 rerere.h component=merge role=header prefix=rerere cochange=merge:16,odb:1
 reset.c component=? role=lib prefix=reset includes=odb:3,index:2,refs:1,setup:1 cochange=index:9,merge:5,odb:3,notes:2,revision:2
 reset.h component=? role=public prefix=reset includes=odb:1,setup:1
-resolve-undo.c component=index role=lib prefix=resolve-undo includes=index:4,odb:1 cochange=index:33,merge:5,revision:4,diff:3,notes:2
-resolve-undo.h component=index role=header prefix=resolve-undo includes=odb:1 cochange=index:12,merge:3,archive:1,revision:1
 revision/bisect.c component=revision role=lib prefix=bisect includes=odb:5,revision:5,setup:2,diff:1,index:1 cochange=revision:61,odb:32,transport:31,refs:13,diff:9
 revision/bisect.h component=revision role=header prefix=bisect cochange=revision:29,odb:2
 revision/blame.c component=revision role=lib prefix=blame includes=odb:5,diff:2,index:2,pack:2,revision:2 cochange=diff:68,revision:66,odb:56,index:29,pack:22
@@ -420,13 +432,7 @@ sideband.h component=transport role=header prefix=sideband cochange=transport:23
 sigchain.c component=? role=lib prefix=sigchain cochange=diff:2,transport:1
 sigchain.h component=? role=public prefix=sigchain cochange=diff:2
 simple-ipc.h component=? role=public prefix=simple-ipc includes=transport:1 cochange=submodule:1
-sparse-index.c component=index role=lib prefix=sparse-index includes=index:7,setup:3,odb:1 cochange=index:42,setup:17,diff:2,odb:2,revision:1
-sparse-index.h component=index role=header prefix=sparse-index cochange=index:16,setup:4,merge:1,revision:1
-split-index.c component=index role=lib prefix=split-index includes=index:2,odb:1,setup:1 cochange=index:46,odb:5,revision:4,pack:3,merge:2
-split-index.h component=index role=header prefix=split-index includes=odb:1 cochange=index:21,archive:1,merge:1,revision:1
 stable-qsort.c component=? role=lib prefix=stable-qsort
-statinfo.c component=index role=lib prefix=environment includes=setup:2,index:1 cochange=index:9,setup:6,diff:2,odb:1,revision:1
-statinfo.h component=index role=header prefix=statinfo cochange=index:8,odb:1,revision:1
 strbuf.c component=? role=lib prefix=strbuf cochange=index:16,odb:12,setup:11,revision:10,transport:10
 strbuf.h component=? role=public prefix=strbuf cochange=revision:15,index:14,odb:14,diff:7,setup:7
 string-list.c component=? role=lib prefix=string-list cochange=transport:14,index:8,notes:7,refs:7,diff:5
@@ -441,8 +447,6 @@ submodule-config.c component=submodule role=lib prefix=submodule-config includes
 submodule-config.h component=submodule role=header prefix=submodule-config includes=odb:1,setup:1,submodule:1 cochange=submodule:54,setup:9,odb:3,diff:2,index:2
 submodule.c component=submodule role=lib prefix=submodule includes=odb:5,setup:4,diff:2,index:2,refs:2 cochange=submodule:134,diff:83,setup:66,index:60,revision:49
 submodule.h component=submodule role=header prefix=submodule cochange=submodule:128,index:22,diff:21,transport:17,setup:6
-symlinks.c component=index role=lib prefix=symlinks includes=index:1,setup:1 cochange=index:23,diff:3,archive:2,convert:1,revision:1
-symlinks.h component=index role=header prefix=symlinks cochange=index:9,diff:1
 tar.h component=? role=public prefix=tar-tree
 tempfile.c component=? role=lib prefix=tempfile cochange=pack:5,setup:4,index:3,odb:3,revision:3
 tempfile.h component=? role=public prefix=tempfile includes=revision:1 cochange=revision:3,diff:2,index:2,setup:2
@@ -463,8 +467,6 @@ unix-socket.c component=? role=lib prefix=unix-socket cochange=diff:3,revision:2
 unix-socket.h component=? role=public prefix=unix-socket
 unix-stream-server.c component=? role=lib prefix=unix-stream-server
 unix-stream-server.h component=? role=public prefix=unix-stream-server
-unpack-trees.c component=index role=lib prefix=unpack-trees includes=index:11,odb:3,setup:3,submodule:2,convert:1 cochange=index:262,odb:49,diff:41,transport:19,revision:18
-unpack-trees.h component=index role=header prefix=unpack-trees includes=convert:1,index:1,odb:1 cochange=index:75,diff:9,odb:6,setup:5,merge:4
 upload-pack.c component=transport role=lib prefix=upload-pack includes=transport:6,odb:4,revision:4,setup:4,diff:1 cochange=transport:198,odb:88,revision:80,refs:55,pack:34
 upload-pack.h component=transport role=header prefix=upload-pack cochange=transport:18,refs:5,submodule:1
 url.c component=? role=lib prefix=url cochange=transport:12,revision:8,diff:6,index:2,refs:2
@@ -490,5 +492,3 @@ write-or-die.c component=? role=lib prefix=write-or-die cochange=pack:6,setup:6,
 write-or-die.h component=? role=public prefix=write-or-die
 ws.c component=convert role=lib prefix=whitespace includes=convert:2 cochange=convert:24,diff:18,archive:9,index:5,setup:5
 ws.h component=convert role=header prefix=whitespace cochange=diff:5,convert:2,setup:2
-wt-status.c component=index role=lib prefix=wt-status includes=odb:5,index:4,setup:3,diff:2,refs:2 cochange=index:149,diff:83,transport:55,refs:45,revision:45
-wt-status.h component=index role=header prefix=wt-status includes=index:1,transport:1 cochange=index:89,diff:10,refs:9,revision:4,transport:4
diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
index 2da56ca8fc..63468494c1 100644
--- a/Documentation/MyFirstContribution.adoc
+++ b/Documentation/MyFirstContribution.adoc
@@ -390,7 +390,7 @@ to `repo_config()`. Let's modify the code we wrote in the previous commit.
 Be sure to include the header to allow you to use `struct wt_status`:
 
 ----
-#include "wt-status.h"
+#include "index/wt-status.h"
 ----
 
 Then modify your `cmd_psuh` implementation to declare your `struct wt_status`,
diff --git a/Makefile b/Makefile
index 74013e8380..5e404ffa5e 100644
--- a/Makefile
+++ b/Makefile
@@ -1117,10 +1117,10 @@ LIB_OBJS += pack/bloom.o
 LIB_OBJS += branch.o
 LIB_OBJS += bundle-uri.o
 LIB_OBJS += bundle.o
-LIB_OBJS += cache-tree.o
+LIB_OBJS += index/cache-tree.o
 LIB_OBJS += odb/cbtree.o
 LIB_OBJS += chdir-notify.o
-LIB_OBJS += checkout.o
+LIB_OBJS += index/checkout.o
 LIB_OBJS += pack/chunk-format.o
 LIB_OBJS += color.o
 LIB_OBJS += column.o
@@ -1158,10 +1158,10 @@ LIB_OBJS += diff/diffcore-order.o
 LIB_OBJS += diff/diffcore-pickaxe.o
 LIB_OBJS += diff/diffcore-rename.o
 LIB_OBJS += diff/diffcore-rotate.o
-LIB_OBJS += dir-iterator.o
-LIB_OBJS += dir.o
+LIB_OBJS += index/dir-iterator.o
+LIB_OBJS += index/dir.o
 LIB_OBJS += editor.o
-LIB_OBJS += entry.o
+LIB_OBJS += index/entry.o
 LIB_OBJS += environment.o
 LIB_OBJS += ewah/bitmap.o
 LIB_OBJS += ewah/ewah_bitmap.o
@@ -1173,9 +1173,9 @@ LIB_OBJS += fetch-object-info.o
 LIB_OBJS += fetch-pack.o
 LIB_OBJS += fmt-merge-msg.o
 LIB_OBJS += odb/fsck.o
-LIB_OBJS += fsmonitor.o
-LIB_OBJS += fsmonitor-ipc.o
-LIB_OBJS += fsmonitor-settings.o
+LIB_OBJS += index/fsmonitor.o
+LIB_OBJS += index/fsmonitor-ipc.o
+LIB_OBJS += index/fsmonitor-settings.o
 LIB_OBJS += gettext.o
 LIB_OBJS += git-zlib.o
 LIB_OBJS += gpg-interface.o
@@ -1213,7 +1213,7 @@ LIB_OBJS += merge-ort-wrappers.o
 LIB_OBJS += merge.o
 LIB_OBJS += pack/midx.o
 LIB_OBJS += pack/midx-write.o
-LIB_OBJS += name-hash.o
+LIB_OBJS += index/name-hash.o
 LIB_OBJS += negotiator/default.o
 LIB_OBJS += negotiator/noop.o
 LIB_OBJS += negotiator/skipping.o
@@ -1252,7 +1252,7 @@ LIB_OBJS += pack/pack-write.o
 LIB_OBJS += pack/packfile.o
 LIB_OBJS += pack/packfile-list.o
 LIB_OBJS += pager.o
-LIB_OBJS += parallel-checkout.o
+LIB_OBJS += index/parallel-checkout.o
 LIB_OBJS += parse.o
 LIB_OBJS += parse-options-cb.o
 LIB_OBJS += parse-options.o
@@ -1260,9 +1260,9 @@ LIB_OBJS += pack/patch-delta.o
 LIB_OBJS += diff/patch-ids.o
 LIB_OBJS += path.o
 LIB_OBJS += path-walk.o
-LIB_OBJS += pathspec.o
+LIB_OBJS += index/pathspec.o
 LIB_OBJS += pkt-line.o
-LIB_OBJS += preload-index.o
+LIB_OBJS += index/preload-index.o
 LIB_OBJS += revision/pretty.o
 LIB_OBJS += prio-queue.o
 LIB_OBJS += progress.o
@@ -1275,7 +1275,7 @@ LIB_OBJS += pack/pseudo-merge.o
 LIB_OBJS += quote.o
 LIB_OBJS += diff/range-diff.o
 LIB_OBJS += pack/reachable.o
-LIB_OBJS += read-cache.o
+LIB_OBJS += index/read-cache.o
 LIB_OBJS += rebase-interactive.o
 LIB_OBJS += rebase.o
 LIB_OBJS += refs/ref-filter.o
@@ -1316,7 +1316,7 @@ LIB_OBJS += repo-settings.o
 LIB_OBJS += repository.o
 LIB_OBJS += rerere.o
 LIB_OBJS += reset.o
-LIB_OBJS += resolve-undo.o
+LIB_OBJS += index/resolve-undo.o
 LIB_OBJS += revision/revision.o
 LIB_OBJS += run-command.o
 LIB_OBJS += send-pack.o
@@ -1327,10 +1327,10 @@ LIB_OBJS += setup.o
 LIB_OBJS += revision/shallow.o
 LIB_OBJS += sideband.o
 LIB_OBJS += sigchain.o
-LIB_OBJS += sparse-index.o
-LIB_OBJS += split-index.o
+LIB_OBJS += index/sparse-index.o
+LIB_OBJS += index/split-index.o
 LIB_OBJS += stable-qsort.o
-LIB_OBJS += statinfo.o
+LIB_OBJS += index/statinfo.o
 LIB_OBJS += strbuf.o
 LIB_OBJS += string-list.o
 LIB_OBJS += strmap.o
@@ -1338,7 +1338,7 @@ LIB_OBJS += strvec.o
 LIB_OBJS += sub-process.o
 LIB_OBJS += submodule-config.o
 LIB_OBJS += submodule.o
-LIB_OBJS += symlinks.o
+LIB_OBJS += index/symlinks.o
 LIB_OBJS += odb/tag.o
 LIB_OBJS += tempfile.o
 LIB_OBJS += thread-utils.o
@@ -1363,7 +1363,7 @@ LIB_OBJS += transport.o
 LIB_OBJS += diff/tree-diff.o
 LIB_OBJS += odb/tree-walk.o
 LIB_OBJS += odb/tree.o
-LIB_OBJS += unpack-trees.o
+LIB_OBJS += index/unpack-trees.o
 LIB_OBJS += upload-pack.o
 LIB_OBJS += url.o
 LIB_OBJS += urlmatch.o
@@ -1381,7 +1381,7 @@ LIB_OBJS += refs/worktree.o
 LIB_OBJS += wrapper.o
 LIB_OBJS += write-or-die.o
 LIB_OBJS += ws.o
-LIB_OBJS += wt-status.o
+LIB_OBJS += index/wt-status.o
 LIB_OBJS += diff/xdiff-interface.o
 LIB_OBJS += xdiff/xdiffi.o
 LIB_OBJS += xdiff/xemit.o
@@ -3219,7 +3219,7 @@ LOCALIZED_C_CORE += builtin/index-pack.c
 LOCALIZED_C_CORE += builtin/push.c
 LOCALIZED_C_CORE += builtin/reset.c
 LOCALIZED_C_CORE += remote.c
-LOCALIZED_C_CORE += wt-status.c
+LOCALIZED_C_CORE += index/wt-status.c
 
 LOCALIZED_C_CORE_GEN_PO = $(LOCALIZED_C_CORE:%=.build/pot/po/%.po)
 
diff --git a/add-interactive.c b/add-interactive.c
index 7bfc410361..5f4d379910 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -7,14 +7,14 @@
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
-#include "preload-index.h"
-#include "read-cache-ll.h"
+#include "index/preload-index.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "revision/revision.h"
 #include "refs/refs.h"
 #include "string-list.h"
 #include "lockfile.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "run-command.h"
 #include "prompt.h"
 #include "odb/tree.h"
diff --git a/add-patch.c b/add-patch.c
index c6860310c1..0499152dbc 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -13,13 +13,13 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "pager.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "strbuf.h"
 #include "sigchain.h"
 #include "run-command.h"
 #include "strvec.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "color.h"
 #include "compat/terminal.h"
 #include "prompt.h"
diff --git a/apply.c b/apply.c
index b8d97d140d..70d5461fbe 100644
--- a/apply.c
+++ b/apply.c
@@ -17,26 +17,26 @@
 #include "odb/odb.h"
 #include "pack/delta.h"
 #include "diff/diff.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "diff/xdiff-interface.h"
 #include "merge-ll.h"
 #include "lockfile.h"
-#include "name-hash.h"
+#include "index/name-hash.h"
 #include "odb/object-name.h"
 #include "odb/object-file.h"
 #include "parse-options.h"
 #include "path.h"
 #include "quote.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 #include "repository.h"
 #include "rerere.h"
 #include "apply.h"
-#include "entry.h"
+#include "index/entry.h"
 #include "setup.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "wildmatch.h"
 #include "ws.h"
 
diff --git a/archive.c b/archive.c
index a2402fb7e6..e6fdd2ea8f 100644
--- a/archive.c
+++ b/archive.c
@@ -21,7 +21,7 @@
 #include "attr.h"
 #include "archive.h"
 #include "parse-options.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 #include "quote.h"
 
 static char const * const archive_usage[] = {
diff --git a/archive.h b/archive.h
index bbe65ba0f9..d1496a485b 100644
--- a/archive.h
+++ b/archive.h
@@ -1,7 +1,7 @@
 #ifndef ARCHIVE_H
 #define ARCHIVE_H
 
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "string-list.h"
 
 struct repository;
diff --git a/attr.c b/attr.c
index e7d364d490..841d2f23ae 100644
--- a/attr.c
+++ b/attr.c
@@ -14,12 +14,12 @@
 #include "environment.h"
 #include "exec-cmd.h"
 #include "attr.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "gettext.h"
 #include "path.h"
 #include "utf8.h"
 #include "quote.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "refs/refs.h"
 #include "revision/revision.h"
 #include "odb/odb.h"
diff --git a/builtin/add.c b/builtin/add.c
index 4dbdccd928..e544220eb2 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -10,18 +10,18 @@
 #include "environment.h"
 #include "lockfile.h"
 #include "editor.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "gettext.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "run-command.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/transaction.h"
 #include "parse-options.h"
 #include "path.h"
-#include "preload-index.h"
+#include "index/preload-index.h"
 #include "diff/diff.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 #include "revision/revision.h"
 #include "strvec.h"
 #include "submodule.h"
diff --git a/builtin/am.c b/builtin/am.c
index 5dbe1f171b..0b6d77004f 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -15,20 +15,20 @@
 #include "gettext.h"
 #include "hex.h"
 #include "parse-options.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "run-command.h"
 #include "hook.h"
 #include "quote.h"
 #include "tempfile.h"
 #include "lockfile.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "refs/refs.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 #include "branch.h"
 #include "odb/object-name.h"
-#include "preload-index.h"
+#include "index/preload-index.h"
 #include "sequencer.h"
 #include "revision/revision.h"
 #include "merge-ort-wrappers.h"
diff --git a/builtin/backfill.c b/builtin/backfill.c
index d2ef39bc58..b8e21c844c 100644
--- a/builtin/backfill.c
+++ b/builtin/backfill.c
@@ -7,7 +7,7 @@
 #include "parse-options.h"
 #include "repository.h"
 #include "odb/commit.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "hex.h"
 #include "odb/tree.h"
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 644c9a414f..1d2c3cb8db 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -1,11 +1,11 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "quote.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "parse-options.h"
 #include "submodule.h"
 #include "write-or-die.h"
diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c
index e0772b718b..9c49474753 100644
--- a/builtin/checkout--worker.c
+++ b/builtin/checkout--worker.c
@@ -3,13 +3,13 @@
 
 #include "builtin.h"
 #include "config.h"
-#include "entry.h"
+#include "index/entry.h"
 #include "environment.h"
 #include "gettext.h"
-#include "parallel-checkout.h"
+#include "index/parallel-checkout.h"
 #include "parse-options.h"
 #include "pkt-line.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 
 static void packet_to_pc_item(const char *buffer, int len,
 			      struct parallel_checkout_item *pc_item)
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 311b94ff31..c659e5c764 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -13,13 +13,13 @@
 #include "gettext.h"
 #include "lockfile.h"
 #include "quote.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "parse-options.h"
-#include "entry.h"
-#include "parallel-checkout.h"
-#include "read-cache-ll.h"
+#include "index/entry.h"
+#include "index/parallel-checkout.h"
+#include "index/read-cache-ll.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 
 #define CHECKOUT_ALL 4
 static int nul_term_line;
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 286fcdc1ba..48882b0f8e 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -4,12 +4,12 @@
 #include "builtin.h"
 #include "advice.h"
 #include "branch.h"
-#include "cache-tree.h"
-#include "checkout.h"
+#include "index/cache-tree.h"
+#include "index/checkout.h"
 #include "odb/commit.h"
 #include "config.h"
 #include "diff/diff.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
@@ -22,27 +22,27 @@
 #include "odb/odb.h"
 #include "parse-options.h"
 #include "path.h"
-#include "preload-index.h"
-#include "read-cache.h"
+#include "index/preload-index.h"
+#include "index/read-cache.h"
 #include "refs/refs.h"
 #include "remote.h"
 #include "repo-settings.h"
-#include "resolve-undo.h"
+#include "index/resolve-undo.h"
 #include "revision/revision.h"
 #include "sequencer.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "strvec.h"
 #include "submodule.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "trace2.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "unpack-trees.h"
-#include "wt-status.h"
+#include "index/unpack-trees.h"
+#include "index/wt-status.h"
 #include "diff/xdiff-interface.h"
-#include "entry.h"
-#include "parallel-checkout.h"
+#include "index/entry.h"
+#include "index/parallel-checkout.h"
 #include "add-interactive.h"
 
 struct checkout_opts {
diff --git a/builtin/clean.c b/builtin/clean.c
index 1d5e7e5366..81b3b86491 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -12,18 +12,18 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "path.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "setup.h"
 #include "string-list.h"
 #include "quote.h"
 #include "column.h"
 #include "color.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "help.h"
 #include "prompt.h"
 
diff --git a/builtin/clone.c b/builtin/clone.c
index 8ed07e1a15..58cf9761a0 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -28,11 +28,11 @@
 #include "odb/odb.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 #include "transport.h"
 #include "strbuf.h"
-#include "dir.h"
-#include "dir-iterator.h"
+#include "index/dir.h"
+#include "index/dir-iterator.h"
 #include "iterator.h"
 #include "sigchain.h"
 #include "branch.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index aa89e0dc52..85ab748ff0 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -12,9 +12,9 @@
 #include "advice.h"
 #include "config.h"
 #include "lockfile.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "color.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "editor.h"
 #include "environment.h"
 #include "diff/diff.h"
@@ -22,21 +22,21 @@
 #include "add-interactive.h"
 #include "gettext.h"
 #include "revision/revision.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
-#include "preload-index.h"
-#include "read-cache.h"
+#include "index/preload-index.h"
+#include "index/read-cache.h"
 #include "repository.h"
 #include "string-list.h"
 #include "rerere.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 #include "column.h"
 #include "sequencer.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "mailmap.h"
 #include "help.h"
 #include "revision/commit-reach.h"
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index 45a7a61cd3..cf10ddcae1 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -6,7 +6,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "path.h"
diff --git a/builtin/describe.c b/builtin/describe.c
index bbeba1e465..c22158d157 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -12,7 +12,7 @@
 #include "refs/refs.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "revision/revision.h"
 #include "diff/diff.h"
 #include "hashmap.h"
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index d1e8d2b462..1f67480362 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -12,7 +12,7 @@
 #include "diff/diff.h"
 #include "diff/diff-merges.h"
 #include "odb/commit.h"
-#include "preload-index.h"
+#include "index/preload-index.h"
 #include "revision/revision.h"
 
 static const char diff_files_usage[] =
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index f3b2eadda0..dac8099081 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -6,7 +6,7 @@
 #include "diff/diff.h"
 #include "diff/diff-merges.h"
 #include "odb/commit.h"
-#include "preload-index.h"
+#include "index/preload-index.h"
 #include "revision/revision.h"
 #include "setup.h"
 
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 2bd5ed4004..8f7f48ac67 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -7,7 +7,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "revision/log-tree.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "revision/revision.h"
 #include "odb/tmp-objdir.h"
 #include "odb/tree.h"
diff --git a/builtin/diff.c b/builtin/diff.c
index e4487901d3..0e8c488408 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -18,8 +18,8 @@
 #include "diff/diff.h"
 #include "diff/diff-merges.h"
 #include "diff/diffcore.h"
-#include "preload-index.h"
-#include "read-cache-ll.h"
+#include "index/preload-index.h"
+#include "index/read-cache-ll.h"
 #include "revision/revision.h"
 #include "revision/log-tree.h"
 #include "setup.h"
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 075112d344..1d3fae8793 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -23,16 +23,16 @@
 #include "hex.h"
 #include "parse-options.h"
 #include "path.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "strvec.h"
 #include "strbuf.h"
 #include "lockfile.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
-#include "dir.h"
-#include "entry.h"
+#include "index/dir.h"
+#include "index/entry.h"
 #include "setup.h"
 
 static const char *const builtin_difftool_usage[] = {
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index f3af94307f..da586c7c63 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -15,11 +15,11 @@
 #include "pack/delta.h"
 #include "pack/pack.h"
 #include "path.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "refs/refs.h"
 #include "csum-file.h"
 #include "quote.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "run-command.h"
 #include "pack/packfile.h"
 #include "odb/object-file.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index a00ca35703..6e8fd0e828 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -8,7 +8,7 @@
 #include "odb/tag.h"
 #include "refs/refs.h"
 #include "pack/pack.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "odb/fsck.h"
 #include "parse-options.h"
 #include "progress.h"
@@ -18,11 +18,11 @@
 #include "odb/odb.h"
 #include "odb/streaming.h"
 #include "path.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "odb/replace-object.h"
-#include "resolve-undo.h"
+#include "index/resolve-undo.h"
 #include "run-command.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "refs/worktree.h"
 #include "pack/pack-revindex.h"
 #include "pack/pack-bitmap.h"
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index 4161dd8282..49b492fba0 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -4,16 +4,16 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "parse-options.h"
-#include "fsmonitor-ll.h"
-#include "fsmonitor-ipc.h"
-#include "fsmonitor-settings.h"
+#include "index/fsmonitor-ll.h"
+#include "index/fsmonitor-ipc.h"
+#include "index/fsmonitor-settings.h"
 #include "compat/fsmonitor/fsm-health.h"
 #include "compat/fsmonitor/fsm-listen.h"
-#include "fsmonitor--daemon.h"
+#include "index/fsmonitor--daemon.h"
 
 #include "simple-ipc.h"
 #include "strmap.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index c340489c64..0243b34e3e 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -16,7 +16,7 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "date.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "hex.h"
 #include "config.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index d13858caec..20cd821af7 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -20,8 +20,8 @@
 #include "run-command.h"
 #include "grep.h"
 #include "quote.h"
-#include "dir.h"
-#include "pathspec.h"
+#include "index/dir.h"
+#include "index/pathspec.h"
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
@@ -33,7 +33,7 @@
 #include "pager.h"
 #include "path.h"
 #include "promisor-remote.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "write-or-die.h"
 
 static const char *grep_prefix;
diff --git a/builtin/history.c b/builtin/history.c
index 73a31ce152..c817745f30 100644
--- a/builtin/history.c
+++ b/builtin/history.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "odb/commit.h"
 #include "revision/commit-reach.h"
 #include "config.h"
@@ -14,7 +14,7 @@
 #include "odb/oidmap.h"
 #include "parse-options.h"
 #include "path.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 #include "refs/refs.h"
 #include "replay.h"
 #include "reset.h"
@@ -23,8 +23,8 @@
 #include "strvec.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "unpack-trees.h"
-#include "wt-status.h"
+#include "index/unpack-trees.h"
+#include "index/wt-status.h"
 
 #define GIT_HISTORY_DROP_USAGE \
 	N_("git history drop <commit> [--dry-run] [--update-refs=(branches|head)] [--empty=(drop|keep|abort)]")
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index fc3f8f4a72..49e8a685e3 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -13,18 +13,18 @@
 #include "convert.h"
 #include "environment.h"
 #include "quote.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "gettext.h"
 #include "odb/object-name.h"
 #include "strbuf.h"
 #include "parse-options.h"
-#include "resolve-undo.h"
+#include "index/resolve-undo.h"
 #include "string-list.h"
 #include "path.h"
-#include "pathspec.h"
-#include "read-cache.h"
+#include "index/pathspec.h"
+#include "index/read-cache.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "submodule.h"
 #include "odb/odb.h"
 #include "hex.h"
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 4f7d1d2b6d..b59c186a21 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -16,7 +16,7 @@
 #include "path.h"
 #include "quote.h"
 #include "parse-options.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 
 static const char * const ls_tree_usage[] = {
 	N_("git ls-tree [<options>] <tree-ish> [<path>...]"),
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index 3314fb1336..a0dafe16dc 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -3,9 +3,9 @@
 
 #include "builtin.h"
 #include "hex.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "run-command.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 
 static const char *pgm;
 static int one_shot, quiet;
diff --git a/builtin/merge.c b/builtin/merge.c
index 268ffc4855..da37fb11eb 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -32,15 +32,15 @@
 #include "diff/diffcore.h"
 #include "path.h"
 #include "revision/revision.h"
-#include "unpack-trees.h"
-#include "cache-tree.h"
-#include "dir.h"
+#include "index/unpack-trees.h"
+#include "index/cache-tree.h"
+#include "index/dir.h"
 #include "color.h"
 #include "rerere.h"
 #include "help.h"
 #include "merge.h"
 #include "merge-ort-wrappers.h"
-#include "resolve-undo.h"
+#include "index/resolve-undo.h"
 #include "remote.h"
 #include "fmt-merge-msg.h"
 #include "sequencer.h"
@@ -49,7 +49,7 @@
 #include "alias.h"
 #include "branch.h"
 #include "revision/commit-reach.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 #include "pack/commit-graph.h"
 
 #define DEFAULT_TWOHEAD (1<<0)
diff --git a/builtin/mv.c b/builtin/mv.c
index e347c100c0..f49eec035e 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -13,21 +13,21 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-#include "name-hash.h"
+#include "index/name-hash.h"
 #include "odb/object-file.h"
 #include "path.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "lockfile.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "string-list.h"
 #include "parse-options.h"
-#include "read-cache-ll.h"
-#include "symlinks.h"
+#include "index/read-cache-ll.h"
+#include "index/symlinks.h"
 
 #include "setup.h"
 #include "strvec.h"
 #include "submodule.h"
-#include "entry.h"
+#include "index/entry.h"
 
 static const char * const builtin_mv_usage[] = {
 	N_("git mv [-v] [-f] [-n] [-k] <source> <destination>"),
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 3b025a08e9..b611b27573 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -36,7 +36,7 @@
 #include "odb/odb.h"
 #include "odb/streaming.h"
 #include "odb/replace-object.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "pack/midx.h"
 #include "trace2.h"
 #include "revision/shallow.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index ba7b1303b3..d2d5bd2619 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -3,7 +3,7 @@
 #include "builtin.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/pull.c b/builtin/pull.c
index af120a7e1b..818ddbf956 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -20,15 +20,15 @@
 #include "run-command.h"
 #include "odb/oid-array.h"
 #include "remote.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "path.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "rebase.h"
 #include "refs/refs.h"
 #include "refs/refspec.h"
 #include "submodule.h"
 #include "submodule-config.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 #include "revision/commit-reach.h"
 #include "sequencer.h"
 
diff --git a/builtin/push.c b/builtin/push.c
index 39b6ff4b8b..280cfd289f 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -8,7 +8,7 @@
 #include "advice.h"
 #include "branch.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 8898354baa..2bc2f43729 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -14,12 +14,12 @@
 #include "odb/object-name.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "cache-tree.h"
-#include "unpack-trees.h"
+#include "index/cache-tree.h"
+#include "index/unpack-trees.h"
 #include "parse-options.h"
-#include "resolve-undo.h"
+#include "index/resolve-undo.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "submodule.h"
 
 static int nr_trees;
diff --git a/builtin/rebase.c b/builtin/rebase.c
index a14a31d60e..62b58da192 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -15,10 +15,10 @@
 #include "hex.h"
 #include "run-command.h"
 #include "strvec.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "refs/refs.h"
 #include "config.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 #include "lockfile.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
@@ -26,7 +26,7 @@
 #include "path.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 #include "revision/revision.h"
 #include "revision/commit-reach.h"
 #include "rerere.h"
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 545ffe2715..4b1b7d49ce 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -9,7 +9,7 @@
 #include "string-list.h"
 #include "xdiff/xdiff.h"
 #include "diff/xdiff-interface.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 
 static const char * const rerere_usage[] = {
 	N_("git rerere [clear | forget <pathspec>... | diff | status | remaining | gc]"),
diff --git a/builtin/reset.c b/builtin/reset.c
index eed0d0ea0b..96c7bf9cf1 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -29,14 +29,14 @@
 #include "parse-options.h"
 #include "path.h"
 #include "repository.h"
-#include "unpack-trees.h"
-#include "cache-tree.h"
+#include "index/unpack-trees.h"
+#include "index/cache-tree.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "submodule.h"
 #include "trace.h"
 #include "trace2.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "add-interactive.h"
 
 #define REFRESH_INDEX_DELAY_WARNING_IN_MS (2 * 1000)
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index ef4b6795dd..1d97c4869b 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -23,12 +23,12 @@
 #include "parse-options.h"
 #include "path.h"
 #include "diff/diff.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repo-settings.h"
 #include "repository.h"
 #include "revision/revision.h"
 #include "setup.h"
-#include "split-index.h"
+#include "index/split-index.h"
 #include "submodule.h"
 #include "revision/commit-reach.h"
 #include "revision/shallow.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index c856b88d09..4f7194f541 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -11,19 +11,19 @@
 #include "config.h"
 #include "environment.h"
 #include "lockfile.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "odb/tree-walk.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 
 #include "string-list.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "submodule.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 
 static const char * const builtin_rm_usage[] = {
 	N_("git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch]\n"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 8db11f6e4c..e0e912439c 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -14,7 +14,7 @@
 #include "odb/object-name.h"
 #include "parse-options.h"
 
-#include "dir.h"
+#include "index/dir.h"
 #include "odb/commit-slab.h"
 #include "date.h"
 #include "wildmatch.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 9b4cad87a5..efe6f7897e 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -4,21 +4,21 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "strbuf.h"
 #include "string-list.h"
 #include "lockfile.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 #include "quote.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "refs/worktree.h"
 
 static const char *empty_base = "";
diff --git a/builtin/stash.c b/builtin/stash.c
index 6458e3a2d6..a8337ffdc4 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -11,20 +11,20 @@
 #include "parse-options.h"
 #include "refs/refs.h"
 #include "lockfile.h"
-#include "cache-tree.h"
-#include "unpack-trees.h"
+#include "index/cache-tree.h"
+#include "index/unpack-trees.h"
 #include "merge-ort-wrappers.h"
 #include "strvec.h"
 #include "run-command.h"
-#include "dir.h"
-#include "entry.h"
-#include "preload-index.h"
-#include "read-cache.h"
+#include "index/dir.h"
+#include "index/entry.h"
+#include "index/preload-index.h"
+#include "index/read-cache.h"
 #include "repository.h"
 #include "rerere.h"
 #include "revision/revision.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "revision/log-tree.h"
 #include "diff/diffcore.h"
 #include "refs/reflog.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 0e061827f9..5226a5f331 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -10,12 +10,12 @@
 #include "parse-options.h"
 #include "quote.h"
 #include "path.h"
-#include "pathspec.h"
-#include "preload-index.h"
-#include "dir.h"
-#include "read-cache.h"
+#include "index/pathspec.h"
+#include "index/preload-index.h"
+#include "index/dir.h"
+#include "index/read-cache.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "submodule.h"
 #include "submodule-config.h"
 #include "string-list.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 54741c3241..b5c8fae02c 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -15,22 +15,22 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "quote.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "odb/tree-walk.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/transaction.h"
 #include "refs/refs.h"
-#include "resolve-undo.h"
+#include "index/resolve-undo.h"
 #include "parse-options.h"
-#include "pathspec.h"
-#include "dir.h"
-#include "read-cache.h"
+#include "index/pathspec.h"
+#include "index/dir.h"
+#include "index/read-cache.h"
 #include "setup.h"
-#include "sparse-index.h"
-#include "split-index.h"
-#include "symlinks.h"
-#include "fsmonitor.h"
+#include "index/sparse-index.h"
+#include "index/split-index.h"
+#include "index/symlinks.h"
+#include "index/fsmonitor.h"
 #include "write-or-die.h"
 
 /*
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 90af2193c1..c4068b45d6 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -4,10 +4,10 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "advice.h"
-#include "checkout.h"
+#include "index/checkout.h"
 #include "config.h"
 #include "copy.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
@@ -17,7 +17,7 @@
 #include "path.h"
 #include "strvec.h"
 #include "branch.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "refs/refs.h"
 #include "remote.h"
 #include "run-command.h"
diff --git a/builtin/write-tree.c b/builtin/write-tree.c
index 2e463ab394..4a2b1ceb58 100644
--- a/builtin/write-tree.c
+++ b/builtin/write-tree.c
@@ -10,7 +10,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/tree.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "parse-options.h"
 
 static const char * const write_tree_usage[] = {
diff --git a/compat/fsmonitor/fsm-health-darwin.c b/compat/fsmonitor/fsm-health-darwin.c
index c2afcbe6c8..f24d56b3d2 100644
--- a/compat/fsmonitor/fsm-health-darwin.c
+++ b/compat/fsmonitor/fsm-health-darwin.c
@@ -1,8 +1,8 @@
 #include "git-compat-util.h"
 #include "config.h"
-#include "fsmonitor-ll.h"
+#include "index/fsmonitor-ll.h"
 #include "fsm-health.h"
-#include "fsmonitor--daemon.h"
+#include "index/fsmonitor--daemon.h"
 
 int fsm_health__ctor(struct fsmonitor_daemon_state *state UNUSED)
 {
diff --git a/compat/fsmonitor/fsm-health-linux.c b/compat/fsmonitor/fsm-health-linux.c
index 43d67c4b8b..7be822fb1c 100644
--- a/compat/fsmonitor/fsm-health-linux.c
+++ b/compat/fsmonitor/fsm-health-linux.c
@@ -1,8 +1,8 @@
 #include "git-compat-util.h"
 #include "config.h"
-#include "fsmonitor-ll.h"
+#include "index/fsmonitor-ll.h"
 #include "fsm-health.h"
-#include "fsmonitor--daemon.h"
+#include "index/fsmonitor--daemon.h"
 
 /*
  * The Linux fsmonitor implementation uses inotify which has its own
diff --git a/compat/fsmonitor/fsm-health-win32.c b/compat/fsmonitor/fsm-health-win32.c
index 2aa8c219ac..09dee50777 100644
--- a/compat/fsmonitor/fsm-health-win32.c
+++ b/compat/fsmonitor/fsm-health-win32.c
@@ -1,8 +1,8 @@
 #include "git-compat-util.h"
 #include "config.h"
-#include "fsmonitor-ll.h"
+#include "index/fsmonitor-ll.h"
 #include "fsm-health.h"
-#include "fsmonitor--daemon.h"
+#include "index/fsmonitor--daemon.h"
 #include "gettext.h"
 #include "simple-ipc.h"
 
diff --git a/compat/fsmonitor/fsm-ipc-unix.c b/compat/fsmonitor/fsm-ipc-unix.c
index fe149a1b37..ffd864ae92 100644
--- a/compat/fsmonitor/fsm-ipc-unix.c
+++ b/compat/fsmonitor/fsm-ipc-unix.c
@@ -7,9 +7,9 @@
 #include "path.h"
 #include "repository.h"
 #include "strbuf.h"
-#include "fsmonitor-ll.h"
-#include "fsmonitor-ipc.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor-ll.h"
+#include "index/fsmonitor-ipc.h"
+#include "index/fsmonitor-path-utils.h"
 
 static GIT_PATH_FUNC(fsmonitor_ipc__get_default_path, "fsmonitor--daemon.ipc")
 
diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c
index 41984ea48e..bc92e1fd20 100644
--- a/compat/fsmonitor/fsm-ipc-win32.c
+++ b/compat/fsmonitor/fsm-ipc-win32.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "config.h"
-#include "fsmonitor-ipc.h"
+#include "index/fsmonitor-ipc.h"
 #include "path.h"
 
 const char *fsmonitor_ipc__get_path(struct repository *r) {
diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c
index 43c3a915a0..fac5256a74 100644
--- a/compat/fsmonitor/fsm-listen-darwin.c
+++ b/compat/fsmonitor/fsm-listen-darwin.c
@@ -24,10 +24,10 @@
 #endif
 
 #include "git-compat-util.h"
-#include "fsmonitor-ll.h"
+#include "index/fsmonitor-ll.h"
 #include "fsm-listen.h"
-#include "fsmonitor--daemon.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor--daemon.h"
+#include "index/fsmonitor-path-utils.h"
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "string-list.h"
diff --git a/compat/fsmonitor/fsm-listen-linux.c b/compat/fsmonitor/fsm-listen-linux.c
index e3dca14b62..0208a6d942 100644
--- a/compat/fsmonitor/fsm-listen-linux.c
+++ b/compat/fsmonitor/fsm-listen-linux.c
@@ -1,9 +1,9 @@
 #include "git-compat-util.h"
-#include "dir.h"
-#include "fsmonitor-ll.h"
+#include "index/dir.h"
+#include "index/fsmonitor-ll.h"
 #include "fsm-listen.h"
-#include "fsmonitor--daemon.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor--daemon.h"
+#include "index/fsmonitor-path-utils.h"
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "string-list.h"
diff --git a/compat/fsmonitor/fsm-listen-win32.c b/compat/fsmonitor/fsm-listen-win32.c
index 9a6efc9bea..c8cbdf4a97 100644
--- a/compat/fsmonitor/fsm-listen-win32.c
+++ b/compat/fsmonitor/fsm-listen-win32.c
@@ -1,8 +1,8 @@
 #include "git-compat-util.h"
 #include "config.h"
-#include "fsmonitor-ll.h"
+#include "index/fsmonitor-ll.h"
 #include "fsm-listen.h"
-#include "fsmonitor--daemon.h"
+#include "index/fsmonitor--daemon.h"
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "trace2.h"
diff --git a/compat/fsmonitor/fsm-path-utils-darwin.c b/compat/fsmonitor/fsm-path-utils-darwin.c
index 049f97eaaf..b67b1262c0 100644
--- a/compat/fsmonitor/fsm-path-utils-darwin.c
+++ b/compat/fsmonitor/fsm-path-utils-darwin.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
-#include "fsmonitor-ll.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor-ll.h"
+#include "index/fsmonitor-path-utils.h"
 #include "gettext.h"
 #include "trace.h"
 #include <dirent.h>
diff --git a/compat/fsmonitor/fsm-path-utils-linux.c b/compat/fsmonitor/fsm-path-utils-linux.c
index c9866b1b24..da62f0b167 100644
--- a/compat/fsmonitor/fsm-path-utils-linux.c
+++ b/compat/fsmonitor/fsm-path-utils-linux.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
-#include "fsmonitor-ll.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor-ll.h"
+#include "index/fsmonitor-path-utils.h"
 #include "gettext.h"
 #include "trace.h"
 
diff --git a/compat/fsmonitor/fsm-path-utils-win32.c b/compat/fsmonitor/fsm-path-utils-win32.c
index f4f9cc1f33..112149cf81 100644
--- a/compat/fsmonitor/fsm-path-utils-win32.c
+++ b/compat/fsmonitor/fsm-path-utils-win32.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
-#include "fsmonitor-ll.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor-ll.h"
+#include "index/fsmonitor-path-utils.h"
 #include "gettext.h"
 #include "trace.h"
 
diff --git a/compat/fsmonitor/fsm-settings-unix.c b/compat/fsmonitor/fsm-settings-unix.c
index a382590635..41106355b1 100644
--- a/compat/fsmonitor/fsm-settings-unix.c
+++ b/compat/fsmonitor/fsm-settings-unix.c
@@ -1,9 +1,9 @@
 #include "git-compat-util.h"
 #include "config.h"
-#include "fsmonitor-ll.h"
-#include "fsmonitor-ipc.h"
-#include "fsmonitor-settings.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor-ll.h"
+#include "index/fsmonitor-ipc.h"
+#include "index/fsmonitor-settings.h"
+#include "index/fsmonitor-path-utils.h"
 
  /*
  * For the builtin FSMonitor, we create the Unix domain socket for the
diff --git a/compat/fsmonitor/fsm-settings-win32.c b/compat/fsmonitor/fsm-settings-win32.c
index 0f2aa321f6..5b2872a4f1 100644
--- a/compat/fsmonitor/fsm-settings-win32.c
+++ b/compat/fsmonitor/fsm-settings-win32.c
@@ -1,9 +1,9 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "repository.h"
-#include "fsmonitor-ll.h"
-#include "fsmonitor-settings.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor-ll.h"
+#include "index/fsmonitor-settings.h"
+#include "index/fsmonitor-path-utils.h"
 
 /*
  * VFS for Git is incompatible with FSMonitor.
diff --git a/compat/mingw.c b/compat/mingw.c
index 785de5beb7..64814ac35d 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -5,13 +5,13 @@
 #include "abspath.h"
 #include "odb/alloc.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "repository.h"
 #include "gettext.h"
 #include "run-command.h"
 #include "strbuf.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "trace2.h"
 #include "win32.h"
 #include "win32/exit-process.h"
diff --git a/config.c b/config.c
index 3f335dbec1..59c6029654 100644
--- a/config.c
+++ b/config.c
@@ -12,7 +12,7 @@
 #include "date.h"
 #include "branch.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "parse.h"
 #include "convert.h"
 #include "environment.h"
diff --git a/convert.c b/convert.c
index 25c800eea2..f71d6dcefd 100644
--- a/convert.c
+++ b/convert.c
@@ -12,7 +12,7 @@
 #include "attr.h"
 #include "run-command.h"
 #include "quote.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "sigchain.h"
 #include "pkt-line.h"
 #include "sub-process.h"
diff --git a/diagnose.c b/diagnose.c
index 716dabf05c..0bac203282 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -2,7 +2,7 @@
 #include "diagnose.h"
 #include "compat/disk.h"
 #include "archive.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "help.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/diff/diff-lib.c b/diff/diff-lib.c
index d48196f7c7..4a932f9067 100644
--- a/diff/diff-lib.c
+++ b/diff/diff-lib.c
@@ -13,17 +13,17 @@
 #include "odb/hash.h"
 #include "hex.h"
 #include "odb/object-name.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 #include "revision/revision.h"
-#include "cache-tree.h"
-#include "unpack-trees.h"
+#include "index/cache-tree.h"
+#include "index/unpack-trees.h"
 #include "refs/refs.h"
 #include "repository.h"
 #include "submodule.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "trace.h"
-#include "dir.h"
-#include "fsmonitor.h"
+#include "index/dir.h"
+#include "index/fsmonitor.h"
 #include "revision/commit-reach.h"
 
 /*
diff --git a/diff/diff-no-index.c b/diff/diff-no-index.c
index 19cb90d121..12a793096b 100644
--- a/diff/diff-no-index.c
+++ b/diff/diff-no-index.c
@@ -15,9 +15,9 @@
 #include "gettext.h"
 #include "revision/revision.h"
 #include "parse-options.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "string-list.h"
-#include "dir.h"
+#include "index/dir.h"
 
 static int read_directory_contents(const char *path, struct string_list *list,
 				   const struct pathspec *pathspec,
diff --git a/diff/diff.c b/diff/diff.c
index 2b87f27238..c00b87cca2 100644
--- a/diff/diff.c
+++ b/diff/diff.c
@@ -39,10 +39,10 @@
 #include "parse-options.h"
 #include "help.h"
 #include "promisor-remote.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "setup.h"
 #include "strmap.h"
 #include "ws.h"
diff --git a/diff/diff.h b/diff/diff.h
index 502bf24432..2ef74733b9 100644
--- a/diff/diff.h
+++ b/diff/diff.h
@@ -5,7 +5,7 @@
 #define DIFF_H
 
 #include "odb/hash.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "strbuf.h"
 #include "color.h"
 
diff --git a/diff/tree-diff.c b/diff/tree-diff.c
index 4b7c90f6db..a34559daa5 100644
--- a/diff/tree-diff.c
+++ b/diff/tree-diff.c
@@ -11,7 +11,7 @@
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
 #include "repository.h"
-#include "dir.h"
+#include "index/dir.h"
 
 /*
  * Some mode bits are also used internally for computations.
diff --git a/git.c b/git.c
index 9dace05858..f01a80867b 100644
--- a/git.c
+++ b/git.c
@@ -8,7 +8,7 @@
 #include "help.h"
 #include "odb/object-file.h"
 #include "pager.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "run-command.h"
 #include "alias.h"
 #include "odb/replace-object.h"
diff --git a/gpg-interface.c b/gpg-interface.c
index 034bed7aaa..45a922496b 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -7,7 +7,7 @@
 #include "gettext.h"
 #include "run-command.h"
 #include "strbuf.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "ident.h"
 #include "gpg-interface.h"
 #include "path.h"
diff --git a/help.c b/help.c
index 96f98ec621..f7a0950f6c 100644
--- a/help.c
+++ b/help.c
@@ -18,7 +18,7 @@
 #include "refs/refs.h"
 #include "parse-options.h"
 #include "prompt.h"
-#include "fsmonitor-ipc.h"
+#include "index/fsmonitor-ipc.h"
 #include "repository.h"
 #include "alias.h"
 #include "utf8.h"
diff --git a/cache-tree.c b/index/cache-tree.c
similarity index 99%
rename from cache-tree.c
rename to index/cache-tree.c
index 1c4295761a..e7c4bfe45c 100644
--- a/cache-tree.c
+++ b/index/cache-tree.c
@@ -7,11 +7,11 @@
 #include "lockfile.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/transaction.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "odb/replace-object.h"
 #include "repository.h"
 #include "promisor-remote.h"
diff --git a/cache-tree.h b/index/cache-tree.h
similarity index 100%
rename from cache-tree.h
rename to index/cache-tree.h
diff --git a/checkout.c b/index/checkout.c
similarity index 98%
rename from checkout.c
rename to index/checkout.c
index e3b4d341da..13d8895032 100644
--- a/checkout.c
+++ b/index/checkout.c
@@ -5,7 +5,7 @@
 #include "remote.h"
 #include "refs/refspec.h"
 #include "repository.h"
-#include "checkout.h"
+#include "index/checkout.h"
 #include "config.h"
 #include "strbuf.h"
 
diff --git a/checkout.h b/index/checkout.h
similarity index 100%
rename from checkout.h
rename to index/checkout.h
diff --git a/dir-iterator.c b/index/dir-iterator.c
similarity index 99%
rename from dir-iterator.c
rename to index/dir-iterator.c
index 857e1d9bda..382bd4325c 100644
--- a/dir-iterator.c
+++ b/index/dir-iterator.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "iterator.h"
-#include "dir-iterator.h"
+#include "index/dir-iterator.h"
 #include "string-list.h"
 
 struct dir_iterator_level {
diff --git a/dir-iterator.h b/index/dir-iterator.h
similarity index 100%
rename from dir-iterator.h
rename to index/dir-iterator.h
diff --git a/dir.c b/index/dir.c
similarity index 99%
rename from dir.c
rename to index/dir.c
index d230ecdec1..6f74a3e87c 100644
--- a/dir.c
+++ b/index/dir.c
@@ -13,26 +13,26 @@
 #include "abspath.h"
 #include "config.h"
 #include "convert.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
-#include "name-hash.h"
+#include "index/name-hash.h"
 #include "odb/object-file.h"
 #include "path.h"
 #include "refs/refs.h"
 #include "repository.h"
 #include "wildmatch.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "utf8.h"
 #include "varint.h"
 #include "ewah/ewok.h"
-#include "fsmonitor-ll.h"
-#include "read-cache-ll.h"
+#include "index/fsmonitor-ll.h"
+#include "index/read-cache-ll.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "strbuf.h"
 #include "submodule-config.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "trace2.h"
 #include "odb/tree.h"
 #include "hex.h"
diff --git a/dir.h b/index/dir.h
similarity index 99%
rename from dir.h
rename to index/dir.h
index 239c7efb1e..c44cff5bdd 100644
--- a/dir.h
+++ b/index/dir.h
@@ -3,8 +3,8 @@
 
 #include "odb/hash.h"
 #include "hashmap.h"
-#include "pathspec.h"
-#include "statinfo.h"
+#include "index/pathspec.h"
+#include "index/statinfo.h"
 #include "strbuf.h"
 
 struct repository;
diff --git a/entry.c b/index/entry.c
similarity index 98%
rename from entry.c
rename to index/entry.c
index 823a433539..5b89ad2294 100644
--- a/entry.c
+++ b/index/entry.c
@@ -3,18 +3,18 @@
 #include "git-compat-util.h"
 #include "odb/odb.h"
 #include "odb/streaming.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "name-hash.h"
-#include "sparse-index.h"
+#include "index/name-hash.h"
+#include "index/sparse-index.h"
 #include "submodule.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "progress.h"
-#include "fsmonitor.h"
-#include "entry.h"
-#include "parallel-checkout.h"
+#include "index/fsmonitor.h"
+#include "index/entry.h"
+#include "index/parallel-checkout.h"
 
 static void create_directories(const char *path, int path_len,
 			       const struct checkout *state)
diff --git a/entry.h b/index/entry.h
similarity index 100%
rename from entry.h
rename to index/entry.h
diff --git a/fsmonitor--daemon.h b/index/fsmonitor--daemon.h
similarity index 99%
rename from fsmonitor--daemon.h
rename to index/fsmonitor--daemon.h
index 5cbbec8d94..9a542198cd 100644
--- a/fsmonitor--daemon.h
+++ b/index/fsmonitor--daemon.h
@@ -5,7 +5,7 @@
 
 #include "hashmap.h"
 #include "thread-utils.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor-path-utils.h"
 
 struct fsmonitor_batch;
 struct fsmonitor_token_data;
diff --git a/fsmonitor-ipc.c b/index/fsmonitor-ipc.c
similarity index 99%
rename from fsmonitor-ipc.c
rename to index/fsmonitor-ipc.c
index 6112d13064..7c213245a1 100644
--- a/fsmonitor-ipc.c
+++ b/index/fsmonitor-ipc.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "simple-ipc.h"
-#include "fsmonitor-ipc.h"
+#include "index/fsmonitor-ipc.h"
 #include "repository.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/fsmonitor-ipc.h b/index/fsmonitor-ipc.h
similarity index 100%
rename from fsmonitor-ipc.h
rename to index/fsmonitor-ipc.h
diff --git a/fsmonitor-ll.h b/index/fsmonitor-ll.h
similarity index 100%
rename from fsmonitor-ll.h
rename to index/fsmonitor-ll.h
diff --git a/fsmonitor-path-utils.h b/index/fsmonitor-path-utils.h
similarity index 100%
rename from fsmonitor-path-utils.h
rename to index/fsmonitor-path-utils.h
diff --git a/fsmonitor-settings.c b/index/fsmonitor-settings.c
similarity index 98%
rename from fsmonitor-settings.c
rename to index/fsmonitor-settings.c
index a6587a8972..883b5902a9 100644
--- a/fsmonitor-settings.c
+++ b/index/fsmonitor-settings.c
@@ -2,9 +2,9 @@
 #include "config.h"
 #include "gettext.h"
 #include "repository.h"
-#include "fsmonitor-ipc.h"
-#include "fsmonitor-settings.h"
-#include "fsmonitor-path-utils.h"
+#include "index/fsmonitor-ipc.h"
+#include "index/fsmonitor-settings.h"
+#include "index/fsmonitor-path-utils.h"
 
 /*
  * We keep this structure definition private and have getters
diff --git a/fsmonitor-settings.h b/index/fsmonitor-settings.h
similarity index 100%
rename from fsmonitor-settings.h
rename to index/fsmonitor-settings.h
diff --git a/fsmonitor.c b/index/fsmonitor.c
similarity index 99%
rename from fsmonitor.c
rename to index/fsmonitor.c
index 107767527e..606a59d36d 100644
--- a/fsmonitor.c
+++ b/index/fsmonitor.c
@@ -3,12 +3,12 @@
 
 #include "git-compat-util.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "ewah/ewok.h"
-#include "fsmonitor.h"
-#include "fsmonitor-ipc.h"
-#include "name-hash.h"
+#include "index/fsmonitor.h"
+#include "index/fsmonitor-ipc.h"
+#include "index/name-hash.h"
 #include "repository.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/fsmonitor.h b/index/fsmonitor.h
similarity index 95%
rename from fsmonitor.h
rename to index/fsmonitor.h
index 59591ee49e..95f4eaefa4 100644
--- a/fsmonitor.h
+++ b/index/fsmonitor.h
@@ -1,11 +1,11 @@
 #ifndef FSMONITOR_H
 #define FSMONITOR_H
 
-#include "fsmonitor-ll.h"
-#include "dir.h"
-#include "fsmonitor-settings.h"
+#include "index/fsmonitor-ll.h"
+#include "index/dir.h"
+#include "index/fsmonitor-settings.h"
 #include "odb/object.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "trace.h"
 
 /*
diff --git a/name-hash.c b/index/name-hash.c
similarity index 99%
rename from name-hash.c
rename to index/name-hash.c
index 1464b6d066..5d126bc1a3 100644
--- a/name-hash.c
+++ b/index/name-hash.c
@@ -12,13 +12,13 @@
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
-#include "name-hash.h"
+#include "index/name-hash.h"
 #include "odb/object.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "thread-utils.h"
 #include "trace.h"
 #include "trace2.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 
 struct dir_entry {
 	struct hashmap_entry ent;
diff --git a/name-hash.h b/index/name-hash.h
similarity index 100%
rename from name-hash.h
rename to index/name-hash.h
diff --git a/parallel-checkout.c b/index/parallel-checkout.c
similarity index 99%
rename from parallel-checkout.c
rename to index/parallel-checkout.c
index 85d1c25a81..971c4b33fa 100644
--- a/parallel-checkout.c
+++ b/index/parallel-checkout.c
@@ -3,18 +3,18 @@
 
 #include "git-compat-util.h"
 #include "config.h"
-#include "entry.h"
+#include "index/entry.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
-#include "parallel-checkout.h"
+#include "index/parallel-checkout.h"
 #include "pkt-line.h"
 #include "progress.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "odb/streaming.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "thread-utils.h"
 #include "trace2.h"
 
diff --git a/parallel-checkout.h b/index/parallel-checkout.h
similarity index 100%
rename from parallel-checkout.h
rename to index/parallel-checkout.h
diff --git a/pathspec.c b/index/pathspec.c
similarity index 99%
rename from pathspec.c
rename to index/pathspec.c
index 281858f21f..7a0c152fb9 100644
--- a/pathspec.c
+++ b/index/pathspec.c
@@ -3,16 +3,16 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "parse.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "attr.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 #include "repository.h"
 #include "setup.h"
 #include "strvec.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "quote.h"
 #include "wildmatch.h"
 
diff --git a/pathspec.h b/index/pathspec.h
similarity index 100%
rename from pathspec.h
rename to index/pathspec.h
diff --git a/preload-index.c b/index/preload-index.c
similarity index 96%
rename from preload-index.c
rename to index/preload-index.c
index b222821b44..eab3bfc602 100644
--- a/preload-index.c
+++ b/index/preload-index.c
@@ -5,18 +5,18 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "pathspec.h"
-#include "dir.h"
+#include "index/pathspec.h"
+#include "index/dir.h"
 #include "environment.h"
-#include "fsmonitor.h"
+#include "index/fsmonitor.h"
 #include "gettext.h"
 #include "parse.h"
-#include "preload-index.h"
+#include "index/preload-index.h"
 #include "progress.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 #include "thread-utils.h"
 #include "repository.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "trace2.h"
 #include "config.h"
 
diff --git a/preload-index.h b/index/preload-index.h
similarity index 100%
rename from preload-index.h
rename to index/preload-index.h
diff --git a/read-cache-ll.h b/index/read-cache-ll.h
similarity index 99%
rename from read-cache-ll.h
rename to index/read-cache-ll.h
index 312e65ff3c..450de019b4 100644
--- a/read-cache-ll.h
+++ b/index/read-cache-ll.h
@@ -3,7 +3,7 @@
 
 #include "odb/hash.h"
 #include "hashmap.h"
-#include "statinfo.h"
+#include "index/statinfo.h"
 
 /*
  * Basic data structures for the directory cache
diff --git a/read-cache.c b/index/read-cache.c
similarity index 99%
rename from read-cache.c
rename to index/read-cache.c
index a970eb1b6a..9c62ae5ee8 100644
--- a/read-cache.c
+++ b/index/read-cache.c
@@ -15,9 +15,9 @@
 #include "hex.h"
 #include "tempfile.h"
 #include "lockfile.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "refs/refs.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/transaction.h"
@@ -27,24 +27,24 @@
 #include "environment.h"
 #include "gettext.h"
 #include "mem-pool.h"
-#include "name-hash.h"
+#include "index/name-hash.h"
 #include "odb/object-name.h"
 #include "path.h"
-#include "preload-index.h"
-#include "read-cache.h"
+#include "index/preload-index.h"
+#include "index/read-cache.h"
 #include "repository.h"
-#include "resolve-undo.h"
+#include "index/resolve-undo.h"
 #include "revision/revision.h"
 #include "strbuf.h"
 #include "trace2.h"
 #include "varint.h"
-#include "split-index.h"
-#include "symlinks.h"
+#include "index/split-index.h"
+#include "index/symlinks.h"
 #include "utf8.h"
-#include "fsmonitor.h"
+#include "index/fsmonitor.h"
 #include "thread-utils.h"
 #include "progress.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "csum-file.h"
 #include "promisor-remote.h"
 #include "hook.h"
diff --git a/read-cache.h b/index/read-cache.h
similarity index 95%
rename from read-cache.h
rename to index/read-cache.h
index 69a7118a66..d8519c7b36 100644
--- a/read-cache.h
+++ b/index/read-cache.h
@@ -1,9 +1,9 @@
 #ifndef READ_CACHE_H
 #define READ_CACHE_H
 
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "odb/object.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "environment.h"
 
 /*
diff --git a/resolve-undo.c b/index/resolve-undo.c
similarity index 97%
rename from resolve-undo.c
rename to index/resolve-undo.c
index a54b6c0f79..b94d8b403c 100644
--- a/resolve-undo.c
+++ b/index/resolve-undo.c
@@ -1,11 +1,11 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "odb/hash.h"
-#include "read-cache.h"
-#include "resolve-undo.h"
-#include "sparse-index.h"
+#include "index/read-cache.h"
+#include "index/resolve-undo.h"
+#include "index/sparse-index.h"
 #include "string-list.h"
 
 /* The only error case is to run out of memory in string-list */
diff --git a/resolve-undo.h b/index/resolve-undo.h
similarity index 100%
rename from resolve-undo.h
rename to index/resolve-undo.h
diff --git a/sparse-index.c b/index/sparse-index.c
similarity index 99%
rename from sparse-index.c
rename to index/sparse-index.c
index 8e00862442..0a061a7658 100644
--- a/sparse-index.c
+++ b/index/sparse-index.c
@@ -5,17 +5,17 @@
 #include "environment.h"
 #include "ewah/ewok.h"
 #include "gettext.h"
-#include "name-hash.h"
-#include "read-cache-ll.h"
+#include "index/name-hash.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "odb/tree.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "trace2.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "config.h"
-#include "dir.h"
-#include "fsmonitor-ll.h"
+#include "index/dir.h"
+#include "index/fsmonitor-ll.h"
 #include "advice.h"
 
 /**
diff --git a/sparse-index.h b/index/sparse-index.h
similarity index 100%
rename from sparse-index.h
rename to index/sparse-index.h
diff --git a/split-index.c b/index/split-index.c
similarity index 99%
rename from split-index.c
rename to index/split-index.c
index 2737cc6118..02a5b011c5 100644
--- a/split-index.c
+++ b/index/split-index.c
@@ -4,9 +4,9 @@
 #include "gettext.h"
 #include "odb/hash.h"
 #include "mem-pool.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
-#include "split-index.h"
+#include "index/split-index.h"
 #include "strbuf.h"
 #include "ewah/ewok.h"
 
diff --git a/split-index.h b/index/split-index.h
similarity index 100%
rename from split-index.h
rename to index/split-index.h
diff --git a/statinfo.c b/index/statinfo.c
similarity index 99%
rename from statinfo.c
rename to index/statinfo.c
index 5e00af127d..4a22923009 100644
--- a/statinfo.c
+++ b/index/statinfo.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "environment.h"
-#include "statinfo.h"
+#include "index/statinfo.h"
 #include "repository.h"
 
 /*
diff --git a/statinfo.h b/index/statinfo.h
similarity index 100%
rename from statinfo.h
rename to index/statinfo.h
diff --git a/symlinks.c b/index/symlinks.c
similarity index 99%
rename from symlinks.c
rename to index/symlinks.c
index 9e01ab3bc8..18fadf3f75 100644
--- a/symlinks.c
+++ b/index/symlinks.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "setup.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 
 static int threaded_check_leading_path(struct cache_def *cache, const char *name,
 				       int len, int warn_on_lstat_err);
diff --git a/symlinks.h b/index/symlinks.h
similarity index 100%
rename from symlinks.h
rename to index/symlinks.h
diff --git a/unpack-trees.c b/index/unpack-trees.c
similarity index 99%
rename from unpack-trees.c
rename to index/unpack-trees.c
index b911700d74..68d85f622e 100644
--- a/unpack-trees.c
+++ b/index/unpack-trees.c
@@ -6,30 +6,30 @@
 #include "strvec.h"
 #include "repository.h"
 #include "parse.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "name-hash.h"
+#include "index/name-hash.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "cache-tree.h"
-#include "unpack-trees.h"
+#include "index/cache-tree.h"
+#include "index/unpack-trees.h"
 #include "progress.h"
 #include "refs/refs.h"
 #include "attr.h"
-#include "read-cache.h"
-#include "split-index.h"
-#include "sparse-index.h"
+#include "index/read-cache.h"
+#include "index/split-index.h"
+#include "index/sparse-index.h"
 #include "submodule.h"
 #include "submodule-config.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "trace2.h"
-#include "fsmonitor.h"
+#include "index/fsmonitor.h"
 #include "odb/odb.h"
 #include "promisor-remote.h"
-#include "entry.h"
-#include "parallel-checkout.h"
+#include "index/entry.h"
+#include "index/parallel-checkout.h"
 #include "setup.h"
 
 /*
diff --git a/unpack-trees.h b/index/unpack-trees.h
similarity index 99%
rename from unpack-trees.h
rename to index/unpack-trees.h
index d9d3ce09fd..f652a43f11 100644
--- a/unpack-trees.h
+++ b/index/unpack-trees.h
@@ -2,7 +2,7 @@
 #define UNPACK_TREES_H
 
 #include "convert.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "strvec.h"
 #include "string-list.h"
 #include "odb/tree-walk.h"
diff --git a/wt-status.c b/index/wt-status.c
similarity index 99%
rename from wt-status.c
rename to index/wt-status.c
index 83fdf5334f..3381a40e75 100644
--- a/wt-status.c
+++ b/index/wt-status.c
@@ -3,9 +3,9 @@
 
 #include "git-compat-util.h"
 #include "advice.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 #include "odb/object.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
 #include "environment.h"
@@ -24,7 +24,7 @@
 #include "refs/refs.h"
 #include "submodule.h"
 #include "column.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 #include "setup.h"
 #include "strbuf.h"
 #include "trace.h"
@@ -34,7 +34,7 @@
 #include "refs/worktree.h"
 #include "lockfile.h"
 #include "sequencer.h"
-#include "fsmonitor-settings.h"
+#include "index/fsmonitor-settings.h"
 
 #define AB_DELAY_WARNING_IN_MS (2 * 1000)
 #define UF_DELAY_WARNING_IN_MS (2 * 1000)
diff --git a/wt-status.h b/index/wt-status.h
similarity index 99%
rename from wt-status.h
rename to index/wt-status.h
index e9fe32e98c..b7a508186d 100644
--- a/wt-status.h
+++ b/index/wt-status.h
@@ -3,7 +3,7 @@
 
 #include "string-list.h"
 #include "color.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "remote.h"
 
 struct repository;
diff --git a/merge-ort-wrappers.c b/merge-ort-wrappers.c
index 846753abdf..c31ed7028d 100644
--- a/merge-ort-wrappers.c
+++ b/merge-ort-wrappers.c
@@ -5,7 +5,7 @@
 #include "lockfile.h"
 #include "merge-ort.h"
 #include "merge-ort-wrappers.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "odb/tag.h"
 #include "odb/tree.h"
diff --git a/merge-ort.c b/merge-ort.c
index 71274c24bf..516cd265c5 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -23,17 +23,17 @@
 #include "odb/alloc.h"
 #include "advice.h"
 #include "attr.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "odb/commit.h"
 #include "revision/commit-reach.h"
 #include "config.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "entry.h"
+#include "index/entry.h"
 #include "merge-ll.h"
 #include "odb/match-trees.h"
 #include "mem-pool.h"
@@ -43,14 +43,14 @@
 #include "odb/oid-array.h"
 #include "path.h"
 #include "promisor-remote.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "refs/refs.h"
 #include "revision/revision.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "strmap.h"
 #include "trace2.h"
 #include "odb/tree.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 #include "diff/xdiff-interface.h"
 
 /*
diff --git a/merge.c b/merge.c
index f46d968b70..0fcfc1460f 100644
--- a/merge.c
+++ b/merge.c
@@ -9,10 +9,10 @@
 #include "odb/commit.h"
 #include "repository.h"
 #include "run-command.h"
-#include "resolve-undo.h"
+#include "index/resolve-undo.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 
 static const char *merge_argument(struct commit *commit)
 {
diff --git a/meson.build b/meson.build
index 65be53078d..c61ebc35a6 100644
--- a/meson.build
+++ b/meson.build
@@ -326,10 +326,10 @@ libgit_sources = [
   'branch.c',
   'bundle-uri.c',
   'bundle.c',
-  'cache-tree.c',
+  'index/cache-tree.c',
   'odb/cbtree.c',
   'chdir-notify.c',
-  'checkout.c',
+  'index/checkout.c',
   'pack/chunk-format.c',
   'color.c',
   'column.c',
@@ -363,10 +363,10 @@ libgit_sources = [
   'diff/diffcore-pickaxe.c',
   'diff/diffcore-rename.c',
   'diff/diffcore-rotate.c',
-  'dir-iterator.c',
-  'dir.c',
+  'index/dir-iterator.c',
+  'index/dir.c',
   'editor.c',
-  'entry.c',
+  'index/entry.c',
   'environment.c',
   'ewah/bitmap.c',
   'ewah/ewah_bitmap.c',
@@ -378,9 +378,9 @@ libgit_sources = [
   'fetch-pack.c',
   'fmt-merge-msg.c',
   'odb/fsck.c',
-  'fsmonitor.c',
-  'fsmonitor-ipc.c',
-  'fsmonitor-settings.c',
+  'index/fsmonitor.c',
+  'index/fsmonitor-ipc.c',
+  'index/fsmonitor-settings.c',
   'gettext.c',
   'git-zlib.c',
   'gpg-interface.c',
@@ -418,7 +418,7 @@ libgit_sources = [
   'merge.c',
   'pack/midx.c',
   'pack/midx-write.c',
-  'name-hash.c',
+  'index/name-hash.c',
   'negotiator/default.c',
   'negotiator/noop.c',
   'negotiator/skipping.c',
@@ -457,7 +457,7 @@ libgit_sources = [
   'pack/packfile.c',
   'pack/packfile-list.c',
   'pager.c',
-  'parallel-checkout.c',
+  'index/parallel-checkout.c',
   'parse.c',
   'parse-options-cb.c',
   'parse-options.c',
@@ -465,9 +465,9 @@ libgit_sources = [
   'diff/patch-ids.c',
   'path.c',
   'path-walk.c',
-  'pathspec.c',
+  'index/pathspec.c',
   'pkt-line.c',
-  'preload-index.c',
+  'index/preload-index.c',
   'revision/pretty.c',
   'prio-queue.c',
   'progress.c',
@@ -480,7 +480,7 @@ libgit_sources = [
   'quote.c',
   'diff/range-diff.c',
   'pack/reachable.c',
-  'read-cache.c',
+  'index/read-cache.c',
   'rebase-interactive.c',
   'rebase.c',
   'refs/ref-filter.c',
@@ -521,7 +521,7 @@ libgit_sources = [
   'repository.c',
   'rerere.c',
   'reset.c',
-  'resolve-undo.c',
+  'index/resolve-undo.c',
   'revision/revision.c',
   'run-command.c',
   'send-pack.c',
@@ -532,10 +532,10 @@ libgit_sources = [
   'revision/shallow.c',
   'sideband.c',
   'sigchain.c',
-  'sparse-index.c',
-  'split-index.c',
+  'index/sparse-index.c',
+  'index/split-index.c',
   'stable-qsort.c',
-  'statinfo.c',
+  'index/statinfo.c',
   'strbuf.c',
   'string-list.c',
   'strmap.c',
@@ -543,7 +543,7 @@ libgit_sources = [
   'sub-process.c',
   'submodule-config.c',
   'submodule.c',
-  'symlinks.c',
+  'index/symlinks.c',
   'odb/tag.c',
   'tempfile.c',
   'thread-utils.c',
@@ -568,7 +568,7 @@ libgit_sources = [
   'diff/tree-diff.c',
   'odb/tree-walk.c',
   'odb/tree.c',
-  'unpack-trees.c',
+  'index/unpack-trees.c',
   'upload-pack.c',
   'url.c',
   'urlmatch.c',
@@ -583,7 +583,7 @@ libgit_sources = [
   'wrapper.c',
   'write-or-die.c',
   'ws.c',
-  'wt-status.c',
+  'index/wt-status.c',
   'diff/xdiff-interface.c',
   'xdiff/xdiffi.c',
   'xdiff/xemit.c',
diff --git a/notes-merge.c b/notes-merge.c
index 53f42ba863..2bb6ad735e 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -16,7 +16,7 @@
 #include "hex.h"
 #include "diff/xdiff-interface.h"
 #include "merge-ll.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "notes.h"
 #include "notes-merge.h"
 #include "strbuf.h"
diff --git a/odb/commit.c b/odb/commit.c
index 1b0703a9ef..3b490c760c 100644
--- a/odb/commit.c
+++ b/odb/commit.c
@@ -20,7 +20,7 @@
 #include "odb/commit-slab.h"
 #include "prio-queue.h"
 #include "odb/hash-lookup.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 #include "advice.h"
 #include "refs/refs.h"
 #include "revision/commit-reach.h"
diff --git a/odb/fsck.c b/odb/fsck.c
index 8c953f61a4..e889268b48 100644
--- a/odb/fsck.c
+++ b/odb/fsck.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "date.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "hex.h"
 #include "odb/odb.h"
diff --git a/odb/hash-lookup.c b/odb/hash-lookup.c
index cf2d4a0245..9e8e5efb4f 100644
--- a/odb/hash-lookup.c
+++ b/odb/hash-lookup.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "odb/hash.h"
 #include "odb/hash-lookup.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 
 static uint32_t take2(const struct object_id *oid, size_t ofs)
 {
diff --git a/odb/object-file.c b/odb/object-file.c
index 41ee67abb6..847b78e5c7 100644
--- a/odb/object-file.c
+++ b/odb/object-file.c
@@ -11,7 +11,7 @@
 
 #include "git-compat-util.h"
 #include "convert.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "odb/fsck.h"
 #include "gettext.h"
@@ -25,7 +25,7 @@
 #include "pack/pack.h"
 #include "pack/packfile.h"
 #include "path.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "setup.h"
 #include "strvec.h"
 #include "tempfile.h"
diff --git a/odb/object-name.c b/odb/object-name.c
index 825fc717bf..95a63c7f64 100644
--- a/odb/object-name.c
+++ b/odb/object-name.c
@@ -14,11 +14,11 @@
 #include "odb/tree-walk.h"
 #include "refs/refs.h"
 #include "remote.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "odb/odb.h"
 #include "odb/oid-array.h"
 #include "revision/pretty.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repo-settings.h"
 #include "repository.h"
 #include "setup.h"
diff --git a/odb/object.c b/odb/object.c
index 7c2f920d3f..cd93a7b47b 100644
--- a/odb/object.c
+++ b/odb/object.c
@@ -8,7 +8,7 @@
 #include "odb/object-file.h"
 #include "odb/streaming.h"
 #include "odb/blob.h"
-#include "statinfo.h"
+#include "index/statinfo.h"
 #include "odb/tree.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
diff --git a/odb/odb.c b/odb/odb.c
index e942149d91..4e408501e8 100644
--- a/odb/odb.c
+++ b/odb/odb.c
@@ -2,7 +2,7 @@
 #include "abspath.h"
 #include "pack/commit-graph.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/odb/source-packed.c b/odb/source-packed.c
index c1e2756471..d3def038c6 100644
--- a/odb/source-packed.c
+++ b/odb/source-packed.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "chdir-notify.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "git-zlib.h"
 #include "revision/list-objects-filter-options.h"
 #include "mergesort.h"
diff --git a/odb/tmp-objdir.c b/odb/tmp-objdir.c
index b9ba5c4cd3..21219e8797 100644
--- a/odb/tmp-objdir.c
+++ b/odb/tmp-objdir.c
@@ -2,7 +2,7 @@
 #include "odb/tmp-objdir.h"
 #include "abspath.h"
 #include "chdir-notify.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "odb/object-file.h"
 #include "path.h"
diff --git a/odb/tree-walk.c b/odb/tree-walk.c
index 51e8037ef5..e3e22e1a32 100644
--- a/odb/tree-walk.c
+++ b/odb/tree-walk.c
@@ -2,17 +2,17 @@
 
 #include "git-compat-util.h"
 #include "odb/tree-walk.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "trace2.h"
 #include "odb/tree.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "json-writer.h"
 #include "environment.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 
 static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size, struct strbuf *err)
 {
diff --git a/organize/gitorganize-format.c b/organize/gitorganize-format.c
index 541dd373aa..8edf1659e0 100644
--- a/organize/gitorganize-format.c
+++ b/organize/gitorganize-format.c
@@ -2,7 +2,7 @@
 #include "gitorganize-format.h"
 #include "gettext.h"
 #include "quote.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "strbuf.h"
 #include "string-list.h"
 #include "wrapper.h"
diff --git a/organize/organize.c b/organize/organize.c
index 298557a3da..f1f0aec6ea 100644
--- a/organize/organize.c
+++ b/organize/organize.c
@@ -5,16 +5,16 @@
 #include "organizer-protocol.h"
 #include "config.h"
 #include "gettext.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "quote.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "wrapper.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 
 /* The configured command organize.<key> (labeler or organizer), or NULL. */
 static const char *organize_command(struct repository *repo, const char *key)
diff --git a/pack/midx.c b/pack/midx.c
index 2608e99468..76e77d0dd2 100644
--- a/pack/midx.c
+++ b/pack/midx.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "hex.h"
 #include "pack/packfile.h"
 #include "odb/hash-lookup.h"
diff --git a/pack/packfile.c b/pack/packfile.c
index 72252faffe..77de6bb821 100644
--- a/pack/packfile.c
+++ b/pack/packfile.c
@@ -7,7 +7,7 @@
 #include "revision/list.h"
 #include "pack/pack.h"
 #include "repository.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "pack/packfile.h"
 #include "pack/delta.h"
 #include "odb/hash-lookup.h"
diff --git a/pack/reachable.c b/pack/reachable.c
index f61525308e..5b8a2a4f79 100644
--- a/pack/reachable.c
+++ b/pack/reachable.c
@@ -9,7 +9,7 @@
 #include "diff/diff.h"
 #include "revision/revision.h"
 #include "pack/reachable.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "progress.h"
 #include "revision/list-objects.h"
 #include "pack/packfile.h"
diff --git a/pack/repack.c b/pack/repack.c
index 91dde13b29..52e7779a44 100644
--- a/pack/repack.c
+++ b/pack/repack.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "pack/midx.h"
 #include "odb/odb.h"
 #include "pack/packfile.h"
diff --git a/pack/server-info.c b/pack/server-info.c
index 627d2e3c98..dbd86d6fd2 100644
--- a/pack/server-info.c
+++ b/pack/server-info.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "hex.h"
 #include "repository.h"
 #include "refs/refs.h"
diff --git a/path-walk.c b/path-walk.c
index 4b8ddb2a28..00686d3dbf 100644
--- a/path-walk.c
+++ b/path-walk.c
@@ -5,7 +5,7 @@
 #include "path-walk.h"
 #include "odb/blob.h"
 #include "odb/commit.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "hashmap.h"
 #include "hex.h"
 #include "revision/list-objects.h"
diff --git a/path.c b/path.c
index 516abb3f82..e4d489e10a 100644
--- a/path.c
+++ b/path.c
@@ -8,7 +8,7 @@
 #include "repository.h"
 #include "strbuf.h"
 #include "string-list.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "refs/worktree.h"
 #include "setup.h"
 #include "submodule-config.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index df9c2d1275..ee2ef8b535 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -11,7 +11,7 @@
 #include "strbuf.h"
 #include "odb/commit-slab.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "odb/object-name.h"
 
 static const char edit_todo_list_advice[] =
diff --git a/refs/files-backend.c b/refs/files-backend.c
index a792297d8f..e6e07938a3 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -16,10 +16,10 @@
 #include "packed-backend.h"
 #include "../ident.h"
 #include "../iterator.h"
-#include "../dir-iterator.h"
+#include "index/dir-iterator.h"
 #include "../lockfile.h"
 #include "../path.h"
-#include "../dir.h"
+#include "index/dir.h"
 #include "../chdir-notify.h"
 #include "../setup.h"
 #include "refs/worktree.h"
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index afcb800a5f..97f76c1d76 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -2,7 +2,7 @@
 
 #include "../git-compat-util.h"
 #include "../config.h"
-#include "../dir.h"
+#include "index/dir.h"
 #include "odb/fsck.h"
 #include "../gettext.h"
 #include "odb/hash.h"
@@ -13,7 +13,7 @@
 #include "../iterator.h"
 #include "../lockfile.h"
 #include "../chdir-notify.h"
-#include "../statinfo.h"
+#include "index/statinfo.h"
 #include "refs/worktree.h"
 #include "../wrapper.h"
 #include "../write-or-die.h"
diff --git a/refs/ref-filter.c b/refs/ref-filter.c
index 7635e13f88..32027789a8 100644
--- a/refs/ref-filter.c
+++ b/refs/ref-filter.c
@@ -28,7 +28,7 @@
 #include "utf8.h"
 #include "versioncmp.h"
 #include "trailer.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 #include "odb/commit-slab.h"
 #include "revision/commit-reach.h"
 #include "refs/worktree.h"
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index 120f9c947f..0c02b2d287 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -2,7 +2,7 @@
 #include "../abspath.h"
 #include "../chdir-notify.h"
 #include "../config.h"
-#include "../dir.h"
+#include "index/dir.h"
 #include "../environment.h"
 #include "odb/fsck.h"
 #include "../gettext.h"
diff --git a/refs/worktree.c b/refs/worktree.c
index 3578229534..0f1fe6a7d2 100644
--- a/refs/worktree.c
+++ b/refs/worktree.c
@@ -10,8 +10,8 @@
 #include "setup.h"
 #include "strbuf.h"
 #include "refs/worktree.h"
-#include "dir.h"
-#include "wt-status.h"
+#include "index/dir.h"
+#include "index/wt-status.h"
 #include "config.h"
 
 void free_worktree(struct worktree *worktree)
diff --git a/remote.c b/remote.c
index 8a65967fb0..2b376893b3 100644
--- a/remote.c
+++ b/remote.c
@@ -18,7 +18,7 @@
 #include "odb/commit.h"
 #include "diff/diff.h"
 #include "revision/revision.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "setup.h"
 #include "string-list.h"
 #include "strvec.h"
diff --git a/repository.c b/repository.c
index b5e442f9f3..8771145515 100644
--- a/repository.c
+++ b/repository.c
@@ -9,12 +9,12 @@
 #include "odb/object.h"
 #include "lockfile.h"
 #include "path.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "remote.h"
 #include "setup.h"
 #include "odb/loose.h"
 #include "submodule-config.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "trace2.h"
 #include "promisor-remote.h"
 #include "refs/refs.h"
diff --git a/rerere.c b/rerere.c
index 3055989a41..df30ebbe93 100644
--- a/rerere.c
+++ b/rerere.c
@@ -10,14 +10,14 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "string-list.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "rerere.h"
 #include "diff/xdiff-interface.h"
-#include "dir.h"
-#include "resolve-undo.h"
+#include "index/dir.h"
+#include "index/resolve-undo.h"
 #include "merge-ll.h"
 #include "path.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "strmap.h"
diff --git a/reset.c b/reset.c
index 29bbeaa9d4..0eddc94d8c 100644
--- a/reset.c
+++ b/reset.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
@@ -8,7 +8,7 @@
 #include "reset.h"
 #include "odb/tree-walk.h"
 #include "odb/tree.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 #include "hook.h"
 
 static int update_refs(struct repository *repo,
diff --git a/revision/bisect.c b/revision/bisect.c
index 696e365310..7805872c3e 100644
--- a/revision/bisect.c
+++ b/revision/bisect.c
@@ -22,7 +22,7 @@
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "path.h"
-#include "dir.h"
+#include "index/dir.h"
 
 static struct oid_array good_revs;
 static struct oid_array skipped_revs;
diff --git a/revision/blame.c b/revision/blame.c
index 54284ed8da..a75bf22193 100644
--- a/revision/blame.c
+++ b/revision/blame.c
@@ -4,7 +4,7 @@
 #include "git-compat-util.h"
 #include "refs/refs.h"
 #include "odb/odb.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "mergesort.h"
 #include "odb/commit.h"
 #include "convert.h"
@@ -13,7 +13,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "path.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 #include "revision/revision.h"
 #include "setup.h"
 #include "odb/tag.h"
diff --git a/revision/list-objects-filter.c b/revision/list-objects-filter.c
index 0ea4cb826e..da88781aef 100644
--- a/revision/list-objects-filter.c
+++ b/revision/list-objects-filter.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/commit.h"
diff --git a/revision/revision.c b/revision/revision.c
index 9a19a5654a..97c6fa6fef 100644
--- a/revision/revision.c
+++ b/revision/revision.c
@@ -29,14 +29,14 @@
 #include "revision/log-tree.h"
 #include "mailmap.h"
 #include "odb/commit-slab.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "revision/bisect.h"
 #include "pack/packfile.h"
 #include "refs/worktree.h"
 #include "path.h"
-#include "read-cache.h"
+#include "index/read-cache.h"
 #include "setup.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "strvec.h"
 #include "trace2.h"
 #include "revision/commit-reach.h"
@@ -47,7 +47,7 @@
 #include "pack/bloom.h"
 #include "json-writer.h"
 #include "revision/list-objects-filter-options.h"
-#include "resolve-undo.h"
+#include "index/resolve-undo.h"
 #include "parse-options.h"
 #include "wildmatch.h"
 
diff --git a/revision/shallow.c b/revision/shallow.c
index 51ba602971..f4ce207278 100644
--- a/revision/shallow.c
+++ b/revision/shallow.c
@@ -18,7 +18,7 @@
 #include "revision/list-objects.h"
 #include "revision/commit-reach.h"
 #include "revision/shallow.h"
-#include "statinfo.h"
+#include "index/statinfo.h"
 #include "trace.h"
 
 void set_alternate_shallow_file(struct repository *r, const char *path)
diff --git a/run-command.c b/run-command.c
index e0c4325900..80382354dc 100644
--- a/run-command.c
+++ b/run-command.c
@@ -7,7 +7,7 @@
 #include "gettext.h"
 #include "sigchain.h"
 #include "strvec.h"
-#include "symlinks.h"
+#include "index/symlinks.h"
 #include "thread-utils.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/scalar.c b/scalar.c
index 2cb09af1a5..d1e397ef50 100644
--- a/scalar.c
+++ b/scalar.c
@@ -11,10 +11,10 @@
 #include "config.h"
 #include "run-command.h"
 #include "simple-ipc.h"
-#include "fsmonitor-ipc.h"
-#include "fsmonitor-settings.h"
+#include "index/fsmonitor-ipc.h"
+#include "index/fsmonitor-settings.h"
 #include "refs/refs.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "pack/packfile.h"
 #include "help.h"
 #include "setup.h"
diff --git a/sequencer.c b/sequencer.c
index d5b1eb9719..f4a0f77eaf 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -10,7 +10,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
@@ -21,7 +21,7 @@
 #include "run-command.h"
 #include "hook.h"
 #include "utf8.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "diff/diff.h"
 #include "path.h"
 #include "revision/revision.h"
@@ -30,16 +30,16 @@
 #include "merge-ort.h"
 #include "merge-ort-wrappers.h"
 #include "refs/refs.h"
-#include "sparse-index.h"
+#include "index/sparse-index.h"
 #include "strvec.h"
 #include "quote.h"
 #include "trailer.h"
 #include "revision/log-tree.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 #include "hashmap.h"
 #include "notes-utils.h"
 #include "sigchain.h"
-#include "unpack-trees.h"
+#include "index/unpack-trees.h"
 #include "odb/oidmap.h"
 #include "odb/oidset.h"
 #include "odb/commit-slab.h"
diff --git a/sequencer.h b/sequencer.h
index 64a9c7fb1b..0906cc127d 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -3,7 +3,7 @@
 
 #include "strbuf.h"
 #include "strvec.h"
-#include "wt-status.h"
+#include "index/wt-status.h"
 
 struct commit;
 struct index_state;
diff --git a/setup.c b/setup.c
index 62fbda948d..e4e9ca83fe 100644
--- a/setup.c
+++ b/setup.c
@@ -12,7 +12,7 @@
 #include "refs/refs.h"
 #include "repository.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "setup.h"
 #include "revision/shallow.h"
 #include "string-list.h"
diff --git a/submodule-config.c b/submodule-config.c
index 094e64d8fd..c8be0acbb1 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -2,7 +2,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/submodule.c b/submodule.c
index 16f4d30b82..e14b53d3c8 100644
--- a/submodule.c
+++ b/submodule.c
@@ -7,7 +7,7 @@
 #include "config.h"
 #include "submodule-config.h"
 #include "submodule.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "diff/diff.h"
 #include "odb/commit.h"
 #include "environment.h"
@@ -29,7 +29,7 @@
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "revision/commit-reach.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "setup.h"
 #include "advice.h"
 #include "url.h"
diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c
index 9f613d2911..cf7e7efc5d 100644
--- a/t/helper/test-cache-tree.c
+++ b/t/helper/test-cache-tree.c
@@ -5,9 +5,9 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/tree.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 #include "parse-options.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
 
diff --git a/t/helper/test-dir-iterator.c b/t/helper/test-dir-iterator.c
index 8d46e8ba40..f2734c5f88 100644
--- a/t/helper/test-dir-iterator.c
+++ b/t/helper/test-dir-iterator.c
@@ -2,7 +2,7 @@
 #include "git-compat-util.h"
 #include "strbuf.h"
 #include "iterator.h"
-#include "dir-iterator.h"
+#include "index/dir-iterator.h"
 
 static const char *error_name(int error_number)
 {
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index 849727d69b..599b316ac1 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -4,8 +4,8 @@
 #include "odb/hash.h"
 #include "hex.h"
 #include "odb/tree.h"
-#include "cache-tree.h"
-#include "read-cache-ll.h"
+#include "index/cache-tree.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
 
diff --git a/t/helper/test-dump-fsmonitor.c b/t/helper/test-dump-fsmonitor.c
index c991cbbb8a..1dbdb28fbf 100644
--- a/t/helper/test-dump-fsmonitor.c
+++ b/t/helper/test-dump-fsmonitor.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
 
diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c
index aae0a40a74..79c8628005 100644
--- a/t/helper/test-dump-split-index.c
+++ b/t/helper/test-dump-split-index.c
@@ -2,10 +2,10 @@
 
 #include "test-tool.h"
 #include "hex.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
-#include "split-index.h"
+#include "index/split-index.h"
 #include "ewah/ewok.h"
 
 static void show_bit(size_t pos, void *data UNUSED)
diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
index 24308bd371..c31d01f3b5 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
@@ -1,9 +1,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "hex.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
 
diff --git a/t/helper/test-fsmonitor-client.c b/t/helper/test-fsmonitor-client.c
index dc1dff23fb..845c1db493 100644
--- a/t/helper/test-fsmonitor-client.c
+++ b/t/helper/test-fsmonitor-client.c
@@ -7,8 +7,8 @@
 
 #include "test-tool.h"
 #include "parse-options.h"
-#include "fsmonitor-ipc.h"
-#include "read-cache-ll.h"
+#include "index/fsmonitor-ipc.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
 #include "thread-utils.h"
diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c
index 43cead6d7d..6f16fcf7e8 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -2,9 +2,9 @@
 
 #include "test-tool.h"
 #include "environment.h"
-#include "name-hash.h"
+#include "index/name-hash.h"
 #include "parse-options.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
 #include "trace.h"
diff --git a/t/helper/test-parse-pathspec-file.c b/t/helper/test-parse-pathspec-file.c
index 89ecefd1cd..1b21e919db 100644
--- a/t/helper/test-parse-pathspec-file.c
+++ b/t/helper/test-parse-pathspec-file.c
@@ -1,6 +1,6 @@
 #include "test-tool.h"
 #include "parse-options.h"
-#include "pathspec.h"
+#include "index/pathspec.h"
 
 int cmd__parse_pathspec_file(int argc, const char **argv)
 {
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index f77b3f9d70..fd98a5bfd9 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -5,7 +5,7 @@
 #include "abspath.h"
 #include "environment.h"
 #include "path.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "setup.h"
 #include "string-list.h"
 #include "trace.h"
diff --git a/t/helper/test-path-walk.c b/t/helper/test-path-walk.c
index 71d052d504..f689ff3c53 100644
--- a/t/helper/test-path-walk.c
+++ b/t/helper/test-path-walk.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "environment.h"
 #include "hex.h"
 #include "revision/list-objects-filter-options.h"
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index 6b08ba8f07..dad40b8ad7 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -3,7 +3,7 @@
 #include "test-tool.h"
 #include "config.h"
 #include "environment.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
 
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index f4f7df067d..8e40a08436 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -2,11 +2,11 @@
 
 #include "test-tool.h"
 #include "lockfile.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
 #include "odb/tree.h"
-#include "cache-tree.h"
+#include "index/cache-tree.h"
 
 int cmd__scrap_cache_tree(int ac UNUSED, const char **av UNUSED)
 {
diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c
index 98e1477c98..ffe468b445 100644
--- a/t/helper/test-write-cache.c
+++ b/t/helper/test-write-cache.c
@@ -2,7 +2,7 @@
 
 #include "test-tool.h"
 #include "lockfile.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 #include "repository.h"
 #include "setup.h"
 
diff --git a/t/unit-tests/test-lib.c b/t/unit-tests/test-lib.c
index 72ee20a06f..4d4e37019e 100644
--- a/t/unit-tests/test-lib.c
+++ b/t/unit-tests/test-lib.c
@@ -31,7 +31,7 @@ static struct {
  * There are other compilers that do the same, and are not for
  * Windows.
  */
-#include "dir.h"
+#include "index/dir.h"
 
 static const char *make_relative(const char *location)
 {
diff --git a/t/unit-tests/u-dir.c b/t/unit-tests/u-dir.c
index 2d0adaa39e..72de0b0299 100644
--- a/t/unit-tests/u-dir.c
+++ b/t/unit-tests/u-dir.c
@@ -1,5 +1,5 @@
 #include "unit-test.h"
-#include "dir.h"
+#include "index/dir.h"
 
 #define TEST_WITHIN_DEPTH(path, depth, max_depth, expect) do { \
 		int actual = within_depth(path, strlen(path), \
diff --git a/t/unit-tests/u-reftable-stack.c b/t/unit-tests/u-reftable-stack.c
index e6c1635940..4c53301154 100644
--- a/t/unit-tests/u-reftable-stack.c
+++ b/t/unit-tests/u-reftable-stack.c
@@ -9,7 +9,7 @@ license that can be found in the LICENSE file or at
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "unit-test.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "lib-reftable.h"
 #include "reftable/merged.h"
 #include "reftable/reftable-error.h"
diff --git a/t/unit-tests/u-strcmp-offset.c b/t/unit-tests/u-strcmp-offset.c
index 7e8e9acf3c..8b65c5555c 100644
--- a/t/unit-tests/u-strcmp-offset.c
+++ b/t/unit-tests/u-strcmp-offset.c
@@ -1,5 +1,5 @@
 #include "unit-test.h"
-#include "read-cache-ll.h"
+#include "index/read-cache-ll.h"
 
 static void check_strcmp_offset(const char *string1, const char *string2,
 				int expect_result, uintmax_t expect_offset)
diff --git a/trace2/tr2_sysenv.c b/trace2/tr2_sysenv.c
index 4abc218514..c63aebbec5 100644
--- a/trace2/tr2_sysenv.c
+++ b/trace2/tr2_sysenv.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "config.h"
-#include "dir.h"
+#include "index/dir.h"
 #include "tr2_sysenv.h"
 
 /*
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 13/14] setup: gather the setup sources under setup/
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (11 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 12/14] index: gather the index sources under index/ Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  2026-08-23 17:18 ` [RFC PATCH 14/14] transport: gather the transport sources under transport/ Michael Montalbo
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Move the 9 setup C sources and 9 headers into setup/ as renames. Repoint
every reference to their old paths to the new ones: the #include lines
across the tree, the Makefile and meson.build build entries, and the
tutorial #include examples.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize                                 | 36 ++++++++++----------
 Documentation/MyFirstContribution.adoc       |  4 +--
 Documentation/MyFirstObjectWalk.adoc         |  2 +-
 Makefile                                     | 30 ++++++++--------
 add-interactive.c                            |  2 +-
 add-patch.c                                  |  6 ++--
 advice.c                                     |  4 +--
 apply.c                                      |  8 ++---
 archive-tar.c                                |  2 +-
 archive-zip.c                                |  2 +-
 archive.c                                    |  6 ++--
 attr.c                                       |  6 ++--
 branch.c                                     |  6 ++--
 builtin.h                                    |  2 +-
 builtin/add.c                                |  4 +--
 builtin/am.c                                 |  6 ++--
 builtin/backfill.c                           |  6 ++--
 builtin/bisect.c                             |  2 +-
 builtin/blame.c                              |  6 ++--
 builtin/branch.c                             |  4 +--
 builtin/bugreport.c                          |  6 ++--
 builtin/bundle.c                             |  2 +-
 builtin/cat-file.c                           |  8 ++---
 builtin/check-attr.c                         |  6 ++--
 builtin/check-ignore.c                       |  4 +--
 builtin/check-mailmap.c                      |  6 ++--
 builtin/check-ref-format.c                   |  2 +-
 builtin/checkout--worker.c                   |  4 +--
 builtin/checkout-index.c                     |  6 ++--
 builtin/checkout.c                           | 10 +++---
 builtin/clean.c                              |  6 ++--
 builtin/clone.c                              |  8 ++---
 builtin/column.c                             |  2 +-
 builtin/commit-graph.c                       |  4 +--
 builtin/commit-tree.c                        |  4 +--
 builtin/commit.c                             |  6 ++--
 builtin/config.c                             |  8 ++---
 builtin/count-objects.c                      |  4 +--
 builtin/credential-cache--daemon.c           |  2 +-
 builtin/credential-store.c                   |  2 +-
 builtin/credential.c                         |  4 +--
 builtin/describe.c                           |  6 ++--
 builtin/diff-files.c                         |  2 +-
 builtin/diff-index.c                         |  4 +--
 builtin/diff-pairs.c                         |  2 +-
 builtin/diff-tree.c                          |  2 +-
 builtin/diff.c                               |  4 +--
 builtin/difftool.c                           |  8 ++---
 builtin/fast-export.c                        |  4 +--
 builtin/fast-import.c                        |  4 +--
 builtin/fetch.c                              |  4 +--
 builtin/fmt-merge-msg.c                      |  2 +-
 builtin/for-each-ref.c                       |  4 +--
 builtin/for-each-repo.c                      |  4 +--
 builtin/fsck.c                               |  2 +-
 builtin/fsmonitor--daemon.c                  |  4 +--
 builtin/gc.c                                 |  8 ++---
 builtin/grep.c                               |  6 ++--
 builtin/hash-object.c                        |  6 ++--
 builtin/help.c                               |  8 ++---
 builtin/history.c                            |  4 +--
 builtin/hook.c                               |  6 ++--
 builtin/index-pack.c                         |  6 ++--
 builtin/init-db.c                            |  4 +--
 builtin/interpret-trailers.c                 |  4 +--
 builtin/last-modified.c                      |  6 ++--
 builtin/log.c                                |  6 ++--
 builtin/ls-files.c                           |  6 ++--
 builtin/ls-tree.c                            |  4 +--
 builtin/mailinfo.c                           |  2 +-
 builtin/merge-base.c                         |  4 +--
 builtin/merge-file.c                         |  4 +--
 builtin/merge-ours.c                         |  4 +--
 builtin/merge-tree.c                         |  4 +--
 builtin/merge.c                              | 10 +++---
 builtin/mktag.c                              |  2 +-
 builtin/multi-pack-index.c                   |  6 ++--
 builtin/mv.c                                 |  6 ++--
 builtin/name-rev.c                           |  4 +--
 builtin/notes.c                              |  4 +--
 builtin/organize.c                           |  2 +-
 builtin/pack-objects.c                       |  4 +--
 builtin/patch-id.c                           |  6 ++--
 builtin/prune.c                              |  2 +-
 builtin/pull.c                               |  4 +--
 builtin/push.c                               |  4 +--
 builtin/range-diff.c                         |  2 +-
 builtin/read-tree.c                          |  6 ++--
 builtin/rebase.c                             |  6 ++--
 builtin/receive-pack.c                       | 10 +++---
 builtin/reflog.c                             |  2 +-
 builtin/refs.c                               |  2 +-
 builtin/remote.c                             |  4 +--
 builtin/repack.c                             |  4 +--
 builtin/replace.c                            |  4 +--
 builtin/replay.c                             |  2 +-
 builtin/repo.c                               |  4 +--
 builtin/rerere.c                             |  2 +-
 builtin/reset.c                              |  8 ++---
 builtin/rev-list.c                           |  4 +--
 builtin/rev-parse.c                          | 10 +++---
 builtin/revert.c                             |  2 +-
 builtin/rm.c                                 |  6 ++--
 builtin/send-pack.c                          |  4 +--
 builtin/shortlog.c                           |  6 ++--
 builtin/show-branch.c                        |  4 +--
 builtin/show-ref.c                           |  4 +--
 builtin/sparse-checkout.c                    |  6 ++--
 builtin/stash.c                              |  8 ++---
 builtin/stripspace.c                         |  6 ++--
 builtin/submodule--helper.c                  |  6 ++--
 builtin/symbolic-ref.c                       |  4 +--
 builtin/tag.c                                |  4 +--
 builtin/unpack-file.c                        |  4 +--
 builtin/unpack-objects.c                     |  4 +--
 builtin/update-index.c                       |  6 ++--
 builtin/update-ref.c                         |  4 +--
 builtin/update-server-info.c                 |  4 +--
 builtin/upload-archive.c                     |  2 +-
 builtin/upload-pack.c                        |  4 +--
 builtin/var.c                                |  6 ++--
 builtin/verify-commit.c                      |  4 +--
 builtin/verify-pack.c                        |  4 +--
 builtin/verify-tag.c                         |  4 +--
 builtin/worktree.c                           |  6 ++--
 builtin/write-tree.c                         |  4 +--
 bundle-uri.c                                 |  2 +-
 bundle.c                                     |  4 +--
 color.c                                      |  2 +-
 column.c                                     |  2 +-
 common-init.c                                |  4 +--
 compat/fsmonitor/fsm-health-darwin.c         |  2 +-
 compat/fsmonitor/fsm-health-linux.c          |  2 +-
 compat/fsmonitor/fsm-health-win32.c          |  2 +-
 compat/fsmonitor/fsm-ipc-unix.c              |  4 +--
 compat/fsmonitor/fsm-ipc-win32.c             |  2 +-
 compat/fsmonitor/fsm-listen-win32.c          |  2 +-
 compat/fsmonitor/fsm-settings-unix.c         |  2 +-
 compat/fsmonitor/fsm-settings-win32.c        |  4 +--
 compat/mingw.c                               |  6 ++--
 compat/precompose_utf8.c                     |  4 +--
 compat/regex/regex.c                         |  2 +-
 compat/win32/path-utils.c                    |  4 +--
 compat/win32/trace2_win32_process_info.c     |  2 +-
 connect.c                                    |  8 ++---
 contrib/libgit-sys/public_symbol_export.c    |  4 +--
 convert.c                                    |  2 +-
 credential.c                                 |  6 ++--
 daemon.c                                     |  6 ++--
 diagnose.c                                   |  2 +-
 diff/combine-diff.c                          |  2 +-
 diff/diff-lib.c                              |  2 +-
 diff/diff.c                                  |  6 ++--
 diff/range-diff.c                            |  4 +--
 diff/tree-diff.c                             |  2 +-
 diff/userdiff.c                              |  4 +--
 diff/xdiff-interface.c                       |  4 +--
 editor.c                                     |  4 +--
 exec-cmd.c                                   |  2 +-
 fetch-negotiator.c                           |  2 +-
 fetch-pack.c                                 |  8 ++---
 fmt-merge-msg.c                              |  4 +--
 gettext.c                                    |  2 +-
 git.c                                        |  8 ++---
 gpg-interface.c                              |  6 ++--
 grep.c                                       |  2 +-
 help.c                                       |  8 ++---
 http-backend.c                               |  8 ++---
 http-fetch.c                                 |  6 ++--
 http-push.c                                  |  6 ++--
 http-walker.c                                |  2 +-
 http.c                                       |  6 ++--
 imap-send.c                                  |  6 ++--
 index/cache-tree.c                           |  2 +-
 index/checkout.c                             |  4 +--
 index/dir.c                                  |  8 ++---
 index/entry.c                                |  2 +-
 index/fsmonitor-ipc.c                        |  2 +-
 index/fsmonitor-settings.c                   |  4 +--
 index/fsmonitor.c                            |  6 ++--
 index/name-hash.c                            |  2 +-
 index/parallel-checkout.c                    |  2 +-
 index/pathspec.c                             |  6 ++--
 index/preload-index.c                        |  6 ++--
 index/read-cache.c                           |  8 ++---
 index/read-cache.h                           |  2 +-
 index/sparse-index.c                         |  6 ++--
 index/split-index.c                          |  2 +-
 index/statinfo.c                             |  4 +--
 index/symlinks.c                             |  2 +-
 index/unpack-trees.c                         |  6 ++--
 index/wt-status.c                            |  6 ++--
 lockfile.c                                   |  2 +-
 mailinfo.c                                   |  4 +--
 mailmap.c                                    |  6 ++--
 merge-ll.c                                   |  2 +-
 merge-ort-wrappers.c                         |  2 +-
 merge-ort.c                                  |  4 +--
 merge.c                                      |  2 +-
 meson.build                                  | 18 +++++-----
 negotiator/default.c                         |  2 +-
 negotiator/skipping.c                        |  2 +-
 notes-cache.c                                |  2 +-
 notes-merge.c                                |  2 +-
 notes-utils.c                                |  4 +--
 notes.c                                      |  4 +--
 odb/alloc.c                                  |  2 +-
 odb/commit.c                                 |  8 ++---
 odb/fsck.c                                   |  6 ++--
 odb/hash.h                                   |  2 +-
 odb/loose.c                                  |  2 +-
 odb/match-trees.c                            |  2 +-
 odb/object-file-convert.c                    |  2 +-
 odb/object-file.c                            |  4 +--
 odb/object-name.c                            | 10 +++---
 odb/odb.c                                    |  6 ++--
 odb/replace-object.c                         |  2 +-
 odb/replace-object.h                         |  2 +-
 odb/source-files.c                           |  2 +-
 odb/source-inmemory.c                        |  2 +-
 odb/source-loose.c                           |  2 +-
 odb/streaming.c                              |  4 +--
 odb/tag.c                                    |  4 +--
 odb/tmp-objdir.c                             |  4 +--
 odb/tree-walk.c                              |  2 +-
 odb/tree.c                                   |  4 +--
 organize/organize.c                          |  4 +--
 oss-fuzz/fuzz-commit-graph.c                 |  2 +-
 oss-fuzz/fuzz-config.c                       |  2 +-
 pack/bloom.c                                 |  4 +--
 pack/commit-graph.c                          |  4 +--
 pack/delta-islands.c                         |  2 +-
 pack/midx-write.c                            |  2 +-
 pack/midx.c                                  |  2 +-
 pack/pack-bitmap-write.c                     |  4 +--
 pack/pack-bitmap.c                           |  4 +--
 pack/pack-check.c                            |  4 +--
 pack/pack-objects.c                          |  2 +-
 pack/pack-revindex.c                         |  2 +-
 pack/pack-write.c                            |  4 +--
 pack/packfile.c                              |  4 +--
 pack/packfile.h                              |  2 +-
 pack/prune-packed.c                          |  2 +-
 pack/pseudo-merge.c                          |  2 +-
 pack/reachable.c                             |  2 +-
 pack/repack-cruft.c                          |  2 +-
 pack/repack-filtered.c                       |  2 +-
 pack/repack-geometry.c                       |  2 +-
 pack/repack-promisor.c                       |  2 +-
 pack/repack.c                                |  2 +-
 pack/server-info.c                           |  2 +-
 pager.c                                      |  8 ++---
 parse-options-cb.c                           |  4 +--
 path-walk.c                                  |  2 +-
 path.c                                       |  4 +--
 path.h                                       |  2 +-
 progress.c                                   |  2 +-
 promisor-remote.c                            |  6 ++--
 promisor-remote.h                            |  2 +-
 prompt.c                                     |  4 +--
 protocol-caps.c                              |  2 +-
 protocol.c                                   |  4 +--
 rebase-interactive.c                         |  6 ++--
 refs/files-backend.c                         | 10 +++---
 refs/ls-refs.c                               |  6 ++--
 refs/pack-refs.c                             |  4 +--
 refs/packed-backend.c                        |  2 +-
 refs/ref-cache.c                             |  2 +-
 refs/ref-filter.c                            | 10 +++---
 refs/reflog-walk.c                           |  2 +-
 refs/reflog.c                                |  4 +--
 refs/refs.c                                  | 12 +++----
 refs/refs.h                                  |  4 +--
 refs/reftable-backend.c                      | 10 +++---
 refs/worktree.c                              |  8 ++---
 remote-curl.c                                |  6 ++--
 remote.c                                     |  6 ++--
 replay.c                                     |  2 +-
 rerere.c                                     |  4 +--
 reset.c                                      |  2 +-
 reset.h                                      |  2 +-
 revision/bisect.c                            |  4 +--
 revision/blame.c                             |  2 +-
 revision/graph.c                             |  2 +-
 revision/line-log.c                          |  4 +--
 revision/list-objects-filter-options.c       |  2 +-
 revision/list-objects.c                      |  2 +-
 revision/log-tree.c                          |  6 ++--
 revision/pretty.c                            |  4 +--
 revision/revision.c                          |  8 ++---
 revision/revision.h                          |  2 +-
 revision/shallow.c                           |  2 +-
 revision/shallow.h                           |  2 +-
 run-command.c                                |  4 +--
 scalar.c                                     |  4 +--
 send-pack.c                                  |  4 +--
 sequencer.c                                  |  8 ++---
 serve.c                                      |  6 ++--
 alias.c => setup/alias.c                     |  4 +--
 alias.h => setup/alias.h                     |  0
 config.c => setup/config.c                   |  8 ++---
 config.h => setup/config.h                   |  2 +-
 environment.c => setup/environment.c         | 10 +++---
 environment.h => setup/environment.h         |  2 +-
 hook.c => setup/hook.c                       |  8 ++---
 hook.h => setup/hook.h                       |  2 +-
 ident.c => setup/ident.c                     |  4 +--
 ident.h => setup/ident.h                     |  0
 repo-settings.c => setup/repo-settings.c     |  8 ++---
 repo-settings.h => setup/repo-settings.h     |  0
 repository.c => setup/repository.c           |  8 ++---
 repository.h => setup/repository.h           |  4 +--
 setup.c => setup/setup.c                     |  8 ++---
 setup.h => setup/setup.h                     |  0
 version.c => setup/version.c                 |  2 +-
 version.h => setup/version.h                 |  0
 shell.c                                      |  2 +-
 sideband.c                                   |  2 +-
 submodule-config.c                           |  6 ++--
 submodule-config.h                           |  2 +-
 submodule.c                                  |  8 ++---
 t/helper/test-advise.c                       |  6 ++--
 t/helper/test-bitmap.c                       |  2 +-
 t/helper/test-bloom.c                        |  4 +--
 t/helper/test-cache-tree.c                   |  4 +--
 t/helper/test-config.c                       |  4 +--
 t/helper/test-dump-cache-tree.c              |  4 +--
 t/helper/test-dump-fsmonitor.c               |  4 +--
 t/helper/test-dump-split-index.c             |  4 +--
 t/helper/test-dump-untracked-cache.c         |  4 +--
 t/helper/test-find-pack.c                    |  2 +-
 t/helper/test-fsmonitor-client.c             |  4 +--
 t/helper/test-lazy-init-name-hash.c          |  6 ++--
 t/helper/test-match-trees.c                  |  4 +--
 t/helper/test-pack-deltas.c                  |  2 +-
 t/helper/test-pack-mtimes.c                  |  2 +-
 t/helper/test-partial-clone.c                |  4 +--
 t/helper/test-path-utils.c                   |  4 +--
 t/helper/test-path-walk.c                    |  4 +--
 t/helper/test-progress.c                     |  2 +-
 t/helper/test-reach.c                        |  2 +-
 t/helper/test-read-cache.c                   |  8 ++---
 t/helper/test-read-graph.c                   |  4 +--
 t/helper/test-read-midx.c                    |  4 +--
 t/helper/test-ref-store.c                    |  4 +--
 t/helper/test-repository.c                   |  6 ++--
 t/helper/test-revision-walking.c             |  4 +--
 t/helper/test-scrap-cache-tree.c             |  4 +--
 t/helper/test-serve-v2.c                     |  4 +--
 t/helper/test-submodule-config.c             |  6 ++--
 t/helper/test-submodule-nested-repo-config.c |  4 +--
 t/helper/test-submodule.c                    |  4 +--
 t/helper/test-subprocess.c                   |  2 +-
 t/helper/test-synthesize.c                   |  4 +--
 t/helper/test-trace2.c                       |  4 +--
 t/helper/test-userdiff.c                     |  4 +--
 t/helper/test-write-cache.c                  |  4 +--
 t/unit-tests/u-example-decorate.c            |  2 +-
 t/unit-tests/u-odb-inmemory.c                |  2 +-
 trace.c                                      |  4 +--
 trace2.c                                     |  4 +--
 trace2/tr2_cfg.c                             |  2 +-
 trace2/tr2_sysenv.c                          |  2 +-
 trace2/tr2_tgt_event.c                       |  6 ++--
 trace2/tr2_tgt_normal.c                      |  6 ++--
 trace2/tr2_tgt_perf.c                        |  6 ++--
 trailer.c                                    |  4 +--
 transport-helper.c                           |  4 +--
 transport.c                                  |  6 ++--
 upload-pack.c                                |  8 ++---
 urlmatch.h                                   |  2 +-
 versioncmp.c                                 |  2 +-
 walker.c                                     |  2 +-
 373 files changed, 798 insertions(+), 798 deletions(-)
 rename alias.c => setup/alias.c (98%)
 rename alias.h => setup/alias.h (100%)
 rename config.c => setup/config.c (99%)
 rename config.h => setup/config.h (99%)
 rename environment.c => setup/environment.c (99%)
 rename environment.h => setup/environment.h (99%)
 rename hook.c => setup/hook.c (99%)
 rename hook.h => setup/hook.h (99%)
 rename ident.c => setup/ident.c (99%)
 rename ident.h => setup/ident.h (100%)
 rename repo-settings.c => setup/repo-settings.c (98%)
 rename repo-settings.h => setup/repo-settings.h (100%)
 rename repository.c => setup/repository.c (99%)
 rename repository.h => setup/repository.h (99%)
 rename setup.c => setup/setup.c (99%)
 rename setup.h => setup/setup.h (100%)
 rename version.c => setup/version.c (98%)
 rename version.h => setup/version.h (100%)

diff --git a/.gitorganize b/.gitorganize
index fe81c40f09..cb6416bfc3 100644
--- a/.gitorganize
+++ b/.gitorganize
@@ -28,8 +28,6 @@ add-patch.c component=? role=lib prefix=add-patch includes=setup:3,index:2,odb:2
 add-patch.h component=? role=public prefix=add-patch cochange=odb:1
 advice.c component=? role=lib prefix=advice includes=setup:2 cochange=transport:18,index:12,odb:9,diff:8,revision:8
 advice.h component=? role=public prefix=advice cochange=transport:14,index:9,odb:6,submodule:4,pack:3
-alias.c component=setup role=lib prefix=alias includes=setup:2 cochange=setup:8,diff:4,transport:3,convert:2,index:2
-alias.h component=setup role=header prefix=completion cochange=setup:3,transport:2,pack:1,revision:1
 apply.c component=? role=lib prefix=apply includes=index:5,setup:4,odb:3,diff:2,merge:2 cochange=index:93,setup:43,diff:41,odb:26,merge:24
 apply.h component=? role=public prefix=apply includes=odb:1 cochange=diff:2
 archive-tar.c component=archive role=lib prefix=archive-tar includes=archive:1,odb:1,setup:1 cochange=archive:59,index:12,diff:9,odb:9,transport:8
@@ -58,8 +56,6 @@ common-exit.c component=? role=lib prefix=common-main
 common-init.c component=? role=lib prefix=common-main includes=odb:2,setup:2,convert:1 cochange=setup:1
 common-init.h component=? role=public prefix=common-main
 common-main.c component=? role=lib prefix=common-main cochange=setup:5,transport:4,convert:3,index:1
-config.c component=setup role=lib prefix=config includes=setup:4,odb:2,convert:1,index:1,refs:1 cochange=setup:274,index:93,diff:75,refs:48,revision:46
-config.h component=setup role=header prefix=config includes=setup:1 cochange=setup:100,index:30,transport:23,submodule:21,merge:6
 connect.c component=transport role=lib prefix=connect includes=transport:7,setup:4,odb:1,refs:1 cochange=transport:238,setup:19,diff:13,index:10,refs:10
 connect.h component=transport role=header prefix=connect includes=transport:1 cochange=transport:58,refs:1
 connected.c component=transport role=lib prefix=connected includes=transport:3,odb:1,pack:1 cochange=transport:39,pack:31,odb:7,diff:6,index:5
@@ -103,8 +99,6 @@ diff/xdiff-interface.c component=diff role=lib prefix=xdiff-interface includes=s
 diff/xdiff-interface.h component=diff role=header prefix=xdiff-interface includes=odb:1 cochange=diff:62,index:2,notes:2,merge:1,odb:1
 editor.c component=? role=lib prefix=editor includes=setup:2 cochange=transport:20,setup:12,index:8,odb:4,submodule:4
 editor.h component=? role=public prefix=editor cochange=transport:1
-environment.c component=setup role=lib prefix=environment includes=setup:5,convert:3,odb:2,merge:1,refs:1 cochange=setup:281,index:77,odb:48,refs:36,transport:28
-environment.h component=setup role=header prefix=environment includes=setup:1 cochange=setup:135,index:37,odb:15,refs:11,pack:9
 exec-cmd.c component=? role=lib prefix=strvec includes=setup:1
 exec-cmd.h component=? role=public prefix=argv-array cochange=refs:4,transport:4,odb:1,setup:1,submodule:1
 fetch-negotiator.c component=transport role=lib prefix=repo-settings includes=setup:1,transport:1 cochange=setup:8,transport:7,index:2,odb:1
@@ -135,16 +129,12 @@ hex-ll.c component=? role=lib prefix=hex-ll
 hex-ll.h component=? role=public prefix=hex-ll
 hex.c component=? role=lib prefix=hex includes=odb:1 cochange=odb:7,revision:5,notes:3,transport:3,refs:2
 hex.h component=? role=public prefix=hex includes=odb:1 cochange=revision:3,odb:2,convert:1,merge:1,pack:1
-hook.c component=setup role=lib prefix=hook includes=setup:4 cochange=setup:37,transport:10,odb:8,refs:5,diff:3
-hook.h component=setup role=header prefix=hook includes=setup:1 cochange=setup:34,transport:6,odb:5,refs:5,pack:3
 http-backend.c component=? role=program prefix=http-backend includes=setup:4,odb:3,transport:2,pack:1,refs:1 cochange=transport:57,pack:41,setup:19,refs:14,revision:13
 http-fetch.c component=? role=program prefix=http-fetch includes=setup:3,transport:2 cochange=transport:46,setup:10,pack:9,index:7,refs:7
 http-push.c component=? role=program prefix=http-push includes=odb:7,revision:3,setup:3,transport:2,diff:1 cochange=transport:272,odb:134,revision:82,pack:60,diff:34
 http-walker.c component=transport role=lib prefix=http includes=transport:3,odb:2,pack:1,revision:1,setup:1 cochange=transport:73,pack:40,odb:17,index:11,refs:7
 http.c component=transport role=lib prefix=http includes=transport:4,setup:3,odb:2,pack:2 cochange=transport:195,pack:71,odb:27,diff:8,setup:8
 http.h component=transport role=header prefix=http includes=transport:1 cochange=transport:149,pack:15,diff:6,odb:4,archive:3
-ident.c component=setup role=lib prefix=ident includes=setup:2 cochange=setup:19,revision:10,odb:6,refs:6,pack:4
-ident.h component=setup role=header prefix=ident cochange=setup:3,revision:1
 imap-send.c component=? role=program prefix=imap-send includes=setup:3,transport:1 cochange=transport:47,diff:16,index:16,refs:9,odb:8
 index/cache-tree.c component=index role=lib prefix=cache-tree includes=odb:5,index:2,setup:1,transport:1 cochange=index:94,odb:69,revision:27,transport:21,diff:20
 index/cache-tree.h component=index role=header prefix=cache-tree includes=odb:2 cochange=index:42,diff:4,revision:4,odb:3,refs:1
@@ -373,10 +363,6 @@ remote.c component=transport role=lib prefix=remote includes=odb:3,setup:3,trans
 remote.h component=transport role=header prefix=remote includes=odb:1,refs:1 cochange=transport:245,refs:24,index:12,revision:6,setup:2
 replay.c component=? role=lib prefix=replay includes=odb:2,merge:1,refs:1,revision:1,setup:1 cochange=transport:1
 replay.h component=? role=public prefix=replay includes=odb:1
-repo-settings.c component=setup role=lib prefix=repo-settings includes=setup:4,pack:2 cochange=setup:65,pack:17,index:8,transport:8,odb:6
-repo-settings.h component=setup role=header prefix=environment cochange=setup:40,pack:7,refs:6,odb:4,diff:2
-repository.c component=setup role=lib prefix=repository includes=setup:4,odb:3,index:2,transport:2,refs:1 cochange=setup:141,odb:39,index:27,refs:18,submodule:17
-repository.h component=setup role=header prefix=repository includes=setup:2 cochange=setup:157,index:31,refs:25,pack:22,odb:19
 rerere.c component=merge role=lib prefix=rerere includes=index:4,merge:2,odb:2,setup:2,diff:1 cochange=index:54,merge:29,pack:26,odb:25,transport:25
 rerere.h component=merge role=header prefix=rerere cochange=merge:16,odb:1
 reset.c component=? role=lib prefix=reset includes=odb:3,index:2,refs:1,setup:1 cochange=index:9,merge:5,odb:3,notes:2,revision:2
@@ -420,8 +406,24 @@ sequencer.c component=? role=lib prefix=sequencer includes=odb:8,index:5,merge:4
 sequencer.h component=? role=public prefix=sequencer includes=index:1 cochange=revision:5,index:4,notes:3,odb:3,transport:3
 serve.c component=transport role=lib prefix=serve includes=transport:6,setup:3,odb:1,refs:1 cochange=transport:53,refs:7,odb:4,setup:3,index:1
 serve.h component=transport role=header prefix=serve cochange=transport:9,refs:3,submodule:1
-setup.c component=setup role=lib prefix=setup includes=setup:4,odb:2,refs:2,index:1,revision:1 cochange=setup:177,refs:47,transport:44,index:39,odb:24
-setup.h component=setup role=header prefix=setup includes=refs:1 cochange=setup:70,refs:8,index:5,revision:4,submodule:4
+setup/alias.c component=setup role=lib prefix=alias includes=setup:2 cochange=setup:8,diff:4,transport:3,convert:2,index:2
+setup/alias.h component=setup role=header prefix=completion cochange=setup:3,transport:2,pack:1,revision:1
+setup/config.c component=setup role=lib prefix=config includes=setup:4,odb:2,convert:1,index:1,refs:1 cochange=setup:274,index:93,diff:75,refs:48,revision:46
+setup/config.h component=setup role=header prefix=config includes=setup:1 cochange=setup:100,index:30,transport:23,submodule:21,merge:6
+setup/environment.c component=setup role=lib prefix=environment includes=setup:5,convert:3,odb:2,merge:1,refs:1 cochange=setup:281,index:77,odb:48,refs:36,transport:28
+setup/environment.h component=setup role=header prefix=environment includes=setup:1 cochange=setup:135,index:37,odb:15,refs:11,pack:9
+setup/hook.c component=setup role=lib prefix=hook includes=setup:4 cochange=setup:37,transport:10,odb:8,refs:5,diff:3
+setup/hook.h component=setup role=header prefix=hook includes=setup:1 cochange=setup:34,transport:6,odb:5,refs:5,pack:3
+setup/ident.c component=setup role=lib prefix=ident includes=setup:2 cochange=setup:19,revision:10,odb:6,refs:6,pack:4
+setup/ident.h component=setup role=header prefix=ident cochange=setup:3,revision:1
+setup/repo-settings.c component=setup role=lib prefix=repo-settings includes=setup:4,pack:2 cochange=setup:65,pack:17,index:8,transport:8,odb:6
+setup/repo-settings.h component=setup role=header prefix=environment cochange=setup:40,pack:7,refs:6,odb:4,diff:2
+setup/repository.c component=setup role=lib prefix=repository includes=setup:4,odb:3,index:2,transport:2,refs:1 cochange=setup:141,odb:39,index:27,refs:18,submodule:17
+setup/repository.h component=setup role=header prefix=repository includes=setup:2 cochange=setup:157,index:31,refs:25,pack:22,odb:19
+setup/setup.c component=setup role=lib prefix=setup includes=setup:4,odb:2,refs:2,index:1,revision:1 cochange=setup:177,refs:47,transport:44,index:39,odb:24
+setup/setup.h component=setup role=header prefix=setup includes=refs:1 cochange=setup:70,refs:8,index:5,revision:4,submodule:4
+setup/version.c component=setup role=lib prefix=version includes=setup:1 cochange=setup:8,transport:2
+setup/version.h component=setup role=header prefix=version cochange=setup:8,transport:2
 sh-i18n--envsubst.c component=? role=program prefix=sh-i18n--envsubst cochange=index:3,diff:1,transport:1
 sha1dc_git.c component=? role=lib prefix=sha1dc cochange=diff:3,odb:2,revision:2,setup:1
 sha1dc_git.h component=? role=public prefix=sha1dc cochange=odb:2
@@ -478,8 +480,6 @@ utf8.c component=? role=lib prefix=utf8 cochange=revision:6,index:3,setup:3,tran
 utf8.h component=? role=public prefix=utf8 cochange=revision:6,index:2,setup:2,transport:2,convert:1
 varint.c component=? role=lib prefix=varint cochange=index:2,transport:1
 varint.h component=? role=public prefix=varint cochange=index:2,transport:1
-version.c component=setup role=lib prefix=version includes=setup:1 cochange=setup:8,transport:2
-version.h component=setup role=header prefix=version cochange=setup:8,transport:2
 versioncmp.c component=? role=lib prefix=versioncmp includes=setup:1 cochange=setup:5,pack:3,transport:3,index:2,refs:2
 versioncmp.h component=? role=public prefix=versioncmp cochange=refs:1
 walker.c component=transport role=lib prefix=refs includes=odb:6,refs:1,setup:1,transport:1 cochange=odb:70,transport:55,revision:42,refs:24,pack:17
diff --git a/Documentation/MyFirstContribution.adoc b/Documentation/MyFirstContribution.adoc
index 63468494c1..9d899efb36 100644
--- a/Documentation/MyFirstContribution.adoc
+++ b/Documentation/MyFirstContribution.adoc
@@ -331,8 +331,8 @@ on the command line, including the name of our command. (If `prefix` is empty
 for you, try `cd Documentation/ && ../bin-wrappers/git psuh`). That's not so
 helpful. So what other context can we get?
 
-Add a line to `#include "config.h"`, `#include "repository.h"` and
-`#include "environment.h"`.
+Add a line to `#include "setup/config.h"`, `#include "setup/repository.h"` and
+`#include "setup/environment.h"`.
 Then, add the following bits to the function body:
 function body:
 
diff --git a/Documentation/MyFirstObjectWalk.adoc b/Documentation/MyFirstObjectWalk.adoc
index 7fb63e6861..6e3715bad7 100644
--- a/Documentation/MyFirstObjectWalk.adoc
+++ b/Documentation/MyFirstObjectWalk.adoc
@@ -219,7 +219,7 @@ Add a new function to `builtin/walken.c`.
 We'll also need to include the `config.h` header:
 
 ----
-#include "config.h"
+#include "setup/config.h"
 
 ...
 
diff --git a/Makefile b/Makefile
index 5e404ffa5e..cec75e834a 100644
--- a/Makefile
+++ b/Makefile
@@ -1102,7 +1102,7 @@ LIB_OBJS += abspath.o
 LIB_OBJS += add-interactive.o
 LIB_OBJS += add-patch.o
 LIB_OBJS += advice.o
-LIB_OBJS += alias.o
+LIB_OBJS += setup/alias.o
 LIB_OBJS += odb/alloc.o
 LIB_OBJS += apply.o
 LIB_OBJS += archive-tar.o
@@ -1135,7 +1135,7 @@ LIB_OBJS += compat/obstack.o
 LIB_OBJS += compat/open.o
 LIB_OBJS += compat/terminal.o
 LIB_OBJS += compiler-tricks/not-constant.o
-LIB_OBJS += config.o
+LIB_OBJS += setup/config.o
 LIB_OBJS += connect.o
 LIB_OBJS += connected.o
 LIB_OBJS += convert.o
@@ -1162,7 +1162,7 @@ LIB_OBJS += index/dir-iterator.o
 LIB_OBJS += index/dir.o
 LIB_OBJS += editor.o
 LIB_OBJS += index/entry.o
-LIB_OBJS += environment.o
+LIB_OBJS += setup/environment.o
 LIB_OBJS += ewah/bitmap.o
 LIB_OBJS += ewah/ewah_bitmap.o
 LIB_OBJS += ewah/ewah_io.o
@@ -1187,8 +1187,8 @@ LIB_OBJS += hashmap.o
 LIB_OBJS += help.o
 LIB_OBJS += hex.o
 LIB_OBJS += hex-ll.o
-LIB_OBJS += hook.o
-LIB_OBJS += ident.o
+LIB_OBJS += setup/hook.o
+LIB_OBJS += setup/ident.o
 LIB_OBJS += json-writer.o
 LIB_OBJS += kwset.o
 LIB_OBJS += levenshtein.o
@@ -1312,8 +1312,8 @@ LIB_OBJS += pack/repack-midx.o
 LIB_OBJS += pack/repack-promisor.o
 LIB_OBJS += odb/replace-object.o
 LIB_OBJS += replay.o
-LIB_OBJS += repo-settings.o
-LIB_OBJS += repository.o
+LIB_OBJS += setup/repo-settings.o
+LIB_OBJS += setup/repository.o
 LIB_OBJS += rerere.o
 LIB_OBJS += reset.o
 LIB_OBJS += index/resolve-undo.o
@@ -1323,7 +1323,7 @@ LIB_OBJS += send-pack.o
 LIB_OBJS += sequencer.o
 LIB_OBJS += serve.o
 LIB_OBJS += pack/server-info.o
-LIB_OBJS += setup.o
+LIB_OBJS += setup/setup.o
 LIB_OBJS += revision/shallow.o
 LIB_OBJS += sideband.o
 LIB_OBJS += sigchain.o
@@ -1373,7 +1373,7 @@ LIB_OBJS += utf8.o
 ifdef NO_RUST
 LIB_OBJS += varint.o
 endif
-LIB_OBJS += version.o
+LIB_OBJS += setup/version.o
 LIB_OBJS += versioncmp.o
 LIB_OBJS += walker.o
 LIB_OBJS += wildmatch.o
@@ -2691,7 +2691,7 @@ git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
 
 help.sp help.s help.o: command-list.h
 builtin/bugreport.sp builtin/bugreport.s builtin/bugreport.o: hook-list.h
-hook.sp hook.s hook.o: hook-list.h
+setup/hook.sp setup/hook.s setup/hook.o: hook-list.h
 
 builtin/help.sp builtin/help.s builtin/help.o: config-list.h GIT-PREFIX
 builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
@@ -2708,7 +2708,7 @@ pager.sp pager.s pager.o: EXTRA_CPPFLAGS = \
 version-def.h: version-def.h.in GIT-VERSION-GEN GIT-VERSION-FILE GIT-USER-AGENT
 	$(QUIET_GEN)$(call version_gen,"$(shell pwd)",$<,$@)
 
-version.sp version.s version.o: version-def.h
+setup/version.sp setup/version.s setup/version.o: version-def.h
 
 $(BUILT_INS): git$X
 	$(QUIET_BUILT_IN)$(RM) $@ && \
@@ -2973,12 +2973,12 @@ exec-cmd.sp exec-cmd.s exec-cmd.o: EXTRA_CPPFLAGS = \
 	'-DBINDIR="$(bindir_relative_SQ)"' \
 	'-DFALLBACK_RUNTIME_PREFIX="$(prefix_SQ)"'
 
-setup.sp setup.s setup.o: GIT-PREFIX
-setup.sp setup.s setup.o: EXTRA_CPPFLAGS = \
+setup/setup.sp setup/setup.s setup/setup.o: GIT-PREFIX
+setup/setup.sp setup/setup.s setup/setup.o: EXTRA_CPPFLAGS = \
 	-DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
 
-config.sp config.s config.o: GIT-PREFIX
-config.sp config.s config.o: EXTRA_CPPFLAGS = \
+setup/config.sp setup/config.s setup/config.o: GIT-PREFIX
+setup/config.sp setup/config.s setup/config.o: EXTRA_CPPFLAGS = \
 	-DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"'
 
 attr.sp attr.s attr.o: GIT-PREFIX
diff --git a/add-interactive.c b/add-interactive.c
index 5f4d379910..e14a2c98f3 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -9,7 +9,7 @@
 #include "hex.h"
 #include "index/preload-index.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "revision/revision.h"
 #include "refs/refs.h"
 #include "string-list.h"
diff --git a/add-patch.c b/add-patch.c
index 0499152dbc..f1f4b0c4c6 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -5,16 +5,16 @@
 #include "add-patch.h"
 #include "advice.h"
 #include "odb/commit.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
 #include "pager.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 #include "sigchain.h"
 #include "run-command.h"
diff --git a/advice.c b/advice.c
index 63bf8b0c5f..3139ac5e87 100644
--- a/advice.c
+++ b/advice.c
@@ -1,8 +1,8 @@
 #include "git-compat-util.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "color.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "help.h"
 #include "string-list.h"
diff --git a/apply.c b/apply.c
index 70d5461fbe..75f81b1444 100644
--- a/apply.c
+++ b/apply.c
@@ -13,12 +13,12 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "base85.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/odb.h"
 #include "pack/delta.h"
 #include "diff/diff.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "diff/xdiff-interface.h"
@@ -31,11 +31,11 @@
 #include "path.h"
 #include "quote.h"
 #include "index/read-cache.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "rerere.h"
 #include "apply.h"
 #include "index/entry.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/symlinks.h"
 #include "wildmatch.h"
 #include "ws.h"
diff --git a/archive-tar.c b/archive-tar.c
index 318b9bcc24..525b517749 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -5,7 +5,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "git-zlib.h"
 #include "hex.h"
diff --git a/archive-zip.c b/archive-zip.c
index df1edadd33..1e8baf3205 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -5,7 +5,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "archive.h"
 #include "gettext.h"
 #include "git-zlib.h"
diff --git a/archive.c b/archive.c
index e6fdd2ea8f..3f3922c3e6 100644
--- a/archive.c
+++ b/archive.c
@@ -3,16 +3,16 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "config.h"
+#include "setup/config.h"
 #include "convert.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "git-zlib.h"
 #include "hex.h"
 #include "odb/object-name.h"
 #include "path.h"
 #include "revision/pretty.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "refs/refs.h"
 #include "odb/odb.h"
 #include "odb/commit.h"
diff --git a/attr.c b/attr.c
index 841d2f23ae..9180683faa 100644
--- a/attr.c
+++ b/attr.c
@@ -10,8 +10,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "exec-cmd.h"
 #include "attr.h"
 #include "index/dir.h"
@@ -23,7 +23,7 @@
 #include "refs/refs.h"
 #include "revision/revision.h"
 #include "odb/odb.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "thread-utils.h"
 #include "odb/tree-walk.h"
 #include "odb/object-name.h"
diff --git a/branch.c b/branch.c
index d752e55b88..14483c1402 100644
--- a/branch.c
+++ b/branch.c
@@ -2,9 +2,9 @@
 
 #include "git-compat-util.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "branch.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
@@ -12,7 +12,7 @@
 #include "refs/refs.h"
 #include "refs/refspec.h"
 #include "remote.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "sequencer.h"
 #include "odb/commit.h"
 #include "refs/worktree.h"
diff --git a/builtin.h b/builtin.h
index 0ac855e534..7c48a8e29f 100644
--- a/builtin.h
+++ b/builtin.h
@@ -2,7 +2,7 @@
 #define BUILTIN_H
 
 #include "git-compat-util.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 /*
  * builtin API
diff --git a/builtin/add.c b/builtin/add.c
index e544220eb2..69b6d7e7ca 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -6,8 +6,8 @@
 
 #include "builtin.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "lockfile.h"
 #include "editor.h"
 #include "index/dir.h"
diff --git a/builtin/am.c b/builtin/am.c
index 0b6d77004f..053043e477 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -9,15 +9,15 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "parse-options.h"
 #include "index/dir.h"
 #include "run-command.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "quote.h"
 #include "tempfile.h"
 #include "lockfile.h"
diff --git a/builtin/backfill.c b/builtin/backfill.c
index b8e21c844c..f30addad55 100644
--- a/builtin/backfill.c
+++ b/builtin/backfill.c
@@ -3,12 +3,12 @@
 
 #include "builtin.h"
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "parse-options.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/commit.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index cfb0741d22..61205f13b6 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -3,7 +3,7 @@
 
 #include "builtin.h"
 #include "copy.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index 9e5776e31b..23e6f77d42 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -8,9 +8,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "color.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/commit.h"
@@ -31,7 +31,7 @@
 #include "pager.h"
 #include "revision/blame.h"
 #include "refs/refs.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "odb/tag.h"
 #include "write-or-die.h"
 
diff --git a/builtin/branch.c b/builtin/branch.c
index c80df76d36..eeab13a4b6 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -8,10 +8,10 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "color.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "refs/refs.h"
 #include "odb/commit.h"
 #include "gettext.h"
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index f78c3f2aed..dffed32db6 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -8,11 +8,11 @@
 #include "strbuf.h"
 #include "help.h"
 #include "compat/compiler.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "hook-list.h"
 #include "diagnose.h"
-#include "setup.h"
-#include "version.h"
+#include "setup/setup.h"
+#include "setup/version.h"
 
 static void get_system_info(struct strbuf *sys_info)
 {
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 1e170e9278..6dbe478bcb 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -2,7 +2,7 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "gettext.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strvec.h"
 #include "parse-options.h"
 #include "pkt-line.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 94979a2683..4a5c73720d 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -8,13 +8,13 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "convert.h"
 #include "diff/diff.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "ident.h"
+#include "setup/ident.h"
 #include "revision/list-objects-filter-options.h"
 #include "parse-options.h"
 #include "diff/userdiff.h"
@@ -28,7 +28,7 @@
 #include "promisor-remote.h"
 #include "mailmap.h"
 #include "write-or-die.h"
-#include "alias.h"
+#include "setup/alias.h"
 #include "remote.h"
 #include "transport.h"
 
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 02ff3b4eb5..8eb5d4e748 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -1,12 +1,12 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "attr.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/object-name.h"
 #include "quote.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "parse-options.h"
 #include "write-or-die.h"
 
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 1d2c3cb8db..00a04404bd 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "quote.h"
 #include "index/pathspec.h"
diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c
index 3f2a39cae0..4c3fc0de7a 100644
--- a/builtin/check-mailmap.c
+++ b/builtin/check-mailmap.c
@@ -1,9 +1,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
-#include "ident.h"
+#include "setup/ident.h"
 #include "mailmap.h"
 #include "parse-options.h"
 #include "strbuf.h"
diff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c
index 5de8c0e6f5..cb8f539b02 100644
--- a/builtin/check-ref-format.c
+++ b/builtin/check-ref-format.c
@@ -6,7 +6,7 @@
 
 #include "builtin.h"
 #include "refs/refs.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 
 static const char builtin_check_ref_format_usage[] =
diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c
index 9c49474753..aa1ca1ed14 100644
--- a/builtin/checkout--worker.c
+++ b/builtin/checkout--worker.c
@@ -2,9 +2,9 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/entry.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "index/parallel-checkout.h"
 #include "parse-options.h"
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index c659e5c764..139f4f9441 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -8,8 +8,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "lockfile.h"
 #include "quote.h"
@@ -18,7 +18,7 @@
 #include "index/entry.h"
 #include "index/parallel-checkout.h"
 #include "index/read-cache-ll.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 
 #define CHECKOUT_ALL 4
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 48882b0f8e..3dedddc61a 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -7,13 +7,13 @@
 #include "index/cache-tree.h"
 #include "index/checkout.h"
 #include "odb/commit.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "merge-ll.h"
 #include "lockfile.h"
 #include "mem-pool.h"
@@ -26,11 +26,11 @@
 #include "index/read-cache.h"
 #include "refs/refs.h"
 #include "remote.h"
-#include "repo-settings.h"
+#include "setup/repo-settings.h"
 #include "index/resolve-undo.h"
 #include "revision/revision.h"
 #include "sequencer.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "strvec.h"
 #include "submodule.h"
diff --git a/builtin/clean.c b/builtin/clean.c
index 81b3b86491..35a5c1465d 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -11,14 +11,14 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "path.h"
 #include "index/read-cache-ll.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "string-list.h"
 #include "quote.h"
 #include "column.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 58cf9761a0..a8f7e1b6f3 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -15,9 +15,9 @@
 
 #include "abspath.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "copy.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
@@ -38,13 +38,13 @@
 #include "branch.h"
 #include "remote.h"
 #include "run-command.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "connected.h"
 #include "pack/packfile.h"
 #include "path.h"
 #include "pkt-line.h"
 #include "revision/list-objects-filter-options.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "bundle.h"
 #include "bundle-uri.h"
 
diff --git a/builtin/column.c b/builtin/column.c
index 87dce3c6e5..8603d23d1f 100644
--- a/builtin/column.c
+++ b/builtin/column.c
@@ -1,6 +1,6 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "strbuf.h"
 #include "parse-options.h"
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 2de897402e..d4dc4985d3 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "odb/commit.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "parse-options.h"
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 598ef30372..eb6fa99d14 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -5,8 +5,8 @@
  */
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 85ab748ff0..3bf6f012c0 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -10,13 +10,13 @@
 
 #include "builtin.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "lockfile.h"
 #include "index/cache-tree.h"
 #include "color.h"
 #include "index/dir.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "diff/diff.h"
 #include "odb/commit.h"
 #include "add-interactive.h"
@@ -30,7 +30,7 @@
 #include "path.h"
 #include "index/preload-index.h"
 #include "index/read-cache.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "string-list.h"
 #include "rerere.h"
 #include "index/unpack-trees.h"
diff --git a/builtin/config.c b/builtin/config.c
index 15782dfe64..3c56c7380d 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -2,18 +2,18 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "color.h"
 #include "date.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
-#include "ident.h"
+#include "setup/ident.h"
 #include "parse-options.h"
 #include "urlmatch.h"
 #include "path.h"
 #include "quote.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "refs/worktree.h"
 
diff --git a/builtin/count-objects.c b/builtin/count-objects.c
index cf10ddcae1..0a28c0a552 100644
--- a/builtin/count-objects.c
+++ b/builtin/count-objects.c
@@ -5,9 +5,9 @@
  */
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "path.h"
 #include "parse-options.h"
diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index 65cc619bec..313f4c58e8 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -7,7 +7,7 @@
 
 #ifndef NO_UNIX_SOCKETS
 
-#include "config.h"
+#include "setup/config.h"
 #include "tempfile.h"
 #include "credential.h"
 #include "unix-socket.h"
diff --git a/builtin/credential-store.c b/builtin/credential-store.c
index bc1453c6b2..91004b6188 100644
--- a/builtin/credential-store.c
+++ b/builtin/credential-store.c
@@ -1,6 +1,6 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "lockfile.h"
 #include "credential.h"
diff --git a/builtin/credential.c b/builtin/credential.c
index a295c80b36..1917982734 100644
--- a/builtin/credential.c
+++ b/builtin/credential.c
@@ -3,8 +3,8 @@
 #include "git-compat-util.h"
 #include "credential.h"
 #include "builtin.h"
-#include "environment.h"
-#include "config.h"
+#include "setup/environment.h"
+#include "setup/config.h"
 
 static const char usage_msg[] =
 	"git credential (fill|approve|reject)";
diff --git a/builtin/describe.c b/builtin/describe.c
index c22158d157..0c840c84ad 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -2,8 +2,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
@@ -16,7 +16,7 @@
 #include "revision/revision.h"
 #include "diff/diff.h"
 #include "hashmap.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strvec.h"
 #include "run-command.h"
 #include "odb/odb.h"
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index 1f67480362..d536ce8475 100644
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
@@ -8,7 +8,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
 #include "diff/diff-merges.h"
 #include "odb/commit.h"
diff --git a/builtin/diff-index.c b/builtin/diff-index.c
index dac8099081..dac7eac2d8 100644
--- a/builtin/diff-index.c
+++ b/builtin/diff-index.c
@@ -2,13 +2,13 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
 #include "diff/diff-merges.h"
 #include "odb/commit.h"
 #include "index/preload-index.h"
 #include "revision/revision.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 static const char diff_cache_usage[] =
 "git diff-index [-m] [--cached] [--merge-base] "
diff --git a/builtin/diff-pairs.c b/builtin/diff-pairs.c
index df5630be47..6400caf0a6 100644
--- a/builtin/diff-pairs.c
+++ b/builtin/diff-pairs.c
@@ -1,5 +1,5 @@
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
 #include "gettext.h"
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 8f7f48ac67..010a996ab6 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
 #include "odb/commit.h"
 #include "gettext.h"
diff --git a/builtin/diff.c b/builtin/diff.c
index 0e8c488408..badef1411b 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -8,7 +8,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "ewah/ewok.h"
 #include "lockfile.h"
 #include "color.h"
@@ -22,7 +22,7 @@
 #include "index/read-cache-ll.h"
 #include "revision/revision.h"
 #include "revision/log-tree.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "odb/oid-array.h"
 #include "odb/tree.h"
 
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 1d3fae8793..425f3ddf83 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -15,16 +15,16 @@
 #include "builtin.h"
 
 #include "abspath.h"
-#include "config.h"
+#include "setup/config.h"
 #include "copy.h"
 #include "run-command.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "parse-options.h"
 #include "path.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/sparse-index.h"
 #include "strvec.h"
 #include "strbuf.h"
@@ -33,7 +33,7 @@
 #include "odb/odb.h"
 #include "index/dir.h"
 #include "index/entry.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 static const char *const builtin_difftool_usage[] = {
 	N_("git difftool [<options>] [<commit> [<commit>]] [--] [<path>...]"),
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 565cdccb40..5e5e100884 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -8,8 +8,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs/refs.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index da586c7c63..16353c1d71 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -3,10 +3,10 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "config.h"
+#include "setup/config.h"
 #include "lockfile.h"
 #include "odb/object.h"
 #include "odb/blob.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 2f744ac8b8..60be51f079 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -7,9 +7,9 @@
 
 #include "builtin.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "refs/refs.h"
 #include "refs/refspec.h"
diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index cf4273a52c..a7e681afdf 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -1,5 +1,5 @@
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "fmt-merge-msg.h"
 #include "gettext.h"
 #include "parse-options.h"
diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c
index 9b3f277cb8..6a39f52698 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -1,7 +1,7 @@
 #include "builtin.h"
 #include "odb/commit.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "for-each-ref.h"
 #include "gettext.h"
 #include "odb/object.h"
diff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c
index 927d3d92da..0ee86283cd 100644
--- a/builtin/for-each-repo.c
+++ b/builtin/for-each-repo.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "path.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 6e8fd0e828..049f32e13a 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -1,7 +1,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "hex.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
 #include "odb/tree.h"
 #include "odb/blob.h"
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index 49b492fba0..8d82f210cc 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -3,9 +3,9 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "index/fsmonitor-ll.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index 0243b34e3e..e4c482c243 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -17,9 +17,9 @@
 #include "abspath.h"
 #include "date.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
-#include "config.h"
+#include "setup/config.h"
 #include "tempfile.h"
 #include "lockfile.h"
 #include "parse-options.h"
@@ -39,8 +39,8 @@
 #include "remote.h"
 #include "exec-cmd.h"
 #include "gettext.h"
-#include "hook.h"
-#include "setup.h"
+#include "setup/hook.h"
+#include "setup/setup.h"
 #include "trace2.h"
 #include "refs/worktree.h"
 
diff --git a/builtin/grep.c b/builtin/grep.c
index 20cd821af7..10df2dacef 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -9,10 +9,10 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/tag.h"
 #include "odb/tree-walk.h"
 #include "parse-options.h"
@@ -22,7 +22,7 @@
 #include "quote.h"
 #include "index/dir.h"
 #include "index/pathspec.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
 #include "odb/object-name.h"
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index 335575862c..95a5105c2a 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -7,8 +7,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-file.h"
@@ -16,7 +16,7 @@
 #include "odb/blob.h"
 #include "quote.h"
 #include "parse-options.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "write-or-die.h"
 
diff --git a/builtin/help.c b/builtin/help.c
index a140339999..4d1c5e18bd 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -5,8 +5,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "pager.h"
@@ -15,8 +15,8 @@
 #include "run-command.h"
 #include "config-list.h"
 #include "help.h"
-#include "alias.h"
-#include "setup.h"
+#include "setup/alias.h"
+#include "setup/setup.h"
 
 #ifndef DEFAULT_HELP_FORMAT
 #define DEFAULT_HELP_FORMAT "man"
diff --git a/builtin/history.c b/builtin/history.c
index c817745f30..9c38be5b38 100644
--- a/builtin/history.c
+++ b/builtin/history.c
@@ -4,9 +4,9 @@
 #include "index/cache-tree.h"
 #include "odb/commit.h"
 #include "revision/commit-reach.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
diff --git a/builtin/hook.c b/builtin/hook.c
index cceeb3586e..6cff5b0889 100644
--- a/builtin/hook.c
+++ b/builtin/hook.c
@@ -1,9 +1,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "parse-options.h"
 #include "thread-utils.h"
 
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 23d7e68020..167a6df9e7 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -2,9 +2,9 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "pack/delta.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "pack/pack.h"
@@ -29,7 +29,7 @@
 #include "odb/tree-walk.h"
 #include "promisor-remote.h"
 #include "run-command.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strvec.h"
 
 static const char index_pack_usage[] =
diff --git a/builtin/init-db.c b/builtin/init-db.c
index f459635129..bc8496b585 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -6,12 +6,12 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "path.h"
 #include "refs/refs.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 
 static int guess_repository_type(const char *git_dir)
diff --git a/builtin/interpret-trailers.c b/builtin/interpret-trailers.c
index e7e86e9523..2462307a98 100644
--- a/builtin/interpret-trailers.c
+++ b/builtin/interpret-trailers.c
@@ -6,13 +6,13 @@
  */
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "tempfile.h"
 #include "trailer.h"
-#include "config.h"
+#include "setup/config.h"
 
 static const char * const git_interpret_trailers_usage[] = {
 	N_("git interpret-trailers [--in-place] [--trim-empty]\n"
diff --git a/builtin/last-modified.c b/builtin/last-modified.c
index 88e122db9b..763d0f93a7 100644
--- a/builtin/last-modified.c
+++ b/builtin/last-modified.c
@@ -4,10 +4,10 @@
 #include "pack/commit-graph.h"
 #include "odb/commit-slab.h"
 #include "odb/commit.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "ewah/ewok.h"
 #include "hashmap.h"
 #include "hex.h"
@@ -16,7 +16,7 @@
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "quote.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "revision/revision.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/builtin/log.c b/builtin/log.c
index 82144cf2b6..5b79637af3 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -9,8 +9,8 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs/refs.h"
@@ -37,7 +37,7 @@
 #include "parse-options.h"
 #include "revision/line-log.h"
 #include "branch.h"
-#include "version.h"
+#include "setup/version.h"
 #include "mailmap.h"
 #include "progress.h"
 #include "odb/commit-slab.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 49e8a685e3..3ef55beb89 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -9,9 +9,9 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "convert.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "quote.h"
 #include "index/dir.h"
 #include "gettext.h"
@@ -23,7 +23,7 @@
 #include "path.h"
 #include "index/pathspec.h"
 #include "index/read-cache.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "submodule.h"
 #include "odb/odb.h"
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index b59c186a21..70ca5dca69 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -6,8 +6,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index 8de7ba7de1..943757ebcf 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -5,7 +5,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "strbuf.h"
 #include "mailinfo.h"
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 7eec05ae7b..fa9c4945d4 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
diff --git a/builtin/merge-file.c b/builtin/merge-file.c
index 12701b1d81..7075fce70d 100644
--- a/builtin/merge-file.c
+++ b/builtin/merge-file.c
@@ -8,9 +8,9 @@
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "xdiff/xdiff.h"
 #include "diff/xdiff-interface.h"
 #include "parse-options.h"
diff --git a/builtin/merge-ours.c b/builtin/merge-ours.c
index c33e176c65..3900f64b5d 100644
--- a/builtin/merge-ours.c
+++ b/builtin/merge-ours.c
@@ -10,8 +10,8 @@
 
 #include "git-compat-util.h"
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "diff/diff.h"
 
 static const char builtin_merge_ours_usage[] =
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 41d8bbcbc1..7a73454060 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "odb/tree-walk.h"
 #include "diff/xdiff-interface.h"
 #include "help.h"
@@ -17,7 +17,7 @@
 #include "merge-blobs.h"
 #include "quote.h"
 #include "odb/tree.h"
-#include "config.h"
+#include "setup/config.h"
 #include "strvec.h"
 #include "write-or-die.h"
 
diff --git a/builtin/merge.c b/builtin/merge.c
index da37fb11eb..090e2a8fb1 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -13,17 +13,17 @@
 
 #include "abspath.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "lockfile.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "diff/diff.h"
 #include "diff/diff-merges.h"
 #include "refs/refs.h"
@@ -46,7 +46,7 @@
 #include "sequencer.h"
 #include "string-list.h"
 #include "odb/tag.h"
-#include "alias.h"
+#include "setup/alias.h"
 #include "branch.h"
 #include "revision/commit-reach.h"
 #include "index/wt-status.h"
diff --git a/builtin/mktag.c b/builtin/mktag.c
index eb25acc4a5..f7ed512639 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -8,7 +8,7 @@
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "odb/fsck.h"
-#include "config.h"
+#include "setup/config.h"
 
 static char const * const builtin_mktag_usage[] = {
 	"git mktag",
diff --git a/builtin/multi-pack-index.c b/builtin/multi-pack-index.c
index 81401e37d5..2d78a08326 100644
--- a/builtin/multi-pack-index.c
+++ b/builtin/multi-pack-index.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "pack/midx.h"
@@ -12,7 +12,7 @@
 #include "odb/source.h"
 #include "odb/source-files.h"
 #include "odb/replace-object.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 #define BUILTIN_MIDX_WRITE_USAGE \
 	N_("git multi-pack-index [<options>] write [--preferred-pack=<pack>]\n" \
diff --git a/builtin/mv.c b/builtin/mv.c
index f49eec035e..bc51d64c95 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -10,8 +10,8 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "index/name-hash.h"
 #include "odb/object-file.h"
@@ -24,7 +24,7 @@
 #include "index/read-cache-ll.h"
 #include "index/symlinks.h"
 
-#include "setup.h"
+#include "setup/setup.h"
 #include "strvec.h"
 #include "submodule.h"
 #include "index/entry.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 31bc960b34..5cccf689f5 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -2,10 +2,10 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
 #include "refs/refs.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 61087b0fa5..5a1201b315 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -8,9 +8,9 @@
  */
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
diff --git a/builtin/organize.c b/builtin/organize.c
index 925ef17128..35bf5cf90d 100644
--- a/builtin/organize.c
+++ b/builtin/organize.c
@@ -13,7 +13,7 @@
 #include "gettext.h"
 #include "organize/organize.h"
 #include "parse-options.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strvec.h"
 
 static const char *const organize_usage[] = {
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index b611b27573..cc97d7e814 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -2,10 +2,10 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "config.h"
+#include "setup/config.h"
 #include "attr.h"
 #include "odb/object.h"
 #include "odb/commit.h"
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index 7207279cef..22196195d2 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -1,14 +1,14 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
 #include "parse-options.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 static void flush_current_id(size_t patchlen, struct object_id *id, struct object_id *result)
 {
diff --git a/builtin/prune.c b/builtin/prune.c
index d2d5bd2619..fc70161992 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -4,7 +4,7 @@
 #include "odb/commit.h"
 #include "diff/diff.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "revision/revision.h"
diff --git a/builtin/pull.c b/builtin/pull.c
index 818ddbf956..cca98abb65 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -10,8 +10,8 @@
 
 #include "builtin.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "merge.h"
diff --git a/builtin/push.c b/builtin/push.c
index 280cfd289f..b4556466d7 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -7,9 +7,9 @@
 #include "builtin.h"
 #include "advice.h"
 #include "branch.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs/refspec.h"
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index 323046c696..ffb36c6086 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -5,7 +5,7 @@
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "diff/range-diff.h"
-#include "config.h"
+#include "setup/config.h"
 #include "parse.h"
 #include "color.h"
 
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 2bc2f43729..6c2ea503f7 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -5,8 +5,8 @@
  */
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
@@ -18,7 +18,7 @@
 #include "index/unpack-trees.h"
 #include "parse-options.h"
 #include "index/resolve-undo.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "submodule.h"
 
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 62b58da192..03bc28aba9 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -10,14 +10,14 @@
 #include "builtin.h"
 
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "run-command.h"
 #include "strvec.h"
 #include "index/dir.h"
 #include "refs/refs.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/unpack-trees.h"
 #include "lockfile.h"
 #include "odb/object-file.h"
@@ -35,7 +35,7 @@
 #include "rebase-interactive.h"
 #include "reset.h"
 #include "trace2.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "trailer.h"
 
 static char const * const builtin_rebase_usage[] = {
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 9a816f1e86..718073653c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -5,16 +5,16 @@
 #include "abspath.h"
 #include "odb/commit.h"
 #include "revision/commit-reach.h"
-#include "config.h"
+#include "setup/config.h"
 #include "connect.h"
 #include "connected.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "exec-cmd.h"
 #include "odb/fsck.h"
 #include "gettext.h"
 #include "gpg-interface.h"
 #include "hex.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "lockfile.h"
 #include "odb/object.h"
 #include "odb/object-file.h"
@@ -31,7 +31,7 @@
 #include "remote.h"
 #include "run-command.h"
 #include "pack/server-info.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "revision/shallow.h"
 #include "sideband.h"
 #include "sigchain.h"
@@ -39,7 +39,7 @@
 #include "strvec.h"
 #include "trace.h"
 #include "trace2.h"
-#include "version.h"
+#include "setup/version.h"
 #include "refs/worktree.h"
 
 static const char * const receive_pack_usage[] = {
diff --git a/builtin/reflog.c b/builtin/reflog.c
index d8d1cb2c6a..83e40a0194 100644
--- a/builtin/reflog.c
+++ b/builtin/reflog.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/odb.h"
diff --git a/builtin/refs.c b/builtin/refs.c
index abfc0acdd2..d6e28a6043 100644
--- a/builtin/refs.c
+++ b/builtin/refs.c
@@ -1,5 +1,5 @@
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/fsck.h"
 #include "refs/pack-refs.h"
 #include "parse-options.h"
diff --git a/builtin/remote.c b/builtin/remote.c
index 3f6cee14ff..5a4fa6de8b 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -2,10 +2,10 @@
 
 #include "builtin.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "date.h"
 #include "gettext.h"
-#include "ident.h"
+#include "setup/ident.h"
 #include "parse-options.h"
 #include "path.h"
 #include "transport.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index aa74f2161a..1d861c6062 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -1,8 +1,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "parse-options.h"
 #include "path.h"
 #include "run-command.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index 83497cd974..37f3dbd537 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -9,9 +9,9 @@
  */
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs/refs.h"
diff --git a/builtin/replay.c b/builtin/replay.c
index 4f5515a314..f2f8c16343 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -5,7 +5,7 @@
 #include "git-compat-util.h"
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "hex.h"
 #include "odb/object-name.h"
 #include "parse-options.h"
diff --git a/builtin/repo.c b/builtin/repo.c
index b296e2cda7..e736c97e9a 100644
--- a/builtin/repo.c
+++ b/builtin/repo.c
@@ -2,7 +2,7 @@
 
 #include "builtin.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "odb/hash.h"
 #include "hex.h"
 #include "odb/odb.h"
@@ -14,7 +14,7 @@
 #include "refs/ref-filter.h"
 #include "refs/refs.h"
 #include "revision/revision.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "string-list.h"
 #include "revision/shallow.h"
diff --git a/builtin/rerere.c b/builtin/rerere.c
index 4b1b7d49ce..f7d406168c 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "rerere.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 96c7bf9cf1..2202e0006d 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -12,8 +12,8 @@
 
 #include "builtin.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
@@ -28,10 +28,10 @@
 #include "odb/object-name.h"
 #include "parse-options.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/unpack-trees.h"
 #include "index/cache-tree.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "submodule.h"
 #include "trace.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index 21d7b8aa81..54aabd084f 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -2,10 +2,10 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "revision/revision.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 1d97c4869b..6f394db8d2 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -11,9 +11,9 @@
 
 #include "abspath.h"
 #include "revision/bisect.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
@@ -24,10 +24,10 @@
 #include "path.h"
 #include "diff/diff.h"
 #include "index/read-cache-ll.h"
-#include "repo-settings.h"
-#include "repository.h"
+#include "setup/repo-settings.h"
+#include "setup/repository.h"
 #include "revision/revision.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/split-index.h"
 #include "submodule.h"
 #include "revision/commit-reach.h"
diff --git a/builtin/revert.c b/builtin/revert.c
index ae3f186f12..f220268baa 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -4,7 +4,7 @@
 #include "builtin.h"
 #include "parse-options.h"
 #include "diff/diff.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "revision/revision.h"
 #include "rerere.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index 4f7194f541..cf59a9895d 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -8,8 +8,8 @@
 
 #include "builtin.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "lockfile.h"
 #include "index/dir.h"
 #include "gettext.h"
@@ -20,7 +20,7 @@
 #include "index/read-cache.h"
 
 #include "string-list.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "submodule.h"
 #include "index/pathspec.h"
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 2597a47bde..1e358bc0b0 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -1,6 +1,6 @@
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "pkt-line.h"
 #include "run-command.h"
diff --git a/builtin/shortlog.c b/builtin/shortlog.c
index 2fe86d6f46..fe98e4f21b 100644
--- a/builtin/shortlog.c
+++ b/builtin/shortlog.c
@@ -1,16 +1,16 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "string-list.h"
 #include "revision/revision.h"
 #include "utf8.h"
 #include "mailmap.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "shortlog.h"
 #include "parse-options.h"
 #include "trailer.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index e0e912439c..31008f6d51 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -2,8 +2,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index e4b186b930..77362ae6c7 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs/refs-internal.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index efe6f7897e..8f2daa10ac 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -3,9 +3,9 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
@@ -17,7 +17,7 @@
 #include "lockfile.h"
 #include "index/unpack-trees.h"
 #include "quote.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "refs/worktree.h"
 
diff --git a/builtin/stash.c b/builtin/stash.c
index a8337ffdc4..81b3506598 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -2,8 +2,8 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
@@ -20,10 +20,10 @@
 #include "index/entry.h"
 #include "index/preload-index.h"
 #include "index/read-cache.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "rerere.h"
 #include "revision/revision.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "revision/log-tree.h"
 #include "diff/diffcore.h"
diff --git a/builtin/stripspace.c b/builtin/stripspace.c
index 18705f1a5b..9547c474e3 100644
--- a/builtin/stripspace.c
+++ b/builtin/stripspace.c
@@ -1,10 +1,10 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "parse-options.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "write-or-die.h"
 
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 5226a5f331..5a97263743 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -2,11 +2,11 @@
 
 #include "builtin.h"
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 
-#include "config.h"
+#include "setup/config.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "path.h"
@@ -14,7 +14,7 @@
 #include "index/preload-index.h"
 #include "index/dir.h"
 #include "index/read-cache.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "submodule.h"
 #include "submodule-config.h"
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c
index 9ea9ca6500..d5461ac52c 100644
--- a/builtin/symbolic-ref.c
+++ b/builtin/symbolic-ref.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "refs/refs.h"
 #include "parse-options.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 46df0f7c27..08a50c3c43 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -11,9 +11,9 @@
 
 #include "builtin.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs/refs.h"
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 47f43f5a87..600da7fd06 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index fb724e46ea..9081e618b3 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -2,8 +2,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "git-zlib.h"
 #include "hex.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index b5c8fae02c..1824c9590e 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -8,8 +8,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
@@ -26,7 +26,7 @@
 #include "index/pathspec.h"
 #include "index/dir.h"
 #include "index/read-cache.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "index/split-index.h"
 #include "index/symlinks.h"
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 5bcd100e52..57090fffae 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -2,8 +2,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c
index 41bbd0114f..ca087aa41f 100644
--- a/builtin/update-server-info.c
+++ b/builtin/update-server-info.c
@@ -1,6 +1,6 @@
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "pack/server-info.h"
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index 718e74b3ac..7b63b0185b 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -5,7 +5,7 @@
 #include "builtin.h"
 #include "archive.h"
 #include "pkt-line.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "sideband.h"
 #include "run-command.h"
 #include "strvec.h"
diff --git a/builtin/upload-pack.c b/builtin/upload-pack.c
index dc37ffb70c..7131fb6689 100644
--- a/builtin/upload-pack.c
+++ b/builtin/upload-pack.c
@@ -9,9 +9,9 @@
 #include "odb/replace-object.h"
 #include "upload-pack.h"
 #include "serve.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 
 static const char * const upload_pack_usage[] = {
 	N_("git-upload-pack [--[no-]strict] [--timeout=<n>] [--stateless-rpc]\n"
diff --git a/builtin/var.c b/builtin/var.c
index d01c87dfa2..0d48bd81a8 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -9,10 +9,10 @@
 #include "builtin.h"
 
 #include "attr.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
-#include "environment.h"
-#include "ident.h"
+#include "setup/environment.h"
+#include "setup/ident.h"
 #include "pager.h"
 #include "refs/refs.h"
 #include "path.h"
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 3ec03f016c..529b2d2573 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -6,8 +6,8 @@
  * Based on git-verify-tag
  */
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/object-name.h"
 #include "odb/commit.h"
diff --git a/builtin/verify-pack.c b/builtin/verify-pack.c
index 65fd6629a0..1b282e6bb9 100644
--- a/builtin/verify-pack.c
+++ b/builtin/verify-pack.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "run-command.h"
 #include "parse-options.h"
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 460244f25b..82edf73980 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -6,8 +6,8 @@
  * Based on git-verify-tag.sh
  */
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/tag.h"
 #include "odb/object-name.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index c4068b45d6..1d808800cc 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -5,10 +5,10 @@
 #include "abspath.h"
 #include "advice.h"
 #include "index/checkout.h"
-#include "config.h"
+#include "setup/config.h"
 #include "copy.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-file.h"
@@ -21,7 +21,7 @@
 #include "refs/refs.h"
 #include "remote.h"
 #include "run-command.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "sigchain.h"
 #include "submodule.h"
 #include "utf8.h"
diff --git a/builtin/write-tree.c b/builtin/write-tree.c
index 4a2b1ceb58..7d21f64007 100644
--- a/builtin/write-tree.c
+++ b/builtin/write-tree.c
@@ -5,8 +5,8 @@
  */
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/tree.h"
diff --git a/bundle-uri.c b/bundle-uri.c
index 96ddf92347..cd26d38249 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -10,7 +10,7 @@
 #include "run-command.h"
 #include "hashmap.h"
 #include "pkt-line.h"
-#include "config.h"
+#include "setup/config.h"
 #include "fetch-pack.h"
 #include "remote.h"
 #include "trace2.h"
diff --git a/bundle.c b/bundle.c
index dc50661bdd..1e01ab38d4 100644
--- a/bundle.c
+++ b/bundle.c
@@ -4,11 +4,11 @@
 #include "git-compat-util.h"
 #include "lockfile.h"
 #include "bundle.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/odb.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/object.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
diff --git a/color.c b/color.c
index 00b53f97ac..06a0b92958 100644
--- a/color.c
+++ b/color.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "color.h"
 #include "editor.h"
 #include "gettext.h"
diff --git a/column.c b/column.c
index 93fae316b4..505abf2bfb 100644
--- a/column.c
+++ b/column.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "column.h"
 #include "string-list.h"
 #include "pager.h"
diff --git a/common-init.c b/common-init.c
index 7e6b392800..aacfc85db6 100644
--- a/common-init.c
+++ b/common-init.c
@@ -7,9 +7,9 @@
 #include "attr.h"
 #include "odb/odb.h"
 #include "parse.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/replace-object.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "trace2.h"
 
diff --git a/compat/fsmonitor/fsm-health-darwin.c b/compat/fsmonitor/fsm-health-darwin.c
index f24d56b3d2..dfa07f4b7b 100644
--- a/compat/fsmonitor/fsm-health-darwin.c
+++ b/compat/fsmonitor/fsm-health-darwin.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/fsmonitor-ll.h"
 #include "fsm-health.h"
 #include "index/fsmonitor--daemon.h"
diff --git a/compat/fsmonitor/fsm-health-linux.c b/compat/fsmonitor/fsm-health-linux.c
index 7be822fb1c..60f878b55e 100644
--- a/compat/fsmonitor/fsm-health-linux.c
+++ b/compat/fsmonitor/fsm-health-linux.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/fsmonitor-ll.h"
 #include "fsm-health.h"
 #include "index/fsmonitor--daemon.h"
diff --git a/compat/fsmonitor/fsm-health-win32.c b/compat/fsmonitor/fsm-health-win32.c
index 09dee50777..c4574f1eb0 100644
--- a/compat/fsmonitor/fsm-health-win32.c
+++ b/compat/fsmonitor/fsm-health-win32.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/fsmonitor-ll.h"
 #include "fsm-health.h"
 #include "index/fsmonitor--daemon.h"
diff --git a/compat/fsmonitor/fsm-ipc-unix.c b/compat/fsmonitor/fsm-ipc-unix.c
index ffd864ae92..bb1bed15fb 100644
--- a/compat/fsmonitor/fsm-ipc-unix.c
+++ b/compat/fsmonitor/fsm-ipc-unix.c
@@ -1,11 +1,11 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "hex.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 #include "index/fsmonitor-ll.h"
 #include "index/fsmonitor-ipc.h"
diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c
index bc92e1fd20..d3febb8dbd 100644
--- a/compat/fsmonitor/fsm-ipc-win32.c
+++ b/compat/fsmonitor/fsm-ipc-win32.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/fsmonitor-ipc.h"
 #include "path.h"
 
diff --git a/compat/fsmonitor/fsm-listen-win32.c b/compat/fsmonitor/fsm-listen-win32.c
index c8cbdf4a97..4c49b04a7b 100644
--- a/compat/fsmonitor/fsm-listen-win32.c
+++ b/compat/fsmonitor/fsm-listen-win32.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/fsmonitor-ll.h"
 #include "fsm-listen.h"
 #include "index/fsmonitor--daemon.h"
diff --git a/compat/fsmonitor/fsm-settings-unix.c b/compat/fsmonitor/fsm-settings-unix.c
index 41106355b1..67c49d0ca7 100644
--- a/compat/fsmonitor/fsm-settings-unix.c
+++ b/compat/fsmonitor/fsm-settings-unix.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/fsmonitor-ll.h"
 #include "index/fsmonitor-ipc.h"
 #include "index/fsmonitor-settings.h"
diff --git a/compat/fsmonitor/fsm-settings-win32.c b/compat/fsmonitor/fsm-settings-win32.c
index 5b2872a4f1..4c822e01ed 100644
--- a/compat/fsmonitor/fsm-settings-win32.c
+++ b/compat/fsmonitor/fsm-settings-win32.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
-#include "config.h"
-#include "repository.h"
+#include "setup/config.h"
+#include "setup/repository.h"
 #include "index/fsmonitor-ll.h"
 #include "index/fsmonitor-settings.h"
 #include "index/fsmonitor-path-utils.h"
diff --git a/compat/mingw.c b/compat/mingw.c
index 64814ac35d..9fce208dde 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -4,10 +4,10 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "odb/alloc.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "environment.h"
-#include "repository.h"
+#include "setup/environment.h"
+#include "setup/repository.h"
 #include "gettext.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c
index 8077f6235b..c047c17675 100644
--- a/compat/precompose_utf8.c
+++ b/compat/precompose_utf8.c
@@ -7,8 +7,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "path.h"
 #include "strbuf.h"
diff --git a/compat/regex/regex.c b/compat/regex/regex.c
index 4b09cc4e14..25f7e13d9e 100644
--- a/compat/regex/regex.c
+++ b/compat/regex/regex.c
@@ -20,7 +20,7 @@
 #pragma GCC diagnostic ignored "-Wsign-compare"
 
 #ifdef HAVE_CONFIG_H
-#include "config.h"
+#include "setup/config.h"
 #endif
 
 /* Make sure no one compiles this code with a C++ compiler.  */
diff --git a/compat/win32/path-utils.c b/compat/win32/path-utils.c
index f779f367cf..043b077d67 100644
--- a/compat/win32/path-utils.c
+++ b/compat/win32/path-utils.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "../../git-compat-util.h"
-#include "../../environment.h"
-#include "../../repository.h"
+#include "setup/environment.h"
+#include "setup/repository.h"
 
 int win32_has_dos_drive_prefix(const char *path)
 {
diff --git a/compat/win32/trace2_win32_process_info.c b/compat/win32/trace2_win32_process_info.c
index 6a6a396078..6fe122e637 100644
--- a/compat/win32/trace2_win32_process_info.c
+++ b/compat/win32/trace2_win32_process_info.c
@@ -2,7 +2,7 @@
 
 #include "../../git-compat-util.h"
 #include "../../json-writer.h"
-#include "../../repository.h"
+#include "setup/repository.h"
 #include "../../strvec.h"
 #include "../../trace2.h"
 #include "lazyload.h"
diff --git a/connect.c b/connect.c
index a24b019b2c..2a1b177490 100644
--- a/connect.c
+++ b/connect.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "pkt-line.h"
@@ -18,9 +18,9 @@
 #include "transport.h"
 #include "trace2.h"
 #include "strbuf.h"
-#include "version.h"
+#include "setup/version.h"
 #include "protocol.h"
-#include "alias.h"
+#include "setup/alias.h"
 #include "bundle-uri.h"
 #include "promisor-remote.h"
 
diff --git a/contrib/libgit-sys/public_symbol_export.c b/contrib/libgit-sys/public_symbol_export.c
index dfbb257115..02765ba5a9 100644
--- a/contrib/libgit-sys/public_symbol_export.c
+++ b/contrib/libgit-sys/public_symbol_export.c
@@ -5,9 +5,9 @@
  */
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "contrib/libgit-sys/public_symbol_export.h"
-#include "version.h"
+#include "setup/version.h"
 
 #pragma GCC visibility push(default)
 
diff --git a/convert.c b/convert.c
index f71d6dcefd..5490c4a558 100644
--- a/convert.c
+++ b/convert.c
@@ -3,7 +3,7 @@
 
 #include "git-compat-util.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "convert.h"
 #include "copy.h"
 #include "gettext.h"
diff --git a/credential.c b/credential.c
index 2594c0c422..dfbd1e9f74 100644
--- a/credential.c
+++ b/credential.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "config.h"
+#include "setup/config.h"
 #include "credential.h"
 #include "gettext.h"
 #include "string-list.h"
@@ -12,9 +12,9 @@
 #include "sigchain.h"
 #include "strbuf.h"
 #include "urlmatch.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "trace2.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 void credential_init(struct credential *c)
 {
diff --git a/daemon.c b/daemon.c
index 5d7978211c..219eeab179 100644
--- a/daemon.c
+++ b/daemon.c
@@ -2,14 +2,14 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "path.h"
 #include "pkt-line.h"
 #include "protocol.h"
 #include "run-command.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "string-list.h"
 
diff --git a/diagnose.c b/diagnose.c
index 0bac203282..341354ee6d 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -10,7 +10,7 @@
 #include "odb/odb.h"
 #include "pack/packfile.h"
 #include "parse-options.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "write-or-die.h"
 
 struct archive_dir {
diff --git a/diff/combine-diff.c b/diff/combine-diff.c
index 8e03062f39..4446183707 100644
--- a/diff/combine-diff.c
+++ b/diff/combine-diff.c
@@ -7,7 +7,7 @@
 #include "convert.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "odb/object-name.h"
 #include "quote.h"
diff --git a/diff/diff-lib.c b/diff/diff-lib.c
index 4a932f9067..fa3ca39389 100644
--- a/diff/diff-lib.c
+++ b/diff/diff-lib.c
@@ -18,7 +18,7 @@
 #include "index/cache-tree.h"
 #include "index/unpack-trees.h"
 #include "refs/refs.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "submodule.h"
 #include "index/symlinks.h"
 #include "trace.h"
diff --git a/diff/diff.c b/diff/diff.c
index c00b87cca2..4603493a36 100644
--- a/diff/diff.c
+++ b/diff/diff.c
@@ -8,9 +8,9 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "base85.h"
-#include "config.h"
+#include "setup/config.h"
 #include "convert.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "tempfile.h"
 #include "revision/revision.h"
@@ -43,7 +43,7 @@
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "index/read-cache-ll.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strmap.h"
 #include "ws.h"
 
diff --git a/diff/range-diff.c b/diff/range-diff.c
index 281c043480..80ebfe1114 100644
--- a/diff/range-diff.c
+++ b/diff/range-diff.c
@@ -2,7 +2,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "diff/range-diff.h"
 #include "odb/object-name.h"
@@ -16,7 +16,7 @@
 #include "odb/commit.h"
 #include "pager.h"
 #include "revision/pretty.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "diff/userdiff.h"
 #include "apply.h"
 #include "revision/revision.h"
diff --git a/diff/tree-diff.c b/diff/tree-diff.c
index a34559daa5..30fc2725e7 100644
--- a/diff/tree-diff.c
+++ b/diff/tree-diff.c
@@ -10,7 +10,7 @@
 #include "odb/hash.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/dir.h"
 
 /*
diff --git a/diff/userdiff.c b/diff/userdiff.c
index 8993b622c1..63d195e7d7 100644
--- a/diff/userdiff.c
+++ b/diff/userdiff.c
@@ -2,11 +2,11 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/userdiff.h"
 #include "attr.h"
 #include "strbuf.h"
-#include "environment.h"
+#include "setup/environment.h"
 
 static struct userdiff_driver *drivers;
 static int ndrivers;
diff --git a/diff/xdiff-interface.c b/diff/xdiff-interface.c
index 2c87316caa..8b016b327c 100644
--- a/diff/xdiff-interface.c
+++ b/diff/xdiff-interface.c
@@ -1,9 +1,9 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
-#include "config.h"
+#include "setup/config.h"
 #include "hex.h"
 #include "odb/odb.h"
 #include "strbuf.h"
diff --git a/editor.c b/editor.c
index 0d1cb8768d..5c0238eb80 100644
--- a/editor.c
+++ b/editor.c
@@ -3,9 +3,9 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "pager.h"
 #include "path.h"
diff --git a/exec-cmd.c b/exec-cmd.c
index 507e67d528..5e0e00fb79 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "path.h"
diff --git a/fetch-negotiator.c b/fetch-negotiator.c
index be383367f5..90fee42b50 100644
--- a/fetch-negotiator.c
+++ b/fetch-negotiator.c
@@ -3,7 +3,7 @@
 #include "negotiator/default.h"
 #include "negotiator/skipping.h"
 #include "negotiator/noop.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 void fetch_negotiator_init(struct repository *r,
 			   struct fetch_negotiator *negotiator)
diff --git a/fetch-pack.c b/fetch-pack.c
index d27a28502f..5bc72eb370 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -2,10 +2,10 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "repository.h"
-#include "config.h"
+#include "setup/repository.h"
+#include "setup/config.h"
 #include "date.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
@@ -20,7 +20,7 @@
 #include "run-command.h"
 #include "connect.h"
 #include "trace2.h"
-#include "version.h"
+#include "setup/version.h"
 #include "odb/oid-array.h"
 #include "odb/oidset.h"
 #include "pack/packfile.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 4993cc4a02..d38b2b5c8c 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -2,8 +2,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "refs/refs.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
diff --git a/gettext.c b/gettext.c
index 8d08a61f84..7bb4305ad6 100644
--- a/gettext.c
+++ b/gettext.c
@@ -6,7 +6,7 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "utf8.h"
diff --git a/git.c b/git.c
index f01a80867b..693604a598 100644
--- a/git.c
+++ b/git.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "help.h"
@@ -10,9 +10,9 @@
 #include "pager.h"
 #include "index/read-cache-ll.h"
 #include "run-command.h"
-#include "alias.h"
+#include "setup/alias.h"
 #include "odb/replace-object.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "attr.h"
 #include "revision/shallow.h"
 #include "trace.h"
diff --git a/gpg-interface.c b/gpg-interface.c
index 45a922496b..69e99d56c0 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -2,18 +2,18 @@
 
 #include "git-compat-util.h"
 #include "odb/commit.h"
-#include "config.h"
+#include "setup/config.h"
 #include "date.h"
 #include "gettext.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "index/dir.h"
-#include "ident.h"
+#include "setup/ident.h"
 #include "gpg-interface.h"
 #include "path.h"
 #include "sigchain.h"
 #include "tempfile.h"
-#include "alias.h"
+#include "setup/alias.h"
 
 static int git_gpg_config(const char *, const char *,
 			  const struct config_context *, void *);
diff --git a/grep.c b/grep.c
index c4eb18ccd7..9eda692529 100644
--- a/grep.c
+++ b/grep.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "grep.h"
 #include "hex.h"
diff --git a/help.c b/help.c
index f7a0950f6c..34ab22ade5 100644
--- a/help.c
+++ b/help.c
@@ -3,7 +3,7 @@
 
 #include "git-compat-util.h"
 #include "git-zlib.h"
-#include "config.h"
+#include "setup/config.h"
 #include "builtin.h"
 #include "exec-cmd.h"
 #include "run-command.h"
@@ -14,13 +14,13 @@
 #include "command-list.h"
 #include "string-list.h"
 #include "column.h"
-#include "version.h"
+#include "setup/version.h"
 #include "refs/refs.h"
 #include "parse-options.h"
 #include "prompt.h"
 #include "index/fsmonitor-ipc.h"
-#include "repository.h"
-#include "alias.h"
+#include "setup/repository.h"
+#include "setup/alias.h"
 #include "utf8.h"
 
 #ifndef NO_CURL
diff --git a/http-backend.c b/http-backend.c
index 57589cc127..dcf8506c1e 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -2,12 +2,12 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "git-zlib.h"
 #include "hex.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "refs/refs.h"
 #include "pkt-line.h"
 #include "odb/object.h"
@@ -16,7 +16,7 @@
 #include "run-command.h"
 #include "string-list.h"
 #include "url.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strvec.h"
 #include "pack/packfile.h"
 #include "odb/odb.h"
diff --git a/http-fetch.c b/http-fetch.c
index 05f68f306a..ad2447ce72 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1,13 +1,13 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "http.h"
 #include "walker.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strvec.h"
 #include "url.h"
 #include "urlmatch.h"
diff --git a/http-push.c b/http-push.c
index d45daee9e0..fb18e8756f 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1,9 +1,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
 #include "odb/blob.h"
@@ -12,7 +12,7 @@
 #include "revision/revision.h"
 #include "remote.h"
 #include "revision/list-objects.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "sigchain.h"
 #include "strvec.h"
 #include "odb/tree.h"
diff --git a/http-walker.c b/http-walker.c
index 8df0c5329b..b5bba74da4 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -2,7 +2,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "hex.h"
 #include "walker.h"
 #include "http.h"
diff --git a/http.c b/http.c
index 24a6b30ab3..5b3b2b24d6 100644
--- a/http.c
+++ b/http.c
@@ -3,16 +3,16 @@
 
 #include "git-compat-util.h"
 #include "git-curl-compat.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "http.h"
-#include "config.h"
+#include "setup/config.h"
 #include "pack/pack.h"
 #include "run-command.h"
 #include "url.h"
 #include "urlmatch.h"
 #include "credential.h"
-#include "version.h"
+#include "setup/version.h"
 #include "pkt-line.h"
 #include "gettext.h"
 #include "trace.h"
diff --git a/imap-send.c b/imap-send.c
index 0d16d02029..de244d8011 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -26,13 +26,13 @@
 
 #include "git-compat-util.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "credential.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "run-command.h"
 #include "parse-options.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #ifdef USE_CURL_FOR_IMAP_SEND
 #include "http.h"
diff --git a/index/cache-tree.c b/index/cache-tree.c
index e7c4bfe45c..bb813bd840 100644
--- a/index/cache-tree.c
+++ b/index/cache-tree.c
@@ -13,7 +13,7 @@
 #include "odb/transaction.h"
 #include "index/read-cache-ll.h"
 #include "odb/replace-object.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "promisor-remote.h"
 #include "trace.h"
 #include "trace2.h"
diff --git a/index/checkout.c b/index/checkout.c
index 13d8895032..b262ada8c7 100644
--- a/index/checkout.c
+++ b/index/checkout.c
@@ -4,9 +4,9 @@
 #include "odb/object-name.h"
 #include "remote.h"
 #include "refs/refspec.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/checkout.h"
-#include "config.h"
+#include "setup/config.h"
 #include "strbuf.h"
 
 struct tracking_name_data {
diff --git a/index/dir.c b/index/dir.c
index 6f74a3e87c..8eb684c005 100644
--- a/index/dir.c
+++ b/index/dir.c
@@ -11,16 +11,16 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "config.h"
+#include "setup/config.h"
 #include "convert.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "index/name-hash.h"
 #include "odb/object-file.h"
 #include "path.h"
 #include "refs/refs.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "wildmatch.h"
 #include "index/pathspec.h"
 #include "utf8.h"
@@ -28,7 +28,7 @@
 #include "ewah/ewok.h"
 #include "index/fsmonitor-ll.h"
 #include "index/read-cache-ll.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "strbuf.h"
 #include "submodule-config.h"
diff --git a/index/entry.c b/index/entry.c
index 5b89ad2294..b37c53198f 100644
--- a/index/entry.c
+++ b/index/entry.c
@@ -4,7 +4,7 @@
 #include "odb/odb.h"
 #include "odb/streaming.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "index/name-hash.h"
diff --git a/index/fsmonitor-ipc.c b/index/fsmonitor-ipc.c
index 7c213245a1..68c0148de6 100644
--- a/index/fsmonitor-ipc.c
+++ b/index/fsmonitor-ipc.c
@@ -4,7 +4,7 @@
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "index/fsmonitor-ipc.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "trace2.h"
diff --git a/index/fsmonitor-settings.c b/index/fsmonitor-settings.c
index 883b5902a9..4668dd424e 100644
--- a/index/fsmonitor-settings.c
+++ b/index/fsmonitor-settings.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/fsmonitor-ipc.h"
 #include "index/fsmonitor-settings.h"
 #include "index/fsmonitor-path-utils.h"
diff --git a/index/fsmonitor.c b/index/fsmonitor.c
index 606a59d36d..32bc60e44a 100644
--- a/index/fsmonitor.c
+++ b/index/fsmonitor.c
@@ -2,14 +2,14 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "ewah/ewok.h"
 #include "index/fsmonitor.h"
 #include "index/fsmonitor-ipc.h"
 #include "index/name-hash.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "trace2.h"
diff --git a/index/name-hash.c b/index/name-hash.c
index 5d126bc1a3..49c0dd5775 100644
--- a/index/name-hash.c
+++ b/index/name-hash.c
@@ -10,7 +10,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "index/name-hash.h"
 #include "odb/object.h"
diff --git a/index/parallel-checkout.c b/index/parallel-checkout.c
index 971c4b33fa..0905a7ff1e 100644
--- a/index/parallel-checkout.c
+++ b/index/parallel-checkout.c
@@ -2,7 +2,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/entry.h"
 #include "gettext.h"
 #include "odb/hash.h"
diff --git a/index/pathspec.c b/index/pathspec.c
index 7a0c152fb9..fe80ab49d1 100644
--- a/index/pathspec.c
+++ b/index/pathspec.c
@@ -4,13 +4,13 @@
 #include "abspath.h"
 #include "parse.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "index/pathspec.h"
 #include "attr.h"
 #include "index/read-cache.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "strvec.h"
 #include "index/symlinks.h"
 #include "quote.h"
diff --git a/index/preload-index.c b/index/preload-index.c
index eab3bfc602..d2d01ae72d 100644
--- a/index/preload-index.c
+++ b/index/preload-index.c
@@ -7,7 +7,7 @@
 #include "git-compat-util.h"
 #include "index/pathspec.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "index/fsmonitor.h"
 #include "gettext.h"
 #include "parse.h"
@@ -15,10 +15,10 @@
 #include "progress.h"
 #include "index/read-cache.h"
 #include "thread-utils.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/symlinks.h"
 #include "trace2.h"
-#include "config.h"
+#include "setup/config.h"
 
 /*
  * Mostly randomly chosen maximum thread counts: we
diff --git a/index/read-cache.c b/index/read-cache.c
index 9c62ae5ee8..20a5e191a4 100644
--- a/index/read-cache.c
+++ b/index/read-cache.c
@@ -8,7 +8,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "date.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
@@ -24,7 +24,7 @@
 #include "odb/oid-array.h"
 #include "odb/tree.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "mem-pool.h"
 #include "index/name-hash.h"
@@ -32,7 +32,7 @@
 #include "path.h"
 #include "index/preload-index.h"
 #include "index/read-cache.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/resolve-undo.h"
 #include "revision/revision.h"
 #include "strbuf.h"
@@ -47,7 +47,7 @@
 #include "index/sparse-index.h"
 #include "csum-file.h"
 #include "promisor-remote.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "submodule.h"
 #include "submodule-config.h"
 #include "advice.h"
diff --git a/index/read-cache.h b/index/read-cache.h
index d8519c7b36..69d04e93be 100644
--- a/index/read-cache.h
+++ b/index/read-cache.h
@@ -4,7 +4,7 @@
 #include "index/read-cache-ll.h"
 #include "odb/object.h"
 #include "index/pathspec.h"
-#include "environment.h"
+#include "setup/environment.h"
 
 /*
  * Determine the appropriate index mode for a file based on its stat()
diff --git a/index/sparse-index.c b/index/sparse-index.c
index 0a061a7658..7ac6142023 100644
--- a/index/sparse-index.c
+++ b/index/sparse-index.c
@@ -2,18 +2,18 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "ewah/ewok.h"
 #include "gettext.h"
 #include "index/name-hash.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/sparse-index.h"
 #include "odb/tree.h"
 #include "index/pathspec.h"
 #include "trace2.h"
 #include "index/cache-tree.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
 #include "index/fsmonitor-ll.h"
 #include "advice.h"
diff --git a/index/split-index.c b/index/split-index.c
index 02a5b011c5..9835b71f21 100644
--- a/index/split-index.c
+++ b/index/split-index.c
@@ -5,7 +5,7 @@
 #include "odb/hash.h"
 #include "mem-pool.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/split-index.h"
 #include "strbuf.h"
 #include "ewah/ewok.h"
diff --git a/index/statinfo.c b/index/statinfo.c
index 4a22923009..5f4d710795 100644
--- a/index/statinfo.c
+++ b/index/statinfo.c
@@ -1,9 +1,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "index/statinfo.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 /*
  * Munge st_size into an unsigned int.
diff --git a/index/symlinks.c b/index/symlinks.c
index 18fadf3f75..ab894f2e05 100644
--- a/index/symlinks.c
+++ b/index/symlinks.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/symlinks.h"
 
 static int threaded_check_leading_path(struct cache_def *cache, const char *name,
diff --git a/index/unpack-trees.c b/index/unpack-trees.c
index 68d85f622e..2eecede699 100644
--- a/index/unpack-trees.c
+++ b/index/unpack-trees.c
@@ -4,10 +4,10 @@
 #include "git-compat-util.h"
 #include "advice.h"
 #include "strvec.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "parse.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "index/name-hash.h"
@@ -30,7 +30,7 @@
 #include "promisor-remote.h"
 #include "index/entry.h"
 #include "index/parallel-checkout.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 /*
  * Error messages expected by scripts out of plumbing commands such as
diff --git a/index/wt-status.c b/index/wt-status.c
index 3381a40e75..847438f121 100644
--- a/index/wt-status.c
+++ b/index/wt-status.c
@@ -8,7 +8,7 @@
 #include "index/dir.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
@@ -17,7 +17,7 @@
 #include "revision/revision.h"
 #include "diff/diffcore.h"
 #include "quote.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "strvec.h"
 #include "remote.h"
@@ -25,7 +25,7 @@
 #include "submodule.h"
 #include "column.h"
 #include "index/read-cache.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "trace.h"
 #include "trace2.h"
diff --git a/lockfile.c b/lockfile.c
index 100f603771..942b919941 100644
--- a/lockfile.c
+++ b/lockfile.c
@@ -9,7 +9,7 @@
 #include "gettext.h"
 #include "lockfile.h"
 #include "parse.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 #include "wrapper.h"
 
diff --git a/mailinfo.c b/mailinfo.c
index 13949ff31e..6c44a6c6c6 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -1,8 +1,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex-ll.h"
 #include "utf8.h"
diff --git a/mailmap.c b/mailmap.c
index 558b1972f8..670fb01403 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,11 +1,11 @@
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "string-list.h"
 #include "mailmap.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
-#include "setup.h"
-#include "config.h"
+#include "setup/setup.h"
+#include "setup/config.h"
 
 struct mailmap_info {
 	char *name;
diff --git a/merge-ll.c b/merge-ll.c
index 2aa45bfa90..9cb5119aa2 100644
--- a/merge-ll.c
+++ b/merge-ll.c
@@ -8,7 +8,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "convert.h"
 #include "attr.h"
 #include "diff/xdiff-interface.h"
diff --git a/merge-ort-wrappers.c b/merge-ort-wrappers.c
index c31ed7028d..227181d105 100644
--- a/merge-ort-wrappers.c
+++ b/merge-ort-wrappers.c
@@ -6,7 +6,7 @@
 #include "merge-ort.h"
 #include "merge-ort-wrappers.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/tag.h"
 #include "odb/tree.h"
 
diff --git a/merge-ort.c b/merge-ort.c
index 516cd265c5..f101b5e0c4 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -26,11 +26,11 @@
 #include "index/cache-tree.h"
 #include "odb/commit.h"
 #include "revision/commit-reach.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "index/entry.h"
diff --git a/merge.c b/merge.c
index 0fcfc1460f..95a943c477 100644
--- a/merge.c
+++ b/merge.c
@@ -7,7 +7,7 @@
 #include "lockfile.h"
 #include "merge.h"
 #include "odb/commit.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "index/resolve-undo.h"
 #include "odb/tree.h"
diff --git a/meson.build b/meson.build
index c61ebc35a6..bad597d8ff 100644
--- a/meson.build
+++ b/meson.build
@@ -311,7 +311,7 @@ libgit_sources = [
   'add-interactive.c',
   'add-patch.c',
   'advice.c',
-  'alias.c',
+  'setup/alias.c',
   'odb/alloc.c',
   'apply.c',
   'archive-tar.c',
@@ -340,7 +340,7 @@ libgit_sources = [
   'common-exit.c',
   'common-init.c',
   'compiler-tricks/not-constant.c',
-  'config.c',
+  'setup/config.c',
   'connect.c',
   'connected.c',
   'convert.c',
@@ -367,7 +367,7 @@ libgit_sources = [
   'index/dir.c',
   'editor.c',
   'index/entry.c',
-  'environment.c',
+  'setup/environment.c',
   'ewah/bitmap.c',
   'ewah/ewah_bitmap.c',
   'ewah/ewah_io.c',
@@ -392,8 +392,8 @@ libgit_sources = [
   'help.c',
   'hex.c',
   'hex-ll.c',
-  'hook.c',
-  'ident.c',
+  'setup/hook.c',
+  'setup/ident.c',
   'json-writer.c',
   'kwset.c',
   'levenshtein.c',
@@ -517,8 +517,8 @@ libgit_sources = [
   'pack/repack-promisor.c',
   'odb/replace-object.c',
   'replay.c',
-  'repo-settings.c',
-  'repository.c',
+  'setup/repo-settings.c',
+  'setup/repository.c',
   'rerere.c',
   'reset.c',
   'index/resolve-undo.c',
@@ -528,7 +528,7 @@ libgit_sources = [
   'sequencer.c',
   'serve.c',
   'pack/server-info.c',
-  'setup.c',
+  'setup/setup.c',
   'revision/shallow.c',
   'sideband.c',
   'sigchain.c',
@@ -575,7 +575,7 @@ libgit_sources = [
   'usage.c',
   'diff/userdiff.c',
   'utf8.c',
-  'version.c',
+  'setup/version.c',
   'versioncmp.c',
   'walker.c',
   'wildmatch.c',
diff --git a/negotiator/default.c b/negotiator/default.c
index 7d67933e06..3211453743 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -6,7 +6,7 @@
 #include "../fetch-negotiator.h"
 #include "../prio-queue.h"
 #include "refs/refs.h"
-#include "../repository.h"
+#include "setup/repository.h"
 #include "odb/tag.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index 9e685f54a1..eabfac6edd 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -7,7 +7,7 @@
 #include "../hex.h"
 #include "../prio-queue.h"
 #include "refs/refs.h"
-#include "../repository.h"
+#include "setup/repository.h"
 #include "odb/tag.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/notes-cache.c b/notes-cache.c
index 1e734c5c19..3963f3bf08 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -5,7 +5,7 @@
 #include "odb/object-file.h"
 #include "odb/odb.h"
 #include "revision/pretty.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/commit.h"
 #include "refs/refs.h"
 #include "strbuf.h"
diff --git a/notes-merge.c b/notes-merge.c
index 2bb6ad735e..67e6da2ebd 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -10,7 +10,7 @@
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
 #include "hex.h"
diff --git a/notes-utils.c b/notes-utils.c
index 491de7a7ce..62a99fdd4b 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -1,9 +1,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "refs/refs.h"
 #include "notes-utils.h"
diff --git a/notes.c b/notes.c
index 5842226c68..87a1cdf542 100644
--- a/notes.c
+++ b/notes.c
@@ -2,8 +2,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "notes.h"
 #include "odb/object-file.h"
diff --git a/odb/alloc.c b/odb/alloc.c
index e0f0146bf8..f261262b6f 100644
--- a/odb/alloc.c
+++ b/odb/alloc.c
@@ -13,7 +13,7 @@
 #include "odb/blob.h"
 #include "odb/tree.h"
 #include "odb/commit.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/tag.h"
 #include "odb/alloc.h"
 
diff --git a/odb/commit.c b/odb/commit.c
index 3b490c760c..83c14e7dc4 100644
--- a/odb/commit.c
+++ b/odb/commit.c
@@ -4,10 +4,10 @@
 #include "odb/tag.h"
 #include "odb/commit.h"
 #include "pack/commit-graph.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "utf8.h"
@@ -24,10 +24,10 @@
 #include "advice.h"
 #include "refs/refs.h"
 #include "revision/commit-reach.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "revision/shallow.h"
 #include "odb/tree.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "parse.h"
 #include "odb/object-file.h"
 #include "odb/object-file-convert.h"
diff --git a/odb/fsck.c b/odb/fsck.c
index e889268b48..ec6c57ef06 100644
--- a/odb/fsck.c
+++ b/odb/fsck.c
@@ -1,11 +1,11 @@
 #include "git-compat-util.h"
 #include "date.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "odb/odb.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/object.h"
 #include "attr.h"
 #include "odb/blob.h"
@@ -20,7 +20,7 @@
 #include "odb/oidset.h"
 #include "pack/packfile.h"
 #include "submodule-config.h"
-#include "config.h"
+#include "setup/config.h"
 #include "help.h"
 
 static ssize_t max_tree_entry_len = 4096;
diff --git a/odb/hash.h b/odb/hash.h
index cf94ad5700..602ca12f28 100644
--- a/odb/hash.h
+++ b/odb/hash.h
@@ -269,7 +269,7 @@ enum get_oid_result {
 };
 
 #ifdef USE_THE_REPOSITORY_VARIABLE
-# include "repository.h"
+# include "setup/repository.h"
 # define the_hash_algo the_repository->hash_algo
 #endif
 
diff --git a/odb/loose.c b/odb/loose.c
index 58af1f7910..d9866de7c7 100644
--- a/odb/loose.c
+++ b/odb/loose.c
@@ -5,7 +5,7 @@
 #include "odb/odb.h"
 #include "odb/source-files.h"
 #include "hex.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "wrapper.h"
 #include "gettext.h"
 #include "odb/loose.h"
diff --git a/odb/match-trees.c b/odb/match-trees.c
index 4062373e11..9672d3d84c 100644
--- a/odb/match-trees.c
+++ b/odb/match-trees.c
@@ -8,7 +8,7 @@
 #include "odb/tree-walk.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 static int score_missing(unsigned mode)
 {
diff --git a/odb/object-file-convert.c b/odb/object-file-convert.c
index cad75963f7..b17574202d 100644
--- a/odb/object-file-convert.c
+++ b/odb/object-file-convert.c
@@ -4,7 +4,7 @@
 #include "gettext.h"
 #include "strbuf.h"
 #include "hex.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/hash.h"
 #include "odb/object.h"
 #include "odb/loose.h"
diff --git a/odb/object-file.c b/odb/object-file.c
index 847b78e5c7..762fedcc8e 100644
--- a/odb/object-file.c
+++ b/odb/object-file.c
@@ -12,7 +12,7 @@
 #include "git-compat-util.h"
 #include "convert.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "odb/fsck.h"
 #include "gettext.h"
 #include "hex.h"
@@ -26,7 +26,7 @@
 #include "pack/packfile.h"
 #include "path.h"
 #include "index/read-cache-ll.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strvec.h"
 #include "tempfile.h"
 #include "odb/tmp-objdir.h"
diff --git a/odb/object-name.c b/odb/object-name.c
index 95a63c7f64..af03d8d0e5 100644
--- a/odb/object-name.c
+++ b/odb/object-name.c
@@ -4,8 +4,8 @@
 #include "git-compat-util.h"
 #include "odb/object-name.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/tag.h"
@@ -19,9 +19,9 @@
 #include "odb/oid-array.h"
 #include "revision/pretty.h"
 #include "index/read-cache-ll.h"
-#include "repo-settings.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repo-settings.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "pack/midx.h"
 #include "revision/commit-reach.h"
 #include "date.h"
diff --git a/odb/odb.c b/odb/odb.c
index 4e408501e8..f326dbb284 100644
--- a/odb/odb.c
+++ b/odb/odb.c
@@ -1,9 +1,9 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "pack/commit-graph.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "khash.h"
@@ -21,7 +21,7 @@
 #include "quote.h"
 #include "odb/replace-object.h"
 #include "run-command.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "submodule.h"
diff --git a/odb/replace-object.c b/odb/replace-object.c
index c69c5aa200..a5b33d27a6 100644
--- a/odb/replace-object.c
+++ b/odb/replace-object.c
@@ -5,7 +5,7 @@
 #include "odb/odb.h"
 #include "odb/replace-object.h"
 #include "refs/refs.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/commit.h"
 
 static int register_replace_ref(const struct reference *ref, void *cb_data)
diff --git a/odb/replace-object.h b/odb/replace-object.h
index d7139028a3..8473817292 100644
--- a/odb/replace-object.h
+++ b/odb/replace-object.h
@@ -2,7 +2,7 @@
 #define REPLACE_OBJECT_H
 
 #include "odb/oidmap.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/odb.h"
 
 struct replace_object {
diff --git a/odb/source-files.c b/odb/source-files.c
index b526e5c219..7b8a21d137 100644
--- a/odb/source-files.c
+++ b/odb/source-files.c
@@ -2,7 +2,7 @@
 #include "abspath.h"
 #include "odb/blob.h"
 #include "chdir-notify.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "lockfile.h"
 #include "odb/object-file.h"
diff --git a/odb/source-inmemory.c b/odb/source-inmemory.c
index 288b51848e..6c3ada4640 100644
--- a/odb/source-inmemory.c
+++ b/odb/source-inmemory.c
@@ -4,7 +4,7 @@
 #include "odb/source-inmemory.h"
 #include "odb/streaming.h"
 #include "odb/oidtree.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 struct inmemory_object {
 	enum object_type type;
diff --git a/odb/source-loose.c b/odb/source-loose.c
index 2b073d2a22..acf5a15b89 100644
--- a/odb/source-loose.c
+++ b/odb/source-loose.c
@@ -12,7 +12,7 @@
 #include "odb/streaming.h"
 #include "odb/oidtree.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 #include "tempfile.h"
 #include "write-or-die.h"
diff --git a/odb/streaming.c b/odb/streaming.c
index c3a06f5622..dd33584a64 100644
--- a/odb/streaming.c
+++ b/odb/streaming.c
@@ -4,8 +4,8 @@
 
 #include "git-compat-util.h"
 #include "convert.h"
-#include "environment.h"
-#include "repository.h"
+#include "setup/environment.h"
+#include "setup/repository.h"
 #include "odb/odb.h"
 #include "odb/source.h"
 #include "odb/streaming.h"
diff --git a/odb/tag.c b/odb/tag.c
index 36cb7732a8..7d74850db3 100644
--- a/odb/tag.c
+++ b/odb/tag.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "odb/tag.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
@@ -12,7 +12,7 @@
 #include "gpg-interface.h"
 #include "hex.h"
 #include "pack/packfile.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 const char *tag_type = "tag";
 
diff --git a/odb/tmp-objdir.c b/odb/tmp-objdir.c
index 21219e8797..281a25bd6a 100644
--- a/odb/tmp-objdir.c
+++ b/odb/tmp-objdir.c
@@ -3,7 +3,7 @@
 #include "abspath.h"
 #include "chdir-notify.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "odb/object-file.h"
 #include "path.h"
 #include "string-list.h"
@@ -12,7 +12,7 @@
 #include "quote.h"
 #include "odb/odb.h"
 #include "odb/source.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 struct tmp_objdir {
 	struct repository *repo;
diff --git a/odb/tree-walk.c b/odb/tree-walk.c
index e3e22e1a32..270913835c 100644
--- a/odb/tree-walk.c
+++ b/odb/tree-walk.c
@@ -11,7 +11,7 @@
 #include "odb/tree.h"
 #include "index/pathspec.h"
 #include "json-writer.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "index/read-cache-ll.h"
 
 static int decode_tree_entry(struct tree_desc *desc, const char *buf, unsigned long size, struct strbuf *err)
diff --git a/odb/tree.c b/odb/tree.c
index f1a9779d1a..3bcb9ef191 100644
--- a/odb/tree.c
+++ b/odb/tree.c
@@ -6,8 +6,8 @@
 #include "odb/commit.h"
 #include "odb/alloc.h"
 #include "odb/tree-walk.h"
-#include "repository.h"
-#include "environment.h"
+#include "setup/repository.h"
+#include "setup/environment.h"
 
 const char *tree_type = "tree";
 
diff --git a/organize/organize.c b/organize/organize.c
index f1f0aec6ea..ef4888aab7 100644
--- a/organize/organize.c
+++ b/organize/organize.c
@@ -3,12 +3,12 @@
 #include "gitorganize-format.h"
 #include "labeler-protocol.h"
 #include "organizer-protocol.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "index/pathspec.h"
 #include "quote.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/oss-fuzz/fuzz-commit-graph.c b/oss-fuzz/fuzz-commit-graph.c
index e0ef2ef871..bc14cb4304 100644
--- a/oss-fuzz/fuzz-commit-graph.c
+++ b/oss-fuzz/fuzz-commit-graph.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "pack/commit-graph.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
 
diff --git a/oss-fuzz/fuzz-config.c b/oss-fuzz/fuzz-config.c
index 94027f5b97..86048ef9d8 100644
--- a/oss-fuzz/fuzz-config.c
+++ b/oss-fuzz/fuzz-config.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 
 int LLVMFuzzerTestOneInput(const uint8_t *, size_t);
 static int config_parser_callback(const char *, const char *,
diff --git a/pack/bloom.c b/pack/bloom.c
index 3fdbbf3aba..c36ebbf9c5 100644
--- a/pack/bloom.c
+++ b/pack/bloom.c
@@ -10,8 +10,8 @@
 #include "odb/commit-slab.h"
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
-#include "config.h"
-#include "repository.h"
+#include "setup/config.h"
+#include "setup/repository.h"
 
 define_commit_slab(bloom_filter_slab, struct bloom_filter);
 
diff --git a/pack/commit-graph.c b/pack/commit-graph.c
index d5537a9ee8..b060a5a16e 100644
--- a/pack/commit-graph.c
+++ b/pack/commit-graph.c
@@ -1,9 +1,9 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "csum-file.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
diff --git a/pack/delta-islands.c b/pack/delta-islands.c
index 7c48204384..e911354aa1 100644
--- a/pack/delta-islands.c
+++ b/pack/delta-islands.c
@@ -17,7 +17,7 @@
 #include "pack/pack-objects.h"
 #include "pack/delta-islands.h"
 #include "odb/oid-array.h"
-#include "config.h"
+#include "setup/config.h"
 
 KHASH_INIT(str, const char *, void *, 1, kh_str_hash_func, kh_str_hash_equal)
 
diff --git a/pack/midx-write.c b/pack/midx-write.c
index 1d5a6525a6..bd4a200b82 100644
--- a/pack/midx-write.c
+++ b/pack/midx-write.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "config.h"
+#include "setup/config.h"
 #include "hex.h"
 #include "lockfile.h"
 #include "pack/packfile.h"
diff --git a/pack/midx.c b/pack/midx.c
index 76e77d0dd2..e3a67aa45a 100644
--- a/pack/midx.c
+++ b/pack/midx.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
 #include "hex.h"
 #include "pack/packfile.h"
diff --git a/pack/pack-bitmap-write.c b/pack/pack-bitmap-write.c
index 3b7b41c5d7..1863ff2dd5 100644
--- a/pack/pack-bitmap-write.c
+++ b/pack/pack-bitmap-write.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/odb.h"
@@ -21,7 +21,7 @@
 #include "odb/tree-walk.h"
 #include "pack/pseudo-merge.h"
 #include "odb/oid-array.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/alloc.h"
 #include "refs/refs.h"
 #include "strmap.h"
diff --git a/pack/pack-bitmap.c b/pack/pack-bitmap.c
index 7cd24a37f5..4851c0d074 100644
--- a/pack/pack-bitmap.c
+++ b/pack/pack-bitmap.c
@@ -15,12 +15,12 @@
 #include "pack/pack-revindex.h"
 #include "pack/pack-objects.h"
 #include "pack/packfile.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "trace2.h"
 #include "odb/odb.h"
 #include "revision/list-objects-filter-options.h"
 #include "pack/midx.h"
-#include "config.h"
+#include "setup/config.h"
 #include "pack/pseudo-merge.h"
 
 /*
diff --git a/pack/pack-check.c b/pack/pack-check.c
index e66ef8f1b7..9123d4da21 100644
--- a/pack/pack-check.c
+++ b/pack/pack-check.c
@@ -1,9 +1,9 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "pack/pack.h"
 #include "progress.h"
 #include "pack/packfile.h"
diff --git a/pack/pack-objects.c b/pack/pack-objects.c
index aa1d5bb1c9..b3059f4865 100644
--- a/pack/pack-objects.c
+++ b/pack/pack-objects.c
@@ -4,7 +4,7 @@
 #include "pack/pack-objects.h"
 #include "pack/packfile.h"
 #include "parse.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 static uint32_t locate_object_entry_hash(struct packing_data *pdata,
 					 const struct object_id *oid,
diff --git a/pack/pack-revindex.c b/pack/pack-revindex.c
index 51cf1f82c6..637802f16b 100644
--- a/pack/pack-revindex.c
+++ b/pack/pack-revindex.c
@@ -6,7 +6,7 @@
 #include "strbuf.h"
 #include "trace2.h"
 #include "parse.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "pack/midx.h"
 #include "csum-file.h"
 
diff --git a/pack/pack-write.c b/pack/pack-write.c
index 3ced89d932..45066b9657 100644
--- a/pack/pack-write.c
+++ b/pack/pack-write.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "pack/pack.h"
@@ -11,7 +11,7 @@
 #include "pack/pack-objects.h"
 #include "pack/pack-revindex.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
diff --git a/pack/packfile.c b/pack/packfile.c
index 77de6bb821..9509d6efcb 100644
--- a/pack/packfile.c
+++ b/pack/packfile.c
@@ -1,12 +1,12 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "revision/list.h"
 #include "pack/pack.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "index/dir.h"
 #include "pack/packfile.h"
 #include "pack/delta.h"
diff --git a/pack/packfile.h b/pack/packfile.h
index 1e6e69fb77..2640288e9b 100644
--- a/pack/packfile.h
+++ b/pack/packfile.h
@@ -8,7 +8,7 @@
 #include "odb/source-packed.h"
 #include "odb/oidset.h"
 #include "pack/packfile-list.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 /* in odb.h */
 struct object_info;
diff --git a/pack/prune-packed.c b/pack/prune-packed.c
index 52473c6bf9..f94fcfebec 100644
--- a/pack/prune-packed.c
+++ b/pack/prune-packed.c
@@ -6,7 +6,7 @@
 #include "pack/packfile.h"
 #include "progress.h"
 #include "pack/prune-packed.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 static struct progress *progress;
 
diff --git a/pack/pseudo-merge.c b/pack/pseudo-merge.c
index 07c6ebea05..a3a0e5b0e9 100644
--- a/pack/pseudo-merge.c
+++ b/pack/pseudo-merge.c
@@ -6,7 +6,7 @@
 #include "date.h"
 #include "odb/oid-array.h"
 #include "strbuf.h"
-#include "config.h"
+#include "setup/config.h"
 #include "string-list.h"
 #include "refs/refs.h"
 #include "pack/pack-bitmap.h"
diff --git a/pack/reachable.c b/pack/reachable.c
index 5b8a2a4f79..4c35f26119 100644
--- a/pack/reachable.c
+++ b/pack/reachable.c
@@ -17,7 +17,7 @@
 #include "odb/object-file.h"
 #include "pack/pack-bitmap.h"
 #include "pack/pack-mtimes.h"
-#include "config.h"
+#include "setup/config.h"
 #include "run-command.h"
 #include "sequencer.h"
 
diff --git a/pack/repack-cruft.c b/pack/repack-cruft.c
index 0f49a59ca7..fc05d13955 100644
--- a/pack/repack-cruft.c
+++ b/pack/repack-cruft.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "pack/repack.h"
 #include "pack/packfile.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
 
 static void combine_small_cruft_packs(FILE *in, off_t combine_cruft_below_size,
diff --git a/pack/repack-filtered.c b/pack/repack-filtered.c
index 2a77018951..a590533bf5 100644
--- a/pack/repack-filtered.c
+++ b/pack/repack-filtered.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "pack/repack.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "string-list.h"
 
diff --git a/pack/repack-geometry.c b/pack/repack-geometry.c
index 1ae2e8be9f..0771905997 100644
--- a/pack/repack-geometry.c
+++ b/pack/repack-geometry.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "pack/repack.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "hex.h"
 #include "pack/midx.h"
 #include "pack/packfile.h"
diff --git a/pack/repack-promisor.c b/pack/repack-promisor.c
index 628903244c..f1538a5365 100644
--- a/pack/repack-promisor.c
+++ b/pack/repack-promisor.c
@@ -4,7 +4,7 @@
 #include "pack/pack.h"
 #include "pack/packfile.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
 
 struct write_oid_context {
diff --git a/pack/repack.c b/pack/repack.c
index 52e7779a44..7c115c30fc 100644
--- a/pack/repack.c
+++ b/pack/repack.c
@@ -5,7 +5,7 @@
 #include "pack/packfile.h"
 #include "path.h"
 #include "pack/repack.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "tempfile.h"
 
diff --git a/pack/server-info.c b/pack/server-info.c
index dbd86d6fd2..ecaaa25e9d 100644
--- a/pack/server-info.c
+++ b/pack/server-info.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "index/dir.h"
 #include "hex.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "refs/refs.h"
 #include "odb/object.h"
 #include "odb/commit.h"
diff --git a/pager.c b/pager.c
index 543ef12936..add45ef679 100644
--- a/pager.c
+++ b/pager.c
@@ -1,12 +1,12 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
 #include "pager.h"
 #include "run-command.h"
 #include "sigchain.h"
-#include "alias.h"
-#include "repository.h"
-#include "environment.h"
+#include "setup/alias.h"
+#include "setup/repository.h"
+#include "setup/environment.h"
 
 int pager_use_color = 1;
 
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 7826b8ad43..ba587028d7 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -6,10 +6,10 @@
 #include "odb/commit.h"
 #include "color.h"
 #include "date.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/object-name.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "odb/oid-array.h"
diff --git a/path-walk.c b/path-walk.c
index 00686d3dbf..e99e43f95a 100644
--- a/path-walk.c
+++ b/path-walk.c
@@ -16,7 +16,7 @@
 #include "odb/oid-array.h"
 #include "path.h"
 #include "prio-queue.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "revision/revision.h"
 #include "string-list.h"
 #include "strmap.h"
diff --git a/path.c b/path.c
index e4d489e10a..1ae08c384b 100644
--- a/path.c
+++ b/path.c
@@ -5,12 +5,12 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "gettext.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 #include "string-list.h"
 #include "index/dir.h"
 #include "refs/worktree.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "submodule-config.h"
 #include "path.h"
 #include "pack/packfile.h"
diff --git a/path.h b/path.h
index 7e7408dd05..36711c6647 100644
--- a/path.h
+++ b/path.h
@@ -294,7 +294,7 @@ void format_path(struct strbuf *dest, const char *path,
 
 # ifdef USE_THE_REPOSITORY_VARIABLE
 #  include "strbuf.h"
-#  include "repository.h"
+#  include "setup/repository.h"
 
 #define GIT_PATH_FUNC(func, filename) \
 	const char *func(void) \
diff --git a/progress.c b/progress.c
index 8315bdc3d4..3faea369df 100644
--- a/progress.c
+++ b/progress.c
@@ -14,7 +14,7 @@
 #include "git-compat-util.h"
 #include "pager.h"
 #include "progress.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 #include "trace.h"
 #include "trace2.h"
diff --git a/promisor-remote.c b/promisor-remote.c
index da6b1225dd..80caaeca99 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -5,15 +5,15 @@
 #include "hex.h"
 #include "odb/odb.h"
 #include "promisor-remote.h"
-#include "config.h"
+#include "setup/config.h"
 #include "trace2.h"
 #include "transport.h"
 #include "strvec.h"
 #include "pack/packfile.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "url.h"
 #include "urlmatch.h"
-#include "version.h"
+#include "setup/version.h"
 #include "wildmatch.h"
 
 struct promisor_remote_config {
diff --git a/promisor-remote.h b/promisor-remote.h
index 301f5ac5cb..9adca948f9 100644
--- a/promisor-remote.h
+++ b/promisor-remote.h
@@ -1,7 +1,7 @@
 #ifndef PROMISOR_REMOTE_H
 #define PROMISOR_REMOTE_H
 
-#include "repository.h"
+#include "setup/repository.h"
 
 struct object_id;
 
diff --git a/prompt.c b/prompt.c
index d8d74c7e37..36f24790f1 100644
--- a/prompt.c
+++ b/prompt.c
@@ -2,8 +2,8 @@
 
 #include "git-compat-util.h"
 #include "parse.h"
-#include "environment.h"
-#include "repository.h"
+#include "setup/environment.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "prompt.h"
diff --git a/protocol-caps.c b/protocol-caps.c
index edac5dbd05..ffda7e11dd 100644
--- a/protocol-caps.c
+++ b/protocol-caps.c
@@ -6,7 +6,7 @@
 #include "odb/hash.h"
 #include "odb/object.h"
 #include "odb/odb.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "string-list.h"
 #include "strbuf.h"
 
diff --git a/protocol.c b/protocol.c
index a3e26a8dd3..7f19dbc04d 100644
--- a/protocol.c
+++ b/protocol.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "protocol.h"
 #include "trace2.h"
 
diff --git a/rebase-interactive.c b/rebase-interactive.c
index ee2ef8b535..f328910af4 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -3,14 +3,14 @@
 #include "git-compat-util.h"
 #include "odb/commit.h"
 #include "editor.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "sequencer.h"
 #include "rebase-interactive.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 #include "odb/commit-slab.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
 #include "odb/object-name.h"
 
diff --git a/refs/files-backend.c b/refs/files-backend.c
index e6e07938a3..22aaa69a23 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -2,26 +2,26 @@
 
 #include "../git-compat-util.h"
 #include "../abspath.h"
-#include "../config.h"
+#include "setup/config.h"
 #include "../copy.h"
-#include "../environment.h"
+#include "setup/environment.h"
 #include "../gettext.h"
 #include "odb/hash.h"
 #include "../hex.h"
 #include "odb/fsck.h"
 #include "refs/refs.h"
-#include "../repo-settings.h"
+#include "setup/repo-settings.h"
 #include "refs-internal.h"
 #include "ref-cache.h"
 #include "packed-backend.h"
-#include "../ident.h"
+#include "setup/ident.h"
 #include "../iterator.h"
 #include "index/dir-iterator.h"
 #include "../lockfile.h"
 #include "../path.h"
 #include "index/dir.h"
 #include "../chdir-notify.h"
-#include "../setup.h"
+#include "setup/setup.h"
 #include "refs/worktree.h"
 #include "../wrapper.h"
 #include "../write-or-die.h"
diff --git a/refs/ls-refs.c b/refs/ls-refs.c
index 75b9b5e620..03ab2720e9 100644
--- a/refs/ls-refs.c
+++ b/refs/ls-refs.c
@@ -1,16 +1,16 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "refs/refs.h"
 #include "strvec.h"
 #include "refs/ls-refs.h"
 #include "pkt-line.h"
-#include "config.h"
+#include "setup/config.h"
 #include "string-list.h"
 
 static enum {
diff --git a/refs/pack-refs.c b/refs/pack-refs.c
index d6c41d64f1..cf586ddf36 100644
--- a/refs/pack-refs.c
+++ b/refs/pack-refs.c
@@ -1,6 +1,6 @@
 #include "builtin.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "refs/pack-refs.h"
 #include "parse-options.h"
 #include "refs/refs.h"
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 97f76c1d76..88fac2f868 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "../git-compat-util.h"
-#include "../config.h"
+#include "setup/config.h"
 #include "index/dir.h"
 #include "odb/fsck.h"
 #include "../gettext.h"
diff --git a/refs/ref-cache.c b/refs/ref-cache.c
index 3599199b8e..e06d56bce5 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -1,7 +1,7 @@
 #include "../git-compat-util.h"
 #include "odb/hash.h"
 #include "refs/refs.h"
-#include "../repository.h"
+#include "setup/repository.h"
 #include "refs-internal.h"
 #include "ref-cache.h"
 #include "../iterator.h"
diff --git a/refs/ref-filter.c b/refs/ref-filter.c
index 32027789a8..9a426b6ce9 100644
--- a/refs/ref-filter.c
+++ b/refs/ref-filter.c
@@ -2,9 +2,9 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gpg-interface.h"
 #include "hex.h"
 #include "parse-options.h"
@@ -14,11 +14,11 @@
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "odb/oid-array.h"
-#include "repo-settings.h"
-#include "repository.h"
+#include "setup/repo-settings.h"
+#include "setup/repository.h"
 #include "odb/commit.h"
 #include "mailmap.h"
-#include "ident.h"
+#include "setup/ident.h"
 #include "remote.h"
 #include "color.h"
 #include "odb/tag.h"
diff --git a/refs/reflog-walk.c b/refs/reflog-walk.c
index 4c321fb3a8..8157b7fb0b 100644
--- a/refs/reflog-walk.c
+++ b/refs/reflog-walk.c
@@ -4,7 +4,7 @@
 #include "odb/commit.h"
 #include "refs/refs.h"
 #include "diff/diff.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "revision/revision.h"
 #include "string-list.h"
 #include "refs/reflog-walk.h"
diff --git a/refs/reflog.c b/refs/reflog.c
index 1050ae6301..cdd8bcf6fd 100644
--- a/refs/reflog.c
+++ b/refs/reflog.c
@@ -2,8 +2,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "odb/odb.h"
diff --git a/refs/refs.c b/refs/refs.c
index 2bc9c3cecd..2cafa50349 100644
--- a/refs/refs.c
+++ b/refs/refs.c
@@ -5,8 +5,8 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "strmap.h"
 #include "gettext.h"
 #include "hex.h"
@@ -14,7 +14,7 @@
 #include "iterator.h"
 #include "refs/refs.h"
 #include "refs/refs-internal.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "odb/object-name.h"
 #include "odb/odb.h"
 #include "odb/object.h"
@@ -22,12 +22,12 @@
 #include "submodule.h"
 #include "refs/worktree.h"
 #include "strvec.h"
-#include "repo-settings.h"
-#include "setup.h"
+#include "setup/repo-settings.h"
+#include "setup/setup.h"
 #include "date.h"
 #include "odb/commit.h"
 #include "wildmatch.h"
-#include "ident.h"
+#include "setup/ident.h"
 #include "odb/fsck.h"
 
 /*
diff --git a/refs/refs.h b/refs/refs.h
index 1746d1035c..03d145deb7 100644
--- a/refs/refs.h
+++ b/refs/refs.h
@@ -3,8 +3,8 @@
 
 #include "odb/object-name.h"
 #include "odb/commit.h"
-#include "repository.h"
-#include "repo-settings.h"
+#include "setup/repository.h"
+#include "setup/repo-settings.h"
 
 struct fsck_options;
 struct object_id;
diff --git a/refs/reftable-backend.c b/refs/reftable-backend.c
index 0c02b2d287..932e91fe8a 100644
--- a/refs/reftable-backend.c
+++ b/refs/reftable-backend.c
@@ -1,14 +1,14 @@
 #include "../git-compat-util.h"
 #include "../abspath.h"
 #include "../chdir-notify.h"
-#include "../config.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "../environment.h"
+#include "setup/environment.h"
 #include "odb/fsck.h"
 #include "../gettext.h"
 #include "odb/hash.h"
 #include "../hex.h"
-#include "../ident.h"
+#include "setup/ident.h"
 #include "../iterator.h"
 #include "../parse.h"
 #include "../path.h"
@@ -19,8 +19,8 @@
 #include "../reftable/reftable-iterator.h"
 #include "../reftable/reftable-record.h"
 #include "../reftable/reftable-stack.h"
-#include "../repo-settings.h"
-#include "../setup.h"
+#include "setup/repo-settings.h"
+#include "setup/setup.h"
 #include "../strmap.h"
 #include "../trace2.h"
 #include "refs/worktree.h"
diff --git a/refs/worktree.c b/refs/worktree.c
index 0f1fe6a7d2..63a7251c47 100644
--- a/refs/worktree.c
+++ b/refs/worktree.c
@@ -2,17 +2,17 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "refs/refs.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "refs/worktree.h"
 #include "index/dir.h"
 #include "index/wt-status.h"
-#include "config.h"
+#include "setup/config.h"
 
 void free_worktree(struct worktree *worktree)
 {
diff --git a/remote-curl.c b/remote-curl.c
index a6a145c046..d0aa42c974 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -3,8 +3,8 @@
 
 #include "git-compat-util.h"
 #include "git-curl-compat.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "remote.h"
@@ -19,7 +19,7 @@
 #include "credential.h"
 #include "odb/oid-array.h"
 #include "send-pack.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "protocol.h"
 #include "quote.h"
 #include "trace2.h"
diff --git a/remote.c b/remote.c
index 2b376893b3..ae77c5b1db 100644
--- a/remote.c
+++ b/remote.c
@@ -3,8 +3,8 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "remote.h"
@@ -19,7 +19,7 @@
 #include "diff/diff.h"
 #include "revision/revision.h"
 #include "index/dir.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "revision/commit-reach.h"
diff --git a/replay.c b/replay.c
index 6922a1f137..97ef099650 100644
--- a/replay.c
+++ b/replay.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "merge-ort.h"
 #include "odb/object-name.h"
diff --git a/rerere.c b/rerere.c
index df30ebbe93..bd6e452036 100644
--- a/rerere.c
+++ b/rerere.c
@@ -3,9 +3,9 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "config.h"
+#include "setup/config.h"
 #include "copy.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
diff --git a/reset.c b/reset.c
index 0eddc94d8c..8155336712 100644
--- a/reset.c
+++ b/reset.c
@@ -9,7 +9,7 @@
 #include "odb/tree-walk.h"
 #include "odb/tree.h"
 #include "index/unpack-trees.h"
-#include "hook.h"
+#include "setup/hook.h"
 
 static int update_refs(struct repository *repo,
 		       const struct reset_working_tree_options *opts,
diff --git a/reset.h b/reset.h
index 52055ad68d..09179ece6d 100644
--- a/reset.h
+++ b/reset.h
@@ -2,7 +2,7 @@
 #define RESET_H
 
 #include "odb/hash.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 #define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
 
diff --git a/revision/bisect.c b/revision/bisect.c
index 7805872c3e..7949d74e14 100644
--- a/revision/bisect.c
+++ b/revision/bisect.c
@@ -2,10 +2,10 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
 #include "diff/diff.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "revision/revision.h"
diff --git a/revision/blame.c b/revision/blame.c
index a75bf22193..11e3dd63ff 100644
--- a/revision/blame.c
+++ b/revision/blame.c
@@ -15,7 +15,7 @@
 #include "path.h"
 #include "index/read-cache.h"
 #include "revision/revision.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "odb/tag.h"
 #include "trace2.h"
 #include "revision/blame.h"
diff --git a/revision/graph.c b/revision/graph.c
index c6f10398a2..9524af5010 100644
--- a/revision/graph.c
+++ b/revision/graph.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "gettext.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
 #include "color.h"
 #include "revision/graph.h"
diff --git a/revision/line-log.c b/revision/line-log.c
index 3da7af2340..97fe28d3ef 100644
--- a/revision/line-log.c
+++ b/revision/line-log.c
@@ -9,12 +9,12 @@
 #include "diff/diff.h"
 #include "odb/commit.h"
 #include "revision/decorate.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "revision/revision.h"
 #include "diff/xdiff-interface.h"
 #include "strbuf.h"
 #include "revision/line-log.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strvec.h"
 #include "pack/bloom.h"
 #include "odb/tree-walk.h"
diff --git a/revision/list-objects-filter-options.c b/revision/list-objects-filter-options.c
index 6730808896..38604a580c 100644
--- a/revision/list-objects-filter-options.c
+++ b/revision/list-objects-filter-options.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "revision/list-objects-filter-options.h"
 #include "promisor-remote.h"
diff --git a/revision/list-objects.c b/revision/list-objects.c
index fdf98b629f..8544ff2a2a 100644
--- a/revision/list-objects.c
+++ b/revision/list-objects.c
@@ -16,7 +16,7 @@
 #include "pack/packfile.h"
 #include "odb/odb.h"
 #include "trace.h"
-#include "environment.h"
+#include "setup/environment.h"
 
 struct traversal_context {
 	struct rev_info *revs;
diff --git a/revision/log-tree.c b/revision/log-tree.c
index e555d07072..679dd21806 100644
--- a/revision/log-tree.c
+++ b/revision/log-tree.c
@@ -4,14 +4,14 @@
 #include "git-compat-util.h"
 #include "revision/commit-reach.h"
 #include "odb/commit-slab.h"
-#include "config.h"
+#include "setup/config.h"
 #include "diff/diff.h"
 #include "diff/diffcore.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "odb/object-name.h"
 #include "odb/object-file.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/tmp-objdir.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
diff --git a/revision/pretty.c b/revision/pretty.c
index cdf63ded49..7925bea766 100644
--- a/revision/pretty.c
+++ b/revision/pretty.c
@@ -2,9 +2,9 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "odb/hash.h"
 #include "hex.h"
diff --git a/revision/revision.c b/revision/revision.c
index 97c6fa6fef..7470333ae6 100644
--- a/revision/revision.c
+++ b/revision/revision.c
@@ -2,8 +2,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
@@ -18,7 +18,7 @@
 #include "diff/diff-merges.h"
 #include "refs/refs.h"
 #include "revision/revision.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "revision/graph.h"
 #include "grep.h"
 #include "refs/reflog-walk.h"
@@ -35,7 +35,7 @@
 #include "refs/worktree.h"
 #include "path.h"
 #include "index/read-cache.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "index/sparse-index.h"
 #include "strvec.h"
 #include "trace2.h"
diff --git a/revision/revision.h b/revision/revision.h
index 9cb9419b22..5a894e27a4 100644
--- a/revision/revision.h
+++ b/revision/revision.h
@@ -10,7 +10,7 @@
 #include "diff/diff.h"
 #include "odb/commit-slab-decl.h"
 #include "revision/decorate.h"
-#include "ident.h"
+#include "setup/ident.h"
 #include "revision/list-objects-filter-options.h"
 #include "prio-queue.h"
 #include "strvec.h"
diff --git a/revision/shallow.c b/revision/shallow.c
index f4ce207278..a6e8a66c14 100644
--- a/revision/shallow.c
+++ b/revision/shallow.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "hex.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "tempfile.h"
 #include "lockfile.h"
 #include "odb/odb.h"
diff --git a/revision/shallow.h b/revision/shallow.h
index 0cb1d5ba70..60b283c9d5 100644
--- a/revision/shallow.h
+++ b/revision/shallow.h
@@ -4,7 +4,7 @@
 #include "odb/commit.h"
 #include "lockfile.h"
 #include "odb/object.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 
 struct oid_array;
diff --git a/run-command.c b/run-command.c
index 80382354dc..83702c99f1 100644
--- a/run-command.c
+++ b/run-command.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "run-command.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "sigchain.h"
@@ -14,7 +14,7 @@
 #include "trace.h"
 #include "trace2.h"
 #include "quote.h"
-#include "config.h"
+#include "setup/config.h"
 #include "pack/packfile.h"
 #include "compat/nonblock.h"
 
diff --git a/scalar.c b/scalar.c
index d1e397ef50..17468d1332 100644
--- a/scalar.c
+++ b/scalar.c
@@ -8,7 +8,7 @@
 #include "abspath.h"
 #include "gettext.h"
 #include "parse-options.h"
-#include "config.h"
+#include "setup/config.h"
 #include "run-command.h"
 #include "simple-ipc.h"
 #include "index/fsmonitor-ipc.h"
@@ -17,7 +17,7 @@
 #include "index/dir.h"
 #include "pack/packfile.h"
 #include "help.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "trace2.h"
 #include "path.h"
 
diff --git a/send-pack.c b/send-pack.c
index f59686f971..546835b0aa 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/commit.h"
 #include "date.h"
 #include "gettext.h"
@@ -12,7 +12,7 @@
 #include "connect.h"
 #include "send-pack.h"
 #include "transport.h"
-#include "version.h"
+#include "setup/version.h"
 #include "odb/oid-array.h"
 #include "gpg-interface.h"
 #include "revision/shallow.h"
diff --git a/sequencer.c b/sequencer.c
index f4a0f77eaf..1dd0c6af95 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -4,9 +4,9 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
-#include "config.h"
+#include "setup/config.h"
 #include "copy.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
@@ -19,7 +19,7 @@
 #include "odb/commit.h"
 #include "sequencer.h"
 #include "run-command.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "utf8.h"
 #include "index/cache-tree.h"
 #include "diff/diff.h"
@@ -43,7 +43,7 @@
 #include "odb/oidmap.h"
 #include "odb/oidset.h"
 #include "odb/commit-slab.h"
-#include "alias.h"
+#include "setup/alias.h"
 #include "revision/commit-reach.h"
 #include "rebase-interactive.h"
 #include "reset.h"
diff --git a/serve.c b/serve.c
index df3086fb3a..4408187c47 100644
--- a/serve.c
+++ b/serve.c
@@ -1,9 +1,9 @@
 #include "git-compat-util.h"
-#include "repository.h"
-#include "config.h"
+#include "setup/repository.h"
+#include "setup/config.h"
 #include "odb/hash.h"
 #include "pkt-line.h"
-#include "version.h"
+#include "setup/version.h"
 #include "refs/ls-refs.h"
 #include "protocol-caps.h"
 #include "serve.h"
diff --git a/alias.c b/setup/alias.c
similarity index 98%
rename from alias.c
rename to setup/alias.c
index e737c49edd..c6939bd88e 100644
--- a/alias.c
+++ b/setup/alias.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "alias.h"
-#include "config.h"
+#include "setup/alias.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/alias.h b/setup/alias.h
similarity index 100%
rename from alias.h
rename to setup/alias.h
diff --git a/config.c b/setup/config.c
similarity index 99%
rename from config.c
rename to setup/config.c
index 59c6029654..3f26a8beda 100644
--- a/config.c
+++ b/setup/config.c
@@ -11,14 +11,14 @@
 #include "advice.h"
 #include "date.h"
 #include "branch.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
 #include "parse.h"
 #include "convert.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "git-zlib.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "lockfile.h"
 #include "exec-cmd.h"
 #include "strbuf.h"
@@ -31,7 +31,7 @@
 #include "utf8.h"
 #include "color.h"
 #include "refs/refs.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strvec.h"
 #include "trace2.h"
 #include "wildmatch.h"
diff --git a/config.h b/setup/config.h
similarity index 99%
rename from config.h
rename to setup/config.h
index 31fe3e2961..44aba10ce1 100644
--- a/config.h
+++ b/setup/config.h
@@ -3,7 +3,7 @@
 
 #include "hashmap.h"
 #include "string-list.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "parse.h"
 
 /**
diff --git a/environment.c b/setup/environment.c
similarity index 99%
rename from environment.c
rename to setup/environment.c
index 6066417b62..0b135d4d8d 100644
--- a/environment.c
+++ b/setup/environment.c
@@ -17,15 +17,15 @@
 #include "branch.h"
 #include "color.h"
 #include "convert.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "git-zlib.h"
-#include "ident.h"
+#include "setup/ident.h"
 #include "lockfile.h"
 #include "mailmap.h"
 #include "odb/object-name.h"
-#include "repository.h"
-#include "config.h"
+#include "setup/repository.h"
+#include "setup/config.h"
 #include "refs/refs.h"
 #include "fmt-merge-msg.h"
 #include "odb/commit.h"
@@ -34,7 +34,7 @@
 #include "path.h"
 #include "quote.h"
 #include "chdir-notify.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "ws.h"
 #include "write-or-die.h"
 
diff --git a/environment.h b/setup/environment.h
similarity index 99%
rename from environment.h
rename to setup/environment.h
index e7ec5b0437..ba8004e179 100644
--- a/environment.h
+++ b/setup/environment.h
@@ -1,7 +1,7 @@
 #ifndef ENVIRONMENT_H
 #define ENVIRONMENT_H
 
-#include "repo-settings.h"
+#include "setup/repo-settings.h"
 #include "branch.h"
 
 /* Double-check local_repo_env below if you add to this list. */
diff --git a/hook.c b/setup/hook.c
similarity index 99%
rename from hook.c
rename to setup/hook.c
index d10eef4763..e4cfca5fa5 100644
--- a/hook.c
+++ b/setup/hook.c
@@ -1,15 +1,15 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "hook-list.h"
 #include "parse.h"
 #include "path.h"
 #include "run-command.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "strmap.h"
 #include "thread-utils.h"
diff --git a/hook.h b/setup/hook.h
similarity index 99%
rename from hook.h
rename to setup/hook.h
index 27bb1aeb2e..f5ca5364cc 100644
--- a/hook.h
+++ b/setup/hook.h
@@ -1,6 +1,6 @@
 #ifndef HOOK_H
 #define HOOK_H
-#include "config.h"
+#include "setup/config.h"
 #include "run-command.h"
 #include "string-list.h"
 #include "strmap.h"
diff --git a/ident.c b/setup/ident.c
similarity index 99%
rename from ident.c
rename to setup/ident.c
index 0b7aacecd7..27e620fdf4 100644
--- a/ident.c
+++ b/setup/ident.c
@@ -6,8 +6,8 @@
  * Copyright (C) 2005 Linus Torvalds
  */
 #include "git-compat-util.h"
-#include "ident.h"
-#include "config.h"
+#include "setup/ident.h"
+#include "setup/config.h"
 #include "date.h"
 #include "gettext.h"
 #include "mailmap.h"
diff --git a/ident.h b/setup/ident.h
similarity index 100%
rename from ident.h
rename to setup/ident.h
diff --git a/repo-settings.c b/setup/repo-settings.c
similarity index 98%
rename from repo-settings.c
rename to setup/repo-settings.c
index f40d1436a9..3c71eb6fc6 100644
--- a/repo-settings.c
+++ b/setup/repo-settings.c
@@ -1,10 +1,10 @@
 #include "git-compat-util.h"
-#include "config.h"
-#include "repo-settings.h"
-#include "repository.h"
+#include "setup/config.h"
+#include "setup/repo-settings.h"
+#include "setup/repository.h"
 #include "pack/midx.h"
 #include "pack/pack-objects.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 static void repo_cfg_bool(struct repository *r, const char *key, int *dest,
 			  int def)
diff --git a/repo-settings.h b/setup/repo-settings.h
similarity index 100%
rename from repo-settings.h
rename to setup/repo-settings.h
diff --git a/repository.c b/setup/repository.c
similarity index 99%
rename from repository.c
rename to setup/repository.c
index 8771145515..77be866c82 100644
--- a/repository.c
+++ b/setup/repository.c
@@ -1,17 +1,17 @@
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "repository.h"
-#include "hook.h"
+#include "setup/repository.h"
+#include "setup/hook.h"
 #include "odb/odb.h"
 #include "odb/source.h"
-#include "config.h"
+#include "setup/config.h"
 #include "gettext.h"
 #include "odb/object.h"
 #include "lockfile.h"
 #include "path.h"
 #include "index/read-cache-ll.h"
 #include "remote.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "odb/loose.h"
 #include "submodule-config.h"
 #include "index/sparse-index.h"
diff --git a/repository.h b/setup/repository.h
similarity index 99%
rename from repository.h
rename to setup/repository.h
index 3b467a2513..3157f56e9c 100644
--- a/repository.h
+++ b/setup/repository.h
@@ -3,8 +3,8 @@
 
 #include "strmap.h"
 #include "string-list.h"
-#include "repo-settings.h"
-#include "environment.h"
+#include "setup/repo-settings.h"
+#include "setup/environment.h"
 
 struct config_set;
 struct git_hash_algo;
diff --git a/setup.c b/setup/setup.c
similarity index 99%
rename from setup.c
rename to setup/setup.c
index e4e9ca83fe..e71fa7b118 100644
--- a/setup.c
+++ b/setup/setup.c
@@ -3,17 +3,17 @@
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "copy.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
 #include "refs/refs.h"
-#include "repository.h"
-#include "config.h"
+#include "setup/repository.h"
+#include "setup/config.h"
 #include "index/dir.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "revision/shallow.h"
 #include "string-list.h"
 #include "strvec.h"
diff --git a/setup.h b/setup/setup.h
similarity index 100%
rename from setup.h
rename to setup/setup.h
diff --git a/version.c b/setup/version.c
similarity index 98%
rename from version.c
rename to setup/version.c
index 21ec7c0fbe..c4a55edb5c 100644
--- a/version.c
+++ b/setup/version.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "version.h"
+#include "setup/version.h"
 #include "strbuf.h"
 #include "gettext.h"
 
diff --git a/version.h b/setup/version.h
similarity index 100%
rename from version.h
rename to setup/version.h
diff --git a/shell.c b/shell.c
index 76333c8068..4e7f8e43c0 100644
--- a/shell.c
+++ b/shell.c
@@ -3,7 +3,7 @@
 #include "exec-cmd.h"
 #include "strbuf.h"
 #include "run-command.h"
-#include "alias.h"
+#include "setup/alias.h"
 
 #define COMMAND_DIR "git-shell-commands"
 #define HELP_COMMAND COMMAND_DIR "/help"
diff --git a/sideband.c b/sideband.c
index 374187402e..b915fdf114 100644
--- a/sideband.c
+++ b/sideband.c
@@ -3,7 +3,7 @@
 
 #include "git-compat-util.h"
 #include "color.h"
-#include "config.h"
+#include "setup/config.h"
 #include "editor.h"
 #include "gettext.h"
 #include "sideband.h"
diff --git a/submodule-config.c b/submodule-config.c
index c8be0acbb1..334cfb54ee 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -3,12 +3,12 @@
 
 #include "git-compat-util.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "path.h"
-#include "repository.h"
-#include "config.h"
+#include "setup/repository.h"
+#include "setup/config.h"
 #include "submodule-config.h"
 #include "submodule.h"
 #include "strbuf.h"
diff --git a/submodule-config.h b/submodule-config.h
index 3f4f0bf454..b1d075a754 100644
--- a/submodule-config.h
+++ b/submodule-config.h
@@ -1,7 +1,7 @@
 #ifndef SUBMODULE_CONFIG_CACHE_H
 #define SUBMODULE_CONFIG_CACHE_H
 
-#include "config.h"
+#include "setup/config.h"
 #include "submodule.h"
 #include "odb/tree-walk.h"
 
diff --git a/submodule.c b/submodule.c
index e14b53d3c8..16b3ffbcc6 100644
--- a/submodule.c
+++ b/submodule.c
@@ -3,14 +3,14 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "repository.h"
-#include "config.h"
+#include "setup/repository.h"
+#include "setup/config.h"
 #include "submodule-config.h"
 #include "submodule.h"
 #include "index/dir.h"
 #include "diff/diff.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "revision/revision.h"
@@ -30,7 +30,7 @@
 #include "odb/odb.h"
 #include "revision/commit-reach.h"
 #include "index/read-cache-ll.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "advice.h"
 #include "url.h"
 
diff --git a/t/helper/test-advise.c b/t/helper/test-advise.c
index 8f9db2693e..1f4a67bb65 100644
--- a/t/helper/test-advise.c
+++ b/t/helper/test-advise.c
@@ -2,9 +2,9 @@
 
 #include "test-tool.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
-#include "setup.h"
+#include "setup/config.h"
+#include "setup/environment.h"
+#include "setup/setup.h"
 
 int cmd__advise_if_enabled(int argc, const char **argv)
 {
diff --git a/t/helper/test-bitmap.c b/t/helper/test-bitmap.c
index 59beba76d2..40bf0c790f 100644
--- a/t/helper/test-bitmap.c
+++ b/t/helper/test-bitmap.c
@@ -6,7 +6,7 @@
 #include "odb/odb.h"
 #include "pack/pack-bitmap.h"
 #include "pack/pseudo-merge.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 static int bitmap_list_commits(void)
 {
diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index 5c469af08d..0be36ac656 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -4,8 +4,8 @@
 #include "pack/bloom.h"
 #include "hex.h"
 #include "odb/commit.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 
 static struct bloom_filter_settings settings = DEFAULT_BLOOM_FILTER_SETTINGS;
 
diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c
index cf7e7efc5d..bbdedf44dd 100644
--- a/t/helper/test-cache-tree.c
+++ b/t/helper/test-cache-tree.c
@@ -8,8 +8,8 @@
 #include "index/cache-tree.h"
 #include "parse-options.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 
 static char const * const test_cache_tree_usage[] = {
 	N_("test-tool cache-tree <options> (control|prime|update)"),
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index cfb3f4b111..8d5a7af0b4 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -2,8 +2,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "test-tool.h"
-#include "config.h"
-#include "setup.h"
+#include "setup/config.h"
+#include "setup/setup.h"
 #include "string-list.h"
 
 /*
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index 599b316ac1..251aea165d 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -6,8 +6,8 @@
 #include "odb/tree.h"
 #include "index/cache-tree.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 
 static void dump_one(struct cache_tree *it, const char *pfx, const char *x)
 {
diff --git a/t/helper/test-dump-fsmonitor.c b/t/helper/test-dump-fsmonitor.c
index 1dbdb28fbf..adcb90bd3a 100644
--- a/t/helper/test-dump-fsmonitor.c
+++ b/t/helper/test-dump-fsmonitor.c
@@ -2,8 +2,8 @@
 
 #include "test-tool.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 
 int cmd__dump_fsmonitor(int ac UNUSED, const char **av UNUSED)
 {
diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c
index 79c8628005..f3013bba91 100644
--- a/t/helper/test-dump-split-index.c
+++ b/t/helper/test-dump-split-index.c
@@ -3,8 +3,8 @@
 #include "test-tool.h"
 #include "hex.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "index/split-index.h"
 #include "ewah/ewok.h"
 
diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
index c31d01f3b5..8fc213e26a 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
@@ -4,8 +4,8 @@
 #include "index/dir.h"
 #include "hex.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 
 static int compare_untracked(const void *a_, const void *b_)
 {
diff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c
index 216e7abb9a..def817ba1b 100644
--- a/t/helper/test-find-pack.c
+++ b/t/helper/test-find-pack.c
@@ -5,7 +5,7 @@
 #include "odb/odb.h"
 #include "pack/packfile.h"
 #include "parse-options.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 /*
  * Display the path(s), one per line, of the packfile(s) containing
diff --git a/t/helper/test-fsmonitor-client.c b/t/helper/test-fsmonitor-client.c
index 845c1db493..35f313e568 100644
--- a/t/helper/test-fsmonitor-client.c
+++ b/t/helper/test-fsmonitor-client.c
@@ -9,8 +9,8 @@
 #include "parse-options.h"
 #include "index/fsmonitor-ipc.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "thread-utils.h"
 #include "trace2.h"
 
diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c
index 6f16fcf7e8..328732f72a 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -1,12 +1,12 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "index/name-hash.h"
 #include "parse-options.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "trace.h"
 
 static int single;
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index b6122af08f..65a56444c8 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -4,8 +4,8 @@
 #include "hex.h"
 #include "odb/match-trees.h"
 #include "odb/object-name.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "odb/tree.h"
 
 int cmd__match_trees(int ac UNUSED, const char **av)
diff --git a/t/helper/test-pack-deltas.c b/t/helper/test-pack-deltas.c
index a3117ca6fc..f86434bf93 100644
--- a/t/helper/test-pack-deltas.c
+++ b/t/helper/test-pack-deltas.c
@@ -9,7 +9,7 @@
 #include "pack/pack.h"
 #include "pack/pack-objects.h"
 #include "parse-options.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "string-list.h"
 
diff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c
index 4750a33140..a662bebb10 100644
--- a/t/helper/test-pack-mtimes.c
+++ b/t/helper/test-pack-mtimes.c
@@ -6,7 +6,7 @@
 #include "odb/odb.h"
 #include "pack/packfile.h"
 #include "pack/pack-mtimes.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 static void dump_mtimes(struct packed_git *p)
 {
diff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c
index 76fc0329fc..db27488954 100644
--- a/t/helper/test-partial-clone.c
+++ b/t/helper/test-partial-clone.c
@@ -2,9 +2,9 @@
 
 #include "test-tool.h"
 #include "hex.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/odb.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 /*
  * Prints the size of the object corresponding to the given hash in a specific
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index fd98a5bfd9..34ccd254e5 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -3,10 +3,10 @@
 
 #include "test-tool.h"
 #include "abspath.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "path.h"
 #include "index/read-cache-ll.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "string-list.h"
 #include "trace.h"
 #include "utf8.h"
diff --git a/t/helper/test-path-walk.c b/t/helper/test-path-walk.c
index f689ff3c53..8bf2ec3dc6 100644
--- a/t/helper/test-path-walk.c
+++ b/t/helper/test-path-walk.c
@@ -2,14 +2,14 @@
 
 #include "test-tool.h"
 #include "index/dir.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "revision/list-objects-filter-options.h"
 #include "odb/object-name.h"
 #include "odb/object.h"
 #include "revision/pretty.h"
 #include "revision/revision.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "parse-options.h"
 #include "strbuf.h"
 #include "path-walk.h"
diff --git a/t/helper/test-progress.c b/t/helper/test-progress.c
index 1f75b7bd19..8146c56f08 100644
--- a/t/helper/test-progress.c
+++ b/t/helper/test-progress.c
@@ -24,7 +24,7 @@
 #include "test-tool.h"
 #include "parse-options.h"
 #include "progress.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 #include "string-list.h"
 
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 7f00cc7d9c..30bde7d2ee 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -7,7 +7,7 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "refs/ref-filter.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "string-list.h"
 #include "odb/tag.h"
 
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index dad40b8ad7..ae2e1f19f4 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -1,11 +1,11 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 
 int cmd__read_cache(int argc, const char **argv)
 {
diff --git a/t/helper/test-read-graph.c b/t/helper/test-read-graph.c
index c80df07586..76f0833cc0 100644
--- a/t/helper/test-read-graph.c
+++ b/t/helper/test-read-graph.c
@@ -2,10 +2,10 @@
 
 #include "test-tool.h"
 #include "pack/commit-graph.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/odb.h"
 #include "pack/bloom.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 static void dump_graph_info(struct commit_graph *graph)
 {
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index 1e3db8cd81..ce8c10d4f1 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -3,11 +3,11 @@
 #include "test-tool.h"
 #include "hex.h"
 #include "pack/midx.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/odb.h"
 #include "pack/pack-bitmap.h"
 #include "pack/packfile.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "gettext.h"
 #include "pack/pack-revindex.h"
 
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index 582e8b4d97..522520046e 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -3,11 +3,11 @@
 #include "test-tool.h"
 #include "hex.h"
 #include "refs/refs.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "refs/worktree.h"
 #include "odb/odb.h"
 #include "path.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 #include "revision/revision.h"
 
diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c
index 58f486a471..947aaf6b94 100644
--- a/t/helper/test-repository.c
+++ b/t/helper/test-repository.c
@@ -3,11 +3,11 @@
 #include "test-tool.h"
 #include "pack/commit-graph.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "odb/object.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "odb/tree.h"
 
 static void test_parse_commit_in_graph(const char *gitdir, const char *worktree,
diff --git a/t/helper/test-revision-walking.c b/t/helper/test-revision-walking.c
index 57e0bcea63..264c96fc59 100644
--- a/t/helper/test-revision-walking.c
+++ b/t/helper/test-revision-walking.c
@@ -15,9 +15,9 @@
 #include "diff/diff.h"
 #include "revision/line-log.h"
 #include "odb/object-name.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "revision/revision.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "string-list.h"
 
 static void print_commit(struct commit *commit)
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index 8e40a08436..0989f969da 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -3,8 +3,8 @@
 #include "test-tool.h"
 #include "lockfile.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "odb/tree.h"
 #include "index/cache-tree.h"
 
diff --git a/t/helper/test-serve-v2.c b/t/helper/test-serve-v2.c
index 27f3ed8947..13452d4eab 100644
--- a/t/helper/test-serve-v2.c
+++ b/t/helper/test-serve-v2.c
@@ -3,9 +3,9 @@
 #include "test-tool.h"
 #include "gettext.h"
 #include "parse-options.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "serve.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 static char const * const serve_usage[] = {
 	N_("test-tool serve-v2 [<options>]"),
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 7a756d4f8d..e928d148f6 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,11 +1,11 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "config.h"
+#include "setup/config.h"
 #include "odb/hash.h"
 #include "odb/object-name.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "submodule-config.h"
 #include "submodule.h"
 
diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c
index 7e31d3fe47..a7078a0ef4 100644
--- a/t/helper/test-submodule-nested-repo-config.c
+++ b/t/helper/test-submodule-nested-repo-config.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "submodule-config.h"
 
 static void die_usage(const char **argv, const char *msg)
diff --git a/t/helper/test-submodule.c b/t/helper/test-submodule.c
index 3c5c4c4a09..7a82e1f0f9 100644
--- a/t/helper/test-submodule.c
+++ b/t/helper/test-submodule.c
@@ -4,8 +4,8 @@
 #include "test-tool-utils.h"
 #include "parse-options.h"
 #include "remote.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "submodule-config.h"
 #include "submodule.h"
diff --git a/t/helper/test-subprocess.c b/t/helper/test-subprocess.c
index a8194d24b3..b2b1d5494e 100644
--- a/t/helper/test-subprocess.c
+++ b/t/helper/test-subprocess.c
@@ -2,7 +2,7 @@
 
 #include "test-tool.h"
 #include "run-command.h"
-#include "setup.h"
+#include "setup/setup.h"
 
 int cmd__subprocess(int argc, const char **argv)
 {
diff --git a/t/helper/test-synthesize.c b/t/helper/test-synthesize.c
index 1997141691..df4a4c972c 100644
--- a/t/helper/test-synthesize.c
+++ b/t/helper/test-synthesize.c
@@ -10,8 +10,8 @@
 #include "pack/pack.h"
 #include "parse-options.h"
 #include "parse.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 #include "strbuf.h"
 #include "write-or-die.h"
 
diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c
index 3b12f4173e..ffd2bd99f1 100644
--- a/t/helper/test-trace2.c
+++ b/t/helper/test-trace2.c
@@ -5,8 +5,8 @@
 #include "strvec.h"
 #include "run-command.h"
 #include "exec-cmd.h"
-#include "config.h"
-#include "repository.h"
+#include "setup/config.h"
+#include "setup/repository.h"
 #include "trace2.h"
 
 typedef int(fn_unit_test)(int argc, const char **argv);
diff --git a/t/helper/test-userdiff.c b/t/helper/test-userdiff.c
index ee829e0868..b01b8d5c84 100644
--- a/t/helper/test-userdiff.c
+++ b/t/helper/test-userdiff.c
@@ -1,9 +1,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "test-tool.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "diff/userdiff.h"
-#include "config.h"
+#include "setup/config.h"
 
 static int driver_cb(struct userdiff_driver *driver,
 		     enum userdiff_driver_type type, void *priv)
diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c
index ffe468b445..f5707e6248 100644
--- a/t/helper/test-write-cache.c
+++ b/t/helper/test-write-cache.c
@@ -3,8 +3,8 @@
 #include "test-tool.h"
 #include "lockfile.h"
 #include "index/read-cache-ll.h"
-#include "repository.h"
-#include "setup.h"
+#include "setup/repository.h"
+#include "setup/setup.h"
 
 int cmd__write_cache(int argc, const char **argv)
 {
diff --git a/t/unit-tests/u-example-decorate.c b/t/unit-tests/u-example-decorate.c
index 85d0277ee2..dde491a450 100644
--- a/t/unit-tests/u-example-decorate.c
+++ b/t/unit-tests/u-example-decorate.c
@@ -3,7 +3,7 @@
 #include "unit-test.h"
 #include "odb/object.h"
 #include "revision/decorate.h"
-#include "repository.h"
+#include "setup/repository.h"
 
 struct test_vars {
 	struct object *one, *two, *three;
diff --git a/t/unit-tests/u-odb-inmemory.c b/t/unit-tests/u-odb-inmemory.c
index 4f923f7267..48e048aa14 100644
--- a/t/unit-tests/u-odb-inmemory.c
+++ b/t/unit-tests/u-odb-inmemory.c
@@ -4,7 +4,7 @@
 #include "odb/source-inmemory.h"
 #include "odb/streaming.h"
 #include "odb/oidset.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "strbuf.h"
 
 #define RANDOM_OID "da39a3ee5e6b4b0d3255bfef95601890afd80709"
diff --git a/trace.c b/trace.c
index 515b99e7f5..67ac945821 100644
--- a/trace.c
+++ b/trace.c
@@ -25,9 +25,9 @@
 
 #include "git-compat-util.h"
 #include "abspath.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "quote.h"
-#include "setup.h"
+#include "setup/setup.h"
 #include "trace.h"
 
 struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
diff --git a/trace2.c b/trace2.c
index c23c0a227b..a8e23ff96f 100644
--- a/trace2.c
+++ b/trace2.c
@@ -1,8 +1,8 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "repository.h"
+#include "setup/config.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "thread-utils.h"
diff --git a/trace2/tr2_cfg.c b/trace2/tr2_cfg.c
index bbcfeda60a..174252feaa 100644
--- a/trace2/tr2_cfg.c
+++ b/trace2/tr2_cfg.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "strbuf.h"
 #include "trace2.h"
 #include "trace2/tr2_cfg.h"
diff --git a/trace2/tr2_sysenv.c b/trace2/tr2_sysenv.c
index c63aebbec5..9da3946d5f 100644
--- a/trace2/tr2_sysenv.c
+++ b/trace2/tr2_sysenv.c
@@ -1,7 +1,7 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "index/dir.h"
 #include "tr2_sysenv.h"
 
diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
index 5a0381791f..fa42082bc6 100644
--- a/trace2/tr2_tgt_event.c
+++ b/trace2/tr2_tgt_event.c
@@ -1,11 +1,11 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "json-writer.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "run-command.h"
-#include "version.h"
+#include "setup/version.h"
 #include "trace2/tr2_dst.h"
 #include "trace2/tr2_tbuf.h"
 #include "trace2/tr2_sid.h"
diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
index 924736ab36..0fc180b021 100644
--- a/trace2/tr2_tgt_normal.c
+++ b/trace2/tr2_tgt_normal.c
@@ -1,10 +1,10 @@
 #include "git-compat-util.h"
-#include "config.h"
-#include "repository.h"
+#include "setup/config.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "quote.h"
-#include "version.h"
+#include "setup/version.h"
 #include "trace2/tr2_dst.h"
 #include "trace2/tr2_sysenv.h"
 #include "trace2/tr2_tbuf.h"
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
index 4eb9289f95..46e5c3d56c 100644
--- a/trace2/tr2_tgt_perf.c
+++ b/trace2/tr2_tgt_perf.c
@@ -1,11 +1,11 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "repository.h"
+#include "setup/config.h"
+#include "setup/repository.h"
 #include "run-command.h"
 #include "quote.h"
-#include "version.h"
+#include "setup/version.h"
 #include "json-writer.h"
 #include "trace2/tr2_dst.h"
 #include "trace2/tr2_sid.h"
diff --git a/trailer.c b/trailer.c
index 7723c5cf52..bf02921cfa 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1,8 +1,8 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "string-list.h"
 #include "run-command.h"
diff --git a/transport-helper.c b/transport-helper.c
index 6721209d46..94d3d9ced8 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -5,11 +5,11 @@
 #include "quote.h"
 #include "run-command.h"
 #include "odb/commit.h"
-#include "environment.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-name.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "remote.h"
 #include "string-list.h"
 #include "thread-utils.h"
diff --git a/transport.c b/transport.c
index 38915e5466..18429b78f5 100644
--- a/transport.c
+++ b/transport.c
@@ -2,11 +2,11 @@
 
 #include "git-compat-util.h"
 #include "advice.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "hex.h"
 #include "transport.h"
-#include "hook.h"
+#include "setup/hook.h"
 #include "pkt-line.h"
 #include "fetch-pack.h"
 #include "fetch-object-info.h"
diff --git a/upload-pack.c b/upload-pack.c
index 09a986e486..23c0357496 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -2,14 +2,14 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "config.h"
-#include "environment.h"
+#include "setup/config.h"
+#include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs/refs.h"
 #include "pkt-line.h"
 #include "sideband.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/odb.h"
 #include "odb/oid-array.h"
 #include "odb/object.h"
@@ -20,7 +20,7 @@
 #include "run-command.h"
 #include "connect.h"
 #include "sigchain.h"
-#include "version.h"
+#include "setup/version.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "trace2.h"
diff --git a/urlmatch.h b/urlmatch.h
index db1a335e72..e3f1ce7477 100644
--- a/urlmatch.h
+++ b/urlmatch.h
@@ -2,7 +2,7 @@
 #define URL_MATCH_H
 
 #include "string-list.h"
-#include "config.h"
+#include "setup/config.h"
 
 struct url_info {
 	/* normalized url on success, must be freed, otherwise NULL */
diff --git a/versioncmp.c b/versioncmp.c
index 3a81b17bc1..cdf130cc28 100644
--- a/versioncmp.c
+++ b/versioncmp.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "config.h"
+#include "setup/config.h"
 #include "strbuf.h"
 #include "string-list.h"
 #include "versioncmp.h"
diff --git a/walker.c b/walker.c
index 83f980c1f3..079dcd378c 100644
--- a/walker.c
+++ b/walker.c
@@ -4,7 +4,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "walker.h"
-#include "repository.h"
+#include "setup/repository.h"
 #include "odb/odb.h"
 #include "odb/commit.h"
 #include "strbuf.h"
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [RFC PATCH 14/14] transport: gather the transport sources under transport/
  2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
                   ` (12 preceding siblings ...)
  2026-08-23 17:18 ` [RFC PATCH 13/14] setup: gather the setup sources under setup/ Michael Montalbo
@ 2026-08-23 17:18 ` Michael Montalbo
  13 siblings, 0 replies; 18+ messages in thread
From: Michael Montalbo @ 2026-08-23 17:18 UTC (permalink / raw)
  To: git; +Cc: Patrick Steinhardt

Move the 22 transport C sources and 21 headers into transport/ as
renames. Repoint every reference to their old paths to the new ones: the
#include lines across the tree, the Makefile and meson.build build
entries, the contrib CMake sources.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
---
 .gitorganize                                  | 86 +++++++++----------
 Makefile                                      | 54 ++++++------
 branch.c                                      |  2 +-
 builtin/archive.c                             |  4 +-
 builtin/backfill.c                            |  2 +-
 builtin/branch.c                              |  2 +-
 builtin/bundle.c                              |  4 +-
 builtin/cat-file.c                            |  6 +-
 builtin/checkout--worker.c                    |  2 +-
 builtin/checkout.c                            |  2 +-
 builtin/clone.c                               | 12 +--
 builtin/fast-export.c                         |  2 +-
 builtin/fetch-pack.c                          | 10 +--
 builtin/fetch.c                               | 12 +--
 builtin/gc.c                                  |  2 +-
 builtin/grep.c                                |  2 +-
 builtin/index-pack.c                          |  2 +-
 builtin/log.c                                 |  4 +-
 builtin/ls-remote.c                           |  6 +-
 builtin/merge.c                               |  2 +-
 builtin/pack-objects.c                        |  4 +-
 builtin/pull.c                                |  2 +-
 builtin/push.c                                |  8 +-
 builtin/receive-pack.c                        | 12 +--
 builtin/remote-ext.c                          |  4 +-
 builtin/remote-fd.c                           |  2 +-
 builtin/remote.c                              |  4 +-
 builtin/repack.c                              |  2 +-
 builtin/send-pack.c                           | 12 +--
 builtin/submodule--helper.c                   |  2 +-
 builtin/upload-archive.c                      |  4 +-
 builtin/upload-pack.c                         |  8 +-
 builtin/worktree.c                            |  2 +-
 compat/simple-ipc/ipc-win32.c                 |  2 +-
 contrib/buildsystems/CMakeLists.txt           |  6 +-
 convert.c                                     |  2 +-
 daemon.c                                      |  4 +-
 diff/diff.c                                   |  2 +-
 diff/diffcore-break.c                         |  2 +-
 diff/diffcore-rename.c                        |  2 +-
 help.c                                        |  2 +-
 http-backend.c                                |  4 +-
 http-fetch.c                                  |  4 +-
 http-push.c                                   |  4 +-
 imap-send.c                                   |  2 +-
 index/cache-tree.c                            |  2 +-
 index/checkout.c                              |  2 +-
 index/parallel-checkout.c                     |  2 +-
 index/read-cache.c                            |  2 +-
 index/unpack-trees.c                          |  2 +-
 index/wt-status.c                             |  2 +-
 index/wt-status.h                             |  2 +-
 merge-ort.c                                   |  2 +-
 meson.build                                   | 46 +++++-----
 negotiator/default.c                          |  2 +-
 negotiator/noop.c                             |  2 +-
 negotiator/skipping.c                         |  2 +-
 odb/object-name.c                             |  2 +-
 odb/odb.c                                     |  2 +-
 odb/source-files.c                            |  2 +-
 pack/pack-write.c                             |  2 +-
 pack/packfile.c                               |  2 +-
 refs/ls-refs.c                                |  2 +-
 refs/ref-filter.c                             |  2 +-
 refs/refspec.c                                |  2 +-
 revision/list-objects-filter-options.c        |  2 +-
 revision/shallow.c                            |  2 +-
 setup/repository.c                            |  4 +-
 simple-ipc.h                                  |  2 +-
 sub-process.c                                 |  2 +-
 submodule.c                                   |  2 +-
 t/helper/test-bundle-uri.c                    |  6 +-
 t/helper/test-pkt-line.c                      |  4 +-
 t/helper/test-proc-receive.c                  |  4 +-
 t/helper/test-rot13-filter.c                  |  2 +-
 t/helper/test-serve-v2.c                      |  2 +-
 t/helper/test-submodule.c                     |  2 +-
 bundle-uri.c => transport/bundle-uri.c        | 10 +--
 bundle-uri.h => transport/bundle-uri.h        |  0
 bundle.c => transport/bundle.c                |  4 +-
 bundle.h => transport/bundle.h                |  0
 connect.c => transport/connect.c              | 14 +--
 connect.h => transport/connect.h              |  2 +-
 connected.c => transport/connected.c          |  6 +-
 connected.h => transport/connected.h          |  0
 .../fetch-negotiator.c                        |  2 +-
 .../fetch-negotiator.h                        |  0
 .../fetch-object-info.c                       |  6 +-
 .../fetch-object-info.h                       |  4 +-
 fetch-pack.c => transport/fetch-pack.c        | 16 ++--
 fetch-pack.h => transport/fetch-pack.h        |  2 +-
 .../git-curl-compat.h                         |  0
 http-walker.c => transport/http-walker.c      |  6 +-
 http.c => transport/http.c                    |  8 +-
 http.h => transport/http.h                    |  2 +-
 pkt-line.c => transport/pkt-line.c            |  4 +-
 pkt-line.h => transport/pkt-line.h            |  0
 .../promisor-remote.c                         |  4 +-
 .../promisor-remote.h                         |  0
 protocol-caps.c => transport/protocol-caps.c  |  4 +-
 protocol-caps.h => transport/protocol-caps.h  |  0
 protocol.c => transport/protocol.c            |  2 +-
 protocol.h => transport/protocol.h            |  0
 remote-curl.c => transport/remote-curl.c      | 18 ++--
 remote.c => transport/remote.c                |  6 +-
 remote.h => transport/remote.h                |  0
 send-pack.c => transport/send-pack.c          | 12 +--
 send-pack.h => transport/send-pack.h          |  0
 serve.c => transport/serve.c                  | 12 +--
 serve.h => transport/serve.h                  |  0
 sideband.c => transport/sideband.c            |  4 +-
 sideband.h => transport/sideband.h            |  0
 .../transport-helper.c                        |  8 +-
 .../transport-internal.h                      |  2 +-
 transport.c => transport/transport.c          | 24 +++---
 transport.h => transport/transport.h          |  4 +-
 upload-pack.c => transport/upload-pack.c      | 12 +--
 upload-pack.h => transport/upload-pack.h      |  0
 walker.c => transport/walker.c                |  2 +-
 walker.h => transport/walker.h                |  2 +-
 120 files changed, 320 insertions(+), 320 deletions(-)
 rename bundle-uri.c => transport/bundle-uri.c (99%)
 rename bundle-uri.h => transport/bundle-uri.h (100%)
 rename bundle.c => transport/bundle.c (99%)
 rename bundle.h => transport/bundle.h (100%)
 rename connect.c => transport/connect.c (99%)
 rename connect.h => transport/connect.h (98%)
 rename connected.c => transport/connected.c (98%)
 rename connected.h => transport/connected.h (100%)
 rename fetch-negotiator.c => transport/fetch-negotiator.c (94%)
 rename fetch-negotiator.h => transport/fetch-negotiator.h (100%)
 rename fetch-object-info.c => transport/fetch-object-info.c (97%)
 rename fetch-object-info.h => transport/fetch-object-info.h (91%)
 rename fetch-pack.c => transport/fetch-pack.c (99%)
 rename fetch-pack.h => transport/fetch-pack.h (99%)
 rename git-curl-compat.h => transport/git-curl-compat.h (100%)
 rename http-walker.c => transport/http-walker.c (99%)
 rename http.c => transport/http.c (99%)
 rename http.h => transport/http.h (99%)
 rename pkt-line.c => transport/pkt-line.c (99%)
 rename pkt-line.h => transport/pkt-line.h (100%)
 rename promisor-remote.c => transport/promisor-remote.c (99%)
 rename promisor-remote.h => transport/promisor-remote.h (100%)
 rename protocol-caps.c => transport/protocol-caps.c (98%)
 rename protocol-caps.h => transport/protocol-caps.h (100%)
 rename protocol.c => transport/protocol.c (98%)
 rename protocol.h => transport/protocol.h (100%)
 rename remote-curl.c => transport/remote-curl.c (99%)
 rename remote.c => transport/remote.c (99%)
 rename remote.h => transport/remote.h (100%)
 rename send-pack.c => transport/send-pack.c (99%)
 rename send-pack.h => transport/send-pack.h (100%)
 rename serve.c => transport/serve.c (97%)
 rename serve.h => transport/serve.h (100%)
 rename sideband.c => transport/sideband.c (99%)
 rename sideband.h => transport/sideband.h (100%)
 rename transport-helper.c => transport/transport-helper.c (99%)
 rename transport-internal.h => transport/transport-internal.h (98%)
 rename transport.c => transport/transport.c (99%)
 rename transport.h => transport/transport.h (99%)
 rename upload-pack.c => transport/upload-pack.c (99%)
 rename upload-pack.h => transport/upload-pack.h (100%)
 rename walker.c => transport/walker.c (99%)
 rename walker.h => transport/walker.h (97%)

diff --git a/.gitorganize b/.gitorganize
index cb6416bfc3..f2f686feac 100644
--- a/.gitorganize
+++ b/.gitorganize
@@ -42,10 +42,6 @@ base85.h component=? role=public prefix=base85 cochange=diff:1
 branch.c component=? role=lib prefix=branch includes=refs:3,setup:3,odb:2,submodule:1,transport:1 cochange=refs:62,transport:41,setup:28,index:19,revision:12
 branch.h component=? role=public prefix=branch cochange=setup:8,refs:4,submodule:4
 builtin.h component=? role=public prefix=builtin includes=setup:1 cochange=diff:15,index:15,transport:12,odb:6,notes:5
-bundle-uri.c component=transport role=lib prefix=bundle-uri includes=transport:5,odb:1,refs:1,setup:1 cochange=transport:28,setup:7,odb:4,merge:2,pack:2
-bundle-uri.h component=transport role=header prefix=bundle-uri cochange=transport:14
-bundle.c component=transport role=lib prefix=bundle includes=odb:3,revision:3,setup:2,transport:2,diff:1 cochange=transport:63,odb:24,revision:21,refs:17,pack:10
-bundle.h component=transport role=header prefix=bundle includes=revision:1 cochange=transport:37,revision:5
 chdir-notify.c component=? role=lib prefix=chdir-notify includes=revision:1 cochange=index:2,archive:1,merge:1,revision:1
 chdir-notify.h component=? role=public prefix=chdir-notify
 color.c component=? role=lib prefix=color includes=setup:1 cochange=diff:21,index:14,revision:13,setup:7,transport:7
@@ -56,10 +52,6 @@ common-exit.c component=? role=lib prefix=common-main
 common-init.c component=? role=lib prefix=common-main includes=odb:2,setup:2,convert:1 cochange=setup:1
 common-init.h component=? role=public prefix=common-main
 common-main.c component=? role=lib prefix=common-main cochange=setup:5,transport:4,convert:3,index:1
-connect.c component=transport role=lib prefix=connect includes=transport:7,setup:4,odb:1,refs:1 cochange=transport:238,setup:19,diff:13,index:10,refs:10
-connect.h component=transport role=header prefix=connect includes=transport:1 cochange=transport:58,refs:1
-connected.c component=transport role=lib prefix=connected includes=transport:3,odb:1,pack:1 cochange=transport:39,pack:31,odb:7,diff:6,index:5
-connected.h component=transport role=header prefix=connected cochange=transport:23
 convert.c component=convert role=lib prefix=convert includes=convert:2,index:1,merge:1,odb:1,setup:1 cochange=convert:59,diff:43,index:41,setup:30,transport:30
 convert.h component=convert role=header prefix=convert includes=odb:1 cochange=convert:29,index:18,diff:8,setup:8,archive:4
 copy.c component=? role=lib prefix=copy cochange=pack:6,transport:5,diff:3,odb:3,merge:2
@@ -101,19 +93,12 @@ editor.c component=? role=lib prefix=editor includes=setup:2 cochange=transport:
 editor.h component=? role=public prefix=editor cochange=transport:1
 exec-cmd.c component=? role=lib prefix=strvec includes=setup:1
 exec-cmd.h component=? role=public prefix=argv-array cochange=refs:4,transport:4,odb:1,setup:1,submodule:1
-fetch-negotiator.c component=transport role=lib prefix=repo-settings includes=setup:1,transport:1 cochange=setup:8,transport:7,index:2,odb:1
-fetch-negotiator.h component=transport role=header prefix=fetch-negotiator cochange=transport:7,setup:3,odb:1,pack:1,revision:1
-fetch-object-info.c component=transport role=lib prefix=cat-file includes=transport:3,odb:2 cochange=transport:7,odb:1
-fetch-object-info.h component=transport role=header prefix=cat-file includes=transport:2 cochange=transport:7,odb:1
-fetch-pack.c component=transport role=lib prefix=fetch-pack includes=transport:8,odb:7,setup:4,pack:3,revision:2 cochange=transport:303,odb:96,revision:46,pack:40,setup:25
-fetch-pack.h component=transport role=header prefix=fetch-pack includes=odb:1,revision:1,transport:1 cochange=transport:108,odb:2,pack:2,refs:2,diff:1
 fmt-merge-msg.c component=merge role=lib prefix=fmt-merge-msg includes=odb:3,diff:2,revision:2,setup:2,merge:1 cochange=revision:10,odb:7,index:6,diff:4,setup:4
 fmt-merge-msg.h component=merge role=header prefix=fmt-merge-msg cochange=merge:3,setup:2
 for-each-ref.h component=? role=public prefix=?
 gettext.c component=? role=lib prefix=gettext includes=setup:1 cochange=pack:5,refs:3,setup:2,transport:2,merge:1
 gettext.h component=? role=public prefix=i18n cochange=transport:2,setup:1
 git-compat-util.h component=? role=public prefix=git-compat-util cochange=setup:48,index:35,odb:22,pack:21,diff:17
-git-curl-compat.h component=transport role=header prefix=git-curl-compat cochange=transport:22
 git-zlib.c component=? role=lib prefix=git-zlib cochange=archive:2,odb:1,transport:1
 git-zlib.h component=? role=public prefix=git-zlib cochange=archive:3,setup:2,odb:1,transport:1
 git.c component=? role=lib prefix=git includes=setup:4,odb:2,convert:1,index:1,revision:1 cochange=setup:70,revision:54,transport:47,index:28,diff:25
@@ -132,9 +117,6 @@ hex.h component=? role=public prefix=hex includes=odb:1 cochange=revision:3,odb:
 http-backend.c component=? role=program prefix=http-backend includes=setup:4,odb:3,transport:2,pack:1,refs:1 cochange=transport:57,pack:41,setup:19,refs:14,revision:13
 http-fetch.c component=? role=program prefix=http-fetch includes=setup:3,transport:2 cochange=transport:46,setup:10,pack:9,index:7,refs:7
 http-push.c component=? role=program prefix=http-push includes=odb:7,revision:3,setup:3,transport:2,diff:1 cochange=transport:272,odb:134,revision:82,pack:60,diff:34
-http-walker.c component=transport role=lib prefix=http includes=transport:3,odb:2,pack:1,revision:1,setup:1 cochange=transport:73,pack:40,odb:17,index:11,refs:7
-http.c component=transport role=lib prefix=http includes=transport:4,setup:3,odb:2,pack:2 cochange=transport:195,pack:71,odb:27,diff:8,setup:8
-http.h component=transport role=header prefix=http includes=transport:1 cochange=transport:149,pack:15,diff:6,odb:4,archive:3
 imap-send.c component=? role=program prefix=imap-send includes=setup:3,transport:1 cochange=transport:47,diff:16,index:16,refs:9,odb:8
 index/cache-tree.c component=index role=lib prefix=cache-tree includes=odb:5,index:2,setup:1,transport:1 cochange=index:94,odb:69,revision:27,transport:21,diff:20
 index/cache-tree.h component=index role=header prefix=cache-tree includes=odb:2 cochange=index:42,diff:4,revision:4,odb:3,refs:1
@@ -322,20 +304,12 @@ path-walk.c component=? role=lib prefix=path-walk includes=odb:9,revision:3,inde
 path-walk.h component=? role=public prefix=path-walk includes=odb:1 cochange=index:2
 path.c component=? role=lib prefix=path includes=setup:2,index:1,odb:1,pack:1,refs:1 cochange=setup:78,refs:29,index:26,transport:15,odb:12
 path.h component=? role=public prefix=path includes=setup:1 cochange=setup:23,refs:13,odb:11,index:10,pack:8
-pkt-line.c component=transport role=lib prefix=pkt-line includes=transport:2 cochange=transport:102,pack:6,convert:5,diff:5,odb:3
-pkt-line.h component=transport role=header prefix=pkt-line cochange=transport:94,pack:5,convert:4,odb:2,diff:1
 prio-queue.c component=? role=lib prefix=prio-queue cochange=odb:5,revision:5,diff:2,pack:2,transport:2
 prio-queue.h component=? role=public prefix=prio-queue cochange=odb:3,revision:2,transport:2,pack:1
 progress.c component=? role=lib prefix=progress includes=setup:1 cochange=index:11,diff:6,setup:6,pack:4,revision:2
 progress.h component=? role=public prefix=progress cochange=index:5,diff:3
-promisor-remote.c component=transport role=lib prefix=promisor-remote includes=setup:3,transport:2,odb:1,pack:1 cochange=transport:32,setup:15,odb:6,pack:5,index:4
-promisor-remote.h component=transport role=header prefix=promisor-remote includes=setup:1 cochange=transport:18,setup:7,diff:4,index:3,revision:3
 prompt.c component=? role=lib prefix=prompt includes=setup:2 cochange=index:7,setup:6,pack:4,diff:3,transport:2
 prompt.h component=? role=public prefix=prompt cochange=transport:1
-protocol-caps.c component=transport role=lib prefix=protocol-caps includes=odb:3,transport:2,setup:1 cochange=transport:6,odb:3,refs:2,merge:1,setup:1
-protocol-caps.h component=transport role=header prefix=protocol-caps cochange=transport:6,refs:2
-protocol.c component=transport role=lib prefix=protocol includes=setup:2,transport:1 cochange=transport:21,index:4,setup:4,refs:2,diff:1
-protocol.h component=transport role=header prefix=protocol cochange=transport:5
 quote.c component=? role=lib prefix=quote cochange=index:15,diff:12,transport:7,odb:6,revision:6
 quote.h component=? role=public prefix=quote cochange=diff:8,transport:6,index:5,odb:5,refs:5
 rebase-interactive.c component=? role=lib prefix=rebase-interactive includes=odb:3,setup:3,index:1 cochange=revision:4,transport:4,index:3,odb:3,merge:2
@@ -358,9 +332,6 @@ refs/refspec.c component=refs role=lib prefix=refspec includes=refs:2,odb:1,tran
 refs/refspec.h component=refs role=header prefix=refspec cochange=transport:31,refs:29,submodule:3,index:2
 refs/worktree.c component=refs role=lib prefix=worktree includes=setup:4,index:2,refs:2 cochange=refs:73,setup:53,index:22,submodule:13,pack:11
 refs/worktree.h component=refs role=header prefix=worktree includes=refs:1 cochange=refs:61,revision:10,pack:5,setup:5,odb:4
-remote-curl.c component=transport role=lib prefix=remote-curl includes=transport:9,setup:3,odb:1 cochange=transport:226,diff:9,revision:6,setup:5,archive:4
-remote.c component=transport role=lib prefix=remote includes=odb:3,setup:3,transport:3,refs:2,revision:2 cochange=transport:272,refs:91,revision:56,index:51,odb:30
-remote.h component=transport role=header prefix=remote includes=odb:1,refs:1 cochange=transport:245,refs:24,index:12,revision:6,setup:2
 replay.c component=? role=lib prefix=replay includes=odb:2,merge:1,refs:1,revision:1,setup:1 cochange=transport:1
 replay.h component=? role=public prefix=replay includes=odb:1
 rerere.c component=merge role=lib prefix=rerere includes=index:4,merge:2,odb:2,setup:2,diff:1 cochange=index:54,merge:29,pack:26,odb:25,transport:25
@@ -400,12 +371,8 @@ run-command.c component=? role=lib prefix=run-command includes=setup:2,index:1,p
 run-command.h component=? role=public prefix=run-command cochange=transport:21,setup:8,odb:6,submodule:5,refs:4
 sane-ctype.h component=? role=public prefix=sane-ctype
 scalar.c component=? role=lib prefix=scalar includes=index:3,setup:2,pack:1,refs:1 cochange=setup:9,transport:7,pack:4,index:3,merge:3
-send-pack.c component=transport role=lib prefix=send-pack includes=transport:6,odb:3,setup:2,revision:1 cochange=transport:177,odb:29,revision:17,refs:15,pack:8
-send-pack.h component=transport role=header prefix=send-pack cochange=transport:39
 sequencer.c component=? role=lib prefix=sequencer includes=odb:8,index:5,merge:4,setup:4,revision:3 cochange=revision:84,odb:83,index:77,refs:60,transport:55
 sequencer.h component=? role=public prefix=sequencer includes=index:1 cochange=revision:5,index:4,notes:3,odb:3,transport:3
-serve.c component=transport role=lib prefix=serve includes=transport:6,setup:3,odb:1,refs:1 cochange=transport:53,refs:7,odb:4,setup:3,index:1
-serve.h component=transport role=header prefix=serve cochange=transport:9,refs:3,submodule:1
 setup/alias.c component=setup role=lib prefix=alias includes=setup:2 cochange=setup:8,diff:4,transport:3,convert:2,index:2
 setup/alias.h component=setup role=header prefix=completion cochange=setup:3,transport:2,pack:1,revision:1
 setup/config.c component=setup role=lib prefix=config includes=setup:4,odb:2,convert:1,index:1,refs:1 cochange=setup:274,index:93,diff:75,refs:48,revision:46
@@ -429,8 +396,6 @@ sha1dc_git.c component=? role=lib prefix=sha1dc cochange=diff:3,odb:2,revision:2
 sha1dc_git.h component=? role=public prefix=sha1dc cochange=odb:2
 shell.c component=? role=program prefix=shell includes=setup:1 cochange=transport:10,setup:4,revision:2
 shortlog.h component=? role=public prefix=shortlog cochange=revision:2
-sideband.c component=transport role=lib prefix=sideband includes=transport:2,setup:1 cochange=transport:51,revision:6,diff:5,index:5,refs:4
-sideband.h component=transport role=header prefix=sideband cochange=transport:23
 sigchain.c component=? role=lib prefix=sigchain cochange=diff:2,transport:1
 sigchain.h component=? role=public prefix=sigchain cochange=diff:2
 simple-ipc.h component=? role=public prefix=simple-ipc includes=transport:1 cochange=submodule:1
@@ -460,17 +425,54 @@ trace2.c component=? role=lib prefix=trace2 includes=setup:2 cochange=setup:2
 trace2.h component=? role=public prefix=trace2 cochange=setup:2
 trailer.c component=? role=lib prefix=trailer includes=setup:2,odb:1,revision:1 cochange=transport:13,revision:12,odb:8,index:7,refs:6
 trailer.h component=? role=public prefix=trailer includes=revision:1 cochange=revision:7,refs:1
-transport-helper.c component=transport role=lib prefix=transport-helper includes=transport:4,odb:2,refs:2,setup:2,pack:1 cochange=transport:210,refs:23,revision:16,odb:14,index:12
-transport-internal.h component=transport role=header prefix=transport includes=transport:1 cochange=transport:42,refs:3,odb:1,submodule:1
-transport.c component=transport role=lib prefix=transport includes=transport:12,setup:3,odb:2,refs:2,submodule:1 cochange=transport:482,refs:35,setup:31,submodule:29,revision:21
-transport.h component=transport role=header prefix=transport includes=transport:2,revision:1 cochange=transport:249,submodule:6,odb:4,revision:2,diff:1
+transport/bundle-uri.c component=transport role=lib prefix=bundle-uri includes=transport:5,odb:1,refs:1,setup:1 cochange=transport:28,setup:7,odb:4,merge:2,pack:2
+transport/bundle-uri.h component=transport role=header prefix=bundle-uri cochange=transport:14
+transport/bundle.c component=transport role=lib prefix=bundle includes=odb:3,revision:3,setup:2,transport:2,diff:1 cochange=transport:63,odb:24,revision:21,refs:17,pack:10
+transport/bundle.h component=transport role=header prefix=bundle includes=revision:1 cochange=transport:37,revision:5
+transport/connect.c component=transport role=lib prefix=connect includes=transport:7,setup:4,odb:1,refs:1 cochange=transport:238,setup:19,diff:13,index:10,refs:10
+transport/connect.h component=transport role=header prefix=connect includes=transport:1 cochange=transport:58,refs:1
+transport/connected.c component=transport role=lib prefix=connected includes=transport:3,odb:1,pack:1 cochange=transport:39,pack:31,odb:7,diff:6,index:5
+transport/connected.h component=transport role=header prefix=connected cochange=transport:23
+transport/fetch-negotiator.c component=transport role=lib prefix=repo-settings includes=setup:1,transport:1 cochange=setup:8,transport:7,index:2,odb:1
+transport/fetch-negotiator.h component=transport role=header prefix=fetch-negotiator cochange=transport:7,setup:3,odb:1,pack:1,revision:1
+transport/fetch-object-info.c component=transport role=lib prefix=cat-file includes=transport:3,odb:2 cochange=transport:7,odb:1
+transport/fetch-object-info.h component=transport role=header prefix=cat-file includes=transport:2 cochange=transport:7,odb:1
+transport/fetch-pack.c component=transport role=lib prefix=fetch-pack includes=transport:8,odb:7,setup:4,pack:3,revision:2 cochange=transport:303,odb:96,revision:46,pack:40,setup:25
+transport/fetch-pack.h component=transport role=header prefix=fetch-pack includes=odb:1,revision:1,transport:1 cochange=transport:108,odb:2,pack:2,refs:2,diff:1
+transport/git-curl-compat.h component=transport role=header prefix=git-curl-compat cochange=transport:22
+transport/http-walker.c component=transport role=lib prefix=http includes=transport:3,odb:2,pack:1,revision:1,setup:1 cochange=transport:73,pack:40,odb:17,index:11,refs:7
+transport/http.c component=transport role=lib prefix=http includes=transport:4,setup:3,odb:2,pack:2 cochange=transport:195,pack:71,odb:27,diff:8,setup:8
+transport/http.h component=transport role=header prefix=http includes=transport:1 cochange=transport:149,pack:15,diff:6,odb:4,archive:3
+transport/pkt-line.c component=transport role=lib prefix=pkt-line includes=transport:2 cochange=transport:102,pack:6,convert:5,diff:5,odb:3
+transport/pkt-line.h component=transport role=header prefix=pkt-line cochange=transport:94,pack:5,convert:4,odb:2,diff:1
+transport/promisor-remote.c component=transport role=lib prefix=promisor-remote includes=setup:3,transport:2,odb:1,pack:1 cochange=transport:32,setup:15,odb:6,pack:5,index:4
+transport/promisor-remote.h component=transport role=header prefix=promisor-remote includes=setup:1 cochange=transport:18,setup:7,diff:4,index:3,revision:3
+transport/protocol-caps.c component=transport role=lib prefix=protocol-caps includes=odb:3,transport:2,setup:1 cochange=transport:6,odb:3,refs:2,merge:1,setup:1
+transport/protocol-caps.h component=transport role=header prefix=protocol-caps cochange=transport:6,refs:2
+transport/protocol.c component=transport role=lib prefix=protocol includes=setup:2,transport:1 cochange=transport:21,index:4,setup:4,refs:2,diff:1
+transport/protocol.h component=transport role=header prefix=protocol cochange=transport:5
+transport/remote-curl.c component=transport role=lib prefix=remote-curl includes=transport:9,setup:3,odb:1 cochange=transport:226,diff:9,revision:6,setup:5,archive:4
+transport/remote.c component=transport role=lib prefix=remote includes=odb:3,setup:3,transport:3,refs:2,revision:2 cochange=transport:272,refs:91,revision:56,index:51,odb:30
+transport/remote.h component=transport role=header prefix=remote includes=odb:1,refs:1 cochange=transport:245,refs:24,index:12,revision:6,setup:2
+transport/send-pack.c component=transport role=lib prefix=send-pack includes=transport:6,odb:3,setup:2,revision:1 cochange=transport:177,odb:29,revision:17,refs:15,pack:8
+transport/send-pack.h component=transport role=header prefix=send-pack cochange=transport:39
+transport/serve.c component=transport role=lib prefix=serve includes=transport:6,setup:3,odb:1,refs:1 cochange=transport:53,refs:7,odb:4,setup:3,index:1
+transport/serve.h component=transport role=header prefix=serve cochange=transport:9,refs:3,submodule:1
+transport/sideband.c component=transport role=lib prefix=sideband includes=transport:2,setup:1 cochange=transport:51,revision:6,diff:5,index:5,refs:4
+transport/sideband.h component=transport role=header prefix=sideband cochange=transport:23
+transport/transport-helper.c component=transport role=lib prefix=transport-helper includes=transport:4,odb:2,refs:2,setup:2,pack:1 cochange=transport:210,refs:23,revision:16,odb:14,index:12
+transport/transport-internal.h component=transport role=header prefix=transport includes=transport:1 cochange=transport:42,refs:3,odb:1,submodule:1
+transport/transport.c component=transport role=lib prefix=transport includes=transport:12,setup:3,odb:2,refs:2,submodule:1 cochange=transport:482,refs:35,setup:31,submodule:29,revision:21
+transport/transport.h component=transport role=header prefix=transport includes=transport:2,revision:1 cochange=transport:249,submodule:6,odb:4,revision:2,diff:1
+transport/upload-pack.c component=transport role=lib prefix=upload-pack includes=transport:6,odb:4,revision:4,setup:4,diff:1 cochange=transport:198,odb:88,revision:80,refs:55,pack:34
+transport/upload-pack.h component=transport role=header prefix=upload-pack cochange=transport:18,refs:5,submodule:1
+transport/walker.c component=transport role=lib prefix=refs includes=odb:6,refs:1,setup:1,transport:1 cochange=odb:70,transport:55,revision:42,refs:24,pack:17
+transport/walker.h component=transport role=header prefix=walker includes=transport:1 cochange=transport:19
 unicode-width.h component=? role=public prefix=unicode
 unix-socket.c component=? role=lib prefix=unix-socket cochange=diff:3,revision:2,setup:1
 unix-socket.h component=? role=public prefix=unix-socket
 unix-stream-server.c component=? role=lib prefix=unix-stream-server
 unix-stream-server.h component=? role=public prefix=unix-stream-server
-upload-pack.c component=transport role=lib prefix=upload-pack includes=transport:6,odb:4,revision:4,setup:4,diff:1 cochange=transport:198,odb:88,revision:80,refs:55,pack:34
-upload-pack.h component=transport role=header prefix=upload-pack cochange=transport:18,refs:5,submodule:1
 url.c component=? role=lib prefix=url cochange=transport:12,revision:8,diff:6,index:2,refs:2
 url.h component=? role=public prefix=url cochange=transport:9,revision:4,submodule:1
 urlmatch.c component=? role=lib prefix=urlmatch cochange=diff:3,odb:2,revision:2,setup:2,transport:2
@@ -482,8 +484,6 @@ varint.c component=? role=lib prefix=varint cochange=index:2,transport:1
 varint.h component=? role=public prefix=varint cochange=index:2,transport:1
 versioncmp.c component=? role=lib prefix=versioncmp includes=setup:1 cochange=setup:5,pack:3,transport:3,index:2,refs:2
 versioncmp.h component=? role=public prefix=versioncmp cochange=refs:1
-walker.c component=transport role=lib prefix=refs includes=odb:6,refs:1,setup:1,transport:1 cochange=odb:70,transport:55,revision:42,refs:24,pack:17
-walker.h component=transport role=header prefix=walker includes=transport:1 cochange=transport:19
 wildmatch.c component=? role=lib prefix=hex cochange=index:4,refs:3,diff:1,odb:1,revision:1
 wildmatch.h component=? role=public prefix=? cochange=index:3,refs:2,diff:1,revision:1,setup:1
 wrapper.c component=? role=lib prefix=wrapper cochange=setup:21,index:16,pack:6,transport:5,convert:4
diff --git a/Makefile b/Makefile
index cec75e834a..396d9b09cf 100644
--- a/Makefile
+++ b/Makefile
@@ -1115,8 +1115,8 @@ LIB_OBJS += revision/blame.o
 LIB_OBJS += odb/blob.o
 LIB_OBJS += pack/bloom.o
 LIB_OBJS += branch.o
-LIB_OBJS += bundle-uri.o
-LIB_OBJS += bundle.o
+LIB_OBJS += transport/bundle-uri.o
+LIB_OBJS += transport/bundle.o
 LIB_OBJS += index/cache-tree.o
 LIB_OBJS += odb/cbtree.o
 LIB_OBJS += chdir-notify.o
@@ -1136,8 +1136,8 @@ LIB_OBJS += compat/open.o
 LIB_OBJS += compat/terminal.o
 LIB_OBJS += compiler-tricks/not-constant.o
 LIB_OBJS += setup/config.o
-LIB_OBJS += connect.o
-LIB_OBJS += connected.o
+LIB_OBJS += transport/connect.o
+LIB_OBJS += transport/connected.o
 LIB_OBJS += convert.o
 LIB_OBJS += copy.o
 LIB_OBJS += credential.o
@@ -1168,9 +1168,9 @@ LIB_OBJS += ewah/ewah_bitmap.o
 LIB_OBJS += ewah/ewah_io.o
 LIB_OBJS += ewah/ewah_rlw.o
 LIB_OBJS += exec-cmd.o
-LIB_OBJS += fetch-negotiator.o
-LIB_OBJS += fetch-object-info.o
-LIB_OBJS += fetch-pack.o
+LIB_OBJS += transport/fetch-negotiator.o
+LIB_OBJS += transport/fetch-object-info.o
+LIB_OBJS += transport/fetch-pack.o
 LIB_OBJS += fmt-merge-msg.o
 LIB_OBJS += odb/fsck.o
 LIB_OBJS += index/fsmonitor.o
@@ -1261,15 +1261,15 @@ LIB_OBJS += diff/patch-ids.o
 LIB_OBJS += path.o
 LIB_OBJS += path-walk.o
 LIB_OBJS += index/pathspec.o
-LIB_OBJS += pkt-line.o
+LIB_OBJS += transport/pkt-line.o
 LIB_OBJS += index/preload-index.o
 LIB_OBJS += revision/pretty.o
 LIB_OBJS += prio-queue.o
 LIB_OBJS += progress.o
-LIB_OBJS += promisor-remote.o
+LIB_OBJS += transport/promisor-remote.o
 LIB_OBJS += prompt.o
-LIB_OBJS += protocol.o
-LIB_OBJS += protocol-caps.o
+LIB_OBJS += transport/protocol.o
+LIB_OBJS += transport/protocol-caps.o
 LIB_OBJS += pack/prune-packed.o
 LIB_OBJS += pack/pseudo-merge.o
 LIB_OBJS += quote.o
@@ -1303,7 +1303,7 @@ LIB_OBJS += reftable/system.o
 LIB_OBJS += reftable/table.o
 LIB_OBJS += reftable/tree.o
 LIB_OBJS += reftable/writer.o
-LIB_OBJS += remote.o
+LIB_OBJS += transport/remote.o
 LIB_OBJS += pack/repack.o
 LIB_OBJS += pack/repack-cruft.o
 LIB_OBJS += pack/repack-filtered.o
@@ -1319,13 +1319,13 @@ LIB_OBJS += reset.o
 LIB_OBJS += index/resolve-undo.o
 LIB_OBJS += revision/revision.o
 LIB_OBJS += run-command.o
-LIB_OBJS += send-pack.o
+LIB_OBJS += transport/send-pack.o
 LIB_OBJS += sequencer.o
-LIB_OBJS += serve.o
+LIB_OBJS += transport/serve.o
 LIB_OBJS += pack/server-info.o
 LIB_OBJS += setup/setup.o
 LIB_OBJS += revision/shallow.o
-LIB_OBJS += sideband.o
+LIB_OBJS += transport/sideband.o
 LIB_OBJS += sigchain.o
 LIB_OBJS += index/sparse-index.o
 LIB_OBJS += index/split-index.o
@@ -1358,13 +1358,13 @@ LIB_OBJS += trace2/tr2_tgt_perf.o
 LIB_OBJS += trace2/tr2_tls.o
 LIB_OBJS += trace2/tr2_tmr.o
 LIB_OBJS += trailer.o
-LIB_OBJS += transport-helper.o
-LIB_OBJS += transport.o
+LIB_OBJS += transport/transport-helper.o
+LIB_OBJS += transport/transport.o
 LIB_OBJS += diff/tree-diff.o
 LIB_OBJS += odb/tree-walk.o
 LIB_OBJS += odb/tree.o
 LIB_OBJS += index/unpack-trees.o
-LIB_OBJS += upload-pack.o
+LIB_OBJS += transport/upload-pack.o
 LIB_OBJS += url.o
 LIB_OBJS += urlmatch.o
 LIB_OBJS += usage.o
@@ -1375,7 +1375,7 @@ LIB_OBJS += varint.o
 endif
 LIB_OBJS += setup/version.o
 LIB_OBJS += versioncmp.o
-LIB_OBJS += walker.o
+LIB_OBJS += transport/walker.o
 LIB_OBJS += wildmatch.o
 LIB_OBJS += refs/worktree.o
 LIB_OBJS += wrapper.o
@@ -1833,7 +1833,7 @@ else
         endif
         ifdef USE_CURL_FOR_IMAP_SEND
 		BASIC_CFLAGS += -DUSE_CURL_FOR_IMAP_SEND
-		IMAP_SEND_BUILDDEPS = http.o
+		IMAP_SEND_BUILDDEPS = transport/http.o
 		IMAP_SEND_LDFLAGS += $(CURL_LIBCURL)
         endif
         ifndef NO_EXPAT
@@ -2901,7 +2901,7 @@ ifdef INCLUDE_LIBGIT_RS
 endif
 
 ifndef NO_CURL
-	OBJECTS += http.o http-walker.o remote-curl.o
+	OBJECTS += transport/http.o transport/http-walker.o transport/remote-curl.o
 endif
 
 .PHONY: objects
@@ -2989,13 +2989,13 @@ gettext.sp gettext.s gettext.o: GIT-PREFIX
 gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \
 	-DGIT_LOCALE_PATH='"$(localedir_relative_SQ)"'
 
-http-push.sp http.sp http-walker.sp remote-curl.sp imap-send.sp: SP_EXTRA_FLAGS += \
+http-push.sp transport/http.sp transport/http-walker.sp transport/remote-curl.sp imap-send.sp: SP_EXTRA_FLAGS += \
 	-DCURL_DISABLE_TYPECHECK
 
 pack/pack-revindex.sp: SP_EXTRA_FLAGS += -Wno-memcpy-max-count
 
 ifdef NO_EXPAT
-http-walker.sp http-walker.s http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
+transport/http-walker.sp transport/http-walker.s transport/http-walker.o: EXTRA_CPPFLAGS = -DNO_EXPAT
 endif
 
 ifdef NO_REGEX
@@ -3017,10 +3017,10 @@ git-imap-send$X: imap-send.o $(IMAP_SEND_BUILDDEPS) GIT-LDFLAGS $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(IMAP_SEND_LDFLAGS) $(LIBS)
 
-git-http-fetch$X: http.o http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
+git-http-fetch$X: transport/http.o transport/http-walker.o http-fetch.o GIT-LDFLAGS $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(LIBS)
-git-http-push$X: http.o http-push.o GIT-LDFLAGS $(GITLIBS)
+git-http-push$X: transport/http.o http-push.o GIT-LDFLAGS $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 
@@ -3030,7 +3030,7 @@ $(REMOTE_CURL_ALIASES): $(REMOTE_CURL_PRIMARY)
 	ln -s $< $@ 2>/dev/null || \
 	cp $< $@
 
-$(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS)
+$(REMOTE_CURL_PRIMARY): transport/remote-curl.o transport/http.o transport/http-walker.o GIT-LDFLAGS $(GITLIBS)
 	$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
 		$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
 
@@ -3218,7 +3218,7 @@ LOCALIZED_C_CORE += builtin/clone.c
 LOCALIZED_C_CORE += builtin/index-pack.c
 LOCALIZED_C_CORE += builtin/push.c
 LOCALIZED_C_CORE += builtin/reset.c
-LOCALIZED_C_CORE += remote.c
+LOCALIZED_C_CORE += transport/remote.c
 LOCALIZED_C_CORE += index/wt-status.c
 
 LOCALIZED_C_CORE_GEN_PO = $(LOCALIZED_C_CORE:%=.build/pot/po/%.po)
diff --git a/branch.c b/branch.c
index 14483c1402..a8b2d808a0 100644
--- a/branch.c
+++ b/branch.c
@@ -11,7 +11,7 @@
 #include "path.h"
 #include "refs/refs.h"
 #include "refs/refspec.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "setup/repository.h"
 #include "sequencer.h"
 #include "odb/commit.h"
diff --git a/builtin/archive.c b/builtin/archive.c
index 3c1288a123..3355461fce 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -5,9 +5,9 @@
 #include "builtin.h"
 #include "archive.h"
 #include "gettext.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "parse-options.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 
 static void create_output_file(const char *output_file)
 {
diff --git a/builtin/backfill.c b/builtin/backfill.c
index f30addad55..4278a46b8c 100644
--- a/builtin/backfill.c
+++ b/builtin/backfill.c
@@ -16,7 +16,7 @@
 #include "odb/odb.h"
 #include "odb/oid-array.h"
 #include "odb/oidset.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "strmap.h"
 #include "string-list.h"
 #include "revision/revision.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index eeab13a4b6..cbaa726584 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -16,7 +16,7 @@
 #include "odb/commit.h"
 #include "gettext.h"
 #include "odb/object-name.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "parse-options.h"
 #include "branch.h"
 #include "path.h"
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 6dbe478bcb..86a9c9b01a 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -5,8 +5,8 @@
 #include "setup/setup.h"
 #include "strvec.h"
 #include "parse-options.h"
-#include "pkt-line.h"
-#include "bundle.h"
+#include "transport/pkt-line.h"
+#include "transport/bundle.h"
 
 /*
  * Basic handler for bundle files to connect repositories via sneakernet.
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 4a5c73720d..536b40a17c 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -25,12 +25,12 @@
 #include "odb/odb.h"
 #include "odb/streaming.h"
 #include "odb/replace-object.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "mailmap.h"
 #include "write-or-die.h"
 #include "setup/alias.h"
-#include "remote.h"
-#include "transport.h"
+#include "transport/remote.h"
+#include "transport/transport.h"
 
 /*
  * Maximum length for a remote URL. While no universal standard exists,
diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c
index aa1ca1ed14..1347f4d2fc 100644
--- a/builtin/checkout--worker.c
+++ b/builtin/checkout--worker.c
@@ -8,7 +8,7 @@
 #include "gettext.h"
 #include "index/parallel-checkout.h"
 #include "parse-options.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "index/read-cache-ll.h"
 
 static void packet_to_pc_item(const char *buffer, int len,
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 3dedddc61a..53ec5431bf 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -25,7 +25,7 @@
 #include "index/preload-index.h"
 #include "index/read-cache.h"
 #include "refs/refs.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "setup/repo-settings.h"
 #include "index/resolve-undo.h"
 #include "revision/revision.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index a8f7e1b6f3..f800d6cf97 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -29,24 +29,24 @@
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
 #include "index/unpack-trees.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "strbuf.h"
 #include "index/dir.h"
 #include "index/dir-iterator.h"
 #include "iterator.h"
 #include "sigchain.h"
 #include "branch.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "run-command.h"
 #include "setup/setup.h"
-#include "connected.h"
+#include "transport/connected.h"
 #include "pack/packfile.h"
 #include "path.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "revision/list-objects-filter-options.h"
 #include "setup/hook.h"
-#include "bundle.h"
-#include "bundle-uri.h"
+#include "transport/bundle.h"
+#include "transport/bundle-uri.h"
 
 /*
  * Overall FIXMEs:
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 5e5e100884..9080474629 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -28,7 +28,7 @@
 #include "utf8.h"
 #include "parse-options.h"
 #include "quote.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "odb/blob.h"
 #include "gpg-interface.h"
 
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index c6ae0197ab..5f2cfefed4 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -5,12 +5,12 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/object-file.h"
-#include "pkt-line.h"
-#include "fetch-pack.h"
-#include "remote.h"
-#include "connect.h"
+#include "transport/pkt-line.h"
+#include "transport/fetch-pack.h"
+#include "transport/remote.h"
+#include "transport/connect.h"
 #include "odb/oid-array.h"
-#include "protocol.h"
+#include "transport/protocol.h"
 
 static const char fetch_pack_usage[] =
 "git fetch-pack [--all] [--stdin] [--quiet | -q] [--keep | -k] [--thin] "
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 60be51f079..b23990bd51 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -19,28 +19,28 @@
 #include "odb/oid-array.h"
 #include "odb/commit.h"
 #include "string-list.h"
-#include "remote.h"
-#include "transport.h"
+#include "transport/remote.h"
+#include "transport/transport.h"
 #include "run-command.h"
 #include "parse-options.h"
 #include "sigchain.h"
 #include "submodule-config.h"
 #include "submodule.h"
-#include "connected.h"
+#include "transport/connected.h"
 #include "strvec.h"
 #include "utf8.h"
 #include "pager.h"
 #include "path.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "revision/list-objects-filter-options.h"
 #include "revision/commit-reach.h"
 #include "branch.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "pack/commit-graph.h"
 #include "revision/shallow.h"
 #include "trace.h"
 #include "trace2.h"
-#include "bundle-uri.h"
+#include "transport/bundle-uri.h"
 
 #define FORCED_UPDATES_DELAY_WARNING_IN_MS (10 * 1000)
 
diff --git a/builtin/gc.c b/builtin/gc.c
index e4c482c243..886be058bd 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -36,7 +36,7 @@
 #include "rerere.h"
 #include "revision/revision.h"
 #include "refs/refs.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "setup/hook.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index 10df2dacef..7e8df3cdd1 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -32,7 +32,7 @@
 #include "odb/oidset.h"
 #include "pager.h"
 #include "path.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "index/read-cache-ll.h"
 #include "write-or-die.h"
 
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 167a6df9e7..9eb9f1d0b0 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -27,7 +27,7 @@
 #include "path.h"
 #include "odb/replace-object.h"
 #include "odb/tree-walk.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "run-command.h"
 #include "setup/setup.h"
 #include "strvec.h"
diff --git a/builtin/log.c b/builtin/log.c
index 5b79637af3..29199b6684 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -32,7 +32,7 @@
 #include "diff/patch-ids.h"
 #include "path.h"
 #include "shortlog.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "string-list.h"
 #include "parse-options.h"
 #include "revision/line-log.h"
@@ -45,7 +45,7 @@
 #include "utf8.h"
 
 #include "revision/commit-reach.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "diff/range-diff.h"
 #include "odb/tmp-objdir.h"
 #include "odb/tree.h"
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 1b12d6e6ec..7d07c9d399 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -2,10 +2,10 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "hex.h"
-#include "transport.h"
-#include "pkt-line.h"
+#include "transport/transport.h"
+#include "transport/pkt-line.h"
 #include "refs/ref-filter.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "parse-options.h"
 #include "wildmatch.h"
 
diff --git a/builtin/merge.c b/builtin/merge.c
index 090e2a8fb1..6605dc1f91 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -41,7 +41,7 @@
 #include "merge.h"
 #include "merge-ort-wrappers.h"
 #include "index/resolve-undo.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "fmt-merge-msg.h"
 #include "sequencer.h"
 #include "string-list.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index cc97d7e814..2376d21a7a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -40,10 +40,10 @@
 #include "pack/midx.h"
 #include "trace2.h"
 #include "revision/shallow.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "pack/pack-mtimes.h"
 #include "parse-options.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "odb/blob.h"
 #include "odb/tree.h"
 #include "path-walk.h"
diff --git a/builtin/pull.c b/builtin/pull.c
index cca98abb65..9206d7d1c2 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -19,7 +19,7 @@
 #include "parse-options.h"
 #include "run-command.h"
 #include "odb/oid-array.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "index/dir.h"
 #include "path.h"
 #include "index/read-cache-ll.h"
diff --git a/builtin/push.c b/builtin/push.c
index b4556466d7..2480f95e5b 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -14,13 +14,13 @@
 #include "hex.h"
 #include "refs/refspec.h"
 #include "run-command.h"
-#include "remote.h"
-#include "transport.h"
+#include "transport/remote.h"
+#include "transport/transport.h"
 #include "parse-options.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "submodule.h"
 #include "submodule-config.h"
-#include "send-pack.h"
+#include "transport/send-pack.h"
 #include "trace2.h"
 #include "color.h"
 
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 718073653c..731fc89894 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -6,8 +6,8 @@
 #include "odb/commit.h"
 #include "revision/commit-reach.h"
 #include "setup/config.h"
-#include "connect.h"
-#include "connected.h"
+#include "transport/connect.h"
+#include "transport/connected.h"
 #include "setup/environment.h"
 #include "exec-cmd.h"
 #include "odb/fsck.h"
@@ -25,15 +25,15 @@
 #include "pack/pack.h"
 #include "pack/packfile.h"
 #include "parse-options.h"
-#include "pkt-line.h"
-#include "protocol.h"
+#include "transport/pkt-line.h"
+#include "transport/protocol.h"
 #include "refs/refs.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "run-command.h"
 #include "pack/server-info.h"
 #include "setup/setup.h"
 #include "revision/shallow.h"
-#include "sideband.h"
+#include "transport/sideband.h"
 #include "sigchain.h"
 #include "string-list.h"
 #include "strvec.h"
diff --git a/builtin/remote-ext.c b/builtin/remote-ext.c
index bd2037f27d..c5409c69c2 100644
--- a/builtin/remote-ext.c
+++ b/builtin/remote-ext.c
@@ -1,7 +1,7 @@
 #include "builtin.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "run-command.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 
 static const char usage_msg[] =
 	"git remote-ext <remote> <url>";
diff --git a/builtin/remote-fd.c b/builtin/remote-fd.c
index 39908546ba..6bccb2a0c7 100644
--- a/builtin/remote-fd.c
+++ b/builtin/remote-fd.c
@@ -1,5 +1,5 @@
 #include "builtin.h"
-#include "transport.h"
+#include "transport/transport.h"
 
 static const char usage_msg[] =
 	"git remote-fd <remote> <url>";
diff --git a/builtin/remote.c b/builtin/remote.c
index 5a4fa6de8b..fe039f8cfc 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -8,8 +8,8 @@
 #include "setup/ident.h"
 #include "parse-options.h"
 #include "path.h"
-#include "transport.h"
-#include "remote.h"
+#include "transport/transport.h"
+#include "transport/remote.h"
 #include "string-list.h"
 #include "strbuf.h"
 #include "run-command.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index 1d861c6062..b54e47053e 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -11,7 +11,7 @@
 #include "pack/midx.h"
 #include "pack/packfile.h"
 #include "pack/prune-packed.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "pack/repack.h"
 #include "revision/shallow.h"
 
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 1e358bc0b0..203f830385 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -2,16 +2,16 @@
 #include "setup/config.h"
 #include "setup/environment.h"
 #include "hex.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "run-command.h"
-#include "remote.h"
-#include "connect.h"
-#include "send-pack.h"
+#include "transport/remote.h"
+#include "transport/connect.h"
+#include "transport/send-pack.h"
 #include "quote.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "odb/oid-array.h"
 #include "gettext.h"
-#include "protocol.h"
+#include "transport/protocol.h"
 #include "parse-options.h"
 #include "write-or-die.h"
 
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 5a97263743..042687f46d 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -20,7 +20,7 @@
 #include "submodule-config.h"
 #include "string-list.h"
 #include "run-command.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "refs/refs.h"
 #include "refs/refspec.h"
 #include "revision/revision.h"
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index 7b63b0185b..f837d8cc78 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -4,9 +4,9 @@
 #define USE_THE_REPOSITORY_VARIABLE
 #include "builtin.h"
 #include "archive.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "setup/setup.h"
-#include "sideband.h"
+#include "transport/sideband.h"
 #include "run-command.h"
 #include "strvec.h"
 
diff --git a/builtin/upload-pack.c b/builtin/upload-pack.c
index 7131fb6689..9eae3a2d9f 100644
--- a/builtin/upload-pack.c
+++ b/builtin/upload-pack.c
@@ -3,12 +3,12 @@
 #include "builtin.h"
 #include "exec-cmd.h"
 #include "gettext.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "parse-options.h"
-#include "protocol.h"
+#include "transport/protocol.h"
 #include "odb/replace-object.h"
-#include "upload-pack.h"
-#include "serve.h"
+#include "transport/upload-pack.h"
+#include "transport/serve.h"
 #include "setup/setup.h"
 #include "odb/commit.h"
 #include "setup/environment.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 1d808800cc..412289cba7 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -19,7 +19,7 @@
 #include "branch.h"
 #include "index/read-cache-ll.h"
 #include "refs/refs.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "run-command.h"
 #include "setup/hook.h"
 #include "sigchain.h"
diff --git a/compat/simple-ipc/ipc-win32.c b/compat/simple-ipc/ipc-win32.c
index 4a3e7df9c7..cf15ab82c0 100644
--- a/compat/simple-ipc/ipc-win32.c
+++ b/compat/simple-ipc/ipc-win32.c
@@ -3,7 +3,7 @@
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "strbuf.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "thread-utils.h"
 #include "trace.h"
 #include "trace2.h"
diff --git a/contrib/buildsystems/CMakeLists.txt b/contrib/buildsystems/CMakeLists.txt
index 8f56203f34..e0c63639f9 100644
--- a/contrib/buildsystems/CMakeLists.txt
+++ b/contrib/buildsystems/CMakeLists.txt
@@ -771,15 +771,15 @@ add_executable(scalar ${CMAKE_SOURCE_DIR}/scalar.c)
 target_link_libraries(scalar common-main)
 
 if(CURL_FOUND)
-	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
+	add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/transport/http.c)
 
 	add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
 	target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
 
-	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
+	add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/transport/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
 	target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
 
-	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
+	add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/transport/http-walker.c ${CMAKE_SOURCE_DIR}/transport/remote-curl.c)
 	target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
 
 	if(EXPAT_FOUND)
diff --git a/convert.c b/convert.c
index 5490c4a558..15fc4fc0d8 100644
--- a/convert.c
+++ b/convert.c
@@ -14,7 +14,7 @@
 #include "quote.h"
 #include "index/read-cache-ll.h"
 #include "sigchain.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "sub-process.h"
 #include "trace.h"
 #include "utf8.h"
diff --git a/daemon.c b/daemon.c
index 219eeab179..5f9ed302ab 100644
--- a/daemon.c
+++ b/daemon.c
@@ -6,8 +6,8 @@
 #include "setup/environment.h"
 #include "gettext.h"
 #include "path.h"
-#include "pkt-line.h"
-#include "protocol.h"
+#include "transport/pkt-line.h"
+#include "transport/protocol.h"
 #include "run-command.h"
 #include "setup/setup.h"
 #include "strbuf.h"
diff --git a/diff/diff.c b/diff/diff.c
index 4603493a36..86c0fddf24 100644
--- a/diff/diff.c
+++ b/diff/diff.c
@@ -38,7 +38,7 @@
 #include "pager.h"
 #include "parse-options.h"
 #include "help.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "index/dir.h"
 #include "odb/object-file.h"
 #include "odb/object-name.h"
diff --git a/diff/diffcore-break.c b/diff/diffcore-break.c
index c822a0d56d..d4689ad0d3 100644
--- a/diff/diffcore-break.c
+++ b/diff/diffcore-break.c
@@ -8,7 +8,7 @@
 #include "diff/diffcore.h"
 #include "odb/hash.h"
 #include "odb/object.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 
 static int should_break(struct repository *r,
 			struct diff_filespec *src,
diff --git a/diff/diffcore-rename.c b/diff/diffcore-rename.c
index 16746444d8..25e40cd39d 100644
--- a/diff/diffcore-rename.c
+++ b/diff/diffcore-rename.c
@@ -13,7 +13,7 @@
 #include "mem-pool.h"
 #include "odb/oid-array.h"
 #include "progress.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "string-list.h"
 #include "strmap.h"
 #include "trace2.h"
diff --git a/help.c b/help.c
index 34ab22ade5..f3440c7695 100644
--- a/help.c
+++ b/help.c
@@ -24,7 +24,7 @@
 #include "utf8.h"
 
 #ifndef NO_CURL
-#include "git-curl-compat.h" /* For LIBCURL_VERSION only */
+#include "transport/git-curl-compat.h" /* For LIBCURL_VERSION only */
 #endif
 
 struct category_description {
diff --git a/http-backend.c b/http-backend.c
index dcf8506c1e..b10f7e02f2 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -9,7 +9,7 @@
 #include "path.h"
 #include "setup/repository.h"
 #include "refs/refs.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "odb/object.h"
 #include "odb/tag.h"
 #include "exec-cmd.h"
@@ -20,7 +20,7 @@
 #include "strvec.h"
 #include "pack/packfile.h"
 #include "odb/odb.h"
-#include "protocol.h"
+#include "transport/protocol.h"
 #include "date.h"
 #include "write-or-die.h"
 
diff --git a/http-fetch.c b/http-fetch.c
index ad2447ce72..e3846d0b41 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -5,8 +5,8 @@
 #include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "http.h"
-#include "walker.h"
+#include "transport/http.h"
+#include "transport/walker.h"
 #include "setup/setup.h"
 #include "strvec.h"
 #include "url.h"
diff --git a/http-push.c b/http-push.c
index fb18e8756f..3014dad9be 100644
--- a/http-push.c
+++ b/http-push.c
@@ -7,10 +7,10 @@
 #include "odb/commit.h"
 #include "odb/tag.h"
 #include "odb/blob.h"
-#include "http.h"
+#include "transport/http.h"
 #include "diff/diff.h"
 #include "revision/revision.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "revision/list-objects.h"
 #include "setup/setup.h"
 #include "sigchain.h"
diff --git a/imap-send.c b/imap-send.c
index de244d8011..6a16304783 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -35,7 +35,7 @@
 #include "setup/setup.h"
 #include "strbuf.h"
 #ifdef USE_CURL_FOR_IMAP_SEND
-#include "http.h"
+#include "transport/http.h"
 #endif
 
 #if defined(USE_CURL_FOR_IMAP_SEND)
diff --git a/index/cache-tree.c b/index/cache-tree.c
index bb813bd840..283c1cbc3d 100644
--- a/index/cache-tree.c
+++ b/index/cache-tree.c
@@ -14,7 +14,7 @@
 #include "index/read-cache-ll.h"
 #include "odb/replace-object.h"
 #include "setup/repository.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "trace.h"
 #include "trace2.h"
 
diff --git a/index/checkout.c b/index/checkout.c
index b262ada8c7..09c1cd14a6 100644
--- a/index/checkout.c
+++ b/index/checkout.c
@@ -2,7 +2,7 @@
 
 #include "git-compat-util.h"
 #include "odb/object-name.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "refs/refspec.h"
 #include "setup/repository.h"
 #include "index/checkout.h"
diff --git a/index/parallel-checkout.c b/index/parallel-checkout.c
index 0905a7ff1e..a525abbcd7 100644
--- a/index/parallel-checkout.c
+++ b/index/parallel-checkout.c
@@ -8,7 +8,7 @@
 #include "odb/hash.h"
 #include "hex.h"
 #include "index/parallel-checkout.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "progress.h"
 #include "index/read-cache-ll.h"
 #include "run-command.h"
diff --git a/index/read-cache.c b/index/read-cache.c
index 20a5e191a4..60d496535a 100644
--- a/index/read-cache.c
+++ b/index/read-cache.c
@@ -46,7 +46,7 @@
 #include "progress.h"
 #include "index/sparse-index.h"
 #include "csum-file.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "setup/hook.h"
 #include "submodule.h"
 #include "submodule-config.h"
diff --git a/index/unpack-trees.c b/index/unpack-trees.c
index 2eecede699..e06b0a6a77 100644
--- a/index/unpack-trees.c
+++ b/index/unpack-trees.c
@@ -27,7 +27,7 @@
 #include "trace2.h"
 #include "index/fsmonitor.h"
 #include "odb/odb.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "index/entry.h"
 #include "index/parallel-checkout.h"
 #include "setup/setup.h"
diff --git a/index/wt-status.c b/index/wt-status.c
index 847438f121..ef7b513214 100644
--- a/index/wt-status.c
+++ b/index/wt-status.c
@@ -20,7 +20,7 @@
 #include "setup/repository.h"
 #include "run-command.h"
 #include "strvec.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "refs/refs.h"
 #include "submodule.h"
 #include "column.h"
diff --git a/index/wt-status.h b/index/wt-status.h
index b7a508186d..81bb7292b9 100644
--- a/index/wt-status.h
+++ b/index/wt-status.h
@@ -4,7 +4,7 @@
 #include "string-list.h"
 #include "color.h"
 #include "index/pathspec.h"
-#include "remote.h"
+#include "transport/remote.h"
 
 struct repository;
 struct worktree;
diff --git a/merge-ort.c b/merge-ort.c
index f101b5e0c4..cc21e397de 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -42,7 +42,7 @@
 #include "odb/odb.h"
 #include "odb/oid-array.h"
 #include "path.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "index/read-cache-ll.h"
 #include "refs/refs.h"
 #include "revision/revision.h"
diff --git a/meson.build b/meson.build
index bad597d8ff..6902f5de75 100644
--- a/meson.build
+++ b/meson.build
@@ -324,8 +324,8 @@ libgit_sources = [
   'odb/blob.c',
   'pack/bloom.c',
   'branch.c',
-  'bundle-uri.c',
-  'bundle.c',
+  'transport/bundle-uri.c',
+  'transport/bundle.c',
   'index/cache-tree.c',
   'odb/cbtree.c',
   'chdir-notify.c',
@@ -341,8 +341,8 @@ libgit_sources = [
   'common-init.c',
   'compiler-tricks/not-constant.c',
   'setup/config.c',
-  'connect.c',
-  'connected.c',
+  'transport/connect.c',
+  'transport/connected.c',
   'convert.c',
   'copy.c',
   'credential.c',
@@ -373,9 +373,9 @@ libgit_sources = [
   'ewah/ewah_io.c',
   'ewah/ewah_rlw.c',
   'exec-cmd.c',
-  'fetch-negotiator.c',
-  'fetch-object-info.c',
-  'fetch-pack.c',
+  'transport/fetch-negotiator.c',
+  'transport/fetch-object-info.c',
+  'transport/fetch-pack.c',
   'fmt-merge-msg.c',
   'odb/fsck.c',
   'index/fsmonitor.c',
@@ -466,15 +466,15 @@ libgit_sources = [
   'path.c',
   'path-walk.c',
   'index/pathspec.c',
-  'pkt-line.c',
+  'transport/pkt-line.c',
   'index/preload-index.c',
   'revision/pretty.c',
   'prio-queue.c',
   'progress.c',
-  'promisor-remote.c',
+  'transport/promisor-remote.c',
   'prompt.c',
-  'protocol.c',
-  'protocol-caps.c',
+  'transport/protocol.c',
+  'transport/protocol-caps.c',
   'pack/prune-packed.c',
   'pack/pseudo-merge.c',
   'quote.c',
@@ -508,7 +508,7 @@ libgit_sources = [
   'reftable/table.c',
   'reftable/tree.c',
   'reftable/writer.c',
-  'remote.c',
+  'transport/remote.c',
   'pack/repack.c',
   'pack/repack-cruft.c',
   'pack/repack-filtered.c',
@@ -524,13 +524,13 @@ libgit_sources = [
   'index/resolve-undo.c',
   'revision/revision.c',
   'run-command.c',
-  'send-pack.c',
+  'transport/send-pack.c',
   'sequencer.c',
-  'serve.c',
+  'transport/serve.c',
   'pack/server-info.c',
   'setup/setup.c',
   'revision/shallow.c',
-  'sideband.c',
+  'transport/sideband.c',
   'sigchain.c',
   'index/sparse-index.c',
   'index/split-index.c',
@@ -563,13 +563,13 @@ libgit_sources = [
   'trace2/tr2_tls.c',
   'trace2/tr2_tmr.c',
   'trailer.c',
-  'transport-helper.c',
-  'transport.c',
+  'transport/transport-helper.c',
+  'transport/transport.c',
   'diff/tree-diff.c',
   'odb/tree-walk.c',
   'odb/tree.c',
   'index/unpack-trees.c',
-  'upload-pack.c',
+  'transport/upload-pack.c',
   'url.c',
   'urlmatch.c',
   'usage.c',
@@ -577,7 +577,7 @@ libgit_sources = [
   'utf8.c',
   'setup/version.c',
   'versioncmp.c',
-  'walker.c',
+  'transport/walker.c',
   'wildmatch.c',
   'refs/worktree.c',
   'wrapper.c',
@@ -1918,14 +1918,14 @@ bin_wrappers += executable('scalar',
 if curl.found()
   libgit_curl = declare_dependency(
     sources: [
-      'http.c',
-      'http-walker.c',
+      'transport/http.c',
+      'transport/http-walker.c',
     ],
     dependencies: [libgit_commonmain, curl],
   )
 
   test_dependencies += executable('git-remote-http',
-    sources: 'remote-curl.c',
+    sources: 'transport/remote-curl.c',
     dependencies: [libgit_curl],
     install: true,
     install_dir: git_exec_path,
@@ -1949,7 +1949,7 @@ if curl.found()
 
   foreach alias : [ 'git-remote-https', 'git-remote-ftp', 'git-remote-ftps' ]
     test_dependencies += executable(alias,
-      sources: 'remote-curl.c',
+      sources: 'transport/remote-curl.c',
       dependencies: [libgit_curl],
     )
 
diff --git a/negotiator/default.c b/negotiator/default.c
index 3211453743..98f2b44b7e 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "default.h"
 #include "odb/commit.h"
-#include "../fetch-negotiator.h"
+#include "transport/fetch-negotiator.h"
 #include "../prio-queue.h"
 #include "refs/refs.h"
 #include "setup/repository.h"
diff --git a/negotiator/noop.c b/negotiator/noop.c
index edf1b456f3..e547d6bb1f 100644
--- a/negotiator/noop.c
+++ b/negotiator/noop.c
@@ -1,6 +1,6 @@
 #include "git-compat-util.h"
 #include "noop.h"
-#include "../fetch-negotiator.h"
+#include "transport/fetch-negotiator.h"
 
 static void known_common(struct fetch_negotiator *n UNUSED,
 			 struct commit *c UNUSED)
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index eabfac6edd..e01c339dd0 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "skipping.h"
 #include "odb/commit.h"
-#include "../fetch-negotiator.h"
+#include "transport/fetch-negotiator.h"
 #include "../hex.h"
 #include "../prio-queue.h"
 #include "refs/refs.h"
diff --git a/odb/object-name.c b/odb/object-name.c
index af03d8d0e5..e734455585 100644
--- a/odb/object-name.c
+++ b/odb/object-name.c
@@ -13,7 +13,7 @@
 #include "odb/tree.h"
 #include "odb/tree-walk.h"
 #include "refs/refs.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "index/dir.h"
 #include "odb/odb.h"
 #include "odb/oid-array.h"
diff --git a/odb/odb.c b/odb/odb.c
index f326dbb284..76b0712120 100644
--- a/odb/odb.c
+++ b/odb/odb.c
@@ -17,7 +17,7 @@
 #include "odb/source-inmemory.h"
 #include "pack/packfile.h"
 #include "path.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "quote.h"
 #include "odb/replace-object.h"
 #include "run-command.h"
diff --git a/odb/source-files.c b/odb/source-files.c
index 7b8a21d137..02671605ab 100644
--- a/odb/source-files.c
+++ b/odb/source-files.c
@@ -13,7 +13,7 @@
 #include "pack/pack-objects.h"
 #include "pack/packfile.h"
 #include "path.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "pack/repack.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/pack/pack-write.c b/pack/pack-write.c
index 45066b9657..59b4638839 100644
--- a/pack/pack-write.c
+++ b/pack/pack-write.c
@@ -4,7 +4,7 @@
 #include "hex.h"
 #include "pack/pack.h"
 #include "csum-file.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "pack/chunk-format.h"
 #include "odb/object-file.h"
 #include "pack/pack-mtimes.h"
diff --git a/pack/packfile.c b/pack/packfile.c
index 9509d6efcb..15df048ce7 100644
--- a/pack/packfile.c
+++ b/pack/packfile.c
@@ -23,7 +23,7 @@
 #include "pack/midx.h"
 #include "pack/commit-graph.h"
 #include "pack/pack-revindex.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "pack/pack-mtimes.h"
 
 char *odb_pack_name(struct repository *r, struct strbuf *buf,
diff --git a/refs/ls-refs.c b/refs/ls-refs.c
index 03ab2720e9..83f847de81 100644
--- a/refs/ls-refs.c
+++ b/refs/ls-refs.c
@@ -9,7 +9,7 @@
 #include "refs/refs.h"
 #include "strvec.h"
 #include "refs/ls-refs.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "setup/config.h"
 #include "string-list.h"
 
diff --git a/refs/ref-filter.c b/refs/ref-filter.c
index 9a426b6ce9..c369856b54 100644
--- a/refs/ref-filter.c
+++ b/refs/ref-filter.c
@@ -19,7 +19,7 @@
 #include "odb/commit.h"
 #include "mailmap.h"
 #include "setup/ident.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "color.h"
 #include "odb/tag.h"
 #include "quote.h"
diff --git a/refs/refspec.c b/refs/refspec.c
index 324c274bff..bbd520f54b 100644
--- a/refs/refspec.c
+++ b/refs/refspec.c
@@ -8,7 +8,7 @@
 #include "strvec.h"
 #include "refs/refs.h"
 #include "refs/refspec.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "strbuf.h"
 
 /*
diff --git a/revision/list-objects-filter-options.c b/revision/list-objects-filter-options.c
index 38604a580c..a22dc5b435 100644
--- a/revision/list-objects-filter-options.c
+++ b/revision/list-objects-filter-options.c
@@ -4,7 +4,7 @@
 #include "setup/config.h"
 #include "gettext.h"
 #include "revision/list-objects-filter-options.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "trace.h"
 #include "url.h"
 #include "parse-options.h"
diff --git a/revision/shallow.c b/revision/shallow.c
index a6e8a66c14..8822ef7f4c 100644
--- a/revision/shallow.c
+++ b/revision/shallow.c
@@ -8,7 +8,7 @@
 #include "odb/odb.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "refs/refs.h"
 #include "odb/oid-array.h"
 #include "path.h"
diff --git a/setup/repository.c b/setup/repository.c
index 77be866c82..cd2719fb33 100644
--- a/setup/repository.c
+++ b/setup/repository.c
@@ -10,13 +10,13 @@
 #include "lockfile.h"
 #include "path.h"
 #include "index/read-cache-ll.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "setup/setup.h"
 #include "odb/loose.h"
 #include "submodule-config.h"
 #include "index/sparse-index.h"
 #include "trace2.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "refs/refs.h"
 
 /*
diff --git a/simple-ipc.h b/simple-ipc.h
index 701e005cb8..038ae97f02 100644
--- a/simple-ipc.h
+++ b/simple-ipc.h
@@ -37,7 +37,7 @@ enum ipc_active_state {
 };
 
 #ifdef SUPPORTS_SIMPLE_IPC
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 
 /*
  * Simple IPC Client Side API.
diff --git a/sub-process.c b/sub-process.c
index 2d5c965169..e639cca9b9 100644
--- a/sub-process.c
+++ b/sub-process.c
@@ -4,7 +4,7 @@
 #include "git-compat-util.h"
 #include "sub-process.h"
 #include "sigchain.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 
 int cmd2process_cmp(const void *cmp_data UNUSED,
 		    const struct hashmap_entry *eptr,
diff --git a/submodule.c b/submodule.c
index 16b3ffbcc6..0272a7d553 100644
--- a/submodule.c
+++ b/submodule.c
@@ -22,7 +22,7 @@
 #include "strvec.h"
 #include "thread-utils.h"
 #include "path.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "refs/worktree.h"
 #include "parse-options.h"
 #include "odb/object-file.h"
diff --git a/t/helper/test-bundle-uri.c b/t/helper/test-bundle-uri.c
index 0c5fa723d8..48946a6fc2 100644
--- a/t/helper/test-bundle-uri.c
+++ b/t/helper/test-bundle-uri.c
@@ -1,11 +1,11 @@
 #include "test-tool.h"
 #include "parse-options.h"
-#include "bundle-uri.h"
+#include "transport/bundle-uri.h"
 #include "gettext.h"
 #include "strbuf.h"
 #include "string-list.h"
-#include "transport.h"
-#include "remote.h"
+#include "transport/transport.h"
+#include "transport/remote.h"
 
 enum input_mode {
 	KEY_VALUE_PAIRS,
diff --git a/t/helper/test-pkt-line.c b/t/helper/test-pkt-line.c
index 4daa82f00f..2ddc243472 100644
--- a/t/helper/test-pkt-line.c
+++ b/t/helper/test-pkt-line.c
@@ -1,7 +1,7 @@
 #include "git-compat-util.h"
 #include "test-tool.h"
-#include "pkt-line.h"
-#include "sideband.h"
+#include "transport/pkt-line.h"
+#include "transport/sideband.h"
 #include "write-or-die.h"
 #include "parse-options.h"
 
diff --git a/t/helper/test-proc-receive.c b/t/helper/test-proc-receive.c
index 8eccc34216..01576400b8 100644
--- a/t/helper/test-proc-receive.c
+++ b/t/helper/test-proc-receive.c
@@ -1,8 +1,8 @@
 #include "test-tool.h"
-#include "connect.h"
+#include "transport/connect.h"
 #include "hex.h"
 #include "parse-options.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "sigchain.h"
 #include "string-list.h"
 
diff --git a/t/helper/test-rot13-filter.c b/t/helper/test-rot13-filter.c
index ad37e10034..40da1eac59 100644
--- a/t/helper/test-rot13-filter.c
+++ b/t/helper/test-rot13-filter.c
@@ -37,7 +37,7 @@
  */
 
 #include "test-tool.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "string-list.h"
 #include "strmap.h"
 #include "parse-options.h"
diff --git a/t/helper/test-serve-v2.c b/t/helper/test-serve-v2.c
index 13452d4eab..56754c27d3 100644
--- a/t/helper/test-serve-v2.c
+++ b/t/helper/test-serve-v2.c
@@ -4,7 +4,7 @@
 #include "gettext.h"
 #include "parse-options.h"
 #include "setup/repository.h"
-#include "serve.h"
+#include "transport/serve.h"
 #include "setup/setup.h"
 
 static char const * const serve_usage[] = {
diff --git a/t/helper/test-submodule.c b/t/helper/test-submodule.c
index 7a82e1f0f9..2290808d5c 100644
--- a/t/helper/test-submodule.c
+++ b/t/helper/test-submodule.c
@@ -3,7 +3,7 @@
 #include "test-tool.h"
 #include "test-tool-utils.h"
 #include "parse-options.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "setup/repository.h"
 #include "setup/setup.h"
 #include "strbuf.h"
diff --git a/bundle-uri.c b/transport/bundle-uri.c
similarity index 99%
rename from bundle-uri.c
rename to transport/bundle-uri.c
index cd26d38249..e2466e27a2 100644
--- a/bundle-uri.c
+++ b/transport/bundle-uri.c
@@ -2,17 +2,17 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "bundle-uri.h"
-#include "bundle.h"
+#include "transport/bundle-uri.h"
+#include "transport/bundle.h"
 #include "copy.h"
 #include "gettext.h"
 #include "refs/refs.h"
 #include "run-command.h"
 #include "hashmap.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "setup/config.h"
-#include "fetch-pack.h"
-#include "remote.h"
+#include "transport/fetch-pack.h"
+#include "transport/remote.h"
 #include "trace2.h"
 #include "odb/odb.h"
 
diff --git a/bundle-uri.h b/transport/bundle-uri.h
similarity index 100%
rename from bundle-uri.h
rename to transport/bundle-uri.h
diff --git a/bundle.c b/transport/bundle.c
similarity index 99%
rename from bundle.c
rename to transport/bundle.c
index 1e01ab38d4..6a272e9390 100644
--- a/bundle.c
+++ b/transport/bundle.c
@@ -3,7 +3,7 @@
 
 #include "git-compat-util.h"
 #include "lockfile.h"
-#include "bundle.h"
+#include "transport/bundle.h"
 #include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
@@ -18,7 +18,7 @@
 #include "refs/refs.h"
 #include "strvec.h"
 #include "revision/list-objects-filter-options.h"
-#include "connected.h"
+#include "transport/connected.h"
 #include "write-or-die.h"
 
 static const char v2_bundle_signature[] = "# v2 git bundle\n";
diff --git a/bundle.h b/transport/bundle.h
similarity index 100%
rename from bundle.h
rename to transport/bundle.h
diff --git a/connect.c b/transport/connect.c
similarity index 99%
rename from connect.c
rename to transport/connect.c
index 2a1b177490..e11fc530f6 100644
--- a/connect.c
+++ b/transport/connect.c
@@ -5,24 +5,24 @@
 #include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "quote.h"
 #include "refs/refs.h"
 #include "run-command.h"
-#include "remote.h"
-#include "connect.h"
+#include "transport/remote.h"
+#include "transport/connect.h"
 #include "url.h"
 #include "string-list.h"
 #include "odb/oid-array.h"
 #include "path.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "trace2.h"
 #include "strbuf.h"
 #include "setup/version.h"
-#include "protocol.h"
+#include "transport/protocol.h"
 #include "setup/alias.h"
-#include "bundle-uri.h"
-#include "promisor-remote.h"
+#include "transport/bundle-uri.h"
+#include "transport/promisor-remote.h"
 
 static char *server_capabilities_v1;
 static struct strvec server_capabilities_v2 = STRVEC_INIT;
diff --git a/connect.h b/transport/connect.h
similarity index 98%
rename from connect.h
rename to transport/connect.h
index 957e5fe2b9..97828112d7 100644
--- a/connect.h
+++ b/transport/connect.h
@@ -1,7 +1,7 @@
 #ifndef CONNECT_H
 #define CONNECT_H
 
-#include "protocol.h"
+#include "transport/protocol.h"
 
 #define CONNECT_VERBOSE       (1u << 0)
 #define CONNECT_DIAG_URL      (1u << 1)
diff --git a/connected.c b/transport/connected.c
similarity index 98%
rename from connected.c
rename to transport/connected.c
index 1884614b80..c5b8edda1e 100644
--- a/connected.c
+++ b/transport/connected.c
@@ -6,10 +6,10 @@
 #include "odb/odb.h"
 #include "run-command.h"
 #include "sigchain.h"
-#include "connected.h"
-#include "transport.h"
+#include "transport/connected.h"
+#include "transport/transport.h"
 #include "pack/packfile.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 
 static int promised_object_cb(const struct object_id *oid UNUSED,
 			      struct object_info *oi UNUSED,
diff --git a/connected.h b/transport/connected.h
similarity index 100%
rename from connected.h
rename to transport/connected.h
diff --git a/fetch-negotiator.c b/transport/fetch-negotiator.c
similarity index 94%
rename from fetch-negotiator.c
rename to transport/fetch-negotiator.c
index 90fee42b50..19670d0c2c 100644
--- a/fetch-negotiator.c
+++ b/transport/fetch-negotiator.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "fetch-negotiator.h"
+#include "transport/fetch-negotiator.h"
 #include "negotiator/default.h"
 #include "negotiator/skipping.h"
 #include "negotiator/noop.h"
diff --git a/fetch-negotiator.h b/transport/fetch-negotiator.h
similarity index 100%
rename from fetch-negotiator.h
rename to transport/fetch-negotiator.h
diff --git a/fetch-object-info.c b/transport/fetch-object-info.c
similarity index 97%
rename from fetch-object-info.c
rename to transport/fetch-object-info.c
index 30cf131aed..d834731c91 100644
--- a/fetch-object-info.c
+++ b/transport/fetch-object-info.c
@@ -1,11 +1,11 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
-#include "pkt-line.h"
-#include "connect.h"
+#include "transport/pkt-line.h"
+#include "transport/connect.h"
 #include "odb/oid-array.h"
 #include "odb/odb.h"
-#include "fetch-object-info.h"
+#include "transport/fetch-object-info.h"
 #include "string-list.h"
 
 /* Sends object-info command and its arguments into the request buffer. */
diff --git a/fetch-object-info.h b/transport/fetch-object-info.h
similarity index 91%
rename from fetch-object-info.h
rename to transport/fetch-object-info.h
index 269cebb3f7..12ae9dc3b5 100644
--- a/fetch-object-info.h
+++ b/transport/fetch-object-info.h
@@ -1,8 +1,8 @@
 #ifndef FETCH_OBJECT_INFO_H
 #define FETCH_OBJECT_INFO_H
 
-#include "pkt-line.h"
-#include "protocol.h"
+#include "transport/pkt-line.h"
+#include "transport/protocol.h"
 
 struct object_info_args {
 	struct string_list *object_info_options;
diff --git a/fetch-pack.c b/transport/fetch-pack.c
similarity index 99%
rename from fetch-pack.c
rename to transport/fetch-pack.c
index 5bc72eb370..953de0a964 100644
--- a/fetch-pack.c
+++ b/transport/fetch-pack.c
@@ -10,15 +10,15 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "refs/refs.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "odb/commit.h"
 #include "odb/tag.h"
 #include "pack/pack.h"
-#include "sideband.h"
-#include "fetch-pack.h"
-#include "remote.h"
+#include "transport/sideband.h"
+#include "transport/fetch-pack.h"
+#include "transport/remote.h"
 #include "run-command.h"
-#include "connect.h"
+#include "transport/connect.h"
 #include "trace2.h"
 #include "setup/version.h"
 #include "odb/oid-array.h"
@@ -27,8 +27,8 @@
 #include "odb/odb.h"
 #include "odb/object-name.h"
 #include "path.h"
-#include "connected.h"
-#include "fetch-negotiator.h"
+#include "transport/connected.h"
+#include "transport/fetch-negotiator.h"
 #include "odb/fsck.h"
 #include "revision/shallow.h"
 #include "revision/commit-reach.h"
@@ -36,7 +36,7 @@
 #include "sigchain.h"
 #include "mergesort.h"
 #include "prio-queue.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 
 static int transfer_unpack_limit = -1;
 static int fetch_unpack_limit = -1;
diff --git a/fetch-pack.h b/transport/fetch-pack.h
similarity index 99%
rename from fetch-pack.h
rename to transport/fetch-pack.h
index 42922616be..be5c5f2143 100644
--- a/fetch-pack.h
+++ b/transport/fetch-pack.h
@@ -2,7 +2,7 @@
 #define FETCH_PACK_H
 
 #include "string-list.h"
-#include "protocol.h"
+#include "transport/protocol.h"
 #include "revision/list-objects-filter-options.h"
 #include "odb/oidset.h"
 
diff --git a/git-curl-compat.h b/transport/git-curl-compat.h
similarity index 100%
rename from git-curl-compat.h
rename to transport/git-curl-compat.h
diff --git a/http-walker.c b/transport/http-walker.c
similarity index 99%
rename from http-walker.c
rename to transport/http-walker.c
index b5bba74da4..e0f8eb7162 100644
--- a/http-walker.c
+++ b/transport/http-walker.c
@@ -4,10 +4,10 @@
 #include "git-compat-util.h"
 #include "setup/repository.h"
 #include "hex.h"
-#include "walker.h"
-#include "http.h"
+#include "transport/walker.h"
+#include "transport/http.h"
 #include "revision/list.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "pack/packfile.h"
 #include "odb/object-file.h"
 #include "odb/odb.h"
diff --git a/http.c b/transport/http.c
similarity index 99%
rename from http.c
rename to transport/http.c
index 5b3b2b24d6..bb92754a80 100644
--- a/http.c
+++ b/transport/http.c
@@ -2,10 +2,10 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "git-curl-compat.h"
+#include "transport/git-curl-compat.h"
 #include "setup/environment.h"
 #include "hex.h"
-#include "http.h"
+#include "transport/http.h"
 #include "setup/config.h"
 #include "pack/pack.h"
 #include "run-command.h"
@@ -13,10 +13,10 @@
 #include "urlmatch.h"
 #include "credential.h"
 #include "setup/version.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "gettext.h"
 #include "trace.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "pack/packfile.h"
 #include "string-list.h"
 #include "odb/object-file.h"
diff --git a/http.h b/transport/http.h
similarity index 99%
rename from http.h
rename to transport/http.h
index 729c51904d..fab359450f 100644
--- a/http.h
+++ b/transport/http.h
@@ -11,7 +11,7 @@ struct packfile_list;
 
 #include "gettext.h"
 #include "strbuf.h"
-#include "remote.h"
+#include "transport/remote.h"
 
 #define DEFAULT_MAX_REQUESTS 5
 
diff --git a/pkt-line.c b/transport/pkt-line.c
similarity index 99%
rename from pkt-line.c
rename to transport/pkt-line.c
index 3fc3e9ea70..d8b341b75e 100644
--- a/pkt-line.c
+++ b/transport/pkt-line.c
@@ -1,10 +1,10 @@
 #include "git-compat-util.h"
 #include "copy.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "gettext.h"
 #include "hex.h"
 #include "run-command.h"
-#include "sideband.h"
+#include "transport/sideband.h"
 #include "trace.h"
 #include "write-or-die.h"
 
diff --git a/pkt-line.h b/transport/pkt-line.h
similarity index 100%
rename from pkt-line.h
rename to transport/pkt-line.h
diff --git a/promisor-remote.c b/transport/promisor-remote.c
similarity index 99%
rename from promisor-remote.c
rename to transport/promisor-remote.c
index 80caaeca99..e32b6d4e30 100644
--- a/promisor-remote.c
+++ b/transport/promisor-remote.c
@@ -4,10 +4,10 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/odb.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 #include "setup/config.h"
 #include "trace2.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "strvec.h"
 #include "pack/packfile.h"
 #include "setup/environment.h"
diff --git a/promisor-remote.h b/transport/promisor-remote.h
similarity index 100%
rename from promisor-remote.h
rename to transport/promisor-remote.h
diff --git a/protocol-caps.c b/transport/protocol-caps.c
similarity index 98%
rename from protocol-caps.c
rename to transport/protocol-caps.c
index ffda7e11dd..6217bebc27 100644
--- a/protocol-caps.c
+++ b/transport/protocol-caps.c
@@ -1,8 +1,8 @@
 #include "git-compat-util.h"
-#include "protocol-caps.h"
+#include "transport/protocol-caps.h"
 #include "gettext.h"
 #include "hex.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "odb/hash.h"
 #include "odb/object.h"
 #include "odb/odb.h"
diff --git a/protocol-caps.h b/transport/protocol-caps.h
similarity index 100%
rename from protocol-caps.h
rename to transport/protocol-caps.h
diff --git a/protocol.c b/transport/protocol.c
similarity index 98%
rename from protocol.c
rename to transport/protocol.c
index 7f19dbc04d..33051e8a08 100644
--- a/protocol.c
+++ b/transport/protocol.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "setup/config.h"
 #include "setup/environment.h"
-#include "protocol.h"
+#include "transport/protocol.h"
 #include "trace2.h"
 
 static enum protocol_version parse_protocol_version(const char *value)
diff --git a/protocol.h b/transport/protocol.h
similarity index 100%
rename from protocol.h
rename to transport/protocol.h
diff --git a/remote-curl.c b/transport/remote-curl.c
similarity index 99%
rename from remote-curl.c
rename to transport/remote-curl.c
index d0aa42c974..f643515c56 100644
--- a/remote-curl.c
+++ b/transport/remote-curl.c
@@ -2,28 +2,28 @@
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
-#include "git-curl-compat.h"
+#include "transport/git-curl-compat.h"
 #include "setup/config.h"
 #include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "remote.h"
-#include "connect.h"
+#include "transport/remote.h"
+#include "transport/connect.h"
 #include "strbuf.h"
-#include "walker.h"
-#include "http.h"
+#include "transport/walker.h"
+#include "transport/http.h"
 #include "run-command.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "credential.h"
 #include "odb/oid-array.h"
-#include "send-pack.h"
+#include "transport/send-pack.h"
 #include "setup/setup.h"
-#include "protocol.h"
+#include "transport/protocol.h"
 #include "quote.h"
 #include "trace2.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "url.h"
 #include "write-or-die.h"
 
diff --git a/remote.c b/transport/remote.c
similarity index 99%
rename from remote.c
rename to transport/remote.c
index ae77c5b1db..fe7962799d 100644
--- a/remote.c
+++ b/transport/remote.c
@@ -7,7 +7,7 @@
 #include "setup/environment.h"
 #include "gettext.h"
 #include "hex.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "url.h"
 #include "urlmatch.h"
 #include "refs/refs.h"
@@ -24,9 +24,9 @@
 #include "strvec.h"
 #include "revision/commit-reach.h"
 #include "advice.h"
-#include "connect.h"
+#include "transport/connect.h"
 #include "parse-options.h"
-#include "transport.h"
+#include "transport/transport.h"
 
 enum map_direction { FROM_SRC, FROM_DST };
 
diff --git a/remote.h b/transport/remote.h
similarity index 100%
rename from remote.h
rename to transport/remote.h
diff --git a/send-pack.c b/transport/send-pack.c
similarity index 99%
rename from send-pack.c
rename to transport/send-pack.c
index 546835b0aa..77079501b8 100644
--- a/send-pack.c
+++ b/transport/send-pack.c
@@ -5,13 +5,13 @@
 #include "gettext.h"
 #include "hex.h"
 #include "odb/odb.h"
-#include "pkt-line.h"
-#include "sideband.h"
+#include "transport/pkt-line.h"
+#include "transport/sideband.h"
 #include "run-command.h"
-#include "remote.h"
-#include "connect.h"
-#include "send-pack.h"
-#include "transport.h"
+#include "transport/remote.h"
+#include "transport/connect.h"
+#include "transport/send-pack.h"
+#include "transport/transport.h"
 #include "setup/version.h"
 #include "odb/oid-array.h"
 #include "gpg-interface.h"
diff --git a/send-pack.h b/transport/send-pack.h
similarity index 100%
rename from send-pack.h
rename to transport/send-pack.h
diff --git a/serve.c b/transport/serve.c
similarity index 97%
rename from serve.c
rename to transport/serve.c
index 4408187c47..0f24d2f682 100644
--- a/serve.c
+++ b/transport/serve.c
@@ -2,15 +2,15 @@
 #include "setup/repository.h"
 #include "setup/config.h"
 #include "odb/hash.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "setup/version.h"
 #include "refs/ls-refs.h"
-#include "protocol-caps.h"
-#include "serve.h"
-#include "upload-pack.h"
-#include "bundle-uri.h"
+#include "transport/protocol-caps.h"
+#include "transport/serve.h"
+#include "transport/upload-pack.h"
+#include "transport/bundle-uri.h"
 #include "trace2.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 
 static int advertise_sid = -1;
 static int advertise_object_info = -1;
diff --git a/serve.h b/transport/serve.h
similarity index 100%
rename from serve.h
rename to transport/serve.h
diff --git a/sideband.c b/transport/sideband.c
similarity index 99%
rename from sideband.c
rename to transport/sideband.c
index b915fdf114..cba8394b6a 100644
--- a/sideband.c
+++ b/transport/sideband.c
@@ -6,9 +6,9 @@
 #include "setup/config.h"
 #include "editor.h"
 #include "gettext.h"
-#include "sideband.h"
+#include "transport/sideband.h"
 #include "help.h"
-#include "pkt-line.h"
+#include "transport/pkt-line.h"
 #include "write-or-die.h"
 #include "urlmatch.h"
 
diff --git a/sideband.h b/transport/sideband.h
similarity index 100%
rename from sideband.h
rename to transport/sideband.h
diff --git a/transport-helper.c b/transport/transport-helper.c
similarity index 99%
rename from transport-helper.c
rename to transport/transport-helper.c
index 94d3d9ced8..63a9b80cff 100644
--- a/transport-helper.c
+++ b/transport/transport-helper.c
@@ -1,7 +1,7 @@
 #define USE_THE_REPOSITORY_VARIABLE
 
 #include "git-compat-util.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "quote.h"
 #include "run-command.h"
 #include "odb/commit.h"
@@ -10,15 +10,15 @@
 #include "hex.h"
 #include "odb/object-name.h"
 #include "setup/repository.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "string-list.h"
 #include "thread-utils.h"
 #include "sigchain.h"
 #include "strvec.h"
 #include "refs/refs.h"
 #include "refs/refspec.h"
-#include "transport-internal.h"
-#include "protocol.h"
+#include "transport/transport-internal.h"
+#include "transport/protocol.h"
 #include "pack/packfile.h"
 
 static int debug;
diff --git a/transport-internal.h b/transport/transport-internal.h
similarity index 98%
rename from transport-internal.h
rename to transport/transport-internal.h
index 60db0bedcd..c3edf136b7 100644
--- a/transport-internal.h
+++ b/transport/transport-internal.h
@@ -1,7 +1,7 @@
 #ifndef TRANSPORT_INTERNAL_H
 #define TRANSPORT_INTERNAL_H
 
-#include "connect.h"
+#include "transport/connect.h"
 
 struct ref;
 struct transport;
diff --git a/transport.c b/transport/transport.c
similarity index 99%
rename from transport.c
rename to transport/transport.c
index 18429b78f5..dfeae250fd 100644
--- a/transport.c
+++ b/transport/transport.c
@@ -5,15 +5,15 @@
 #include "setup/config.h"
 #include "setup/environment.h"
 #include "hex.h"
-#include "transport.h"
+#include "transport/transport.h"
 #include "setup/hook.h"
-#include "pkt-line.h"
-#include "fetch-pack.h"
-#include "fetch-object-info.h"
-#include "remote.h"
-#include "connect.h"
-#include "send-pack.h"
-#include "bundle.h"
+#include "transport/pkt-line.h"
+#include "transport/fetch-pack.h"
+#include "transport/fetch-object-info.h"
+#include "transport/remote.h"
+#include "transport/connect.h"
+#include "transport/send-pack.h"
+#include "transport/bundle.h"
 #include "gettext.h"
 #include "refs/refs.h"
 #include "refs/refspec.h"
@@ -25,12 +25,12 @@
 #include "odb/oid-array.h"
 #include "sigchain.h"
 #include "trace2.h"
-#include "transport-internal.h"
-#include "protocol.h"
+#include "transport/transport-internal.h"
+#include "transport/protocol.h"
 #include "odb/object-name.h"
 #include "color.h"
-#include "bundle-uri.h"
-#include "sideband.h"
+#include "transport/bundle-uri.h"
+#include "transport/sideband.h"
 
 static enum git_colorbool transport_use_color = GIT_COLOR_UNKNOWN;
 static char transport_colors[][COLOR_MAXLEN] = {
diff --git a/transport.h b/transport/transport.h
similarity index 99%
rename from transport.h
rename to transport/transport.h
index 064f4192cf..af4f1fa0db 100644
--- a/transport.h
+++ b/transport/transport.h
@@ -2,10 +2,10 @@
 #define TRANSPORT_H
 
 #include "run-command.h"
-#include "remote.h"
+#include "transport/remote.h"
 #include "revision/list-objects-filter-options.h"
 #include "string-list.h"
-#include "connect.h"
+#include "transport/connect.h"
 
 struct git_transport_options {
 	unsigned thin : 1;
diff --git a/upload-pack.c b/transport/upload-pack.c
similarity index 99%
rename from upload-pack.c
rename to transport/upload-pack.c
index 23c0357496..73edc8bb28 100644
--- a/upload-pack.c
+++ b/transport/upload-pack.c
@@ -7,8 +7,8 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs/refs.h"
-#include "pkt-line.h"
-#include "sideband.h"
+#include "transport/pkt-line.h"
+#include "transport/sideband.h"
 #include "setup/repository.h"
 #include "odb/odb.h"
 #include "odb/oid-array.h"
@@ -18,14 +18,14 @@
 #include "revision/revision.h"
 #include "revision/list-objects-filter-options.h"
 #include "run-command.h"
-#include "connect.h"
+#include "transport/connect.h"
 #include "sigchain.h"
 #include "setup/version.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "trace2.h"
-#include "protocol.h"
-#include "upload-pack.h"
+#include "transport/protocol.h"
+#include "transport/upload-pack.h"
 #include "pack/commit-graph.h"
 #include "revision/commit-reach.h"
 #include "revision/shallow.h"
@@ -33,7 +33,7 @@
 #include "write-or-die.h"
 #include "json-writer.h"
 #include "strmap.h"
-#include "promisor-remote.h"
+#include "transport/promisor-remote.h"
 
 /* Remember to update object flag allocation in object.h */
 #define THEY_HAVE	(1u << 11)
diff --git a/upload-pack.h b/transport/upload-pack.h
similarity index 100%
rename from upload-pack.h
rename to transport/upload-pack.h
diff --git a/walker.c b/transport/walker.c
similarity index 99%
rename from walker.c
rename to transport/walker.c
index 079dcd378c..330b00a22c 100644
--- a/walker.c
+++ b/transport/walker.c
@@ -3,7 +3,7 @@
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
-#include "walker.h"
+#include "transport/walker.h"
 #include "setup/repository.h"
 #include "odb/odb.h"
 #include "odb/commit.h"
diff --git a/walker.h b/transport/walker.h
similarity index 97%
rename from walker.h
rename to transport/walker.h
index 25aaa3631c..3a1b822965 100644
--- a/walker.h
+++ b/transport/walker.h
@@ -1,7 +1,7 @@
 #ifndef WALKER_H
 #define WALKER_H
 
-#include "remote.h"
+#include "transport/remote.h"
 
 struct walker {
 	void *data;
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [RFC PATCH 07/14] odb: gather the odb sources under odb/
  2026-08-23 17:18 ` [RFC PATCH 07/14] odb: gather the odb sources under odb/ Michael Montalbo
@ 2026-08-24 14:08   ` Oswald Buddenhagen
  2026-08-24 14:43     ` Junio C Hamano
  0 siblings, 1 reply; 18+ messages in thread
From: Oswald Buddenhagen @ 2026-08-24 14:08 UTC (permalink / raw)
  To: Michael Montalbo; +Cc: git, Patrick Steinhardt

On Sun, Aug 23, 2026 at 10:18:51AM -0700, Michael Montalbo wrote:
>Move the 23 odb C sources and 26 headers into odb/ as renames.
>
i for one would go with lib/odb/.

>+++ b/builtin/add.c
>-#include "object-file.h"
>-#include "odb.h"
>+#include "odb/object-file.h"
>+#include "odb/odb.h"
> 
that's the wrong include style here.
it was already wrong in a lot of places, but as you rewrite everything 
anyway, you could fix it just as well.


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC PATCH 07/14] odb: gather the odb sources under odb/
  2026-08-24 14:08   ` Oswald Buddenhagen
@ 2026-08-24 14:43     ` Junio C Hamano
  2026-08-24 20:03       ` Oswald Buddenhagen
  0 siblings, 1 reply; 18+ messages in thread
From: Junio C Hamano @ 2026-08-24 14:43 UTC (permalink / raw)
  To: Oswald Buddenhagen; +Cc: Michael Montalbo, git, Patrick Steinhardt

Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:

> On Sun, Aug 23, 2026 at 10:18:51AM -0700, Michael Montalbo wrote:
>>Move the 23 odb C sources and 26 headers into odb/ as renames.
>>
> i for one would go with lib/odb/.
>
>>+++ b/builtin/add.c
>>-#include "object-file.h"
>>-#include "odb.h"
>>+#include "odb/object-file.h"
>>+#include "odb/odb.h"
>> 
> that's the wrong include style here.
> it was already wrong in a lot of places, but as you rewrite everything 
> anyway, you could fix it just as well.

I do not agree with lib/odb/ suggestion, but I am curious what you
think the "right" include stle is, because I cannot read it out of
what you have written.  Please do not assume that everybody knows
what you think is right or wrong.

Do you mean they should not be quoted in a pair of double quotes
because the behaviour of such includes is implementation-defined
(instead use "<>" as we use -I<path> on the command line)?  Do you
mean they should be alphabetical?  Something else?

Thanks.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [RFC PATCH 07/14] odb: gather the odb sources under odb/
  2026-08-24 14:43     ` Junio C Hamano
@ 2026-08-24 20:03       ` Oswald Buddenhagen
  0 siblings, 0 replies; 18+ messages in thread
From: Oswald Buddenhagen @ 2026-08-24 20:03 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Michael Montalbo, git, Patrick Steinhardt

On Mon, Aug 24, 2026 at 07:43:46AM -0700, Junio C Hamano wrote:
>Oswald Buddenhagen <oswald.buddenhagen@gmx.de> writes:
>> On Sun, Aug 23, 2026 at 10:18:51AM -0700, Michael Montalbo wrote:
>>>Move the 23 odb C sources and 26 headers into odb/ as renames.
>>>
>> i for one would go with lib/odb/.
>>
>I do not agree with lib/odb/ suggestion,
>
why not? it's hugely beneficial for the comprehensibility of the build 
system and discoverability when the physical project structure follows 
the logical one.

>>>+++ b/builtin/add.c
>>>-#include "object-file.h"
>>>-#include "odb.h"
>>>+#include "odb/object-file.h"
>>>+#include "odb/odb.h"
>>> 
>> that's the wrong include style here.
>> it was already wrong in a lot of places, but as you rewrite everything 
>> anyway, you could fix it just as well.
>
>Do you mean they should not be quoted in a pair of double quotes
>because the behaviour of such includes is implementation-defined
>(instead use "<>" as we use -I<path> on the command line)?
>
yes.
(actually, i don't mind relying on the popular interpretation that 
""-style means relative to the including file's containing directory.  
that mostly implies that "" is ok for in-module references when headers 
and sources live side by side.)

> Something else?
>
everything else i can think of would require more context, so it's a 
good first guess to assume that i didn't mean it.

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-08-24 20:03 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-23 17:18 [RFC PATCH 00/14] git organize: record file placement and apply it Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 01/14] organize: add the git organize builtin Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 02/14] organize: add the labeler, organizer, and apply --labels-only Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 03/14] organize: add status --exit-code Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 04/14] organize: add the --label selector Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 05/14] organize: declare Git's scope and layout Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 06/14] organize: record a label for every source in scope Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 07/14] odb: gather the odb sources under odb/ Michael Montalbo
2026-08-24 14:08   ` Oswald Buddenhagen
2026-08-24 14:43     ` Junio C Hamano
2026-08-24 20:03       ` Oswald Buddenhagen
2026-08-23 17:18 ` [RFC PATCH 08/14] refs: gather the refs sources under refs/ Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 09/14] pack: gather the pack sources under pack/ Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 10/14] diff: gather the diff sources under diff/ Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 11/14] revision: gather the revision sources under revision/ Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 12/14] index: gather the index sources under index/ Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 13/14] setup: gather the setup sources under setup/ Michael Montalbo
2026-08-23 17:18 ` [RFC PATCH 14/14] transport: gather the transport sources under transport/ Michael Montalbo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).