git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps)

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Apr 16, 2023, 03:03 UTC
Message-ID
<pull.1517.git.1681614205.gitgitgadget@gmail.com>

Maintainer notes: (1) This series is based on en/header-split-cache-h (now in next). (2) Although I've tweaked the series to minimize conflicts, there is a semantic conflict with sl/sparse-write-tree in next; to resolve, add an include of repository.h in builtin/write-tree.c.

This series continues to focus on splitting declarations from cache.h to separate headers. This series also untangles some dependencies between hash.h and repository.h, and between read-cache.c and tree.[ch], and cleans up a few other headers. At the end of this series the number of cache.h includes drops from 189 down to 149.

The series may appear to be long at first glance, but is filled with mostly repetitive and simple changes similar to those from earlier series. An overview:

 * Patch 1: files depending on strbuf.h should be explicit about it
 * Patches 2-13: move stuff out of cache.h into other more logical headers
 * Patch 14-16: move functions between hash<->repository and
   read-cache<->tree to simplify dependencies
 * Patch 17: remove includes of cache.h permitted by the previous 16 patches
 * Patches 18-22: clean up now-unnecessary includes in other headers
 * Patch 23: start enforcing git-compat-util.h is first include for reftable
   files as well.

And thanks once again to Dscho for gitgitgadget. Getting multiple platform testing + all the special tests (sparse, cocci, hdr-check, etc.) really helps clean out all the issues that would otherwise hit a series like this.

Elijah Newren (23):
  treewide: be explicit about dependence on strbuf.h
  symlinks.h: move declarations for symlinks.c functions from cache.h
  protocol.h: move definition of DEFAULT_GIT_PORT from cache.h
  packfile.h: move pack_window and pack_entry from cache.h
  server-info.h: move declarations for server-info.c functions from
    cache.h
  copy.h: move declarations for copy.c functions from cache.h
  base85.h: move declarations for base85.c functions from cache.h
  pkt-line.h: move declarations for pkt-line.c functions from cache.h
  match-trees.h: move declarations for match-trees.c functions from
    cache.h
  ws.h: move declarations for ws.c functions from cache.h
  versioncmp.h: move declarations for versioncmp.c functions from
    cache.h
  dir.h: move DTYPE defines from cache.h
  tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  hash.h, repository.h: reverse the order of these dependencies
  cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c
  cache,tree: move basic name compare functions from read-cache to tree
  treewide: remove cache.h inclusion due to previous changes
  cache.h: remove unnecessary headers
  fsmonitor: reduce includes of cache.h
  commit.h: reduce unnecessary includes
  object-store.h: reduce unnecessary includes
  diff.h: reduce unnecessary includes
  reftable: ensure git-compat-util.h is the first (indirect) include
 add-interactive.c                            |   1 +
 alloc.c                                      |   1 +
 apply.c                                      |   3 +
 archive-zip.c                                |   2 +-
 archive.c                                    |   2 +
 attr.c                                       |   1 +
 base85.c                                     |   3 +-
 base85.h                                     |   7 +
 bloom.c                                      |   1 +
 branch.c                                     |   1 +
 builtin/apply.c                              |   1 +
 builtin/archive.c                            |   1 +
 builtin/bisect.c                             |   1 +
 builtin/bundle.c                             |   2 +
 builtin/check-attr.c                         |   1 +
 builtin/check-ignore.c                       |   1 +
 builtin/checkout-index.c                     |   1 +
 builtin/checkout.c                           |   1 +
 builtin/clean.c                              |   1 +
 builtin/clone.c                              |   2 +
 builtin/config.c                             |   1 +
 builtin/credential-cache.c                   |   1 +
 builtin/credential-store.c                   |   1 +
 builtin/diff-tree.c                          |   1 +
 builtin/diff.c                               |   1 +
 builtin/difftool.c                           |   1 +
 builtin/fetch.c                              |   1 +
 builtin/for-each-repo.c                      |   2 +
 builtin/gc.c                                 |   1 +
 builtin/help.c                               |   1 +
 builtin/init-db.c                            |   2 +
 builtin/log.c                                |   1 +
 builtin/ls-remote.c                          |   1 +
 builtin/merge-index.c                        |   1 +
 builtin/merge-recursive.c                    |   1 +
 builtin/merge-tree.c                         |   1 +
 builtin/mv.c                                 |   1 +
 builtin/push.c                               |   2 +
 builtin/read-tree.c                          |   1 +
 builtin/receive-pack.c                       |   1 +
 builtin/repack.c                             |   1 +
 builtin/rerere.c                             |   1 +
 builtin/rm.c                                 |   1 +
 builtin/show-branch.c                        |   1 +
 builtin/show-index.c                         |   1 +
 builtin/update-index.c                       |   2 +
 builtin/update-ref.c                         |   1 +
 builtin/update-server-info.c                 |   1 +
 builtin/upload-archive.c                     |   1 +
 builtin/worktree.c                           |   2 +
 bundle-uri.c                                 |   3 +-
 cache.h                                      | 143 +------------------
 checkout.c                                   |   1 +
 chunk-format.c                               |   1 +
 color.c                                      |   3 +-
 combine-diff.c                               |   3 +-
 commit-graph.c                               |   1 +
 commit.c                                     |   1 +
 commit.h                                     |  11 +-
 common-main.c                                |   4 +-
 compat/fsmonitor/fsm-health-darwin.c         |   2 +-
 compat/fsmonitor/fsm-ipc-darwin.c            |   4 +-
 compat/fsmonitor/fsm-ipc-win32.c             |   1 +
 compat/fsmonitor/fsm-listen-darwin.c         |   3 +-
 compat/mingw.c                               |   1 +
 compat/precompose_utf8.c                     |   1 +
 compat/win32/trace2_win32_process_info.c     |   1 +
 config.c                                     |   3 +-
 convert.c                                    |   1 +
 copy.c                                       |   4 +-
 copy.h                                       |  10 ++
 credential.c                                 |   3 +-
 csum-file.c                                  |   1 +
 daemon.c                                     |   4 +-
 date.c                                       |   3 +-
 diagnose.c                                   |   2 +-
 diff-lib.c                                   |   1 +
 diff.c                                       |   2 +
 diff.h                                       |   1 -
 dir.c                                        |   2 +
 dir.h                                        |  15 ++
 editor.c                                     |   1 +
 entry.c                                      |   1 +
 environment.c                                |   3 +-
 exec-cmd.c                                   |   1 +
 fetch-pack.c                                 |   1 +
 fsck.c                                       |   1 +
 fsmonitor--daemon.h                          |   1 -
 fsmonitor-ipc.c                              |   1 +
 gpg-interface.c                              |   2 +
 grep.c                                       |   1 +
 hash-lookup.c                                |   1 +
 hash.h                                       |  97 -------------
 hex.c                                        |   1 +
 hook.c                                       |   1 +
 http-push.c                                  |   2 +
 khash.h                                      |   1 +
 line-log.c                                   |   1 +
 ll-merge.c                                   |   3 +-
 log-tree.c                                   |   1 +
 match-trees.c                                |   3 +-
 match-trees.h                                |  10 ++
 merge-ort-wrappers.c                         |   2 +
 merge-ort.c                                  |   1 +
 merge-recursive.c                            |   2 +
 merge.c                                      |   1 +
 midx.c                                       |   2 +-
 negotiator/default.c                         |   1 +
 negotiator/skipping.c                        |   1 +
 notes-cache.c                                |   1 +
 notes-utils.c                                |   1 +
 object-file.c                                |   3 +-
 object-file.h                                |   2 +
 object-name.c                                |   2 +
 object-store.h                               |   8 +-
 object.h                                     |   1 +
 oid-array.h                                  |   1 +
 oidmap.c                                     |   1 +
 oidtree.c                                    |   1 +
 pack-bitmap-write.c                          |   2 +
 packfile.c                                   |   2 +-
 packfile.h                                   |  16 ++-
 parallel-checkout.c                          |   2 +
 parse-options-cb.c                           |   1 +
 parse-options.c                              |   1 +
 pathspec.c                                   |   2 +
 pkt-line.c                                   |   3 +-
 pkt-line.h                                   |   2 +
 preload-index.c                              |   1 +
 progress.c                                   |   1 +
 protocol.h                                   |  21 +++
 range-diff.c                                 |   2 +-
 read-cache.c                                 |  81 ++---------
 rebase-interactive.c                         |   1 +
 ref-filter.c                                 |   4 +-
 reflog.c                                     |   2 +
 refs/debug.c                                 |   1 +
 refs/files-backend.c                         |   2 +
 refs/packed-backend.c                        |   1 +
 refs/ref-cache.c                             |   1 +
 refs/ref-cache.h                             |   1 +
 refspec.c                                    |   2 +
 reftable/error.c                             |   1 +
 reftable/publicbasics.c                      |   2 +-
 reftable/tree.c                              |   2 +-
 reftable/tree_test.c                         |   1 +
 repository.h                                 |  96 +++++++++++++
 rerere.c                                     |   1 +
 resolve-undo.c                               |   1 +
 revision.h                                   |   1 +
 run-command.c                                |   1 +
 send-pack.c                                  |   1 +
 sequencer.c                                  |   1 +
 server-info.c                                |   3 +-
 server-info.h                                |   7 +
 split-index.c                                |   2 +
 strbuf.c                                     |   1 +
 submodule-config.c                           |   1 +
 symlinks.c                                   |   3 +-
 symlinks.h                                   |  28 ++++
 t/helper/test-bloom.c                        |   1 +
 t/helper/test-cache-tree.c                   |   1 +
 t/helper/test-dump-cache-tree.c              |   1 +
 t/helper/test-dump-fsmonitor.c               |   1 +
 t/helper/test-dump-untracked-cache.c         |   1 +
 t/helper/test-example-decorate.c             |   1 +
 t/helper/test-fsmonitor-client.c             |   1 +
 t/helper/test-lazy-init-name-hash.c          |   1 +
 t/helper/test-match-trees.c                  |   3 +-
 t/helper/test-mergesort.c                    |   2 +-
 t/helper/test-oid-array.c                    |   2 +-
 t/helper/test-oidmap.c                       |   1 +
 t/helper/test-oidtree.c                      |   2 +-
 t/helper/test-parse-options.c                |   2 +-
 t/helper/test-path-utils.c                   |   1 +
 t/helper/test-read-cache.c                   |   1 +
 t/helper/test-read-midx.c                    |   2 +-
 t/helper/test-reftable.c                     |   1 +
 t/helper/test-scrap-cache-tree.c             |   1 +
 t/helper/test-string-list.c                  |   2 +-
 t/helper/test-submodule-config.c             |   1 +
 t/helper/test-submodule-nested-repo-config.c |   1 +
 t/helper/test-submodule.c                    |   1 +
 t/helper/test-trace2.c                       |   1 +
 t/helper/test-write-cache.c                  |   1 +
 trace2.c                                     |   1 +
 trace2/tr2_tgt_event.c                       |   1 +
 trace2/tr2_tgt_normal.c                      |   1 +
 trace2/tr2_tgt_perf.c                        |   1 +
 tree-diff.c                                  |  16 ++-
 tree-walk.c                                  |   2 +-
 tree-walk.h                                  |   1 +
 tree.c                                       |  72 +++++++++-
 tree.h                                       |  11 +-
 unpack-trees.c                               |   1 +
 versioncmp.c                                 |   3 +-
 versioncmp.h                                 |   6 +
 wrapper.c                                    |   5 +-
 ws.c                                         |   6 +-
 ws.h                                         |  33 +++++
 wt-status.c                                  |   1 +
 201 files changed, 598 insertions(+), 371 deletions(-)
 create mode 100644 base85.h
 create mode 100644 copy.h
 create mode 100644 match-trees.h
 create mode 100644 server-info.h
 create mode 100644 symlinks.h
 create mode 100644 versioncmp.h
 create mode 100644 ws.h
base-commit: 4711556905f381c01f1fbae205f67cfa673ab44a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1517%2Fnewren%2Fheader-cleanup-4-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1517/newren/header-cleanup-4-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1517
-- 
gitgitgadget
Next: Elijah Newren via GitGitGadget
Message 1 of 81 in “Header cleanups (more splitting of cache.h and simplifying a few other deps)”
  1. 00/23 Header cleanups (more splitting of cache.h and simplifying a few other deps)Elijah Newren via GitGitGadget, Apr 16, 2023
  2. 06/23 copy.h: move declarations for copy.c functions from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  3. 03/23 protocol.h: move definition of DEFAULT_GIT_PORT from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  4. 02/23 symlinks.h: move declarations for symlinks.c functions from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  5. 01/23 treewide: be explicit about dependence on strbuf.hElijah Newren via GitGitGadget, Apr 16, 2023
  6. 04/23 packfile.h: move pack_window and pack_entry from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  7. 05/23 server-info.h: move declarations for server-info.c functions from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  8. 07/23 base85.h: move declarations for base85.c functions from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  9. 08/23 pkt-line.h: move declarations for pkt-line.c functions from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  10. 09/23 match-trees.h: move declarations for match-trees.c functions from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  11. 11/23 versioncmp.h: move declarations for versioncmp.c functions from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  12. 10/23 ws.h: move declarations for ws.c functions from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  13. 12/23 dir.h: move DTYPE defines from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  14. 15/23 cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.cElijah Newren via GitGitGadget, Apr 16, 2023
  15. 16/23 cache,tree: move basic name compare functions from read-cache to treeElijah Newren via GitGitGadget, Apr 16, 2023
  16. 18/23 cache.h: remove unnecessary headersElijah Newren via GitGitGadget, Apr 16, 2023
  17. 13/23 tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  18. 19/23 fsmonitor: reduce includes of cache.hElijah Newren via GitGitGadget, Apr 16, 2023
  19. 17/23 treewide: remove cache.h inclusion due to previous changesElijah Newren via GitGitGadget, Apr 16, 2023
  20. 14/23 hash.h, repository.h: reverse the order of these dependenciesElijah Newren via GitGitGadget, Apr 16, 2023
  21. Derrick StoleeApr 17, 2023
  22. Elijah NewrenApr 18, 2023
  23. Junio C HamanoApr 18, 2023
  24. Elijah NewrenApr 20, 2023
  25. Derrick StoleeApr 20, 2023
  26. Junio C HamanoApr 20, 2023
  27. Glen ChooApr 20, 2023
  28. 21/23 object-store.h: reduce unnecessary includesElijah Newren via GitGitGadget, Apr 16, 2023
  29. 20/23 commit.h: reduce unnecessary includesElijah Newren via GitGitGadget, Apr 16, 2023
  30. 22/23 diff.h: reduce unnecessary includesElijah Newren via GitGitGadget, Apr 16, 2023
  31. 23/23 reftable: ensure git-compat-util.h is the first (indirect) includeElijah Newren via GitGitGadget, Apr 16, 2023
  32. Derrick StoleeApr 17, 2023
  33. Elijah NewrenApr 18, 2023
  34. 00/22 Header cleanups (more splitting of cache.h and simplifying a few other deps)Elijah Newren via GitGitGadget, Apr 22, 2023
  35. 01/22 treewide: be explicit about dependence on strbuf.hElijah Newren via GitGitGadget, Apr 22, 2023
  36. 02/22 symlinks.h: move declarations for symlinks.c functions from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  37. 03/22 packfile.h: move pack_window and pack_entry from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  38. 07/22 pkt-line.h: move declarations for pkt-line.c functions from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  39. 04/22 server-info.h: move declarations for server-info.c functions from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  40. 05/22 copy.h: move declarations for copy.c functions from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  41. 08/22 match-trees.h: move declarations for match-trees.c functions from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  42. 06/22 base85.h: move declarations for base85.c functions from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  43. 09/22 ws.h: move declarations for ws.c functions from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  44. 10/22 versioncmp.h: move declarations for versioncmp.c functions from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  45. 11/22 dir.h: move DTYPE defines from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  46. 14/22 cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.cElijah Newren via GitGitGadget, Apr 22, 2023
  47. 15/22 cache,tree: move basic name compare functions from read-cache to treeElijah Newren via GitGitGadget, Apr 22, 2023
  48. 12/22 tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  49. Ævar Arnfjörð BjarmasonMay 1, 2023
  50. Junio C HamanoMay 1, 2023
  51. Elijah NewrenMay 2, 2023
  52. Elijah NewrenMay 2, 2023
  53. Junio C HamanoMay 2, 2023
  54. Elijah NewrenMay 2, 2023
  55. 16/22 treewide: remove cache.h inclusion due to previous changesElijah Newren via GitGitGadget, Apr 22, 2023
  56. Ævar Arnfjörð BjarmasonMay 1, 2023
  57. Elijah NewrenMay 2, 2023
  58. 17/22 cache.h: remove unnecessary headersElijah Newren via GitGitGadget, Apr 22, 2023
  59. Ævar Arnfjörð BjarmasonMay 1, 2023
  60. Elijah NewrenMay 2, 2023
  61. 18/22 fsmonitor: reduce includes of cache.hElijah Newren via GitGitGadget, Apr 22, 2023
  62. 20/22 object-store.h: reduce unnecessary includesElijah Newren via GitGitGadget, Apr 22, 2023
  63. Ævar Arnfjörð BjarmasonMay 1, 2023
  64. Elijah NewrenMay 2, 2023
  65. 13/22 hash-ll.h: split out of hash.h to remove dependency on repository.hElijah Newren via GitGitGadget, Apr 22, 2023
  66. Glen ChooApr 24, 2023
  67. Elijah NewrenApr 26, 2023
  68. Glen ChooApr 26, 2023
  69. Junio C HamanoApr 24, 2023
  70. Ævar Arnfjörð BjarmasonMay 1, 2023
  71. Elijah NewrenMay 2, 2023
  72. 19/22 commit.h: reduce unnecessary includesElijah Newren via GitGitGadget, Apr 22, 2023
  73. Ævar Arnfjörð BjarmasonMay 1, 2023
  74. Elijah NewrenMay 2, 2023
  75. 22/22 reftable: ensure git-compat-util.h is the first (indirect) includeElijah Newren via GitGitGadget, Apr 22, 2023
  76. 21/22 diff.h: reduce unnecessary includesElijah Newren via GitGitGadget, Apr 22, 2023
  77. Ævar Arnfjörð BjarmasonMay 1, 2023
  78. Derrick StoleeApr 24, 2023
  79. Junio C HamanoApr 24, 2023
  80. Glen ChooApr 26, 2023
  81. Junio C HamanoApr 26, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.