git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps)
@ 2023-04-16  3:03 Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 01/23] treewide: be explicit about dependence on strbuf.h Elijah Newren via GitGitGadget
                   ` (24 more replies)
  0 siblings, 25 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren

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

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

* [PATCH 01/23] treewide: be explicit about dependence on strbuf.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 02/23] symlinks.h: move declarations for symlinks.c functions from cache.h Elijah Newren via GitGitGadget
                   ` (23 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 color.c                       | 1 +
 common-main.c                 | 1 +
 credential.c                  | 1 +
 date.c                        | 1 +
 ll-merge.c                    | 1 +
 split-index.c                 | 1 +
 t/helper/test-mergesort.c     | 1 +
 t/helper/test-oid-array.c     | 1 +
 t/helper/test-oidtree.c       | 1 +
 t/helper/test-parse-options.c | 1 +
 t/helper/test-string-list.c   | 1 +
 wrapper.c                     | 1 +
 ws.c                          | 1 +
 13 files changed, 13 insertions(+)

diff --git a/color.c b/color.c
index 6031998d3ea..f8a25ca807b 100644
--- a/color.c
+++ b/color.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "pager.h"
+#include "strbuf.h"
 
 static int git_use_color_default = GIT_COLOR_AUTO;
 int color_stdout_is_tty = -1;
diff --git a/common-main.c b/common-main.c
index f3193173535..601a875e2fb 100644
--- a/common-main.c
+++ b/common-main.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "attr.h"
 #include "setup.h"
+#include "strbuf.h"
 #include "trace2.h"
 
 /*
diff --git a/credential.c b/credential.c
index e6417bf8804..42194efc9e0 100644
--- a/credential.c
+++ b/credential.c
@@ -8,6 +8,7 @@
 #include "url.h"
 #include "prompt.h"
 #include "sigchain.h"
+#include "strbuf.h"
 #include "urlmatch.h"
 #include "git-compat-util.h"
 
diff --git a/date.c b/date.c
index e944c8905af..bc030da012f 100644
--- a/date.c
+++ b/date.c
@@ -8,6 +8,7 @@
 #include "date.h"
 #include "gettext.h"
 #include "pager.h"
+#include "strbuf.h"
 
 /*
  * This is like mktime, but without normalization of tm_wday and tm_yday.
diff --git a/ll-merge.c b/ll-merge.c
index 28bc94c45d6..85517e668e3 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -12,6 +12,7 @@
 #include "run-command.h"
 #include "ll-merge.h"
 #include "quote.h"
+#include "strbuf.h"
 #include "wrapper.h"
 
 struct ll_merge_driver;
diff --git a/split-index.c b/split-index.c
index 5602b74994b..3fc4e91485a 100644
--- a/split-index.c
+++ b/split-index.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "mem-pool.h"
 #include "split-index.h"
+#include "strbuf.h"
 #include "ewah/ewok.h"
 
 struct split_index *init_split_index(struct index_state *istate)
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
index 737e0c52358..3aabae6c1c4 100644
--- a/t/helper/test-mergesort.c
+++ b/t/helper/test-mergesort.c
@@ -2,6 +2,7 @@
 #include "cache.h"
 #include "mem-pool.h"
 #include "mergesort.h"
+#include "strbuf.h"
 
 static uint32_t minstd_rand(uint32_t *state)
 {
diff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c
index fd6f73ea03b..ea3bf278984 100644
--- a/t/helper/test-oid-array.c
+++ b/t/helper/test-oid-array.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "oid-array.h"
 #include "setup.h"
+#include "strbuf.h"
 
 static int print_oid(const struct object_id *oid, void *data)
 {
diff --git a/t/helper/test-oidtree.c b/t/helper/test-oidtree.c
index edcb7e9f448..796c9811e0f 100644
--- a/t/helper/test-oidtree.c
+++ b/t/helper/test-oidtree.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "oidtree.h"
 #include "setup.h"
+#include "strbuf.h"
 
 static enum cb_next print_oid(const struct object_id *oid, void *data)
 {
diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
index 506835521a4..20a81a1eb21 100644
--- a/t/helper/test-parse-options.c
+++ b/t/helper/test-parse-options.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "parse-options.h"
+#include "strbuf.h"
 #include "string-list.h"
 #include "trace2.h"
 
diff --git a/t/helper/test-string-list.c b/t/helper/test-string-list.c
index 2123dda85bf..959f27c74c6 100644
--- a/t/helper/test-string-list.c
+++ b/t/helper/test-string-list.c
@@ -1,5 +1,6 @@
 #include "test-tool.h"
 #include "cache.h"
+#include "strbuf.h"
 #include "string-list.h"
 
 /*
diff --git a/wrapper.c b/wrapper.c
index c130d7518bf..e80f83498d8 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "strbuf.h"
 #include "trace2.h"
 #include "wrapper.h"
 
diff --git a/ws.c b/ws.c
index da3d0e28cbb..036ccb8ee9d 100644
--- a/ws.c
+++ b/ws.c
@@ -5,6 +5,7 @@
  */
 #include "cache.h"
 #include "attr.h"
+#include "strbuf.h"
 
 static struct whitespace_rule {
 	const char *rule_name;
-- 
gitgitgadget


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

* [PATCH 02/23] symlinks.h: move declarations for symlinks.c functions from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 01/23] treewide: be explicit about dependence on strbuf.h Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 03/23] protocol.h: move definition of DEFAULT_GIT_PORT " Elijah Newren via GitGitGadget
                   ` (22 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 apply.c                |  1 +
 builtin/checkout.c     |  1 +
 builtin/update-index.c |  1 +
 cache.h                | 22 ----------------------
 compat/mingw.c         |  1 +
 diff-lib.c             |  1 +
 dir.c                  |  1 +
 entry.c                |  1 +
 merge-recursive.c      |  1 +
 parallel-checkout.c    |  1 +
 pathspec.c             |  1 +
 preload-index.c        |  1 +
 read-cache.c           |  1 +
 run-command.c          |  1 +
 symlinks.c             |  3 ++-
 symlinks.h             | 28 ++++++++++++++++++++++++++++
 unpack-trees.c         |  1 +
 17 files changed, 44 insertions(+), 23 deletions(-)
 create mode 100644 symlinks.h

diff --git a/apply.c b/apply.c
index 2868cef5ddd..efe2dcb0e62 100644
--- a/apply.c
+++ b/apply.c
@@ -30,6 +30,7 @@
 #include "apply.h"
 #include "entry.h"
 #include "setup.h"
+#include "symlinks.h"
 #include "wrapper.h"
 
 struct gitdiff_data {
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 6f5d82ed3d3..715eeb5048f 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -28,6 +28,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "symlinks.h"
 #include "trace2.h"
 #include "tree.h"
 #include "tree-walk.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 33b00cef151..58bbc80db77 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -23,6 +23,7 @@
 #include "dir.h"
 #include "setup.h"
 #include "split-index.h"
+#include "symlinks.h"
 #include "fsmonitor.h"
 #include "write-or-die.h"
 
diff --git a/cache.h b/cache.h
index 2f21704da9e..e225964b3ea 100644
--- a/cache.h
+++ b/cache.h
@@ -614,28 +614,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-struct cache_def {
-	struct strbuf path;
-	int flags;
-	int track_flags;
-	int prefix_len_stat_func;
-};
-#define CACHE_DEF_INIT { \
-	.path = STRBUF_INIT, \
-}
-static inline void cache_def_clear(struct cache_def *cache)
-{
-	strbuf_release(&cache->path);
-}
-
-int has_symlink_leading_path(const char *name, int len);
-int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
-int check_leading_path(const char *name, int len, int warn_on_lstat_err);
-int has_dirs_only_path(const char *name, int len, int prefix_len);
-void invalidate_lstat_cache(void);
-void schedule_dir_for_removal(const char *name, int len);
-void remove_scheduled_dirs(void);
-
 struct pack_window {
 	struct pack_window *next;
 	unsigned char *base;
diff --git a/compat/mingw.c b/compat/mingw.c
index abbc3faf32f..d06cdc6254f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -13,6 +13,7 @@
 #include "../config.h"
 #include "../environment.h"
 #include "../trace2.h"
+#include "../symlinks.h"
 #include "../wrapper.h"
 #include "dir.h"
 #include "gettext.h"
diff --git a/diff-lib.c b/diff-lib.c
index d292405a262..60e979dc1bd 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -14,6 +14,7 @@
 #include "unpack-trees.h"
 #include "refs.h"
 #include "submodule.h"
+#include "symlinks.h"
 #include "trace.h"
 #include "dir.h"
 #include "fsmonitor.h"
diff --git a/dir.c b/dir.c
index aa840995c40..ed262fa6e43 100644
--- a/dir.c
+++ b/dir.c
@@ -25,6 +25,7 @@
 #include "fsmonitor.h"
 #include "setup.h"
 #include "submodule-config.h"
+#include "symlinks.h"
 #include "trace2.h"
 #include "wrapper.h"
 
diff --git a/entry.c b/entry.c
index d89e61fa641..91a540bd29f 100644
--- a/entry.c
+++ b/entry.c
@@ -7,6 +7,7 @@
 #include "hex.h"
 #include "streaming.h"
 #include "submodule.h"
+#include "symlinks.h"
 #include "progress.h"
 #include "fsmonitor.h"
 #include "entry.h"
diff --git a/merge-recursive.c b/merge-recursive.c
index 9875bdb11cb..d4d2ab05b2e 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -30,6 +30,7 @@
 #include "string-list.h"
 #include "submodule-config.h"
 #include "submodule.h"
+#include "symlinks.h"
 #include "tag.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 50fd7fe31ef..7f0569cc930 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -10,6 +10,7 @@
 #include "run-command.h"
 #include "sigchain.h"
 #include "streaming.h"
+#include "symlinks.h"
 #include "thread-utils.h"
 #include "trace2.h"
 #include "wrapper.h"
diff --git a/pathspec.c b/pathspec.c
index 6972d515f0c..ec335a214e2 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -8,6 +8,7 @@
 #include "attr.h"
 #include "setup.h"
 #include "strvec.h"
+#include "symlinks.h"
 #include "quote.h"
 
 /*
diff --git a/preload-index.c b/preload-index.c
index 4abf9c983b2..7a26b08c213 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "thread-utils.h"
 #include "repository.h"
+#include "symlinks.h"
 #include "trace2.h"
 
 /*
diff --git a/read-cache.c b/read-cache.c
index f225bf44cd0..206c003e558 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -30,6 +30,7 @@
 #include "trace2.h"
 #include "varint.h"
 #include "split-index.h"
+#include "symlinks.h"
 #include "utf8.h"
 #include "fsmonitor.h"
 #include "thread-utils.h"
diff --git a/run-command.c b/run-command.c
index e64bb08a5bf..d4247d5fcc6 100644
--- a/run-command.c
+++ b/run-command.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "sigchain.h"
 #include "strvec.h"
+#include "symlinks.h"
 #include "thread-utils.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/symlinks.c b/symlinks.c
index 27ecc93693b..b29e340c2da 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -1,6 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "setup.h"
+#include "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/symlinks.h
new file mode 100644
index 00000000000..7ae3d5b8569
--- /dev/null
+++ b/symlinks.h
@@ -0,0 +1,28 @@
+#ifndef SYMLINKS_H
+#define SYMLINKS_H
+
+#include "strbuf.h"
+
+struct cache_def {
+	struct strbuf path;
+	int flags;
+	int track_flags;
+	int prefix_len_stat_func;
+};
+#define CACHE_DEF_INIT { \
+	.path = STRBUF_INIT, \
+}
+static inline void cache_def_clear(struct cache_def *cache)
+{
+	strbuf_release(&cache->path);
+}
+
+int has_symlink_leading_path(const char *name, int len);
+int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
+int check_leading_path(const char *name, int len, int warn_on_lstat_err);
+int has_dirs_only_path(const char *name, int len, int prefix_len);
+void invalidate_lstat_cache(void);
+void schedule_dir_for_removal(const char *name, int len);
+void remove_scheduled_dirs(void);
+
+#endif /* SYMLINKS_H */
diff --git a/unpack-trees.c b/unpack-trees.c
index c6de2ca5a7e..e8a5295e737 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -18,6 +18,7 @@
 #include "sparse-index.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "symlinks.h"
 #include "trace2.h"
 #include "fsmonitor.h"
 #include "object-store.h"
-- 
gitgitgadget


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

* [PATCH 03/23] protocol.h: move definition of DEFAULT_GIT_PORT from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 01/23] treewide: be explicit about dependence on strbuf.h Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 02/23] symlinks.h: move declarations for symlinks.c functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 04/23] packfile.h: move pack_window and pack_entry " Elijah Newren via GitGitGadget
                   ` (21 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h    | 21 ---------------------
 daemon.c   |  1 +
 protocol.h | 21 +++++++++++++++++++++
 3 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/cache.h b/cache.h
index e225964b3ea..ffec289dc5d 100644
--- a/cache.h
+++ b/cache.h
@@ -39,27 +39,6 @@
 #define S_DIFFTREE_IFXMIN_NEQ	0x80000000
 
 
-/*
- * Intensive research over the course of many years has shown that
- * port 9418 is totally unused by anything else. Or
- *
- *	Your search - "port 9418" - did not match any documents.
- *
- * as www.google.com puts it.
- *
- * This port has been properly assigned for git use by IANA:
- * git (Assigned-9418) [I06-050728-0001].
- *
- *	git  9418/tcp   git pack transfer service
- *	git  9418/udp   git pack transfer service
- *
- * with Linus Torvalds <torvalds@osdl.org> as the point of
- * contact. September 2005.
- *
- * See http://www.iana.org/assignments/port-numbers
- */
-#define DEFAULT_GIT_PORT 9418
-
 /*
  * Basic data structures for the directory cache
  */
diff --git a/daemon.c b/daemon.c
index db8a31a6ea2..75c3c064574 100644
--- a/daemon.c
+++ b/daemon.c
@@ -4,6 +4,7 @@
 #include "config.h"
 #include "environment.h"
 #include "pkt-line.h"
+#include "protocol.h"
 #include "run-command.h"
 #include "setup.h"
 #include "strbuf.h"
diff --git a/protocol.h b/protocol.h
index cef1a4a01c7..de66bf80f84 100644
--- a/protocol.h
+++ b/protocol.h
@@ -1,6 +1,27 @@
 #ifndef PROTOCOL_H
 #define PROTOCOL_H
 
+/*
+ * Intensive research over the course of many years has shown that
+ * port 9418 is totally unused by anything else. Or
+ *
+ *	Your search - "port 9418" - did not match any documents.
+ *
+ * as www.google.com puts it.
+ *
+ * This port has been properly assigned for git use by IANA:
+ * git (Assigned-9418) [I06-050728-0001].
+ *
+ *	git  9418/tcp   git pack transfer service
+ *	git  9418/udp   git pack transfer service
+ *
+ * with Linus Torvalds <torvalds@osdl.org> as the point of
+ * contact. September 2005.
+ *
+ * See http://www.iana.org/assignments/port-numbers
+ */
+#define DEFAULT_GIT_PORT 9418
+
 enum protocol_version {
 	protocol_unknown_version = -1,
 	protocol_v0 = 0,
-- 
gitgitgadget


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

* [PATCH 04/23] packfile.h: move pack_window and pack_entry from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (2 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 03/23] protocol.h: move definition of DEFAULT_GIT_PORT " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 05/23] server-info.h: move declarations for server-info.c functions " Elijah Newren via GitGitGadget
                   ` (20 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h                   | 14 --------------
 packfile.h                | 16 ++++++++++++++--
 t/helper/test-read-midx.c |  1 +
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/cache.h b/cache.h
index ffec289dc5d..ffb9028f015 100644
--- a/cache.h
+++ b/cache.h
@@ -593,20 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-struct pack_window {
-	struct pack_window *next;
-	unsigned char *base;
-	off_t offset;
-	size_t len;
-	unsigned int last_used;
-	unsigned int inuse_cnt;
-};
-
-struct pack_entry {
-	off_t offset;
-	struct packed_git *p;
-};
-
 /* Dumb servers support */
 int update_server_info(int);
 
diff --git a/packfile.h b/packfile.h
index 665603b696a..c3692308b8d 100644
--- a/packfile.h
+++ b/packfile.h
@@ -6,10 +6,22 @@
 
 /* in object-store.h */
 struct packed_git;
-struct pack_entry;
-struct pack_window;
 struct object_info;
 
+struct pack_window {
+	struct pack_window *next;
+	unsigned char *base;
+	off_t offset;
+	size_t len;
+	unsigned int last_used;
+	unsigned int inuse_cnt;
+};
+
+struct pack_entry {
+	off_t offset;
+	struct packed_git *p;
+};
+
 /*
  * Generate the filename to be used for a pack file with checksum "sha1" and
  * extension "ext". The result is written into the strbuf "buf", overwriting
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index 05c4f2b2625..b32abff7f11 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -5,6 +5,7 @@
 #include "repository.h"
 #include "object-store.h"
 #include "pack-bitmap.h"
+#include "packfile.h"
 #include "setup.h"
 
 static int read_midx_file(const char *object_dir, int show_objects)
-- 
gitgitgadget


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

* [PATCH 05/23] server-info.h: move declarations for server-info.c functions from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (3 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 04/23] packfile.h: move pack_window and pack_entry " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 06/23] copy.h: move declarations for copy.c " Elijah Newren via GitGitGadget
                   ` (19 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/receive-pack.c       | 1 +
 builtin/repack.c             | 1 +
 builtin/update-server-info.c | 1 +
 cache.h                      | 3 ---
 server-info.c                | 3 ++-
 server-info.h                | 7 +++++++
 6 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 server-info.h

diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 7d921170f1c..dae99e4554d 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -33,6 +33,7 @@
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
+#include "server-info.h"
 #include "trace.h"
 #include "trace2.h"
 #include "worktree.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index df4d8e0f0ba..bed2c2aaafb 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -7,6 +7,7 @@
 #include "hex.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "server-info.h"
 #include "sigchain.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c
index e7bff27ae40..19dce3c0655 100644
--- a/builtin/update-server-info.c
+++ b/builtin/update-server-info.c
@@ -3,6 +3,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "server-info.h"
 
 static const char * const update_server_info_usage[] = {
 	"git update-server-info [-f | --force]",
diff --git a/cache.h b/cache.h
index ffb9028f015..2eb4546473f 100644
--- a/cache.h
+++ b/cache.h
@@ -593,9 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-/* Dumb servers support */
-int update_server_info(int);
-
 #define COPY_READ_ERROR (-2)
 #define COPY_WRITE_ERROR (-3)
 int copy_fd(int ifd, int ofd);
diff --git a/server-info.c b/server-info.c
index 68098ddd1ad..55aa04f00ab 100644
--- a/server-info.c
+++ b/server-info.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "environment.h"
@@ -11,6 +11,7 @@
 #include "packfile.h"
 #include "object-file.h"
 #include "object-store.h"
+#include "server-info.h"
 #include "strbuf.h"
 #include "wrapper.h"
 
diff --git a/server-info.h b/server-info.h
new file mode 100644
index 00000000000..13bbde2c55f
--- /dev/null
+++ b/server-info.h
@@ -0,0 +1,7 @@
+#ifndef SERVER_INFO_H
+#define SERVER_INFO_H
+
+/* Dumb servers support */
+int update_server_info(int);
+
+#endif /* SERVER_INFO_H */
-- 
gitgitgadget


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

* [PATCH 06/23] copy.h: move declarations for copy.c functions from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (4 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 05/23] server-info.h: move declarations for server-info.c functions " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 07/23] base85.h: move declarations for base85.c " Elijah Newren via GitGitGadget
                   ` (18 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/bisect.c     |  1 +
 builtin/clone.c      |  1 +
 builtin/difftool.c   |  1 +
 builtin/init-db.c    |  1 +
 builtin/worktree.c   |  1 +
 bundle-uri.c         |  1 +
 cache.h              |  6 ------
 convert.c            |  1 +
 copy.c               |  1 +
 copy.h               | 10 ++++++++++
 pkt-line.c           |  1 +
 refs/files-backend.c |  1 +
 rerere.c             |  1 +
 sequencer.c          |  1 +
 14 files changed, 22 insertions(+), 6 deletions(-)
 create mode 100644 copy.h

diff --git a/builtin/bisect.c b/builtin/bisect.c
index 4b2143d4557..4812450c393 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "cache.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 4ed0a1d5aad..017ebc3faa8 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -13,6 +13,7 @@
 #include "abspath.h"
 #include "advice.h"
 #include "config.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 3ffb0524be7..409507983f2 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -15,6 +15,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "config.h"
+#include "copy.h"
 #include "builtin.h"
 #include "run-command.h"
 #include "environment.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 6183f3fb3ff..cda6ee75eb5 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -6,6 +6,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "config.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "refs.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 0621f6f708e..0b411e9deee 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "checkout.h"
 #include "config.h"
+#include "copy.h"
 #include "builtin.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/bundle-uri.c b/bundle-uri.c
index 1ff1cf51dad..6d44662ee1f 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "bundle-uri.h"
 #include "bundle.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "object-store.h"
diff --git a/cache.h b/cache.h
index 2eb4546473f..2b661764794 100644
--- a/cache.h
+++ b/cache.h
@@ -593,12 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-#define COPY_READ_ERROR (-2)
-#define COPY_WRITE_ERROR (-3)
-int copy_fd(int ifd, int ofd);
-int copy_file(const char *dst, const char *src, int mode);
-int copy_file_with_time(const char *dst, const char *src, int mode);
-
 /* base85 */
 int decode_85(char *dst, const char *line, int linelen);
 void encode_85(char *buf, const unsigned char *data, int bytes);
diff --git a/convert.c b/convert.c
index 5a2ea5308d6..7cf7bd0c883 100644
--- a/convert.c
+++ b/convert.c
@@ -2,6 +2,7 @@
 #include "advice.h"
 #include "config.h"
 #include "convert.h"
+#include "copy.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/copy.c b/copy.c
index c3250f08221..db6b615c188 100644
--- a/copy.c
+++ b/copy.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "copy.h"
 #include "wrapper.h"
 
 int copy_fd(int ifd, int ofd)
diff --git a/copy.h b/copy.h
new file mode 100644
index 00000000000..2af77cba864
--- /dev/null
+++ b/copy.h
@@ -0,0 +1,10 @@
+#ifndef COPY_H
+#define COPY_H
+
+#define COPY_READ_ERROR (-2)
+#define COPY_WRITE_ERROR (-3)
+int copy_fd(int ifd, int ofd);
+int copy_file(const char *dst, const char *src, int mode);
+int copy_file_with_time(const char *dst, const char *src, int mode);
+
+#endif /* COPY_H */
diff --git a/pkt-line.c b/pkt-line.c
index 3561d853584..8b5fa788517 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "copy.h"
 #include "pkt-line.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index d0581ee41ac..1128a9af292 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1,5 +1,6 @@
 #include "../cache.h"
 #include "../config.h"
+#include "../copy.h"
 #include "../environment.h"
 #include "../gettext.h"
 #include "../hex.h"
diff --git a/rerere.c b/rerere.c
index 7abc94bf444..e968d413d65 100644
--- a/rerere.c
+++ b/rerere.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "copy.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
diff --git a/sequencer.c b/sequencer.c
index fcca3b81447..c16df514434 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3,6 +3,7 @@
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-- 
gitgitgadget


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

* [PATCH 07/23] base85.h: move declarations for base85.c functions from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (5 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 06/23] copy.h: move declarations for copy.c " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 08/23] pkt-line.h: move declarations for pkt-line.c " Elijah Newren via GitGitGadget
                   ` (17 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 apply.c  | 1 +
 base85.c | 3 ++-
 base85.h | 7 +++++++
 cache.h  | 4 ----
 diff.c   | 1 +
 5 files changed, 11 insertions(+), 5 deletions(-)
 create mode 100644 base85.h

diff --git a/apply.c b/apply.c
index efe2dcb0e62..a65a354eef5 100644
--- a/apply.c
+++ b/apply.c
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "alloc.h"
+#include "base85.h"
 #include "config.h"
 #include "object-store.h"
 #include "blob.h"
diff --git a/base85.c b/base85.c
index 5ca601ee14f..bbacdca31b3 100644
--- a/base85.c
+++ b/base85.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "base85.h"
 
 #undef DEBUG_85
 
diff --git a/base85.h b/base85.h
new file mode 100644
index 00000000000..c835086e093
--- /dev/null
+++ b/base85.h
@@ -0,0 +1,7 @@
+#ifndef BASE85_H
+#define BASE85_H
+
+int decode_85(char *dst, const char *line, int linelen);
+void encode_85(char *buf, const unsigned char *data, int bytes);
+
+#endif /* BASE85_H */
diff --git a/cache.h b/cache.h
index 2b661764794..b89f4c59802 100644
--- a/cache.h
+++ b/cache.h
@@ -593,10 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-/* base85 */
-int decode_85(char *dst, const char *line, int linelen);
-void encode_85(char *buf, const unsigned char *data, int bytes);
-
 /* pkt-line.c */
 void packet_trace_identity(const char *prog);
 
diff --git a/diff.c b/diff.c
index fa86d023196..e697f78a645 100644
--- a/diff.c
+++ b/diff.c
@@ -4,6 +4,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "alloc.h"
+#include "base85.h"
 #include "config.h"
 #include "convert.h"
 #include "environment.h"
-- 
gitgitgadget


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

* [PATCH 08/23] pkt-line.h: move declarations for pkt-line.c functions from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (6 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 07/23] base85.h: move declarations for base85.c " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 09/23] match-trees.h: move declarations for match-trees.c " Elijah Newren via GitGitGadget
                   ` (16 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/bundle.c    | 1 +
 builtin/clone.c     | 1 +
 builtin/fetch.c     | 1 +
 builtin/ls-remote.c | 1 +
 builtin/push.c      | 1 +
 cache.h             | 3 ---
 pkt-line.h          | 2 ++
 7 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/builtin/bundle.c b/builtin/bundle.c
index e68fc83d943..584d905d965 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -4,6 +4,7 @@
 #include "setup.h"
 #include "strvec.h"
 #include "parse-options.h"
+#include "pkt-line.h"
 #include "cache.h"
 #include "bundle.h"
 
diff --git a/builtin/clone.c b/builtin/clone.c
index 017ebc3faa8..fa300f483e9 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -39,6 +39,7 @@
 #include "setup.h"
 #include "connected.h"
 #include "packfile.h"
+#include "pkt-line.h"
 #include "list-objects-filter-options.h"
 #include "hook.h"
 #include "bundle.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 61e8ac113b1..4fee2a62376 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -29,6 +29,7 @@
 #include "utf8.h"
 #include "packfile.h"
 #include "pager.h"
+#include "pkt-line.h"
 #include "list-objects-filter-options.h"
 #include "commit-reach.h"
 #include "branch.h"
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 11d9424804a..7972febf726 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "transport.h"
+#include "pkt-line.h"
 #include "ref-filter.h"
 #include "remote.h"
 #include "refs.h"
diff --git a/builtin/push.c b/builtin/push.c
index 6001e4ae0a4..7d2b0505aac 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -14,6 +14,7 @@
 #include "remote.h"
 #include "transport.h"
 #include "parse-options.h"
+#include "pkt-line.h"
 #include "submodule.h"
 #include "submodule-config.h"
 #include "send-pack.h"
diff --git a/cache.h b/cache.h
index b89f4c59802..fde782a96f0 100644
--- a/cache.h
+++ b/cache.h
@@ -593,9 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-/* pkt-line.c */
-void packet_trace_identity(const char *prog);
-
 /* add */
 /*
  * return 0 if success, 1 - if addition of a file failed and
diff --git a/pkt-line.h b/pkt-line.h
index 8e9846f3151..7c23a4bfaf7 100644
--- a/pkt-line.h
+++ b/pkt-line.h
@@ -246,4 +246,6 @@ void packet_writer_error(struct packet_writer *writer, const char *fmt, ...);
 void packet_writer_delim(struct packet_writer *writer);
 void packet_writer_flush(struct packet_writer *writer);
 
+void packet_trace_identity(const char *prog);
+
 #endif
-- 
gitgitgadget


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

* [PATCH 09/23] match-trees.h: move declarations for match-trees.c functions from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (7 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 08/23] pkt-line.h: move declarations for pkt-line.c " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 10/23] ws.h: move declarations for ws.c " Elijah Newren via GitGitGadget
                   ` (15 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h                     |  4 ----
 match-trees.c               |  1 +
 match-trees.h               | 10 ++++++++++
 merge-ort.c                 |  1 +
 merge-recursive.c           |  1 +
 t/helper/test-match-trees.c |  1 +
 6 files changed, 14 insertions(+), 4 deletions(-)
 create mode 100644 match-trees.h

diff --git a/cache.h b/cache.h
index fde782a96f0..0570f9ad07d 100644
--- a/cache.h
+++ b/cache.h
@@ -603,10 +603,6 @@ int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int
 /* diff.c */
 extern int diff_auto_refresh_index;
 
-/* match-trees.c */
-void shift_tree(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, int);
-void shift_tree_by(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, const char *);
-
 /*
  * whitespace rules.
  * used by both diff and apply
diff --git a/match-trees.c b/match-trees.c
index 5877fc64a8f..9b78d99507b 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "hex.h"
+#include "match-trees.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "object-store.h"
diff --git a/match-trees.h b/match-trees.h
new file mode 100644
index 00000000000..e3877acd583
--- /dev/null
+++ b/match-trees.h
@@ -0,0 +1,10 @@
+#ifndef MATCH_TREES_H
+#define MATCH_TREES_H
+
+struct object_id;
+struct repository;
+
+void shift_tree(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, int);
+void shift_tree_by(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, const char *);
+
+#endif /* MATCH_TREES_H */
diff --git a/merge-ort.c b/merge-ort.c
index 2c6a9ed9a41..65837db77f0 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -31,6 +31,7 @@
 #include "hex.h"
 #include "entry.h"
 #include "ll-merge.h"
+#include "match-trees.h"
 #include "mem-pool.h"
 #include "object-name.h"
 #include "object-store.h"
diff --git a/merge-recursive.c b/merge-recursive.c
index d4d2ab05b2e..8e87b6386d9 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -22,6 +22,7 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "match-trees.h"
 #include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 3808e1ac38b..a498fece7a3 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "hex.h"
+#include "match-trees.h"
 #include "object-name.h"
 #include "setup.h"
 #include "tree.h"
-- 
gitgitgadget


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

* [PATCH 10/23] ws.h: move declarations for ws.c functions from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (8 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 09/23] match-trees.h: move declarations for match-trees.c " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 11/23] versioncmp.h: move declarations for versioncmp.c " Elijah Newren via GitGitGadget
                   ` (14 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 apply.c       |  1 +
 cache.h       | 26 --------------------------
 config.c      |  1 +
 diff.c        |  1 +
 environment.c |  1 -
 ws.c          |  5 ++++-
 ws.h          | 33 +++++++++++++++++++++++++++++++++
 7 files changed, 40 insertions(+), 28 deletions(-)
 create mode 100644 ws.h

diff --git a/apply.c b/apply.c
index a65a354eef5..2de8bb203d7 100644
--- a/apply.c
+++ b/apply.c
@@ -32,6 +32,7 @@
 #include "entry.h"
 #include "setup.h"
 #include "symlinks.h"
+#include "ws.h"
 #include "wrapper.h"
 
 struct gitdiff_data {
diff --git a/cache.h b/cache.h
index 0570f9ad07d..dde275c9301 100644
--- a/cache.h
+++ b/cache.h
@@ -603,32 +603,6 @@ int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int
 /* diff.c */
 extern int diff_auto_refresh_index;
 
-/*
- * whitespace rules.
- * used by both diff and apply
- * last two digits are tab width
- */
-#define WS_BLANK_AT_EOL         0100
-#define WS_SPACE_BEFORE_TAB     0200
-#define WS_INDENT_WITH_NON_TAB  0400
-#define WS_CR_AT_EOL           01000
-#define WS_BLANK_AT_EOF        02000
-#define WS_TAB_IN_INDENT       04000
-#define WS_TRAILING_SPACE      (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF)
-#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8)
-#define WS_TAB_WIDTH_MASK        077
-/* All WS_* -- when extended, adapt diff.c emit_symbol */
-#define WS_RULE_MASK           07777
-extern unsigned whitespace_rule_cfg;
-unsigned whitespace_rule(struct index_state *, const char *);
-unsigned parse_whitespace_rule(const char *);
-unsigned ws_check(const char *line, int len, unsigned ws_rule);
-void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
-char *whitespace_error_string(unsigned ws);
-void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *);
-int ws_blank_line(const char *line, int len);
-#define ws_tab_width(rule)     ((rule) & WS_TAB_WIDTH_MASK)
-
 /* ls-files */
 void overlay_tree_on_index(struct index_state *istate,
 			   const char *tree_name, const char *prefix);
diff --git a/config.c b/config.c
index 9beba19b41c..97063a0743e 100644
--- a/config.c
+++ b/config.c
@@ -35,6 +35,7 @@
 #include "setup.h"
 #include "trace2.h"
 #include "worktree.h"
+#include "ws.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/diff.c b/diff.c
index e697f78a645..73d2ac03673 100644
--- a/diff.c
+++ b/diff.c
@@ -41,6 +41,7 @@
 #include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
+#include "ws.h"
 #include "wrapper.h"
 
 #ifdef NO_FAST_WORKING_DIRECTORY
diff --git a/environment.c b/environment.c
index 8a96997539a..541f0b19acf 100644
--- a/environment.c
+++ b/environment.c
@@ -67,7 +67,6 @@ int read_replace_refs = 1;
 enum eol core_eol = EOL_UNSET;
 int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
 char *check_roundtrip_encoding = "SHIFT-JIS";
-unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
diff --git a/ws.c b/ws.c
index 036ccb8ee9d..d356d4ec9ee 100644
--- a/ws.c
+++ b/ws.c
@@ -3,9 +3,12 @@
  *
  * Copyright (c) 2007 Junio C Hamano
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "attr.h"
 #include "strbuf.h"
+#include "ws.h"
+
+unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 
 static struct whitespace_rule {
 	const char *rule_name;
diff --git a/ws.h b/ws.h
new file mode 100644
index 00000000000..5ba676c5595
--- /dev/null
+++ b/ws.h
@@ -0,0 +1,33 @@
+#ifndef WS_H
+#define WS_H
+
+struct index_state;
+struct strbuf;
+
+/*
+ * whitespace rules.
+ * used by both diff and apply
+ * last two digits are tab width
+ */
+#define WS_BLANK_AT_EOL         0100
+#define WS_SPACE_BEFORE_TAB     0200
+#define WS_INDENT_WITH_NON_TAB  0400
+#define WS_CR_AT_EOL           01000
+#define WS_BLANK_AT_EOF        02000
+#define WS_TAB_IN_INDENT       04000
+#define WS_TRAILING_SPACE      (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF)
+#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8)
+#define WS_TAB_WIDTH_MASK        077
+/* All WS_* -- when extended, adapt diff.c emit_symbol */
+#define WS_RULE_MASK           07777
+extern unsigned whitespace_rule_cfg;
+unsigned whitespace_rule(struct index_state *, const char *);
+unsigned parse_whitespace_rule(const char *);
+unsigned ws_check(const char *line, int len, unsigned ws_rule);
+void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
+char *whitespace_error_string(unsigned ws);
+void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *);
+int ws_blank_line(const char *line, int len);
+#define ws_tab_width(rule)     ((rule) & WS_TAB_WIDTH_MASK)
+
+#endif /* WS_H */
-- 
gitgitgadget


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

* [PATCH 11/23] versioncmp.h: move declarations for versioncmp.c functions from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (9 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 10/23] ws.h: move declarations for ws.c " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 12/23] dir.h: move DTYPE defines " Elijah Newren via GitGitGadget
                   ` (13 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h      | 2 --
 ref-filter.c | 1 +
 versioncmp.c | 3 ++-
 versioncmp.h | 6 ++++++
 4 files changed, 9 insertions(+), 3 deletions(-)
 create mode 100644 versioncmp.h

diff --git a/cache.h b/cache.h
index dde275c9301..6955745cccd 100644
--- a/cache.h
+++ b/cache.h
@@ -648,6 +648,4 @@ int stat_validity_check(struct stat_validity *sv, const char *path);
  */
 void stat_validity_update(struct stat_validity *sv, int fd);
 
-int versioncmp(const char *s1, const char *s2);
-
 #endif /* CACHE_H */
diff --git a/ref-filter.c b/ref-filter.c
index 57a5884aec7..5387f79be6d 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -19,6 +19,7 @@
 #include "revision.h"
 #include "utf8.h"
 #include "version.h"
+#include "versioncmp.h"
 #include "trailer.h"
 #include "wt-status.h"
 #include "commit-slab.h"
diff --git a/versioncmp.c b/versioncmp.c
index 069ee94a4d7..9b21ec142dd 100644
--- a/versioncmp.c
+++ b/versioncmp.c
@@ -1,6 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "string-list.h"
+#include "versioncmp.h"
 
 /*
  * versioncmp(): copied from string/strverscmp.c in glibc commit
diff --git a/versioncmp.h b/versioncmp.h
new file mode 100644
index 00000000000..879b510e82a
--- /dev/null
+++ b/versioncmp.h
@@ -0,0 +1,6 @@
+#ifndef VERSIONCMP_H
+#define VERSIONCMP_H
+
+int versioncmp(const char *s1, const char *s2);
+
+#endif /* VERSIONCMP_H */
-- 
gitgitgadget


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

* [PATCH 12/23] dir.h: move DTYPE defines from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (10 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 11/23] versioncmp.h: move declarations for versioncmp.c " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 13/23] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define " Elijah Newren via GitGitGadget
                   ` (12 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h | 14 --------------
 dir.h   | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/cache.h b/cache.h
index 6955745cccd..ad741e70bc2 100644
--- a/cache.h
+++ b/cache.h
@@ -10,20 +10,6 @@
 #include "object.h"
 #include "statinfo.h"
 
-#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
-#define DTYPE(de)	((de)->d_type)
-#else
-#undef DT_UNKNOWN
-#undef DT_DIR
-#undef DT_REG
-#undef DT_LNK
-#define DT_UNKNOWN	0
-#define DT_DIR		1
-#define DT_REG		2
-#define DT_LNK		3
-#define DTYPE(de)	DT_UNKNOWN
-#endif
-
 /*
  * Some mode bits are also used internally for computations.
  *
diff --git a/dir.h b/dir.h
index 3d6c87387e9..79b85a01ee4 100644
--- a/dir.h
+++ b/dir.h
@@ -640,4 +640,19 @@ static inline int starts_with_dot_dot_slash_native(const char *const path)
 
 	return path_match_flags(path, what | PATH_MATCH_NATIVE);
 }
+
+#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
+#define DTYPE(de)	((de)->d_type)
+#else
+#undef DT_UNKNOWN
+#undef DT_DIR
+#undef DT_REG
+#undef DT_LNK
+#define DT_UNKNOWN	0
+#define DT_DIR		1
+#define DT_REG		2
+#define DT_LNK		3
+#define DTYPE(de)	DT_UNKNOWN
+#endif
+
 #endif
-- 
gitgitgadget


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

* [PATCH 13/23] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (11 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 12/23] dir.h: move DTYPE defines " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies Elijah Newren via GitGitGadget
                   ` (11 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

S_DIFFTREE_IFXMIN_NEQ is *only* used in tree-diff.c, so there is no
point exposing it in cache.h.  Move it to tree-diff.c.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h     | 15 ---------------
 tree-diff.c | 13 +++++++++++++
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/cache.h b/cache.h
index ad741e70bc2..7a46f300d9b 100644
--- a/cache.h
+++ b/cache.h
@@ -10,21 +10,6 @@
 #include "object.h"
 #include "statinfo.h"
 
-/*
- * Some mode bits are also used internally for computations.
- *
- * They *must* not overlap with any valid modes, and they *must* not be emitted
- * to outside world - i.e. appear on disk or network. In other words, it's just
- * temporary fields, which we internally use, but they have to stay in-house.
- *
- * ( such approach is valid, as standard S_IF* fits into 16 bits, and in Git
- *   codebase mode is `unsigned int` which is assumed to be at least 32 bits )
- */
-
-/* used internally in tree-diff */
-#define S_DIFFTREE_IFXMIN_NEQ	0x80000000
-
-
 /*
  * Basic data structures for the directory cache
  */
diff --git a/tree-diff.c b/tree-diff.c
index 69031d7cbae..a76e6dae619 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -6,6 +6,19 @@
 #include "diffcore.h"
 #include "tree.h"
 
+/*
+ * Some mode bits are also used internally for computations.
+ *
+ * They *must* not overlap with any valid modes, and they *must* not be emitted
+ * to outside world - i.e. appear on disk or network. In other words, it's just
+ * temporary fields, which we internally use, but they have to stay in-house.
+ *
+ * ( such approach is valid, as standard S_IF* fits into 16 bits, and in Git
+ *   codebase mode is `unsigned int` which is assumed to be at least 32 bits )
+ */
+
+#define S_DIFFTREE_IFXMIN_NEQ	0x80000000
+
 /*
  * internal mode marker, saying a tree entry != entry of tp[imin]
  * (see ll_diff_tree_paths for what it means there)
-- 
gitgitgadget


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

* [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (12 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 13/23] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-17 20:59   ` Derrick Stolee
  2023-04-16  3:03 ` [PATCH 15/23] cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c Elijah Newren via GitGitGadget
                   ` (10 subsequent siblings)
  24 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Previously, hash.h depended upon and included repository.h, due to
the definition and use of the_hash_algo (defined as
the_repository->hash_algo).  Move this #define, and the associated
inline functions that depend upon it, from hash.h to repository.h.
Due to that movement, reverse the dependencies so repository.h includes
hash.h.

This allows hash.h and object.h to be fairly small, minimal headers.  It
also exposes a lot of hidden dependencies on both path.h (which was
brought in by repository.h) and repository.h (which was previously
implicitly brought in by object.h).

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 alloc.c                                      |  1 +
 branch.c                                     |  1 +
 builtin/apply.c                              |  1 +
 builtin/archive.c                            |  1 +
 builtin/bundle.c                             |  1 +
 builtin/check-attr.c                         |  1 +
 builtin/check-ignore.c                       |  1 +
 builtin/checkout-index.c                     |  1 +
 builtin/clean.c                              |  1 +
 builtin/config.c                             |  1 +
 builtin/credential-cache.c                   |  1 +
 builtin/credential-store.c                   |  1 +
 builtin/for-each-repo.c                      |  2 +
 builtin/help.c                               |  1 +
 builtin/init-db.c                            |  1 +
 builtin/merge-index.c                        |  1 +
 builtin/merge-recursive.c                    |  1 +
 builtin/mv.c                                 |  1 +
 builtin/push.c                               |  1 +
 builtin/read-tree.c                          |  1 +
 builtin/rerere.c                             |  1 +
 builtin/rm.c                                 |  1 +
 builtin/show-branch.c                        |  1 +
 builtin/show-index.c                         |  1 +
 builtin/update-index.c                       |  1 +
 builtin/update-ref.c                         |  1 +
 builtin/upload-archive.c                     |  1 +
 builtin/worktree.c                           |  1 +
 checkout.c                                   |  1 +
 chunk-format.c                               |  1 +
 common-main.c                                |  1 +
 compat/fsmonitor/fsm-ipc-darwin.c            |  1 +
 compat/fsmonitor/fsm-ipc-win32.c             |  1 +
 compat/precompose_utf8.c                     |  1 +
 compat/win32/trace2_win32_process_info.c     |  1 +
 copy.c                                       |  1 +
 csum-file.c                                  |  1 +
 daemon.c                                     |  1 +
 editor.c                                     |  1 +
 exec-cmd.c                                   |  1 +
 fsmonitor-ipc.c                              |  1 +
 gpg-interface.c                              |  1 +
 hash-lookup.c                                |  1 +
 hash.h                                       | 97 --------------------
 hex.c                                        |  1 +
 hook.c                                       |  1 +
 khash.h                                      |  1 +
 merge-ort-wrappers.c                         |  1 +
 negotiator/default.c                         |  1 +
 negotiator/skipping.c                        |  1 +
 object-file.h                                |  2 +
 object.h                                     |  1 +
 oid-array.h                                  |  1 +
 oidmap.c                                     |  1 +
 oidtree.c                                    |  1 +
 parallel-checkout.c                          |  1 +
 pathspec.c                                   |  1 +
 progress.c                                   |  1 +
 rebase-interactive.c                         |  1 +
 refs/files-backend.c                         |  1 +
 refs/packed-backend.c                        |  1 +
 refs/ref-cache.c                             |  1 +
 refs/ref-cache.h                             |  1 +
 refspec.c                                    |  1 +
 repository.h                                 | 96 +++++++++++++++++++
 resolve-undo.c                               |  1 +
 split-index.c                                |  1 +
 strbuf.c                                     |  1 +
 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                  |  1 +
 t/helper/test-oidmap.c                       |  1 +
 t/helper/test-path-utils.c                   |  1 +
 t/helper/test-read-cache.c                   |  1 +
 t/helper/test-scrap-cache-tree.c             |  1 +
 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-walk.h                                  |  1 +
 tree.h                                       |  1 +
 wrapper.c                                    |  1 +
 93 files changed, 189 insertions(+), 97 deletions(-)

diff --git a/alloc.c b/alloc.c
index 2886aa93543..377e80f5dda 100644
--- a/alloc.c
+++ b/alloc.c
@@ -13,6 +13,7 @@
 #include "blob.h"
 #include "tree.h"
 #include "commit.h"
+#include "repository.h"
 #include "tag.h"
 #include "alloc.h"
 
diff --git a/branch.c b/branch.c
index 7df982693af..9415ee3f340 100644
--- a/branch.c
+++ b/branch.c
@@ -9,6 +9,7 @@
 #include "refs.h"
 #include "refspec.h"
 #include "remote.h"
+#include "repository.h"
 #include "sequencer.h"
 #include "commit.h"
 #include "worktree.h"
diff --git a/builtin/apply.c b/builtin/apply.c
index fe72c0ec3eb..e3ff02a09e3 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2,6 +2,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "apply.h"
 
 static const char * const apply_usage[] = {
diff --git a/builtin/archive.c b/builtin/archive.c
index d13934f1a80..b0eaa3c14a3 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -9,6 +9,7 @@
 #include "transport.h"
 #include "parse-options.h"
 #include "pkt-line.h"
+#include "repository.h"
 #include "sideband.h"
 
 static void create_output_file(const char *output_file)
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 584d905d965..44113389d7a 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -5,6 +5,7 @@
 #include "strvec.h"
 #include "parse-options.h"
 #include "pkt-line.h"
+#include "repository.h"
 #include "cache.h"
 #include "bundle.h"
 
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 037bf1aaa2a..b2b678847f5 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -7,6 +7,7 @@
 #include "gettext.h"
 #include "object-name.h"
 #include "quote.h"
+#include "repository.h"
 #include "setup.h"
 #include "parse-options.h"
 #include "write-or-die.h"
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 9401dad0070..e4b78782a32 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -7,6 +7,7 @@
 #include "quote.h"
 #include "pathspec.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "submodule.h"
 #include "write-or-die.h"
 
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 7df673e3e70..9375a05539f 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "lockfile.h"
 #include "quote.h"
+#include "repository.h"
 #include "cache-tree.h"
 #include "parse-options.h"
 #include "entry.h"
diff --git a/builtin/clean.c b/builtin/clean.c
index 14c0d555eac..78852d28cec 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -14,6 +14,7 @@
 #include "dir.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "setup.h"
 #include "string-list.h"
 #include "quote.h"
diff --git a/builtin/config.c b/builtin/config.c
index 9401f1e5e3b..7efcf2d2159 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -10,6 +10,7 @@
 #include "parse-options.h"
 #include "urlmatch.h"
 #include "quote.h"
+#include "repository.h"
 #include "setup.h"
 #include "worktree.h"
 #include "wrapper.h"
diff --git a/builtin/credential-cache.c b/builtin/credential-cache.c
index 508da4c6e4d..204e78ac772 100644
--- a/builtin/credential-cache.c
+++ b/builtin/credential-cache.c
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/builtin/credential-store.c b/builtin/credential-store.c
index 8977604eb9d..30c6ccf56c0 100644
--- a/builtin/credential-store.c
+++ b/builtin/credential-store.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "lockfile.h"
 #include "credential.h"
+#include "path.h"
 #include "string-list.h"
 #include "parse-options.h"
 #include "write-or-die.h"
diff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c
index 27425c2fc9e..c28b0b3543a 100644
--- a/builtin/for-each-repo.c
+++ b/builtin/for-each-repo.c
@@ -3,6 +3,8 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "path.h"
+#include "repository.h"
 #include "run-command.h"
 #include "string-list.h"
 
diff --git a/builtin/help.c b/builtin/help.c
index 128aa83099a..d3cf4af3f6e 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -8,6 +8,7 @@
 #include "gettext.h"
 #include "pager.h"
 #include "parse-options.h"
+#include "path.h"
 #include "run-command.h"
 #include "config-list.h"
 #include "help.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index cda6ee75eb5..aef40361052 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -14,6 +14,7 @@
 #include "exec-cmd.h"
 #include "object-file.h"
 #include "parse-options.h"
+#include "path.h"
 #include "setup.h"
 #include "worktree.h"
 #include "wrapper.h"
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index c875f5d37ee..f044382ed8f 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -1,6 +1,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "hex.h"
+#include "repository.h"
 #include "run-command.h"
 
 static const char *pgm;
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index fa1035405c3..eae25c9486e 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -6,6 +6,7 @@
 #include "tag.h"
 #include "merge-recursive.h"
 #include "object-name.h"
+#include "repository.h"
 #include "xdiff-interface.h"
 
 static const char builtin_merge_recursive_usage[] =
diff --git a/builtin/mv.c b/builtin/mv.c
index 32935af48e6..665bd274485 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -18,6 +18,7 @@
 #include "cache-tree.h"
 #include "string-list.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "setup.h"
 #include "submodule.h"
 #include "entry.h"
diff --git a/builtin/push.c b/builtin/push.c
index 7d2b0505aac..4e5780dd50d 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -15,6 +15,7 @@
 #include "transport.h"
 #include "parse-options.h"
 #include "pkt-line.h"
+#include "repository.h"
 #include "submodule.h"
 #include "submodule-config.h"
 #include "send-pack.h"
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index d61cbad96de..440f19b1b87 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "builtin.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "resolve-undo.h"
 #include "setup.h"
 #include "submodule.h"
diff --git a/builtin/rerere.c b/builtin/rerere.c
index d4a03707b1a..d4bd52797f4 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "string-list.h"
 #include "rerere.h"
 #include "wrapper.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index d36072252e7..ccbce94d07d 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -15,6 +15,7 @@
 #include "tree-walk.h"
 #include "object-name.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "string-list.h"
 #include "setup.h"
 #include "submodule.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 20030b75e39..04167b14060 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -10,6 +10,7 @@
 #include "strvec.h"
 #include "object-name.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "dir.h"
 #include "commit-slab.h"
 #include "date.h"
diff --git a/builtin/show-index.c b/builtin/show-index.c
index d4bbbbcd6ce..6608b5d252e 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -4,6 +4,7 @@
 #include "hex.h"
 #include "pack.h"
 #include "parse-options.h"
+#include "repository.h"
 
 static const char *const show_index_usage[] = {
 	"git show-index [--object-format=<hash-algorithm>]",
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 58bbc80db77..df36bc0a42d 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -21,6 +21,7 @@
 #include "parse-options.h"
 #include "pathspec.h"
 #include "dir.h"
+#include "repository.h"
 #include "setup.h"
 #include "split-index.h"
 #include "symlinks.h"
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 6ca85420c3b..ef1fcb86718 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -6,6 +6,7 @@
 #include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
+#include "repository.h"
 #include "strvec.h"
 
 static const char * const git_update_ref_usage[] = {
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index 945ee2b4126..5be97ca1af5 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -6,6 +6,7 @@
 #include "archive.h"
 #include "pkt-line.h"
 #include "sideband.h"
+#include "repository.h"
 #include "run-command.h"
 #include "strvec.h"
 
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 0b411e9deee..5d3ca819e76 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -14,6 +14,7 @@
 #include "strvec.h"
 #include "branch.h"
 #include "refs.h"
+#include "repository.h"
 #include "run-command.h"
 #include "hook.h"
 #include "sigchain.h"
diff --git a/checkout.c b/checkout.c
index 04238b27133..4256e71a7c4 100644
--- a/checkout.c
+++ b/checkout.c
@@ -2,6 +2,7 @@
 #include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
+#include "repository.h"
 #include "checkout.h"
 #include "config.h"
 #include "strbuf.h"
diff --git a/chunk-format.c b/chunk-format.c
index 60a73c1b140..6bd87b7de89 100644
--- a/chunk-format.c
+++ b/chunk-format.c
@@ -3,6 +3,7 @@
 #include "chunk-format.h"
 #include "csum-file.h"
 #include "gettext.h"
+#include "repository.h"
 #include "trace2.h"
 
 /*
diff --git a/common-main.c b/common-main.c
index 601a875e2fb..8ab50fa37a4 100644
--- a/common-main.c
+++ b/common-main.c
@@ -2,6 +2,7 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "attr.h"
+#include "repository.h"
 #include "setup.h"
 #include "strbuf.h"
 #include "trace2.h"
diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
index eb25123fa12..e62f093cc19 100644
--- a/compat/fsmonitor/fsm-ipc-darwin.c
+++ b/compat/fsmonitor/fsm-ipc-darwin.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "config.h"
 #include "hex.h"
+#include "repository.h"
 #include "strbuf.h"
 #include "fsmonitor.h"
 #include "fsmonitor-ipc.h"
diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c
index c9536dfb666..8928fa93ce2 100644
--- a/compat/fsmonitor/fsm-ipc-win32.c
+++ b/compat/fsmonitor/fsm-ipc-win32.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "fsmonitor-ipc.h"
+#include "path.h"
 
 const char *fsmonitor_ipc__get_path(struct repository *r) {
 	static char *ret;
diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c
index 8a9881db077..a4d11376ba5 100644
--- a/compat/precompose_utf8.c
+++ b/compat/precompose_utf8.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "path.h"
 #include "utf8.h"
 #include "precompose_utf8.h"
 
diff --git a/compat/win32/trace2_win32_process_info.c b/compat/win32/trace2_win32_process_info.c
index e3e895c78a2..a4e33768f43 100644
--- a/compat/win32/trace2_win32_process_info.c
+++ b/compat/win32/trace2_win32_process_info.c
@@ -1,5 +1,6 @@
 #include "../../cache.h"
 #include "../../json-writer.h"
+#include "../../repository.h"
 #include "../../trace2.h"
 #include "lazyload.h"
 #include <Psapi.h>
diff --git a/copy.c b/copy.c
index db6b615c188..923d8a6dc61 100644
--- a/copy.c
+++ b/copy.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "copy.h"
+#include "path.h"
 #include "wrapper.h"
 
 int copy_fd(int ifd, int ofd)
diff --git a/csum-file.c b/csum-file.c
index 82ae2973d30..2d14b76c533 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -10,6 +10,7 @@
 #include "git-compat-util.h"
 #include "progress.h"
 #include "csum-file.h"
+#include "repository.h"
 #include "wrapper.h"
 
 static void verify_buffer_or_die(struct hashfile *f,
diff --git a/daemon.c b/daemon.c
index 75c3c064574..f89f99d7ef4 100644
--- a/daemon.c
+++ b/daemon.c
@@ -3,6 +3,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
+#include "path.h"
 #include "pkt-line.h"
 #include "protocol.h"
 #include "run-command.h"
diff --git a/editor.c b/editor.c
index b34e10606d2..38c5dbbb79b 100644
--- a/editor.c
+++ b/editor.c
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "pager.h"
+#include "path.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "run-command.h"
diff --git a/exec-cmd.c b/exec-cmd.c
index 6f618463896..1e34e48c0e4 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
+#include "path.h"
 #include "quote.h"
 #include "strvec.h"
 #include "trace.h"
diff --git a/fsmonitor-ipc.c b/fsmonitor-ipc.c
index 866828e2992..6a6a89764a6 100644
--- a/fsmonitor-ipc.c
+++ b/fsmonitor-ipc.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "fsmonitor-ipc.h"
+#include "repository.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "trace2.h"
diff --git a/gpg-interface.c b/gpg-interface.c
index aceeb083367..8615dcd4b4b 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -7,6 +7,7 @@
 #include "dir.h"
 #include "ident.h"
 #include "gpg-interface.h"
+#include "path.h"
 #include "sigchain.h"
 #include "tempfile.h"
 #include "alias.h"
diff --git a/hash-lookup.c b/hash-lookup.c
index b98ed5e11e8..68cf6d03bf3 100644
--- a/hash-lookup.c
+++ b/hash-lookup.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "hash-lookup.h"
+#include "repository.h"
 
 static uint32_t take2(const struct object_id *oid, size_t ofs)
 {
diff --git a/hash.h b/hash.h
index d39f73618cb..ed963816289 100644
--- a/hash.h
+++ b/hash.h
@@ -1,8 +1,6 @@
 #ifndef HASH_H
 #define HASH_H
 
-#include "repository.h"
-
 #if defined(SHA1_APPLE)
 #include <CommonCrypto/CommonDigest.h>
 #elif defined(SHA1_OPENSSL)
@@ -230,8 +228,6 @@ static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
 	return p - hash_algos;
 }
 
-#define the_hash_algo the_repository->hash_algo
-
 const struct object_id *null_oid(void);
 
 static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
@@ -245,21 +241,6 @@ static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *
 	return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
 }
 
-static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
-{
-	return hashcmp_algop(sha1, sha2, the_hash_algo);
-}
-
-static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
-{
-	const struct git_hash_algo *algop;
-	if (!oid1->algo)
-		algop = the_hash_algo;
-	else
-		algop = &hash_algos[oid1->algo];
-	return hashcmp_algop(oid1->hash, oid2->hash, algop);
-}
-
 static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
 {
 	/*
@@ -271,53 +252,12 @@ static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *s
 	return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
 }
 
-static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
-{
-	return hasheq_algop(sha1, sha2, the_hash_algo);
-}
-
-static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
-{
-	const struct git_hash_algo *algop;
-	if (!oid1->algo)
-		algop = the_hash_algo;
-	else
-		algop = &hash_algos[oid1->algo];
-	return hasheq_algop(oid1->hash, oid2->hash, algop);
-}
-
-static inline int is_null_oid(const struct object_id *oid)
-{
-	return oideq(oid, null_oid());
-}
-
-static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
-{
-	memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
-}
-
 static inline void oidcpy(struct object_id *dst, const struct object_id *src)
 {
 	memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
 	dst->algo = src->algo;
 }
 
-/* Like oidcpy() but zero-pads the unused bytes in dst's hash array. */
-static inline void oidcpy_with_padding(struct object_id *dst,
-				       const struct object_id *src)
-{
-	size_t hashsz;
-
-	if (!src->algo)
-		hashsz = the_hash_algo->rawsz;
-	else
-		hashsz = hash_algos[src->algo].rawsz;
-
-	memcpy(dst->hash, src->hash, hashsz);
-	memset(dst->hash + hashsz, 0, GIT_MAX_RAWSZ - hashsz);
-	dst->algo = src->algo;
-}
-
 static inline struct object_id *oiddup(const struct object_id *src)
 {
 	struct object_id *dst = xmalloc(sizeof(struct object_id));
@@ -325,43 +265,6 @@ static inline struct object_id *oiddup(const struct object_id *src)
 	return dst;
 }
 
-static inline void hashclr(unsigned char *hash)
-{
-	memset(hash, 0, the_hash_algo->rawsz);
-}
-
-static inline void oidclr(struct object_id *oid)
-{
-	memset(oid->hash, 0, GIT_MAX_RAWSZ);
-	oid->algo = hash_algo_by_ptr(the_hash_algo);
-}
-
-static inline void oidread(struct object_id *oid, const unsigned char *hash)
-{
-	memcpy(oid->hash, hash, the_hash_algo->rawsz);
-	oid->algo = hash_algo_by_ptr(the_hash_algo);
-}
-
-static inline int is_empty_blob_sha1(const unsigned char *sha1)
-{
-	return hasheq(sha1, the_hash_algo->empty_blob->hash);
-}
-
-static inline int is_empty_blob_oid(const struct object_id *oid)
-{
-	return oideq(oid, the_hash_algo->empty_blob);
-}
-
-static inline int is_empty_tree_sha1(const unsigned char *sha1)
-{
-	return hasheq(sha1, the_hash_algo->empty_tree->hash);
-}
-
-static inline int is_empty_tree_oid(const struct object_id *oid)
-{
-	return oideq(oid, the_hash_algo->empty_tree);
-}
-
 static inline void oid_set_algo(struct object_id *oid, const struct git_hash_algo *algop)
 {
 	oid->algo = hash_algo_by_ptr(algop);
diff --git a/hex.c b/hex.c
index 0a1bddc1284..f6849b51b28 100644
--- a/hex.c
+++ b/hex.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "hex.h"
+#include "repository.h"
 
 const signed char hexval_table[256] = {
 	 -1, -1, -1, -1, -1, -1, -1, -1,		/* 00-07 */
diff --git a/hook.c b/hook.c
index 76e322f5804..3ca5e60895d 100644
--- a/hook.c
+++ b/hook.c
@@ -2,6 +2,7 @@
 #include "advice.h"
 #include "gettext.h"
 #include "hook.h"
+#include "path.h"
 #include "run-command.h"
 #include "config.h"
 #include "strbuf.h"
diff --git a/khash.h b/khash.h
index 85362718c56..edd5b45d000 100644
--- a/khash.h
+++ b/khash.h
@@ -27,6 +27,7 @@
 #define __AC_KHASH_H
 
 #include "hashmap.h"
+#include "repository.h"
 
 #define AC_VERSION_KHASH_H "0.2.8"
 
diff --git a/merge-ort-wrappers.c b/merge-ort-wrappers.c
index c00dfbab1cd..2d1e8aa7ee7 100644
--- a/merge-ort-wrappers.c
+++ b/merge-ort-wrappers.c
@@ -2,6 +2,7 @@
 #include "gettext.h"
 #include "merge-ort.h"
 #include "merge-ort-wrappers.h"
+#include "repository.h"
 
 #include "commit.h"
 
diff --git a/negotiator/default.c b/negotiator/default.c
index f4b78eb47dd..5cb2b1d2046 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -4,6 +4,7 @@
 #include "../fetch-negotiator.h"
 #include "../prio-queue.h"
 #include "../refs.h"
+#include "../repository.h"
 #include "../tag.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index c7d6ab39bc5..97e7e1ae725 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -5,6 +5,7 @@
 #include "../hex.h"
 #include "../prio-queue.h"
 #include "../refs.h"
+#include "../repository.h"
 #include "../tag.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/object-file.h b/object-file.h
index e0cfc3a5db8..d6414610f80 100644
--- a/object-file.h
+++ b/object-file.h
@@ -4,6 +4,8 @@
 #include "git-zlib.h"
 #include "object.h"
 
+struct index_state;
+
 /*
  * Set this to 0 to prevent oid_object_info_extended() from fetching missing
  * blobs. This has a difference only if extensions.partialClone is set.
diff --git a/object.h b/object.h
index 96e52e24fb1..6cd8b49fa66 100644
--- a/object.h
+++ b/object.h
@@ -4,6 +4,7 @@
 #include "hash.h"
 
 struct buffer_slab;
+struct repository;
 
 struct parsed_object_pool {
 	struct object **obj_hash;
diff --git a/oid-array.h b/oid-array.h
index f60f9af6741..8bfe452259b 100644
--- a/oid-array.h
+++ b/oid-array.h
@@ -2,6 +2,7 @@
 #define OID_ARRAY_H
 
 #include "hash.h"
+#include "repository.h"
 
 /**
  * The API provides storage and manipulation of sets of object identifiers.
diff --git a/oidmap.c b/oidmap.c
index 8c1a139c974..d268486f4e8 100644
--- a/oidmap.c
+++ b/oidmap.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "oidmap.h"
+#include "repository.h"
 
 static int oidmap_neq(const void *hashmap_cmp_fn_data UNUSED,
 		      const struct hashmap_entry *e1,
diff --git a/oidtree.c b/oidtree.c
index 7d57b7b19e3..634214673dd 100644
--- a/oidtree.c
+++ b/oidtree.c
@@ -6,6 +6,7 @@
 #include "oidtree.h"
 #include "alloc.h"
 #include "hash.h"
+#include "repository.h"
 
 struct oidtree_iter_data {
 	oidtree_iter fn;
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 7f0569cc930..78cb6e3003a 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -7,6 +7,7 @@
 #include "parallel-checkout.h"
 #include "pkt-line.h"
 #include "progress.h"
+#include "repository.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "streaming.h"
diff --git a/pathspec.c b/pathspec.c
index ec335a214e2..1e57b6c667d 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -6,6 +6,7 @@
 #include "gettext.h"
 #include "pathspec.h"
 #include "attr.h"
+#include "repository.h"
 #include "setup.h"
 #include "strvec.h"
 #include "symlinks.h"
diff --git a/progress.c b/progress.c
index 72d5e0c73c1..f695798acac 100644
--- a/progress.c
+++ b/progress.c
@@ -12,6 +12,7 @@
 #include "git-compat-util.h"
 #include "pager.h"
 #include "progress.h"
+#include "repository.h"
 #include "strbuf.h"
 #include "trace.h"
 #include "trace2.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 789f4073617..852a3313182 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "sequencer.h"
 #include "rebase-interactive.h"
+#include "repository.h"
 #include "strbuf.h"
 #include "commit-slab.h"
 #include "config.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 1128a9af292..212a0c14ea4 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -14,6 +14,7 @@
 #include "../lockfile.h"
 #include "../object.h"
 #include "../object-file.h"
+#include "../repository.h"
 #include "../dir.h"
 #include "../chdir-notify.h"
 #include "../setup.h"
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 2333ed5a1f7..b3a46f9d4dd 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -9,6 +9,7 @@
 #include "../iterator.h"
 #include "../lockfile.h"
 #include "../chdir-notify.h"
+#include "../repository.h"
 #include "../wrapper.h"
 #include "../write-or-die.h"
 
diff --git a/refs/ref-cache.c b/refs/ref-cache.c
index dc1ca49c85f..84c3838c743 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -4,6 +4,7 @@
 #include "refs-internal.h"
 #include "ref-cache.h"
 #include "../iterator.h"
+#include "../repository.h"
 
 void add_entry_to_dir(struct ref_dir *dir, struct ref_entry *entry)
 {
diff --git a/refs/ref-cache.h b/refs/ref-cache.h
index cf4ad9070b9..31ebe24f6cf 100644
--- a/refs/ref-cache.h
+++ b/refs/ref-cache.h
@@ -5,6 +5,7 @@
 
 struct ref_dir;
 struct ref_store;
+struct repository;
 
 /*
  * If this ref_cache is filled lazily, this function is used to load
diff --git a/refspec.c b/refspec.c
index 7b5c305514d..68020ee84c6 100644
--- a/refspec.c
+++ b/refspec.c
@@ -5,6 +5,7 @@
 #include "strvec.h"
 #include "refs.h"
 #include "refspec.h"
+#include "repository.h"
 
 static struct refspec_item s_tag_refspec = {
 	.force = 0,
diff --git a/repository.h b/repository.h
index 15a8afc5fb5..9e36868207f 100644
--- a/repository.h
+++ b/repository.h
@@ -1,6 +1,7 @@
 #ifndef REPOSITORY_H
 #define REPOSITORY_H
 
+#include "hash.h"
 #include "path.h"
 
 struct config_set;
@@ -238,4 +239,99 @@ void prepare_repo_settings(struct repository *r);
  */
 int upgrade_repository_format(int target_version);
 
+#define the_hash_algo the_repository->hash_algo
+
+static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
+{
+	return hashcmp_algop(sha1, sha2, the_hash_algo);
+}
+
+static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
+{
+	const struct git_hash_algo *algop;
+	if (!oid1->algo)
+		algop = the_hash_algo;
+	else
+		algop = &hash_algos[oid1->algo];
+	return hashcmp_algop(oid1->hash, oid2->hash, algop);
+}
+
+static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
+{
+	return hasheq_algop(sha1, sha2, the_hash_algo);
+}
+
+static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
+{
+	const struct git_hash_algo *algop;
+	if (!oid1->algo)
+		algop = the_hash_algo;
+	else
+		algop = &hash_algos[oid1->algo];
+	return hasheq_algop(oid1->hash, oid2->hash, algop);
+}
+
+static inline int is_null_oid(const struct object_id *oid)
+{
+	return oideq(oid, null_oid());
+}
+
+static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
+{
+	memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
+}
+
+/* Like oidcpy() but zero-pads the unused bytes in dst's hash array. */
+static inline void oidcpy_with_padding(struct object_id *dst,
+				       const struct object_id *src)
+{
+	size_t hashsz;
+
+	if (!src->algo)
+		hashsz = the_hash_algo->rawsz;
+	else
+		hashsz = hash_algos[src->algo].rawsz;
+
+	memcpy(dst->hash, src->hash, hashsz);
+	memset(dst->hash + hashsz, 0, GIT_MAX_RAWSZ - hashsz);
+	dst->algo = src->algo;
+}
+
+static inline void hashclr(unsigned char *hash)
+{
+	memset(hash, 0, the_hash_algo->rawsz);
+}
+
+static inline void oidclr(struct object_id *oid)
+{
+	memset(oid->hash, 0, GIT_MAX_RAWSZ);
+	oid->algo = hash_algo_by_ptr(the_hash_algo);
+}
+
+static inline void oidread(struct object_id *oid, const unsigned char *hash)
+{
+	memcpy(oid->hash, hash, the_hash_algo->rawsz);
+	oid->algo = hash_algo_by_ptr(the_hash_algo);
+}
+
+static inline int is_empty_blob_sha1(const unsigned char *sha1)
+{
+	return hasheq(sha1, the_hash_algo->empty_blob->hash);
+}
+
+static inline int is_empty_blob_oid(const struct object_id *oid)
+{
+	return oideq(oid, the_hash_algo->empty_blob);
+}
+
+static inline int is_empty_tree_sha1(const unsigned char *sha1)
+{
+	return hasheq(sha1, the_hash_algo->empty_tree->hash);
+}
+
+static inline int is_empty_tree_oid(const struct object_id *oid)
+{
+	return oideq(oid, the_hash_algo->empty_tree);
+}
+
 #endif /* REPOSITORY_H */
diff --git a/resolve-undo.c b/resolve-undo.c
index e81096e2d45..7dbd38a2cf9 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "resolve-undo.h"
+#include "repository.h"
 #include "string-list.h"
 
 /* The only error case is to run out of memory in string-list */
diff --git a/split-index.c b/split-index.c
index 3fc4e91485a..bce6480084e 100644
--- a/split-index.c
+++ b/split-index.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "gettext.h"
 #include "mem-pool.h"
+#include "repository.h"
 #include "split-index.h"
 #include "strbuf.h"
 #include "ewah/ewok.h"
diff --git a/strbuf.c b/strbuf.c
index 729378ec824..08eec8f1d8b 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -6,6 +6,7 @@
 #include "hex.h"
 #include "object-name.h"
 #include "refs.h"
+#include "repository.h"
 #include "string-list.h"
 #include "utf8.h"
 #include "date.h"
diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index d2b30d644da..aabe31d724b 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -2,6 +2,7 @@
 #include "bloom.h"
 #include "hex.h"
 #include "commit.h"
+#include "repository.h"
 #include "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 cdaf5046f5a..9507b356e22 100644
--- a/t/helper/test-cache-tree.c
+++ b/t/helper/test-cache-tree.c
@@ -6,6 +6,7 @@
 #include "tree.h"
 #include "cache-tree.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "setup.h"
 
 static char const * const test_cache_tree_usage[] = {
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index 715aabfbae7..df30cc92d24 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -4,6 +4,7 @@
 #include "hex.h"
 #include "tree.h"
 #include "cache-tree.h"
+#include "repository.h"
 #include "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 7e9de296db3..6dc49583375 100644
--- a/t/helper/test-dump-fsmonitor.c
+++ b/t/helper/test-dump-fsmonitor.c
@@ -1,5 +1,6 @@
 #include "test-tool.h"
 #include "cache.h"
+#include "repository.h"
 #include "setup.h"
 
 int cmd__dump_fsmonitor(int ac, const char **av)
diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
index 415f55f31da..d1b99d21dcd 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
@@ -3,6 +3,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "hex.h"
+#include "repository.h"
 #include "setup.h"
 
 static int compare_untracked(const void *a_, const void *b_)
diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c
index 7c7fc8efc13..43707486dd4 100644
--- a/t/helper/test-example-decorate.c
+++ b/t/helper/test-example-decorate.c
@@ -2,6 +2,7 @@
 #include "git-compat-util.h"
 #include "object.h"
 #include "decorate.h"
+#include "repository.h"
 
 int cmd__example_decorate(int argc, const char **argv)
 {
diff --git a/t/helper/test-fsmonitor-client.c b/t/helper/test-fsmonitor-client.c
index a37236cd0a6..bb00e1e5d14 100644
--- a/t/helper/test-fsmonitor-client.c
+++ b/t/helper/test-fsmonitor-client.c
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "parse-options.h"
 #include "fsmonitor-ipc.h"
+#include "repository.h"
 #include "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 f23d983c118..b83a75d19f6 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -3,6 +3,7 @@
 #include "cache.h"
 #include "environment.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "setup.h"
 #include "trace.h"
 
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index a498fece7a3..3c62e33ccdf 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "match-trees.h"
 #include "object-name.h"
+#include "repository.h"
 #include "setup.h"
 #include "tree.h"
 
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index de6ab77fdaa..bba4099f65f 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -2,6 +2,7 @@
 #include "hex.h"
 #include "object-name.h"
 #include "oidmap.h"
+#include "repository.h"
 #include "setup.h"
 #include "strbuf.h"
 
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 6355c9e4b6d..2ef53d5f7a2 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -2,6 +2,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "environment.h"
+#include "path.h"
 #include "setup.h"
 #include "string-list.h"
 #include "trace.h"
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index a4c24d0e421..c1ae2763954 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -2,6 +2,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "config.h"
+#include "repository.h"
 #include "setup.h"
 #include "wrapper.h"
 
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index 15b7688774c..444a4c02c8d 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -2,6 +2,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "lockfile.h"
+#include "repository.h"
 #include "setup.h"
 #include "tree.h"
 #include "cache-tree.h"
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index c7c7fdbea98..8b1969ea48d 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "config.h"
 #include "object-name.h"
+#include "repository.h"
 #include "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 d31f5e48ab5..ecd40ded995 100644
--- a/t/helper/test-submodule-nested-repo-config.c
+++ b/t/helper/test-submodule-nested-repo-config.c
@@ -1,4 +1,5 @@
 #include "test-tool.h"
+#include "repository.h"
 #include "setup.h"
 #include "submodule-config.h"
 
diff --git a/t/helper/test-submodule.c b/t/helper/test-submodule.c
index 0e34581b209..cad8b0ca681 100644
--- a/t/helper/test-submodule.c
+++ b/t/helper/test-submodule.c
@@ -2,6 +2,7 @@
 #include "test-tool-utils.h"
 #include "parse-options.h"
 #include "remote.h"
+#include "repository.h"
 #include "setup.h"
 #include "submodule-config.h"
 #include "submodule.h"
diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c
index a476df6c6cb..ab084d6034e 100644
--- a/t/helper/test-trace2.c
+++ b/t/helper/test-trace2.c
@@ -3,6 +3,7 @@
 #include "run-command.h"
 #include "exec-cmd.h"
 #include "config.h"
+#include "repository.h"
 #include "trace2.h"
 
 typedef int(fn_unit_test)(int argc, const char **argv);
diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c
index a93417ed3a9..eace08072d7 100644
--- a/t/helper/test-write-cache.c
+++ b/t/helper/test-write-cache.c
@@ -2,6 +2,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "lockfile.h"
+#include "repository.h"
 #include "setup.h"
 
 int cmd__write_cache(int argc, const char **argv)
diff --git a/trace2.c b/trace2.c
index 21264df71b7..0efc4e7b958 100644
--- a/trace2.c
+++ b/trace2.c
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "json-writer.h"
 #include "quote.h"
+#include "repository.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "thread-utils.h"
diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
index 9e7aab6d510..2af53e5d4de 100644
--- a/trace2/tr2_tgt_event.c
+++ b/trace2/tr2_tgt_event.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "json-writer.h"
+#include "repository.h"
 #include "run-command.h"
 #include "version.h"
 #include "trace2/tr2_dst.h"
diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
index 8672c2c2d04..1ebfb464d54 100644
--- a/trace2/tr2_tgt_normal.c
+++ b/trace2/tr2_tgt_normal.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "config.h"
+#include "repository.h"
 #include "run-command.h"
 #include "quote.h"
 #include "version.h"
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
index 3f2b2d53118..328e483a05e 100644
--- a/trace2/tr2_tgt_perf.c
+++ b/trace2/tr2_tgt_perf.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "config.h"
+#include "repository.h"
 #include "run-command.h"
 #include "quote.h"
 #include "version.h"
diff --git a/tree-walk.h b/tree-walk.h
index 25fe27e3529..1a3a1b8d4b1 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -4,6 +4,7 @@
 #include "hash.h"
 
 struct index_state;
+struct repository;
 
 #define MAX_TRAVERSE_TREES 8
 
diff --git a/tree.h b/tree.h
index 6efff003e21..0499ad01aa7 100644
--- a/tree.h
+++ b/tree.h
@@ -3,6 +3,7 @@
 
 #include "object.h"
 
+struct pathspec;
 struct repository;
 struct strbuf;
 
diff --git a/wrapper.c b/wrapper.c
index e80f83498d8..5ab0460de5c 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "repository.h"
 #include "strbuf.h"
 #include "trace2.h"
 #include "wrapper.h"
-- 
gitgitgadget


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

* [PATCH 15/23] cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (13 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 16/23] cache,tree: move basic name compare functions from read-cache to tree Elijah Newren via GitGitGadget
                   ` (9 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Since cmp_cache_name_compare() was comparing cache_entry structs, it
was associated with the cache rather than with trees.  Move the
function.  As a side effect, we can make cache_name_stage_compare()
static as well.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h      |  2 +-
 read-cache.c | 13 ++++++++++++-
 tree.c       | 10 ----------
 tree.h       |  1 -
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/cache.h b/cache.h
index 7a46f300d9b..502e4c0b11a 100644
--- a/cache.h
+++ b/cache.h
@@ -562,7 +562,7 @@ int base_name_compare(const char *name1, size_t len1, int mode1,
 int df_name_compare(const char *name1, size_t len1, int mode1,
 		    const char *name2, size_t len2, int mode2);
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
+int cmp_cache_name_compare(const void *a_, const void *b_);
 
 /* add */
 /*
diff --git a/read-cache.c b/read-cache.c
index 206c003e558..8f00da4bf7a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -567,7 +567,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)
 	return 0;
 }
 
-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)
+static int cache_name_stage_compare(const char *name1, int len1, int stage1,
+				    const char *name2, int len2, int stage2)
 {
 	int cmp;
 
@@ -582,6 +583,16 @@ int cache_name_stage_compare(const char *name1, int len1, int stage1, const char
 	return 0;
 }
 
+int cmp_cache_name_compare(const void *a_, const void *b_)
+{
+	const struct cache_entry *ce1, *ce2;
+
+	ce1 = *((const struct cache_entry **)a_);
+	ce2 = *((const struct cache_entry **)b_);
+	return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
+				  ce2->name, ce2->ce_namelen, ce_stage(ce2));
+}
+
 static int index_name_stage_pos(struct index_state *istate,
 				const char *name, int namelen,
 				int stage,
diff --git a/tree.c b/tree.c
index e9d51ce2e00..896b7f4776b 100644
--- a/tree.c
+++ b/tree.c
@@ -94,16 +94,6 @@ int read_tree(struct repository *r,
 	return ret;
 }
 
-int cmp_cache_name_compare(const void *a_, const void *b_)
-{
-	const struct cache_entry *ce1, *ce2;
-
-	ce1 = *((const struct cache_entry **)a_);
-	ce2 = *((const struct cache_entry **)b_);
-	return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
-				  ce2->name, ce2->ce_namelen, ce_stage(ce2));
-}
-
 struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
 {
 	struct object *obj = lookup_object(r, oid);
diff --git a/tree.h b/tree.h
index 0499ad01aa7..8e3c6d441cc 100644
--- a/tree.h
+++ b/tree.h
@@ -29,7 +29,6 @@ void free_tree_buffer(struct tree *tree);
 /* Parses and returns the tree in the given ent, chasing tags and commits. */
 struct tree *parse_tree_indirect(const struct object_id *oid);
 
-int cmp_cache_name_compare(const void *a_, const void *b_);
 
 #define READ_TREE_RECURSIVE 1
 typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);
-- 
gitgitgadget


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

* [PATCH 16/23] cache,tree: move basic name compare functions from read-cache to tree
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (14 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 15/23] cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 17/23] treewide: remove cache.h inclusion due to previous changes Elijah Newren via GitGitGadget
                   ` (8 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

None of base_name_compare(), df_name_compare(), or name_compare()
depended upon a cache_entry or index_state in any way.  By moving these
functions to tree.h, half a dozen other files can stop depending upon
cache.h (though that change will be made in a later commit).

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h      |  5 ----
 read-cache.c | 68 ----------------------------------------------------
 tree.c       | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tree.h       |  9 +++++++
 4 files changed, 77 insertions(+), 73 deletions(-)

diff --git a/cache.h b/cache.h
index 502e4c0b11a..591c67b0595 100644
--- a/cache.h
+++ b/cache.h
@@ -557,11 +557,6 @@ extern int verify_ce_order;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-int base_name_compare(const char *name1, size_t len1, int mode1,
-		      const char *name2, size_t len2, int mode2);
-int df_name_compare(const char *name1, size_t len1, int mode1,
-		    const char *name2, size_t len2, int mode2);
-int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cmp_cache_name_compare(const void *a_, const void *b_);
 
 /* add */
diff --git a/read-cache.c b/read-cache.c
index 8f00da4bf7a..b3e2917ddc9 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -499,74 +499,6 @@ int ie_modified(struct index_state *istate,
 	return 0;
 }
 
-int base_name_compare(const char *name1, size_t len1, int mode1,
-		      const char *name2, size_t len2, int mode2)
-{
-	unsigned char c1, c2;
-	size_t len = len1 < len2 ? len1 : len2;
-	int cmp;
-
-	cmp = memcmp(name1, name2, len);
-	if (cmp)
-		return cmp;
-	c1 = name1[len];
-	c2 = name2[len];
-	if (!c1 && S_ISDIR(mode1))
-		c1 = '/';
-	if (!c2 && S_ISDIR(mode2))
-		c2 = '/';
-	return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
-}
-
-/*
- * df_name_compare() is identical to base_name_compare(), except it
- * compares conflicting directory/file entries as equal. Note that
- * while a directory name compares as equal to a regular file, they
- * then individually compare _differently_ to a filename that has
- * a dot after the basename (because '\0' < '.' < '/').
- *
- * This is used by routines that want to traverse the git namespace
- * but then handle conflicting entries together when possible.
- */
-int df_name_compare(const char *name1, size_t len1, int mode1,
-		    const char *name2, size_t len2, int mode2)
-{
-	unsigned char c1, c2;
-	size_t len = len1 < len2 ? len1 : len2;
-	int cmp;
-
-	cmp = memcmp(name1, name2, len);
-	if (cmp)
-		return cmp;
-	/* Directories and files compare equal (same length, same name) */
-	if (len1 == len2)
-		return 0;
-	c1 = name1[len];
-	if (!c1 && S_ISDIR(mode1))
-		c1 = '/';
-	c2 = name2[len];
-	if (!c2 && S_ISDIR(mode2))
-		c2 = '/';
-	if (c1 == '/' && !c2)
-		return 0;
-	if (c2 == '/' && !c1)
-		return 0;
-	return c1 - c2;
-}
-
-int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)
-{
-	size_t min_len = (len1 < len2) ? len1 : len2;
-	int cmp = memcmp(name1, name2, min_len);
-	if (cmp)
-		return cmp;
-	if (len1 < len2)
-		return -1;
-	if (len1 > len2)
-		return 1;
-	return 0;
-}
-
 static int cache_name_stage_compare(const char *name1, int len1, int stage1,
 				    const char *name2, int len2, int stage2)
 {
diff --git a/tree.c b/tree.c
index 896b7f4776b..f242a7ab691 100644
--- a/tree.c
+++ b/tree.c
@@ -94,6 +94,74 @@ int read_tree(struct repository *r,
 	return ret;
 }
 
+int base_name_compare(const char *name1, size_t len1, int mode1,
+		      const char *name2, size_t len2, int mode2)
+{
+	unsigned char c1, c2;
+	size_t len = len1 < len2 ? len1 : len2;
+	int cmp;
+
+	cmp = memcmp(name1, name2, len);
+	if (cmp)
+		return cmp;
+	c1 = name1[len];
+	c2 = name2[len];
+	if (!c1 && S_ISDIR(mode1))
+		c1 = '/';
+	if (!c2 && S_ISDIR(mode2))
+		c2 = '/';
+	return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
+}
+
+/*
+ * df_name_compare() is identical to base_name_compare(), except it
+ * compares conflicting directory/file entries as equal. Note that
+ * while a directory name compares as equal to a regular file, they
+ * then individually compare _differently_ to a filename that has
+ * a dot after the basename (because '\0' < '.' < '/').
+ *
+ * This is used by routines that want to traverse the git namespace
+ * but then handle conflicting entries together when possible.
+ */
+int df_name_compare(const char *name1, size_t len1, int mode1,
+		    const char *name2, size_t len2, int mode2)
+{
+	unsigned char c1, c2;
+	size_t len = len1 < len2 ? len1 : len2;
+	int cmp;
+
+	cmp = memcmp(name1, name2, len);
+	if (cmp)
+		return cmp;
+	/* Directories and files compare equal (same length, same name) */
+	if (len1 == len2)
+		return 0;
+	c1 = name1[len];
+	if (!c1 && S_ISDIR(mode1))
+		c1 = '/';
+	c2 = name2[len];
+	if (!c2 && S_ISDIR(mode2))
+		c2 = '/';
+	if (c1 == '/' && !c2)
+		return 0;
+	if (c2 == '/' && !c1)
+		return 0;
+	return c1 - c2;
+}
+
+int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)
+{
+	size_t min_len = (len1 < len2) ? len1 : len2;
+	int cmp = memcmp(name1, name2, min_len);
+	if (cmp)
+		return cmp;
+	if (len1 < len2)
+		return -1;
+	if (len1 > len2)
+		return 1;
+	return 0;
+}
+
 struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
 {
 	struct object *obj = lookup_object(r, oid);
diff --git a/tree.h b/tree.h
index 8e3c6d441cc..1b5ecbda6b3 100644
--- a/tree.h
+++ b/tree.h
@@ -29,6 +29,15 @@ void free_tree_buffer(struct tree *tree);
 /* Parses and returns the tree in the given ent, chasing tags and commits. */
 struct tree *parse_tree_indirect(const struct object_id *oid);
 
+/*
+ * Functions for comparing pathnames
+ */
+int base_name_compare(const char *name1, size_t len1, int mode1,
+		      const char *name2, size_t len2, int mode2);
+int df_name_compare(const char *name1, size_t len1, int mode1,
+		    const char *name2, size_t len2, int mode2);
+int name_compare(const char *name1, size_t len1,
+		 const char *name2, size_t len2);
 
 #define READ_TREE_RECURSIVE 1
 typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);
-- 
gitgitgadget


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

* [PATCH 17/23] treewide: remove cache.h inclusion due to previous changes
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (15 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 16/23] cache,tree: move basic name compare functions from read-cache to tree Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 18/23] cache.h: remove unnecessary headers Elijah Newren via GitGitGadget
                   ` (7 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 archive-zip.c                 | 2 +-
 bundle-uri.c                  | 2 +-
 color.c                       | 2 +-
 combine-diff.c                | 2 +-
 common-main.c                 | 2 +-
 config.c                      | 2 +-
 copy.c                        | 2 +-
 credential.c                  | 2 +-
 daemon.c                      | 2 +-
 date.c                        | 2 +-
 diagnose.c                    | 2 +-
 environment.c                 | 2 +-
 ll-merge.c                    | 2 +-
 match-trees.c                 | 2 +-
 midx.c                        | 2 +-
 object-file.c                 | 2 +-
 packfile.c                    | 2 +-
 pkt-line.c                    | 2 +-
 range-diff.c                  | 2 +-
 ref-filter.c                  | 2 +-
 t/helper/test-match-trees.c   | 1 -
 t/helper/test-mergesort.c     | 1 -
 t/helper/test-oid-array.c     | 1 -
 t/helper/test-oidtree.c       | 1 -
 t/helper/test-parse-options.c | 1 -
 t/helper/test-read-midx.c     | 1 -
 t/helper/test-string-list.c   | 1 -
 tree-diff.c                   | 2 +-
 tree-walk.c                   | 2 +-
 tree.c                        | 2 +-
 wrapper.c                     | 3 ++-
 31 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/archive-zip.c b/archive-zip.c
index ef538a90df4..d0d065a312e 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2006 Rene Scharfe
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "archive.h"
 #include "gettext.h"
diff --git a/bundle-uri.c b/bundle-uri.c
index 6d44662ee1f..ec1552bbca2 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "bundle-uri.h"
 #include "bundle.h"
 #include "copy.h"
diff --git a/color.c b/color.c
index f8a25ca807b..83abb11eda0 100644
--- a/color.c
+++ b/color.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "color.h"
 #include "editor.h"
diff --git a/combine-diff.c b/combine-diff.c
index f7e9fb57473..f8d61965776 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "object-store.h"
 #include "commit.h"
 #include "convert.h"
diff --git a/common-main.c b/common-main.c
index 8ab50fa37a4..033778b3c56 100644
--- a/common-main.c
+++ b/common-main.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "attr.h"
diff --git a/config.c b/config.c
index 97063a0743e..2a9ed27efe5 100644
--- a/config.c
+++ b/config.c
@@ -5,7 +5,7 @@
  * Copyright (C) Johannes Schindelin, 2005
  *
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
 #include "alloc.h"
diff --git a/copy.c b/copy.c
index 923d8a6dc61..882c79cffb0 100644
--- a/copy.c
+++ b/copy.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "copy.h"
 #include "path.h"
 #include "wrapper.h"
diff --git a/credential.c b/credential.c
index 42194efc9e0..a600d0c1ac1 100644
--- a/credential.c
+++ b/credential.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
 #include "credential.h"
diff --git a/daemon.c b/daemon.c
index f89f99d7ef4..7139cc201d7 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/date.c b/date.c
index bc030da012f..a6ca6b318bd 100644
--- a/date.c
+++ b/date.c
@@ -4,7 +4,7 @@
  * Copyright (C) Linus Torvalds, 2005
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "date.h"
 #include "gettext.h"
 #include "pager.h"
diff --git a/diagnose.c b/diagnose.c
index f9a2496c7ff..58f49f76c7a 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "diagnose.h"
 #include "compat/disk.h"
 #include "archive.h"
diff --git a/environment.c b/environment.c
index 541f0b19acf..28d18eaca8e 100644
--- a/environment.c
+++ b/environment.c
@@ -7,7 +7,7 @@
  * even if you might want to know where the git directory etc
  * are.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "branch.h"
 #include "convert.h"
diff --git a/ll-merge.c b/ll-merge.c
index 85517e668e3..1993530688e 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2007 Junio C Hamano
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "convert.h"
 #include "attr.h"
diff --git a/match-trees.c b/match-trees.c
index 9b78d99507b..6bc8eb76477 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "hex.h"
 #include "match-trees.h"
 #include "tree.h"
diff --git a/midx.c b/midx.c
index 2d0da573281..c7679c3c4f5 100644
--- a/midx.c
+++ b/midx.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/object-file.c b/object-file.c
index 8163ddbaddd..8e0df7360ae 100644
--- a/object-file.c
+++ b/object-file.c
@@ -6,7 +6,7 @@
  * This handles basic git object files - packing, unpacking,
  * creation etc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/packfile.c b/packfile.c
index 9ae2278c22e..1ee9f65242c 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/pkt-line.c b/pkt-line.c
index 8b5fa788517..62b4208b66e 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "copy.h"
 #include "pkt-line.h"
 #include "gettext.h"
diff --git a/range-diff.c b/range-diff.c
index a1e0cffb9f6..6a704e6f471 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
 #include "range-diff.h"
diff --git a/ref-filter.c b/ref-filter.c
index 5387f79be6d..594e66ad361 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 3c62e33ccdf..a0afc1b4bc8 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "match-trees.h"
 #include "object-name.h"
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
index 3aabae6c1c4..42ccc870516 100644
--- a/t/helper/test-mergesort.c
+++ b/t/helper/test-mergesort.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "mem-pool.h"
 #include "mergesort.h"
 #include "strbuf.h"
diff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c
index ea3bf278984..241e5da3157 100644
--- a/t/helper/test-oid-array.c
+++ b/t/helper/test-oid-array.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "oid-array.h"
 #include "setup.h"
diff --git a/t/helper/test-oidtree.c b/t/helper/test-oidtree.c
index 796c9811e0f..dc509fb8065 100644
--- a/t/helper/test-oidtree.c
+++ b/t/helper/test-oidtree.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "oidtree.h"
 #include "setup.h"
diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
index 20a81a1eb21..3003987ec17 100644
--- a/t/helper/test-parse-options.c
+++ b/t/helper/test-parse-options.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "parse-options.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index b32abff7f11..211addaa005 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "midx.h"
 #include "repository.h"
diff --git a/t/helper/test-string-list.c b/t/helper/test-string-list.c
index 959f27c74c6..042c6ff0059 100644
--- a/t/helper/test-string-list.c
+++ b/t/helper/test-string-list.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "strbuf.h"
 #include "string-list.h"
 
diff --git a/tree-diff.c b/tree-diff.c
index a76e6dae619..9ea2dd7a6c3 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -1,7 +1,7 @@
 /*
  * Helper functions for tree diff generation
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "tree.h"
diff --git a/tree-walk.c b/tree-walk.c
index 2993c48c2f3..d3c48e06df0 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tree-walk.h"
 #include "alloc.h"
 #include "dir.h"
diff --git a/tree.c b/tree.c
index f242a7ab691..0dd2029a8a2 100644
--- a/tree.c
+++ b/tree.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "cache-tree.h"
 #include "hex.h"
 #include "tree.h"
diff --git a/wrapper.c b/wrapper.c
index 5ab0460de5c..67f5f5dbe19 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -1,10 +1,11 @@
 /*
  * Various trivial helper wrappers around standard functions
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "object.h"
 #include "repository.h"
 #include "strbuf.h"
 #include "trace2.h"
-- 
gitgitgadget


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

* [PATCH 18/23] cache.h: remove unnecessary headers
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (16 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 17/23] treewide: remove cache.h inclusion due to previous changes Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 19/23] fsmonitor: reduce includes of cache.h Elijah Newren via GitGitGadget
                   ` (6 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h                              | 2 --
 compat/fsmonitor/fsm-ipc-darwin.c    | 1 +
 compat/fsmonitor/fsm-listen-darwin.c | 1 +
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cache.h b/cache.h
index 591c67b0595..bdedb87e83b 100644
--- a/cache.h
+++ b/cache.h
@@ -4,8 +4,6 @@
 #include "git-compat-util.h"
 #include "strbuf.h"
 #include "hashmap.h"
-#include "gettext.h"
-#include "string-list.h"
 #include "pathspec.h"
 #include "object.h"
 #include "statinfo.h"
diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
index e62f093cc19..bc68dca0cae 100644
--- a/compat/fsmonitor/fsm-ipc-darwin.c
+++ b/compat/fsmonitor/fsm-ipc-darwin.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "config.h"
+#include "gettext.h"
 #include "hex.h"
 #include "repository.h"
 #include "strbuf.h"
diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c
index 5eb6402ab82..18c0e3913dc 100644
--- a/compat/fsmonitor/fsm-listen-darwin.c
+++ b/compat/fsmonitor/fsm-listen-darwin.c
@@ -29,6 +29,7 @@
 #include "fsmonitor--daemon.h"
 #include "fsmonitor-path-utils.h"
 #include "gettext.h"
+#include "string-list.h"
 
 struct fsm_listen_data
 {
-- 
gitgitgadget


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

* [PATCH 19/23] fsmonitor: reduce includes of cache.h
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (17 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 18/23] cache.h: remove unnecessary headers Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 20/23] commit.h: reduce unnecessary includes Elijah Newren via GitGitGadget
                   ` (5 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 compat/fsmonitor/fsm-health-darwin.c | 2 +-
 compat/fsmonitor/fsm-ipc-darwin.c    | 2 +-
 compat/fsmonitor/fsm-listen-darwin.c | 2 +-
 fsmonitor--daemon.h                  | 1 -
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/compat/fsmonitor/fsm-health-darwin.c b/compat/fsmonitor/fsm-health-darwin.c
index b9f709e8548..4c291f8a066 100644
--- a/compat/fsmonitor/fsm-health-darwin.c
+++ b/compat/fsmonitor/fsm-health-darwin.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "fsmonitor.h"
 #include "fsm-health.h"
diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
index bc68dca0cae..793073aaa72 100644
--- a/compat/fsmonitor/fsm-ipc-darwin.c
+++ b/compat/fsmonitor/fsm-ipc-darwin.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c
index 18c0e3913dc..23e24b4b374 100644
--- a/compat/fsmonitor/fsm-listen-darwin.c
+++ b/compat/fsmonitor/fsm-listen-darwin.c
@@ -23,7 +23,7 @@
 #endif
 #endif
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "fsmonitor.h"
 #include "fsm-listen.h"
 #include "fsmonitor--daemon.h"
diff --git a/fsmonitor--daemon.h b/fsmonitor--daemon.h
index e24838f9a86..70d776c54f6 100644
--- a/fsmonitor--daemon.h
+++ b/fsmonitor--daemon.h
@@ -3,7 +3,6 @@
 
 #ifdef HAVE_FSMONITOR_DAEMON_BACKEND
 
-#include "cache.h"
 #include "dir.h"
 #include "run-command.h"
 #include "simple-ipc.h"
-- 
gitgitgadget


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

* [PATCH 20/23] commit.h: reduce unnecessary includes
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (18 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 19/23] fsmonitor: reduce includes of cache.h Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 21/23] object-store.h: " Elijah Newren via GitGitGadget
                   ` (4 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 add-interactive.c    |  1 +
 archive.c            |  2 ++
 bloom.c              |  1 +
 builtin/diff-tree.c  |  1 +
 builtin/diff.c       |  1 +
 builtin/gc.c         |  1 +
 builtin/log.c        |  1 +
 builtin/merge-tree.c |  1 +
 combine-diff.c       |  1 +
 commit-graph.c       |  1 +
 commit.c             |  1 +
 commit.h             | 11 ++++-------
 dir.c                |  1 +
 fetch-pack.c         |  1 +
 fsck.c               |  1 +
 gpg-interface.c      |  1 +
 grep.c               |  1 +
 http-push.c          |  1 +
 log-tree.c           |  1 +
 merge-ort-wrappers.c |  1 +
 merge.c              |  1 +
 notes-cache.c        |  1 +
 notes-utils.c        |  1 +
 object-name.c        |  1 +
 pack-bitmap-write.c  |  1 +
 parse-options-cb.c   |  1 +
 parse-options.c      |  1 +
 read-cache.c         |  1 +
 ref-filter.c         |  1 +
 reflog.c             |  1 +
 refs/debug.c         |  1 +
 refspec.c            |  1 +
 revision.h           |  1 +
 send-pack.c          |  1 +
 wt-status.c          |  1 +
 35 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/add-interactive.c b/add-interactive.c
index 757a9929d41..de877ca0525 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -12,6 +12,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "prompt.h"
+#include "tree.h"
 
 static void init_color(struct repository *r, struct add_i_state *s,
 		       const char *section_and_slot, char *dst,
diff --git a/archive.c b/archive.c
index ab8966d73a5..6226e16b25e 100644
--- a/archive.c
+++ b/archive.c
@@ -6,10 +6,12 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "pretty.h"
 #include "setup.h"
 #include "refs.h"
 #include "object-store.h"
 #include "commit.h"
+#include "tree.h"
 #include "tree-walk.h"
 #include "attr.h"
 #include "archive.h"
diff --git a/bloom.c b/bloom.c
index d0730525da5..aef6b5fea2d 100644
--- a/bloom.c
+++ b/bloom.c
@@ -6,6 +6,7 @@
 #include "hashmap.h"
 #include "commit-graph.h"
 #include "commit.h"
+#include "commit-slab.h"
 
 define_commit_slab(bloom_filter_slab, struct bloom_filter);
 
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 385c2d0230c..0b02c62b85e 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -9,6 +9,7 @@
 #include "builtin.h"
 #include "submodule.h"
 #include "repository.h"
+#include "tree.h"
 
 static struct rev_info log_tree_opt;
 
diff --git a/builtin/diff.c b/builtin/diff.c
index 8f386535d61..457dee14457 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -22,6 +22,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "oid-array.h"
+#include "tree.h"
 
 #define DIFF_NO_INDEX_EXPLICIT 1
 #define DIFF_NO_INDEX_IMPLICIT 2
diff --git a/builtin/gc.c b/builtin/gc.c
index b95154fba16..d11712b1444 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -12,6 +12,7 @@
 
 #include "builtin.h"
 #include "abspath.h"
+#include "date.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/builtin/log.c b/builtin/log.c
index 95de51921f8..137b84b31ef 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -44,6 +44,7 @@
 #include "commit-reach.h"
 #include "range-diff.h"
 #include "tmp-objdir.h"
+#include "tree.h"
 #include "write-or-die.h"
 
 #define MAIL_DEFAULT_WRAP 72
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 6b9f006ec19..aa8040c2a6a 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -16,6 +16,7 @@
 #include "exec-cmd.h"
 #include "merge-blobs.h"
 #include "quote.h"
+#include "tree.h"
 
 static int line_termination = '\n';
 
diff --git a/combine-diff.c b/combine-diff.c
index f8d61965776..1e3cd7fb170 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -13,6 +13,7 @@
 #include "xdiff/xmacros.h"
 #include "log-tree.h"
 #include "refs.h"
+#include "tree.h"
 #include "userdiff.h"
 #include "oid-array.h"
 #include "revision.h"
diff --git a/commit-graph.c b/commit-graph.c
index 0c4f2266445..6f612f368ba 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -23,6 +23,7 @@
 #include "shallow.h"
 #include "json-writer.h"
 #include "trace2.h"
+#include "tree.h"
 #include "chunk-format.h"
 #include "wrapper.h"
 
diff --git a/commit.c b/commit.c
index 878b4473e4c..10676165a1d 100644
--- a/commit.c
+++ b/commit.c
@@ -26,6 +26,7 @@
 #include "run-command.h"
 #include "setup.h"
 #include "shallow.h"
+#include "tree.h"
 #include "hook.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/commit.h
index 69b2f376e9d..28928833c54 100644
--- a/commit.h
+++ b/commit.h
@@ -2,13 +2,10 @@
 #define COMMIT_H
 
 #include "object.h"
-#include "tree.h"
-#include "strbuf.h"
-#include "decorate.h"
-#include "gpg-interface.h"
-#include "string-list.h"
-#include "pretty.h"
-#include "commit-slab.h"
+
+struct signature_check;
+struct strbuf;
+struct tree;
 
 #define COMMIT_NOT_FROM_GRAPH 0xFFFFFFFF
 #define GENERATION_NUMBER_INFINITY ((1ULL << 63) - 1)
diff --git a/dir.c b/dir.c
index ed262fa6e43..a7469df3ac7 100644
--- a/dir.c
+++ b/dir.c
@@ -27,6 +27,7 @@
 #include "submodule-config.h"
 #include "symlinks.h"
 #include "trace2.h"
+#include "tree.h"
 #include "wrapper.h"
 
 /*
diff --git a/fetch-pack.c b/fetch-pack.c
index 677102465a1..a9745bd9faf 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "repository.h"
 #include "config.h"
+#include "date.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/fsck.c b/fsck.c
index adbe8bf59e7..3261ef9ec28 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "alloc.h"
+#include "date.h"
 #include "hex.h"
 #include "object-store.h"
 #include "repository.h"
diff --git a/gpg-interface.c b/gpg-interface.c
index 8615dcd4b4b..49d72c2066b 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "commit.h"
 #include "config.h"
+#include "date.h"
 #include "gettext.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/grep.c b/grep.c
index d144b374894..e620e375b1d 100644
--- a/grep.c
+++ b/grep.c
@@ -4,6 +4,7 @@
 #include "grep.h"
 #include "hex.h"
 #include "object-store.h"
+#include "pretty.h"
 #include "userdiff.h"
 #include "xdiff-interface.h"
 #include "diff.h"
diff --git a/http-push.c b/http-push.c
index 637a4e91f7a..3f184986362 100644
--- a/http-push.c
+++ b/http-push.c
@@ -15,6 +15,7 @@
 #include "setup.h"
 #include "sigchain.h"
 #include "strvec.h"
+#include "tree.h"
 #include "packfile.h"
 #include "object-store.h"
 #include "commit-reach.h"
diff --git a/log-tree.c b/log-tree.c
index b5cf3d8439c..8861900b592 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -24,6 +24,7 @@
 #include "help.h"
 #include "range-diff.h"
 #include "strmap.h"
+#include "tree.h"
 #include "write-or-die.h"
 
 static struct decoration name_decoration = { "object names" };
diff --git a/merge-ort-wrappers.c b/merge-ort-wrappers.c
index 2d1e8aa7ee7..ad2bb676e13 100644
--- a/merge-ort-wrappers.c
+++ b/merge-ort-wrappers.c
@@ -3,6 +3,7 @@
 #include "merge-ort.h"
 #include "merge-ort-wrappers.h"
 #include "repository.h"
+#include "tree.h"
 
 #include "commit.h"
 
diff --git a/merge.c b/merge.c
index da7fa652c27..10aaec3a6c1 100644
--- a/merge.c
+++ b/merge.c
@@ -7,6 +7,7 @@
 #include "commit.h"
 #include "run-command.h"
 #include "resolve-undo.h"
+#include "tree.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
 #include "dir.h"
diff --git a/notes-cache.c b/notes-cache.c
index fbcdfd0dfe5..14288caf98f 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "notes-cache.h"
 #include "object-store.h"
+#include "pretty.h"
 #include "repository.h"
 #include "commit.h"
 #include "refs.h"
diff --git a/notes-utils.c b/notes-utils.c
index cb88171b7bb..4a793eb347f 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -6,6 +6,7 @@
 #include "refs.h"
 #include "notes-utils.h"
 #include "repository.h"
+#include "strbuf.h"
 
 void create_notes_commit(struct repository *r,
 			 struct notes_tree *t,
diff --git a/object-name.c b/object-name.c
index 3cd5b327293..5ccbe854b60 100644
--- a/object-name.c
+++ b/object-name.c
@@ -15,6 +15,7 @@
 #include "dir.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "pretty.h"
 #include "object-store.h"
 #include "repository.h"
 #include "setup.h"
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index faf67c94d37..3d3fd380654 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -18,6 +18,7 @@
 #include "commit-reach.h"
 #include "prio-queue.h"
 #include "trace2.h"
+#include "tree.h"
 
 struct bitmapped_commit {
 	struct commit *commit;
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 26a4c7d08a9..be81158f861 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -3,6 +3,7 @@
 #include "branch.h"
 #include "commit.h"
 #include "color.h"
+#include "date.h"
 #include "environment.h"
 #include "gettext.h"
 #include "object-name.h"
diff --git a/parse-options.c b/parse-options.c
index b6803647d0e..f8a155ee13b 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -5,6 +5,7 @@
 #include "commit.h"
 #include "color.h"
 #include "gettext.h"
+#include "strbuf.h"
 #include "utf8.h"
 
 static int disallow_abbreviated_options;
diff --git a/read-cache.c b/read-cache.c
index b3e2917ddc9..d64d93bc364 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -6,6 +6,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "config.h"
+#include "date.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "hex.h"
diff --git a/ref-filter.c b/ref-filter.c
index 594e66ad361..84eee904ba3 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
+#include "gpg-interface.h"
 #include "hex.h"
 #include "parse-options.h"
 #include "refs.h"
diff --git a/reflog.c b/reflog.c
index 9c094430884..57dc7c0d051 100644
--- a/reflog.c
+++ b/reflog.c
@@ -4,6 +4,7 @@
 #include "reflog.h"
 #include "refs.h"
 #include "revision.h"
+#include "tree.h"
 #include "worktree.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/refs/debug.c b/refs/debug.c
index adc34c836fc..6f11e6de46c 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "hex.h"
 #include "refs-internal.h"
+#include "string-list.h"
 #include "trace.h"
 
 static struct trace_key trace_refs = TRACE_KEY_INIT(REFS);
diff --git a/refspec.c b/refspec.c
index 68020ee84c6..2ddea205d10 100644
--- a/refspec.c
+++ b/refspec.c
@@ -6,6 +6,7 @@
 #include "refs.h"
 #include "refspec.h"
 #include "repository.h"
+#include "strbuf.h"
 
 static struct refspec_item s_tag_refspec = {
 	.force = 0,
diff --git a/revision.h b/revision.h
index 742700504a7..6630bb2eae2 100644
--- a/revision.h
+++ b/revision.h
@@ -8,6 +8,7 @@
 #include "pretty.h"
 #include "diff.h"
 #include "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 351037b07bc..e68da24cc52 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "commit.h"
+#include "date.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
diff --git a/wt-status.c b/wt-status.c
index 97b9c1c0359..068b76ef6d9 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -22,6 +22,7 @@
 #include "strbuf.h"
 #include "trace.h"
 #include "trace2.h"
+#include "tree.h"
 #include "utf8.h"
 #include "worktree.h"
 #include "lockfile.h"
-- 
gitgitgadget


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

* [PATCH 21/23] object-store.h: reduce unnecessary includes
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (19 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 20/23] commit.h: reduce unnecessary includes Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 22/23] diff.h: " Elijah Newren via GitGitGadget
                   ` (3 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 object-file.c      | 1 +
 object-name.c      | 1 +
 object-store.h     | 8 ++++----
 submodule-config.c | 1 +
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/object-file.c b/object-file.c
index 8e0df7360ae..921a717d8a5 100644
--- a/object-file.c
+++ b/object-file.c
@@ -38,6 +38,7 @@
 #include "packfile.h"
 #include "object-file.h"
 #include "object-store.h"
+#include "oidtree.h"
 #include "promisor-remote.h"
 #include "setup.h"
 #include "submodule.h"
diff --git a/object-name.c b/object-name.c
index 5ccbe854b60..88d839f70bc 100644
--- a/object-name.c
+++ b/object-name.c
@@ -14,6 +14,7 @@
 #include "remote.h"
 #include "dir.h"
 #include "oid-array.h"
+#include "oidtree.h"
 #include "packfile.h"
 #include "pretty.h"
 #include "object-store.h"
diff --git a/object-store.h b/object-store.h
index f9d225783ae..23ea86d3702 100644
--- a/object-store.h
+++ b/object-store.h
@@ -2,16 +2,16 @@
 #define OBJECT_STORE_H
 
 #include "object.h"
-#include "oidmap.h"
 #include "list.h"
-#include "oid-array.h"
-#include "strbuf.h"
 #include "thread-utils.h"
 #include "khash.h"
 #include "dir.h"
-#include "oidtree.h"
 #include "oidset.h"
 
+struct oidmap;
+struct oidtree;
+struct strbuf;
+
 struct object_directory {
 	struct object_directory *next;
 
diff --git a/submodule-config.c b/submodule-config.c
index 7fc0812b644..58dfbde9ae5 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -12,6 +12,7 @@
 #include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
+#include "thread-utils.h"
 #include "tree-walk.h"
 
 /*
-- 
gitgitgadget


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

* [PATCH 22/23] diff.h: reduce unnecessary includes
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (20 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 21/23] object-store.h: " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-16  3:03 ` [PATCH 23/23] reftable: ensure git-compat-util.h is the first (indirect) include Elijah Newren via GitGitGadget
                   ` (2 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 attr.c              | 1 +
 diff.h              | 1 -
 http-push.c         | 1 +
 line-log.c          | 1 +
 pack-bitmap-write.c | 1 +
 reflog.c            | 1 +
 tree-diff.c         | 1 +
 7 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/attr.c b/attr.c
index 2d8aeb8b58c..ddf2b0cbc2e 100644
--- a/attr.c
+++ b/attr.c
@@ -20,6 +20,7 @@
 #include "object-store.h"
 #include "setup.h"
 #include "thread-utils.h"
+#include "tree-walk.h"
 
 const char git_attr__true[] = "(builtin)true";
 const char git_attr__false[] = "\0(builtin)false";
diff --git a/diff.h b/diff.h
index 53aeb02a54b..69e574f4315 100644
--- a/diff.h
+++ b/diff.h
@@ -4,7 +4,6 @@
 #ifndef DIFF_H
 #define DIFF_H
 
-#include "tree-walk.h"
 #include "pathspec.h"
 #include "oidset.h"
 #include "strbuf.h"
diff --git a/http-push.c b/http-push.c
index 3f184986362..866ba243a89 100644
--- a/http-push.c
+++ b/http-push.c
@@ -16,6 +16,7 @@
 #include "sigchain.h"
 #include "strvec.h"
 #include "tree.h"
+#include "tree-walk.h"
 #include "packfile.h"
 #include "object-store.h"
 #include "commit-reach.h"
diff --git a/line-log.c b/line-log.c
index 10c19daec4a..6a7ac312a43 100644
--- a/line-log.c
+++ b/line-log.c
@@ -18,6 +18,7 @@
 #include "setup.h"
 #include "strvec.h"
 #include "bloom.h"
+#include "tree-walk.h"
 
 static void range_set_grow(struct range_set *rs, size_t extra)
 {
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 3d3fd380654..cdffe2ce47d 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -19,6 +19,7 @@
 #include "prio-queue.h"
 #include "trace2.h"
 #include "tree.h"
+#include "tree-walk.h"
 
 struct bitmapped_commit {
 	struct commit *commit;
diff --git a/reflog.c b/reflog.c
index 57dc7c0d051..ee1bf5d032c 100644
--- a/reflog.c
+++ b/reflog.c
@@ -5,6 +5,7 @@
 #include "refs.h"
 #include "revision.h"
 #include "tree.h"
+#include "tree-walk.h"
 #include "worktree.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/tree-diff.c b/tree-diff.c
index 9ea2dd7a6c3..20bb15f38d9 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -5,6 +5,7 @@
 #include "diff.h"
 #include "diffcore.h"
 #include "tree.h"
+#include "tree-walk.h"
 
 /*
  * Some mode bits are also used internally for computations.
-- 
gitgitgadget


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

* [PATCH 23/23] reftable: ensure git-compat-util.h is the first (indirect) include
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (21 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 22/23] diff.h: " Elijah Newren via GitGitGadget
@ 2023-04-16  3:03 ` Elijah Newren via GitGitGadget
  2023-04-17 21:07 ` [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Derrick Stolee
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-16  3:03 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 reftable/error.c         | 1 +
 reftable/publicbasics.c  | 2 +-
 reftable/tree.c          | 2 +-
 reftable/tree_test.c     | 1 +
 t/helper/test-reftable.c | 1 +
 5 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/reftable/error.c b/reftable/error.c
index 93941f21457..0d1766735e8 100644
--- a/reftable/error.c
+++ b/reftable/error.c
@@ -6,6 +6,7 @@ license that can be found in the LICENSE file or at
 https://developers.google.com/open-source/licenses/bsd
 */
 
+#include "system.h"
 #include "reftable-error.h"
 
 #include <stdio.h>
diff --git a/reftable/publicbasics.c b/reftable/publicbasics.c
index 0ad7d5c0ff2..bcb82530d6c 100644
--- a/reftable/publicbasics.c
+++ b/reftable/publicbasics.c
@@ -6,10 +6,10 @@ license that can be found in the LICENSE file or at
 https://developers.google.com/open-source/licenses/bsd
 */
 
+#include "system.h"
 #include "reftable-malloc.h"
 
 #include "basics.h"
-#include "system.h"
 
 static void *(*reftable_malloc_ptr)(size_t sz);
 static void *(*reftable_realloc_ptr)(void *, size_t);
diff --git a/reftable/tree.c b/reftable/tree.c
index b8899e060ab..a5bf8809854 100644
--- a/reftable/tree.c
+++ b/reftable/tree.c
@@ -6,10 +6,10 @@ license that can be found in the LICENSE file or at
 https://developers.google.com/open-source/licenses/bsd
 */
 
+#include "system.h"
 #include "tree.h"
 
 #include "basics.h"
-#include "system.h"
 
 struct tree_node *tree_search(void *key, struct tree_node **rootp,
 			      int (*compare)(const void *, const void *),
diff --git a/reftable/tree_test.c b/reftable/tree_test.c
index cbff1255886..ac3a045ad4a 100644
--- a/reftable/tree_test.c
+++ b/reftable/tree_test.c
@@ -6,6 +6,7 @@ license that can be found in the LICENSE file or at
 https://developers.google.com/open-source/licenses/bsd
 */
 
+#include "system.h"
 #include "tree.h"
 
 #include "basics.h"
diff --git a/t/helper/test-reftable.c b/t/helper/test-reftable.c
index 1f0a28cbb64..00237ef0d9e 100644
--- a/t/helper/test-reftable.c
+++ b/t/helper/test-reftable.c
@@ -1,3 +1,4 @@
+#include "reftable/system.h"
 #include "reftable/reftable-tests.h"
 #include "test-tool.h"
 
-- 
gitgitgadget

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

* Re: [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies
  2023-04-16  3:03 ` [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies Elijah Newren via GitGitGadget
@ 2023-04-17 20:59   ` Derrick Stolee
  2023-04-18  2:36     ` Elijah Newren
  2023-04-18 23:29     ` Junio C Hamano
  0 siblings, 2 replies; 81+ messages in thread
From: Derrick Stolee @ 2023-04-17 20:59 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget, git; +Cc: Calvin Wan, Elijah Newren

On 4/15/2023 11:03 PM, Elijah Newren via GitGitGadget wrote:
> From: Elijah Newren <newren@gmail.com>
> 
> Previously, hash.h depended upon and included repository.h, due to
> the definition and use of the_hash_algo (defined as
> the_repository->hash_algo).  Move this #define, and the associated
> inline functions that depend upon it, from hash.h to repository.h.
> Due to that movement, reverse the dependencies so repository.h includes
> hash.h.
> 
> This allows hash.h and object.h to be fairly small, minimal headers.  It
> also exposes a lot of hidden dependencies on both path.h (which was
> brought in by repository.h) and repository.h (which was previously
> implicitly brought in by object.h).

This is the first patch in the series where I don't immediately agree
with the patch. This is a big list of methods that don't seem like
they fit in repository.h:

> diff --git a/repository.h b/repository.h
> +static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
> +static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
> +static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
> +static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
> +static inline int is_null_oid(const struct object_id *oid)
> +static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
> +static inline void oidcpy_with_padding(struct object_id *dst,
> +				       const struct object_id *src)
> +static inline void hashclr(unsigned char *hash)
> +static inline void oidclr(struct object_id *oid)
> +static inline void oidread(struct object_id *oid, const unsigned char *hash)
> +static inline int is_empty_blob_sha1(const unsigned char *sha1)
> +static inline int is_empty_blob_oid(const struct object_id *oid)
> +static inline int is_empty_tree_sha1(const unsigned char *sha1)
> +static inline int is_empty_tree_oid(const struct object_id *oid)

The goal to remove repository.h from hash.h and object.h makes sense
as a goal, but is there another way to do it? Can we redefine
'extern struct repository *the_repository;' in hash.h so we have
access to that pointer?

Thanks,
-Stolee

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

* Re: [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps)
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (22 preceding siblings ...)
  2023-04-16  3:03 ` [PATCH 23/23] reftable: ensure git-compat-util.h is the first (indirect) include Elijah Newren via GitGitGadget
@ 2023-04-17 21:07 ` Derrick Stolee
  2023-04-18  2:41   ` Elijah Newren
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
  24 siblings, 1 reply; 81+ messages in thread
From: Derrick Stolee @ 2023-04-17 21:07 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget, git; +Cc: Calvin Wan, Elijah Newren

On 4/15/2023 11:03 PM, Elijah Newren via GitGitGadget wrote:
> 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.

Thank you for continuing to do this work.

>  * Patch 14-16: move functions between hash<->repository and
>    read-cache<->tree to simplify dependencies

My only comment was on patch 14, where I'm not sure I like the methods
moving from hash.h to repository.h. If we can find an alternative, that
would make me happy.

The rest of the series looked very good.

Thanks,
-Stolee

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

* Re: [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies
  2023-04-17 20:59   ` Derrick Stolee
@ 2023-04-18  2:36     ` Elijah Newren
  2023-04-18 23:29     ` Junio C Hamano
  1 sibling, 0 replies; 81+ messages in thread
From: Elijah Newren @ 2023-04-18  2:36 UTC (permalink / raw)
  To: Derrick Stolee
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan,
	Ævar Arnfjörð Bjarmason

On Mon, Apr 17, 2023 at 1:59 PM Derrick Stolee <derrickstolee@github.com> wrote:
>
> On 4/15/2023 11:03 PM, Elijah Newren via GitGitGadget wrote:
> > From: Elijah Newren <newren@gmail.com>
> >
> > Previously, hash.h depended upon and included repository.h, due to
> > the definition and use of the_hash_algo (defined as
> > the_repository->hash_algo).  Move this #define, and the associated
> > inline functions that depend upon it, from hash.h to repository.h.
> > Due to that movement, reverse the dependencies so repository.h includes
> > hash.h.
> >
> > This allows hash.h and object.h to be fairly small, minimal headers.  It
> > also exposes a lot of hidden dependencies on both path.h (which was
> > brought in by repository.h) and repository.h (which was previously
> > implicitly brought in by object.h).
>
> This is the first patch in the series where I don't immediately agree
> with the patch. This is a big list of methods that don't seem like
> they fit in repository.h:
>
> > diff --git a/repository.h b/repository.h
> > +static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
> > +static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
> > +static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
> > +static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
> > +static inline int is_null_oid(const struct object_id *oid)
> > +static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
> > +static inline void oidcpy_with_padding(struct object_id *dst,
> > +                                    const struct object_id *src)
> > +static inline void hashclr(unsigned char *hash)
> > +static inline void oidclr(struct object_id *oid)
> > +static inline void oidread(struct object_id *oid, const unsigned char *hash)
> > +static inline int is_empty_blob_sha1(const unsigned char *sha1)
> > +static inline int is_empty_blob_oid(const struct object_id *oid)
> > +static inline int is_empty_tree_sha1(const unsigned char *sha1)
> > +static inline int is_empty_tree_oid(const struct object_id *oid)

Yeah, their names suggest they in no way depend upon internals of a
repository, but that's largely because they are misnamed, similar to
our old friends like get_oid() and repo_get_oid().

> The goal to remove repository.h from hash.h and object.h makes sense
> as a goal, but is there another way to do it? Can we redefine
> 'extern struct repository *the_repository;' in hash.h so we have
> access to that pointer?

Having access to the pointer is insufficient.  These functions all
make use of the_repository->hash_algo, and are inline, so the
definition and layout of struct repository is necessary.

An alternate solution might be to just wrap the #define of
the_hash_algo, as well as these functions, with
NO_THE_REPOSITORY_COMPATIBILITY_MACROS, try to convince Ævar that we
put those #ifdefs in before he wrote his series[1] and that he thus
missed some uses of that macro, and then watch him transform all of
them with a series of cocci changes so these functions just go away.
;-)

But that sounds like a separate big series, and I'm dubious about my
ability to hoodwink Ævar.

Any other ideas?


[1] https://lore.kernel.org/git/cover-v2-00.17-00000000000-20230328T110946Z-avarab@gmail.com/

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

* Re: [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps)
  2023-04-17 21:07 ` [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Derrick Stolee
@ 2023-04-18  2:41   ` Elijah Newren
  0 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren @ 2023-04-18  2:41 UTC (permalink / raw)
  To: Derrick Stolee; +Cc: Elijah Newren via GitGitGadget, git, Calvin Wan

On Mon, Apr 17, 2023 at 2:07 PM Derrick Stolee <derrickstolee@github.com> wrote:
>
> On 4/15/2023 11:03 PM, Elijah Newren via GitGitGadget wrote:
> > 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.
>
> Thank you for continuing to do this work.
>
> >  * Patch 14-16: move functions between hash<->repository and
> >    read-cache<->tree to simplify dependencies
>
> My only comment was on patch 14, where I'm not sure I like the methods
> moving from hash.h to repository.h. If we can find an alternative, that
> would make me happy.

I'm not aware of one, but I tried to deviously nerd snipe an expert on
cleaning up compatibility macros for the_repository to see if he might
have any bright ideas.  :-)

Also, if you have any other ideas that might work, I'm all ears.

> The rest of the series looked very good.

Thanks for taking a look!

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

* Re: [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies
  2023-04-17 20:59   ` Derrick Stolee
  2023-04-18  2:36     ` Elijah Newren
@ 2023-04-18 23:29     ` Junio C Hamano
  2023-04-20  5:06       ` Elijah Newren
  1 sibling, 1 reply; 81+ messages in thread
From: Junio C Hamano @ 2023-04-18 23:29 UTC (permalink / raw)
  To: Derrick Stolee
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Elijah Newren

Derrick Stolee <derrickstolee@github.com> writes:

> This is the first patch in the series where I don't immediately agree
> with the patch. This is a big list of methods that don't seem like
> they fit in repository.h:
>
>> diff --git a/repository.h b/repository.h
>> +static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
>> +static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
>> +static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
>> +static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
>> +static inline int is_null_oid(const struct object_id *oid)
>> +static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
>> +static inline void oidcpy_with_padding(struct object_id *dst,
>> +				       const struct object_id *src)
>> +static inline void hashclr(unsigned char *hash)
>> +static inline void oidclr(struct object_id *oid)
>> +static inline void oidread(struct object_id *oid, const unsigned char *hash)
>> +static inline int is_empty_blob_sha1(const unsigned char *sha1)
>> +static inline int is_empty_blob_oid(const struct object_id *oid)
>> +static inline int is_empty_tree_sha1(const unsigned char *sha1)
>> +static inline int is_empty_tree_oid(const struct object_id *oid)
>
> The goal to remove repository.h from hash.h and object.h makes sense
> as a goal, but is there another way to do it?

Indeed.

All of the above sit very well in hash simply because they are all
about hashes.  It does not have much to do with "repository", not
more than "well, hashes we use to identify objects, and objects are
stored in repositories".

From the point of view of somebody who needs to use these macros, it
is utterly unnatural that they have to include "repository.h" (as
opposed to, say, "hash.h") just to be able to compare two hash
values.  Most of our programs interact with only one repository, and
it is understandable to include a header "repository.h" if your
program needs to interact with an extra repository other than the
"current" one.  But this feels backwards and not quite satisfactory,
even though inlines are special and I can fully sympathize with the
author who felt that this patch was necessary.


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

* Re: [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies
  2023-04-18 23:29     ` Junio C Hamano
@ 2023-04-20  5:06       ` Elijah Newren
  2023-04-20 13:14         ` Derrick Stolee
  0 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren @ 2023-04-20  5:06 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Derrick Stolee, Elijah Newren via GitGitGadget, git, Calvin Wan

On Tue, Apr 18, 2023 at 4:29 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Derrick Stolee <derrickstolee@github.com> writes:
>
> > This is the first patch in the series where I don't immediately agree
> > with the patch. This is a big list of methods that don't seem like
> > they fit in repository.h:
> >
> >> diff --git a/repository.h b/repository.h
> >> +static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
> >> +static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
> >> +static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
> >> +static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
> >> +static inline int is_null_oid(const struct object_id *oid)
> >> +static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
> >> +static inline void oidcpy_with_padding(struct object_id *dst,
> >> +                                   const struct object_id *src)
> >> +static inline void hashclr(unsigned char *hash)
> >> +static inline void oidclr(struct object_id *oid)
> >> +static inline void oidread(struct object_id *oid, const unsigned char *hash)
> >> +static inline int is_empty_blob_sha1(const unsigned char *sha1)
> >> +static inline int is_empty_blob_oid(const struct object_id *oid)
> >> +static inline int is_empty_tree_sha1(const unsigned char *sha1)
> >> +static inline int is_empty_tree_oid(const struct object_id *oid)
> >
> > The goal to remove repository.h from hash.h and object.h makes sense
> > as a goal, but is there another way to do it?
>
> Indeed.
>
> All of the above sit very well in hash simply because they are all
> about hashes.  It does not have much to do with "repository", not
> more than "well, hashes we use to identify objects, and objects are
> stored in repositories".
>
> From the point of view of somebody who needs to use these macros, it
> is utterly unnatural that they have to include "repository.h" (as
> opposed to, say, "hash.h") just to be able to compare two hash
> values.  Most of our programs interact with only one repository, and
> it is understandable to include a header "repository.h" if your
> program needs to interact with an extra repository other than the
> "current" one.  But this feels backwards and not quite satisfactory,
> even though inlines are special and I can fully sympathize with the
> author who felt that this patch was necessary.

What would you think of either of the two following alternative solutions:

  * Move these into a new header, say "hash-repository.h" that folks
could include.  People wanting to use these macros would have to
include an alternate header, but one that is perhaps more logically
named, and would allow other headers to get the basics of hash.h
without repository.h

  * Move everything else in hash.h to a new header, say
"hash-basics.h", which hash.h will #include.  That retains the ability
for people to depend on hash.h and use these inline functions, while
also giving other headers the option of including the basics of
today's hash.h without repository.h.

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

* Re: [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies
  2023-04-20  5:06       ` Elijah Newren
@ 2023-04-20 13:14         ` Derrick Stolee
  2023-04-20 15:54           ` Junio C Hamano
  0 siblings, 1 reply; 81+ messages in thread
From: Derrick Stolee @ 2023-04-20 13:14 UTC (permalink / raw)
  To: Elijah Newren, Junio C Hamano
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan

On 4/20/2023 1:06 AM, Elijah Newren wrote:

> What would you think of either of the two following alternative solutions:
> 
>   * Move these into a new header, say "hash-repository.h" that folks
> could include.  People wanting to use these macros would have to
> include an alternate header, but one that is perhaps more logically
> named, and would allow other headers to get the basics of hash.h
> without repository.h
> 
>   * Move everything else in hash.h to a new header, say
> "hash-basics.h", which hash.h will #include.  That retains the ability
> for people to depend on hash.h and use these inline functions, while
> also giving other headers the option of including the basics of
> today's hash.h without repository.h.

I like both of these options, but prefer the second one.

This is mostly because most consumers in the Git codebase will want
these methods, and only the most fundamental hashing code will care
about hashing separate from the_hash_algo. So, the most-natural name
for "the header file that lets me hash stuff" would be "hash.h" and
"hash-basics.h" is for "I'm doing very simple, low-level hashing".

Thanks,
-Stolee

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

* Re: [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies
  2023-04-20 13:14         ` Derrick Stolee
@ 2023-04-20 15:54           ` Junio C Hamano
  2023-04-20 19:54             ` Glen Choo
  0 siblings, 1 reply; 81+ messages in thread
From: Junio C Hamano @ 2023-04-20 15:54 UTC (permalink / raw)
  To: Derrick Stolee
  Cc: Elijah Newren, Elijah Newren via GitGitGadget, git, Calvin Wan

Derrick Stolee <derrickstolee@github.com> writes:

> This is mostly because most consumers in the Git codebase will want
> these methods, and only the most fundamental hashing code will care
> about hashing separate from the_hash_algo. So, the most-natural name
> for "the header file that lets me hash stuff" would be "hash.h" and
> "hash-basics.h" is for "I'm doing very simple, low-level hashing".

I do agree with the reasoning for "most people want 'hash.h'"; what
is called the "basics" sounds more like for advanced users of the
low-level machinery, but somehow I expect "basic" would the one to
be used in sample programs in tutorials or something.  "ll-hash.h"
for low-level hash features?  I dunno.

But whatever the name for the header file meant to be used by
"advanced callers to low-level machinery" would be, I like your
choice of the latter variant between the ones Elijah presented.

Thanks.

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

* Re: [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies
  2023-04-20 15:54           ` Junio C Hamano
@ 2023-04-20 19:54             ` Glen Choo
  0 siblings, 0 replies; 81+ messages in thread
From: Glen Choo @ 2023-04-20 19:54 UTC (permalink / raw)
  To: Junio C Hamano, Derrick Stolee, Emily Shaffer
  Cc: Elijah Newren, Elijah Newren via GitGitGadget, git, Calvin Wan

Junio C Hamano <gitster@pobox.com> writes:

> Derrick Stolee <derrickstolee@github.com> writes:
>
>> This is mostly because most consumers in the Git codebase will want
>> these methods, and only the most fundamental hashing code will care
>> about hashing separate from the_hash_algo. So, the most-natural name
>> for "the header file that lets me hash stuff" would be "hash.h" and
>> "hash-basics.h" is for "I'm doing very simple, low-level hashing".
>
> I do agree with the reasoning for "most people want 'hash.h'"; what
> is called the "basics" sounds more like for advanced users of the
> low-level machinery, but somehow I expect "basic" would the one to
> be used in sample programs in tutorials or something.  "ll-hash.h"
> for low-level hash features?  I dunno.
>
> But whatever the name for the header file meant to be used by
> "advanced callers to low-level machinery" would be, I like your
> choice of the latter variant between the ones Elijah presented.

FWIW, I also think this is a good idea. I suspect that a lot of the
libification effort will need a similar distinction between "a subsystem
supporting the needs of the git binary" (aka high-level) and "basic,
reusable functionality that can be its own library" (aka low-level).

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

* [PATCH v2 00/22] Header cleanups (more splitting of cache.h and simplifying a few other deps)
  2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
                   ` (23 preceding siblings ...)
  2023-04-17 21:07 ` [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Derrick Stolee
@ 2023-04-22 20:17 ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 01/22] treewide: be explicit about dependence on strbuf.h Elijah Newren via GitGitGadget
                     ` (24 more replies)
  24 siblings, 25 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren

Changes since v1:

 * dropped the 3rd patch (it was pulled into the series this one depends
   upon to fix an issue in it)
 * redid the old patch 14 (new patch 13); moved the parts of hash.h not
   depending on repository.h into hash-ll.h so that other headers and files
   could depend upon just that part. (Are people happy with the hash-ll.h
   name or have alternate suggestions?)

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 (22):
  treewide: be explicit about dependence on strbuf.h
  symlinks.h: move declarations for symlinks.c functions 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-ll.h: split out of hash.h to remove dependency on repository.h
  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 +
 apply.h                                      |   2 +-
 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                    |   2 +
 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                                 |   2 +
 builtin/show-branch.c                        |   2 +
 builtin/show-index.c                         |   2 +
 builtin/update-index.c                       |   3 +
 builtin/update-ref.c                         |   2 +
 builtin/update-server-info.c                 |   1 +
 builtin/upload-archive.c                     |   1 +
 builtin/worktree.c                           |   2 +
 bundle-uri.c                                 |   3 +-
 cache.h                                      | 122 +-------
 checkout.c                                   |   1 +
 checkout.h                                   |   2 +-
 chunk-format.c                               |   1 +
 chunk-format.h                               |   2 +-
 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 +
 convert.h                                    |   2 +-
 copy.c                                       |   4 +-
 copy.h                                       |  10 +
 credential.c                                 |   3 +-
 csum-file.c                                  |   1 +
 csum-file.h                                  |   2 +-
 daemon.c                                     |   3 +-
 date.c                                       |   3 +-
 diagnose.c                                   |   2 +-
 diff-lib.c                                   |   1 +
 diff.c                                       |   2 +
 diff.h                                       |   1 -
 diffcore.h                                   |   2 +-
 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-ll.h                                    | 276 +++++++++++++++++++
 hash-lookup.c                                |   1 +
 hash.h                                       | 273 +-----------------
 hashmap.h                                    |   2 +-
 hex.c                                        |   1 +
 hex.h                                        |   2 +-
 hook.c                                       |   1 +
 http-push.c                                  |   2 +
 khash.h                                      |   1 +
 line-log.c                                   |   1 +
 ll-merge.c                                   |   3 +-
 log-tree.c                                   |   1 +
 ls-refs.c                                    |   1 +
 match-trees.c                                |   3 +-
 match-trees.h                                |  10 +
 merge-ort-wrappers.c                         |   2 +
 merge-ort.c                                  |   1 +
 merge-ort.h                                  |   2 +-
 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                                     |   3 +-
 oidmap.c                                     |   1 +
 oidtree.h                                    |   2 +-
 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-caps.c                              |   2 +-
 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                             |   2 +
 refs/ref-cache.h                             |   3 +-
 refspec.c                                    |   2 +
 reftable/dump.c                              |   2 +-
 reftable/error.c                             |   1 +
 reftable/publicbasics.c                      |   2 +-
 reftable/system.h                            |   2 +-
 reftable/tree.c                              |   2 +-
 reftable/tree_test.c                         |   1 +
 rerere.c                                     |   1 +
 reset.h                                      |   2 +-
 resolve-undo.c                               |   1 +
 resolve-undo.h                               |   2 +-
 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 +
 split-index.h                                |   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              |   2 +
 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             |   2 +
 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                                  |   3 +-
 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 +
 xdiff-interface.h                            |   2 +-
 216 files changed, 785 insertions(+), 545 deletions(-)
 create mode 100644 base85.h
 create mode 100644 copy.h
 create mode 100644 hash-ll.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: 331b094eec6d4c937af6e59df2a537112e4d8205
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1517%2Fnewren%2Fheader-cleanup-4-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1517/newren/header-cleanup-4-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1517

Range-diff vs v1:

  1:  6d6b8099374 =  1:  1341ae8125e treewide: be explicit about dependence on strbuf.h
  2:  9f9a3561295 =  2:  4a1f197e1e0 symlinks.h: move declarations for symlinks.c functions from cache.h
  3:  003548de707 <  -:  ----------- protocol.h: move definition of DEFAULT_GIT_PORT from cache.h
  4:  cf28ce0ee20 =  3:  99dfc5eb5dc packfile.h: move pack_window and pack_entry from cache.h
  5:  e22c8f242f3 =  4:  b2ce7a17868 server-info.h: move declarations for server-info.c functions from cache.h
  6:  dbd08e60b58 =  5:  513ffafa597 copy.h: move declarations for copy.c functions from cache.h
  7:  9d9672ebf52 =  6:  c5831480855 base85.h: move declarations for base85.c functions from cache.h
  8:  e8efc37ecb2 =  7:  2d829783f30 pkt-line.h: move declarations for pkt-line.c functions from cache.h
  9:  11c6cd13e2b =  8:  0a321c41c3f match-trees.h: move declarations for match-trees.c functions from cache.h
 10:  e600309df1f =  9:  951eff98a4d ws.h: move declarations for ws.c functions from cache.h
 11:  07e5da241dc = 10:  ff99d0eb207 versioncmp.h: move declarations for versioncmp.c functions from cache.h
 12:  4c951a53737 = 11:  673a3ae4fe2 dir.h: move DTYPE defines from cache.h
 13:  dec377e17f5 = 12:  7b55f82e62e tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
 14:  1c6989ae456 ! 13:  d95f97f5e90 hash.h, repository.h: reverse the order of these dependencies
     @@ Metadata
      Author: Elijah Newren <newren@gmail.com>
      
       ## Commit message ##
     -    hash.h, repository.h: reverse the order of these dependencies
     +    hash-ll.h: split out of hash.h to remove dependency on repository.h
      
     -    Previously, hash.h depended upon and included repository.h, due to
     -    the definition and use of the_hash_algo (defined as
     -    the_repository->hash_algo).  Move this #define, and the associated
     -    inline functions that depend upon it, from hash.h to repository.h.
     -    Due to that movement, reverse the dependencies so repository.h includes
     -    hash.h.
     +    hash.h depends upon and includes repository.h, due to the definition and
     +    use of the_hash_algo (defined as the_repository->hash_algo).  However,
     +    most headers trying to include hash.h are only interested in the layout
     +    of the structs like object_id.  Move the parts of hash.h that do not
     +    depend upon repository.h into a new file hash-ll.h (the "low level"
     +    parts of hash.h), and adjust other files to use this new header where
     +    the convenience inline functions aren't needed.
      
          This allows hash.h and object.h to be fairly small, minimal headers.  It
          also exposes a lot of hidden dependencies on both path.h (which was
          brought in by repository.h) and repository.h (which was previously
     -    implicitly brought in by object.h).
     +    implicitly brought in by object.h), so also adjust other files to be
     +    more explicit about what they depend upon.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
     @@ alloc.c
       #include "alloc.h"
       
      
     + ## apply.h ##
     +@@
     + #ifndef APPLY_H
     + #define APPLY_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + #include "lockfile.h"
     + #include "string-list.h"
     + #include "strmap.h"
     +
       ## branch.c ##
      @@
       #include "refs.h"
     @@ builtin/clean.c
      
       ## builtin/config.c ##
      @@
     + #include "ident.h"
       #include "parse-options.h"
       #include "urlmatch.h"
     ++#include "path.h"
       #include "quote.h"
     -+#include "repository.h"
       #include "setup.h"
       #include "worktree.h"
     - #include "wrapper.h"
      
       ## builtin/credential-cache.c ##
      @@
       #include "builtin.h"
       #include "gettext.h"
       #include "parse-options.h"
     -+#include "repository.h"
     ++#include "path.h"
       #include "wrapper.h"
       #include "write-or-die.h"
       
     @@ builtin/merge-index.c
      
       ## builtin/merge-recursive.c ##
      @@
     + #include "advice.h"
     + #include "commit.h"
     + #include "gettext.h"
     ++#include "hash.h"
       #include "tag.h"
       #include "merge-recursive.h"
       #include "object-name.h"
     @@ builtin/rerere.c
      
       ## builtin/rm.c ##
      @@
     + #include "dir.h"
     + #include "cache-tree.h"
     + #include "gettext.h"
     ++#include "hash.h"
       #include "tree-walk.h"
       #include "object-name.h"
       #include "parse-options.h"
     @@ builtin/rm.c
       #include "submodule.h"
      
       ## builtin/show-branch.c ##
     +@@
     + #include "config.h"
     + #include "environment.h"
     + #include "gettext.h"
     ++#include "hash.h"
     + #include "hex.h"
     + #include "pretty.h"
     + #include "refs.h"
      @@
       #include "strvec.h"
       #include "object-name.h"
     @@ builtin/show-branch.c
      
       ## builtin/show-index.c ##
      @@
     + #include "builtin.h"
     + #include "cache.h"
     + #include "gettext.h"
     ++#include "hash.h"
       #include "hex.h"
       #include "pack.h"
       #include "parse-options.h"
     @@ builtin/show-index.c
       	"git show-index [--object-format=<hash-algorithm>]",
      
       ## builtin/update-index.c ##
     +@@
     + #include "config.h"
     + #include "environment.h"
     + #include "gettext.h"
     ++#include "hash.h"
     + #include "hex.h"
     + #include "lockfile.h"
     + #include "quote.h"
      @@
       #include "parse-options.h"
       #include "pathspec.h"
     @@ builtin/update-index.c
      
       ## builtin/update-ref.c ##
      @@
     + #include "cache.h"
     + #include "config.h"
     + #include "gettext.h"
     ++#include "hash.h"
     + #include "refs.h"
     + #include "builtin.h"
       #include "object-name.h"
       #include "parse-options.h"
       #include "quote.h"
     @@ checkout.c
       #include "config.h"
       #include "strbuf.h"
      
     + ## checkout.h ##
     +@@
     + #ifndef CHECKOUT_H
     + #define CHECKOUT_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + 
     + /*
     +  * Check if the branch name uniquely matches a branch name on a remote
     +
       ## chunk-format.c ##
      @@
       #include "chunk-format.h"
       #include "csum-file.h"
       #include "gettext.h"
     -+#include "repository.h"
     ++#include "hash.h"
       #include "trace2.h"
       
       /*
      
     + ## chunk-format.h ##
     +@@
     + #ifndef CHUNK_FORMAT_H
     + #define CHUNK_FORMAT_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + 
     + struct hashfile;
     + struct chunkfile;
     +
       ## common-main.c ##
      @@
       #include "exec-cmd.h"
     @@ compat/win32/trace2_win32_process_info.c
       #include "lazyload.h"
       #include <Psapi.h>
      
     + ## convert.h ##
     +@@
     + #ifndef CONVERT_H
     + #define CONVERT_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + #include "string-list.h"
     + 
     + struct index_state;
     +
       ## copy.c ##
      @@
       #include "cache.h"
     @@ csum-file.c
       #include "git-compat-util.h"
       #include "progress.h"
       #include "csum-file.h"
     -+#include "repository.h"
     ++#include "hash.h"
       #include "wrapper.h"
       
       static void verify_buffer_or_die(struct hashfile *f,
      
     + ## csum-file.h ##
     +@@
     + #ifndef CSUM_FILE_H
     + #define CSUM_FILE_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + #include "write-or-die.h"
     + 
     + struct progress;
     +
       ## daemon.c ##
      @@
       #include "alloc.h"
     @@ daemon.c
       #include "protocol.h"
       #include "run-command.h"
      
     + ## diffcore.h ##
     +@@
     + #ifndef DIFFCORE_H
     + #define DIFFCORE_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + 
     + struct diff_options;
     + struct mem_pool;
     +
       ## editor.c ##
      @@
       #include "environment.h"
     @@ gpg-interface.c
       #include "tempfile.h"
       #include "alias.h"
      
     + ## hash-ll.h (new) ##
     +@@
     ++#ifndef HASH_LL_H
     ++#define HASH_LL_H
     ++
     ++#if defined(SHA1_APPLE)
     ++#include <CommonCrypto/CommonDigest.h>
     ++#elif defined(SHA1_OPENSSL)
     ++#include <openssl/sha.h>
     ++#elif defined(SHA1_DC)
     ++#include "sha1dc_git.h"
     ++#else /* SHA1_BLK */
     ++#include "block-sha1/sha1.h"
     ++#endif
     ++
     ++#if defined(SHA256_NETTLE)
     ++#include "sha256/nettle.h"
     ++#elif defined(SHA256_GCRYPT)
     ++#define SHA256_NEEDS_CLONE_HELPER
     ++#include "sha256/gcrypt.h"
     ++#elif defined(SHA256_OPENSSL)
     ++#include <openssl/sha.h>
     ++#else
     ++#include "sha256/block/sha256.h"
     ++#endif
     ++
     ++#ifndef platform_SHA_CTX
     ++/*
     ++ * platform's underlying implementation of SHA-1; could be OpenSSL,
     ++ * blk_SHA, Apple CommonCrypto, etc...  Note that the relevant
     ++ * SHA-1 header may have already defined platform_SHA_CTX for our
     ++ * own implementations like block-sha1, so we list
     ++ * the default for OpenSSL compatible SHA-1 implementations here.
     ++ */
     ++#define platform_SHA_CTX	SHA_CTX
     ++#define platform_SHA1_Init	SHA1_Init
     ++#define platform_SHA1_Update	SHA1_Update
     ++#define platform_SHA1_Final    	SHA1_Final
     ++#endif
     ++
     ++#define git_SHA_CTX		platform_SHA_CTX
     ++#define git_SHA1_Init		platform_SHA1_Init
     ++#define git_SHA1_Update		platform_SHA1_Update
     ++#define git_SHA1_Final		platform_SHA1_Final
     ++
     ++#ifndef platform_SHA256_CTX
     ++#define platform_SHA256_CTX	SHA256_CTX
     ++#define platform_SHA256_Init	SHA256_Init
     ++#define platform_SHA256_Update	SHA256_Update
     ++#define platform_SHA256_Final	SHA256_Final
     ++#endif
     ++
     ++#define git_SHA256_CTX		platform_SHA256_CTX
     ++#define git_SHA256_Init		platform_SHA256_Init
     ++#define git_SHA256_Update	platform_SHA256_Update
     ++#define git_SHA256_Final	platform_SHA256_Final
     ++
     ++#ifdef platform_SHA256_Clone
     ++#define git_SHA256_Clone	platform_SHA256_Clone
     ++#endif
     ++
     ++#ifdef SHA1_MAX_BLOCK_SIZE
     ++#include "compat/sha1-chunked.h"
     ++#undef git_SHA1_Update
     ++#define git_SHA1_Update		git_SHA1_Update_Chunked
     ++#endif
     ++
     ++static inline void git_SHA1_Clone(git_SHA_CTX *dst, const git_SHA_CTX *src)
     ++{
     ++	memcpy(dst, src, sizeof(*dst));
     ++}
     ++
     ++#ifndef SHA256_NEEDS_CLONE_HELPER
     ++static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *src)
     ++{
     ++	memcpy(dst, src, sizeof(*dst));
     ++}
     ++#endif
     ++
     ++/*
     ++ * Note that these constants are suitable for indexing the hash_algos array and
     ++ * comparing against each other, but are otherwise arbitrary, so they should not
     ++ * be exposed to the user or serialized to disk.  To know whether a
     ++ * git_hash_algo struct points to some usable hash function, test the format_id
     ++ * field for being non-zero.  Use the name field for user-visible situations and
     ++ * the format_id field for fixed-length fields on disk.
     ++ */
     ++/* An unknown hash function. */
     ++#define GIT_HASH_UNKNOWN 0
     ++/* SHA-1 */
     ++#define GIT_HASH_SHA1 1
     ++/* SHA-256  */
     ++#define GIT_HASH_SHA256 2
     ++/* Number of algorithms supported (including unknown). */
     ++#define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
     ++
     ++/* "sha1", big-endian */
     ++#define GIT_SHA1_FORMAT_ID 0x73686131
     ++
     ++/* The length in bytes and in hex digits of an object name (SHA-1 value). */
     ++#define GIT_SHA1_RAWSZ 20
     ++#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
     ++/* The block size of SHA-1. */
     ++#define GIT_SHA1_BLKSZ 64
     ++
     ++/* "s256", big-endian */
     ++#define GIT_SHA256_FORMAT_ID 0x73323536
     ++
     ++/* The length in bytes and in hex digits of an object name (SHA-256 value). */
     ++#define GIT_SHA256_RAWSZ 32
     ++#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
     ++/* The block size of SHA-256. */
     ++#define GIT_SHA256_BLKSZ 64
     ++
     ++/* The length in byte and in hex digits of the largest possible hash value. */
     ++#define GIT_MAX_RAWSZ GIT_SHA256_RAWSZ
     ++#define GIT_MAX_HEXSZ GIT_SHA256_HEXSZ
     ++/* The largest possible block size for any supported hash. */
     ++#define GIT_MAX_BLKSZ GIT_SHA256_BLKSZ
     ++
     ++struct object_id {
     ++	unsigned char hash[GIT_MAX_RAWSZ];
     ++	int algo;	/* XXX requires 4-byte alignment */
     ++};
     ++
     ++#define GET_OID_QUIETLY           01
     ++#define GET_OID_COMMIT            02
     ++#define GET_OID_COMMITTISH        04
     ++#define GET_OID_TREE             010
     ++#define GET_OID_TREEISH          020
     ++#define GET_OID_BLOB             040
     ++#define GET_OID_FOLLOW_SYMLINKS 0100
     ++#define GET_OID_RECORD_PATH     0200
     ++#define GET_OID_ONLY_TO_DIE    04000
     ++#define GET_OID_REQUIRE_PATH  010000
     ++
     ++#define GET_OID_DISAMBIGUATORS \
     ++	(GET_OID_COMMIT | GET_OID_COMMITTISH | \
     ++	GET_OID_TREE | GET_OID_TREEISH | \
     ++	GET_OID_BLOB)
     ++
     ++enum get_oid_result {
     ++	FOUND = 0,
     ++	MISSING_OBJECT = -1, /* The requested object is missing */
     ++	SHORT_NAME_AMBIGUOUS = -2,
     ++	/* The following only apply when symlinks are followed */
     ++	DANGLING_SYMLINK = -4, /*
     ++				* The initial symlink is there, but
     ++				* (transitively) points to a missing
     ++				* in-tree file
     ++				*/
     ++	SYMLINK_LOOP = -5,
     ++	NOT_DIR = -6, /*
     ++		       * Somewhere along the symlink chain, a path is
     ++		       * requested which contains a file as a
     ++		       * non-final element.
     ++		       */
     ++};
     ++
     ++/* A suitably aligned type for stack allocations of hash contexts. */
     ++union git_hash_ctx {
     ++	git_SHA_CTX sha1;
     ++	git_SHA256_CTX sha256;
     ++};
     ++typedef union git_hash_ctx git_hash_ctx;
     ++
     ++typedef void (*git_hash_init_fn)(git_hash_ctx *ctx);
     ++typedef void (*git_hash_clone_fn)(git_hash_ctx *dst, const git_hash_ctx *src);
     ++typedef void (*git_hash_update_fn)(git_hash_ctx *ctx, const void *in, size_t len);
     ++typedef void (*git_hash_final_fn)(unsigned char *hash, git_hash_ctx *ctx);
     ++typedef void (*git_hash_final_oid_fn)(struct object_id *oid, git_hash_ctx *ctx);
     ++
     ++struct git_hash_algo {
     ++	/*
     ++	 * The name of the algorithm, as appears in the config file and in
     ++	 * messages.
     ++	 */
     ++	const char *name;
     ++
     ++	/* A four-byte version identifier, used in pack indices. */
     ++	uint32_t format_id;
     ++
     ++	/* The length of the hash in binary. */
     ++	size_t rawsz;
     ++
     ++	/* The length of the hash in hex characters. */
     ++	size_t hexsz;
     ++
     ++	/* The block size of the hash. */
     ++	size_t blksz;
     ++
     ++	/* The hash initialization function. */
     ++	git_hash_init_fn init_fn;
     ++
     ++	/* The hash context cloning function. */
     ++	git_hash_clone_fn clone_fn;
     ++
     ++	/* The hash update function. */
     ++	git_hash_update_fn update_fn;
     ++
     ++	/* The hash finalization function. */
     ++	git_hash_final_fn final_fn;
     ++
     ++	/* The hash finalization function for object IDs. */
     ++	git_hash_final_oid_fn final_oid_fn;
     ++
     ++	/* The OID of the empty tree. */
     ++	const struct object_id *empty_tree;
     ++
     ++	/* The OID of the empty blob. */
     ++	const struct object_id *empty_blob;
     ++
     ++	/* The all-zeros OID. */
     ++	const struct object_id *null_oid;
     ++};
     ++extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];
     ++
     ++/*
     ++ * Return a GIT_HASH_* constant based on the name.  Returns GIT_HASH_UNKNOWN if
     ++ * the name doesn't match a known algorithm.
     ++ */
     ++int hash_algo_by_name(const char *name);
     ++/* Identical, except based on the format ID. */
     ++int hash_algo_by_id(uint32_t format_id);
     ++/* Identical, except based on the length. */
     ++int hash_algo_by_length(int len);
     ++/* Identical, except for a pointer to struct git_hash_algo. */
     ++static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
     ++{
     ++	return p - hash_algos;
     ++}
     ++
     ++const struct object_id *null_oid(void);
     ++
     ++static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
     ++{
     ++	/*
     ++	 * Teach the compiler that there are only two possibilities of hash size
     ++	 * here, so that it can optimize for this case as much as possible.
     ++	 */
     ++	if (algop->rawsz == GIT_MAX_RAWSZ)
     ++		return memcmp(sha1, sha2, GIT_MAX_RAWSZ);
     ++	return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
     ++}
     ++
     ++static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
     ++{
     ++	/*
     ++	 * We write this here instead of deferring to hashcmp so that the
     ++	 * compiler can properly inline it and avoid calling memcmp.
     ++	 */
     ++	if (algop->rawsz == GIT_MAX_RAWSZ)
     ++		return !memcmp(sha1, sha2, GIT_MAX_RAWSZ);
     ++	return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
     ++}
     ++
     ++static inline void oidcpy(struct object_id *dst, const struct object_id *src)
     ++{
     ++	memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
     ++	dst->algo = src->algo;
     ++}
     ++
     ++static inline struct object_id *oiddup(const struct object_id *src)
     ++{
     ++	struct object_id *dst = xmalloc(sizeof(struct object_id));
     ++	oidcpy(dst, src);
     ++	return dst;
     ++}
     ++
     ++static inline void oid_set_algo(struct object_id *oid, const struct git_hash_algo *algop)
     ++{
     ++	oid->algo = hash_algo_by_ptr(algop);
     ++}
     ++
     ++const char *empty_tree_oid_hex(void);
     ++const char *empty_blob_oid_hex(void);
     ++
     ++#endif
     +
       ## hash-lookup.c ##
      @@
       #include "cache.h"
     ++#include "hash.h"
       #include "hash-lookup.h"
     -+#include "repository.h"
       
       static uint32_t take2(const struct object_id *oid, size_t ofs)
     - {
      
       ## hash.h ##
      @@
       #ifndef HASH_H
       #define HASH_H
       
     --#include "repository.h"
     ++#include "hash-ll.h"
     + #include "repository.h"
     + 
     +-#if defined(SHA1_APPLE)
     +-#include <CommonCrypto/CommonDigest.h>
     +-#elif defined(SHA1_OPENSSL)
     +-#include <openssl/sha.h>
     +-#elif defined(SHA1_DC)
     +-#include "sha1dc_git.h"
     +-#else /* SHA1_BLK */
     +-#include "block-sha1/sha1.h"
     +-#endif
      -
     - #if defined(SHA1_APPLE)
     - #include <CommonCrypto/CommonDigest.h>
     - #elif defined(SHA1_OPENSSL)
     -@@ hash.h: static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
     - 	return p - hash_algos;
     - }
     - 
     --#define the_hash_algo the_repository->hash_algo
     +-#if defined(SHA256_NETTLE)
     +-#include "sha256/nettle.h"
     +-#elif defined(SHA256_GCRYPT)
     +-#define SHA256_NEEDS_CLONE_HELPER
     +-#include "sha256/gcrypt.h"
     +-#elif defined(SHA256_OPENSSL)
     +-#include <openssl/sha.h>
     +-#else
     +-#include "sha256/block/sha256.h"
     +-#endif
      -
     - const struct object_id *null_oid(void);
     - 
     - static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
     -@@ hash.h: static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *
     - 	return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
     - }
     - 
     --static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
     --{
     --	return hashcmp_algop(sha1, sha2, the_hash_algo);
     --}
     +-#ifndef platform_SHA_CTX
     +-/*
     +- * platform's underlying implementation of SHA-1; could be OpenSSL,
     +- * blk_SHA, Apple CommonCrypto, etc...  Note that the relevant
     +- * SHA-1 header may have already defined platform_SHA_CTX for our
     +- * own implementations like block-sha1, so we list
     +- * the default for OpenSSL compatible SHA-1 implementations here.
     +- */
     +-#define platform_SHA_CTX	SHA_CTX
     +-#define platform_SHA1_Init	SHA1_Init
     +-#define platform_SHA1_Update	SHA1_Update
     +-#define platform_SHA1_Final    	SHA1_Final
     +-#endif
      -
     --static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
     --{
     --	const struct git_hash_algo *algop;
     --	if (!oid1->algo)
     --		algop = the_hash_algo;
     --	else
     --		algop = &hash_algos[oid1->algo];
     --	return hashcmp_algop(oid1->hash, oid2->hash, algop);
     --}
     +-#define git_SHA_CTX		platform_SHA_CTX
     +-#define git_SHA1_Init		platform_SHA1_Init
     +-#define git_SHA1_Update		platform_SHA1_Update
     +-#define git_SHA1_Final		platform_SHA1_Final
      -
     - static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
     - {
     - 	/*
     -@@ hash.h: static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *s
     - 	return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
     - }
     - 
     --static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
     +-#ifndef platform_SHA256_CTX
     +-#define platform_SHA256_CTX	SHA256_CTX
     +-#define platform_SHA256_Init	SHA256_Init
     +-#define platform_SHA256_Update	SHA256_Update
     +-#define platform_SHA256_Final	SHA256_Final
     +-#endif
     +-
     +-#define git_SHA256_CTX		platform_SHA256_CTX
     +-#define git_SHA256_Init		platform_SHA256_Init
     +-#define git_SHA256_Update	platform_SHA256_Update
     +-#define git_SHA256_Final	platform_SHA256_Final
     +-
     +-#ifdef platform_SHA256_Clone
     +-#define git_SHA256_Clone	platform_SHA256_Clone
     +-#endif
     +-
     +-#ifdef SHA1_MAX_BLOCK_SIZE
     +-#include "compat/sha1-chunked.h"
     +-#undef git_SHA1_Update
     +-#define git_SHA1_Update		git_SHA1_Update_Chunked
     +-#endif
     +-
     +-static inline void git_SHA1_Clone(git_SHA_CTX *dst, const git_SHA_CTX *src)
      -{
     --	return hasheq_algop(sha1, sha2, the_hash_algo);
     +-	memcpy(dst, src, sizeof(*dst));
      -}
      -
     --static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
     +-#ifndef SHA256_NEEDS_CLONE_HELPER
     +-static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *src)
      -{
     --	const struct git_hash_algo *algop;
     --	if (!oid1->algo)
     --		algop = the_hash_algo;
     --	else
     --		algop = &hash_algos[oid1->algo];
     --	return hasheq_algop(oid1->hash, oid2->hash, algop);
     +-	memcpy(dst, src, sizeof(*dst));
      -}
     +-#endif
     +-
     +-/*
     +- * Note that these constants are suitable for indexing the hash_algos array and
     +- * comparing against each other, but are otherwise arbitrary, so they should not
     +- * be exposed to the user or serialized to disk.  To know whether a
     +- * git_hash_algo struct points to some usable hash function, test the format_id
     +- * field for being non-zero.  Use the name field for user-visible situations and
     +- * the format_id field for fixed-length fields on disk.
     +- */
     +-/* An unknown hash function. */
     +-#define GIT_HASH_UNKNOWN 0
     +-/* SHA-1 */
     +-#define GIT_HASH_SHA1 1
     +-/* SHA-256  */
     +-#define GIT_HASH_SHA256 2
     +-/* Number of algorithms supported (including unknown). */
     +-#define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
     +-
     +-/* "sha1", big-endian */
     +-#define GIT_SHA1_FORMAT_ID 0x73686131
     +-
     +-/* The length in bytes and in hex digits of an object name (SHA-1 value). */
     +-#define GIT_SHA1_RAWSZ 20
     +-#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
     +-/* The block size of SHA-1. */
     +-#define GIT_SHA1_BLKSZ 64
     +-
     +-/* "s256", big-endian */
     +-#define GIT_SHA256_FORMAT_ID 0x73323536
     +-
     +-/* The length in bytes and in hex digits of an object name (SHA-256 value). */
     +-#define GIT_SHA256_RAWSZ 32
     +-#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
     +-/* The block size of SHA-256. */
     +-#define GIT_SHA256_BLKSZ 64
     +-
     +-/* The length in byte and in hex digits of the largest possible hash value. */
     +-#define GIT_MAX_RAWSZ GIT_SHA256_RAWSZ
     +-#define GIT_MAX_HEXSZ GIT_SHA256_HEXSZ
     +-/* The largest possible block size for any supported hash. */
     +-#define GIT_MAX_BLKSZ GIT_SHA256_BLKSZ
     +-
     +-struct object_id {
     +-	unsigned char hash[GIT_MAX_RAWSZ];
     +-	int algo;	/* XXX requires 4-byte alignment */
     +-};
      -
     --static inline int is_null_oid(const struct object_id *oid)
     +-#define GET_OID_QUIETLY           01
     +-#define GET_OID_COMMIT            02
     +-#define GET_OID_COMMITTISH        04
     +-#define GET_OID_TREE             010
     +-#define GET_OID_TREEISH          020
     +-#define GET_OID_BLOB             040
     +-#define GET_OID_FOLLOW_SYMLINKS 0100
     +-#define GET_OID_RECORD_PATH     0200
     +-#define GET_OID_ONLY_TO_DIE    04000
     +-#define GET_OID_REQUIRE_PATH  010000
     +-
     +-#define GET_OID_DISAMBIGUATORS \
     +-	(GET_OID_COMMIT | GET_OID_COMMITTISH | \
     +-	GET_OID_TREE | GET_OID_TREEISH | \
     +-	GET_OID_BLOB)
     +-
     +-enum get_oid_result {
     +-	FOUND = 0,
     +-	MISSING_OBJECT = -1, /* The requested object is missing */
     +-	SHORT_NAME_AMBIGUOUS = -2,
     +-	/* The following only apply when symlinks are followed */
     +-	DANGLING_SYMLINK = -4, /*
     +-				* The initial symlink is there, but
     +-				* (transitively) points to a missing
     +-				* in-tree file
     +-				*/
     +-	SYMLINK_LOOP = -5,
     +-	NOT_DIR = -6, /*
     +-		       * Somewhere along the symlink chain, a path is
     +-		       * requested which contains a file as a
     +-		       * non-final element.
     +-		       */
     +-};
     +-
     +-/* A suitably aligned type for stack allocations of hash contexts. */
     +-union git_hash_ctx {
     +-	git_SHA_CTX sha1;
     +-	git_SHA256_CTX sha256;
     +-};
     +-typedef union git_hash_ctx git_hash_ctx;
     +-
     +-typedef void (*git_hash_init_fn)(git_hash_ctx *ctx);
     +-typedef void (*git_hash_clone_fn)(git_hash_ctx *dst, const git_hash_ctx *src);
     +-typedef void (*git_hash_update_fn)(git_hash_ctx *ctx, const void *in, size_t len);
     +-typedef void (*git_hash_final_fn)(unsigned char *hash, git_hash_ctx *ctx);
     +-typedef void (*git_hash_final_oid_fn)(struct object_id *oid, git_hash_ctx *ctx);
     +-
     +-struct git_hash_algo {
     +-	/*
     +-	 * The name of the algorithm, as appears in the config file and in
     +-	 * messages.
     +-	 */
     +-	const char *name;
     +-
     +-	/* A four-byte version identifier, used in pack indices. */
     +-	uint32_t format_id;
     +-
     +-	/* The length of the hash in binary. */
     +-	size_t rawsz;
     +-
     +-	/* The length of the hash in hex characters. */
     +-	size_t hexsz;
     +-
     +-	/* The block size of the hash. */
     +-	size_t blksz;
     +-
     +-	/* The hash initialization function. */
     +-	git_hash_init_fn init_fn;
     +-
     +-	/* The hash context cloning function. */
     +-	git_hash_clone_fn clone_fn;
     +-
     +-	/* The hash update function. */
     +-	git_hash_update_fn update_fn;
     +-
     +-	/* The hash finalization function. */
     +-	git_hash_final_fn final_fn;
     +-
     +-	/* The hash finalization function for object IDs. */
     +-	git_hash_final_oid_fn final_oid_fn;
     +-
     +-	/* The OID of the empty tree. */
     +-	const struct object_id *empty_tree;
     +-
     +-	/* The OID of the empty blob. */
     +-	const struct object_id *empty_blob;
     +-
     +-	/* The all-zeros OID. */
     +-	const struct object_id *null_oid;
     +-};
     +-extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];
     +-
     +-/*
     +- * Return a GIT_HASH_* constant based on the name.  Returns GIT_HASH_UNKNOWN if
     +- * the name doesn't match a known algorithm.
     +- */
     +-int hash_algo_by_name(const char *name);
     +-/* Identical, except based on the format ID. */
     +-int hash_algo_by_id(uint32_t format_id);
     +-/* Identical, except based on the length. */
     +-int hash_algo_by_length(int len);
     +-/* Identical, except for a pointer to struct git_hash_algo. */
     +-static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
      -{
     --	return oideq(oid, null_oid());
     +-	return p - hash_algos;
      -}
      -
     --static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
     + #define the_hash_algo the_repository->hash_algo
     + 
     +-const struct object_id *null_oid(void);
     +-
     +-static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
      -{
     --	memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
     +-	/*
     +-	 * Teach the compiler that there are only two possibilities of hash size
     +-	 * here, so that it can optimize for this case as much as possible.
     +-	 */
     +-	if (algop->rawsz == GIT_MAX_RAWSZ)
     +-		return memcmp(sha1, sha2, GIT_MAX_RAWSZ);
     +-	return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
      -}
      -
     - static inline void oidcpy(struct object_id *dst, const struct object_id *src)
     + static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
       {
     - 	memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
     - 	dst->algo = src->algo;
     + 	return hashcmp_algop(sha1, sha2, the_hash_algo);
     +@@ hash.h: static inline int oidcmp(const struct object_id *oid1, const struct object_id *o
     + 	return hashcmp_algop(oid1->hash, oid2->hash, algop);
       }
       
     --/* Like oidcpy() but zero-pads the unused bytes in dst's hash array. */
     --static inline void oidcpy_with_padding(struct object_id *dst,
     --				       const struct object_id *src)
     +-static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
      -{
     --	size_t hashsz;
     --
     --	if (!src->algo)
     --		hashsz = the_hash_algo->rawsz;
     --	else
     --		hashsz = hash_algos[src->algo].rawsz;
     --
     --	memcpy(dst->hash, src->hash, hashsz);
     --	memset(dst->hash + hashsz, 0, GIT_MAX_RAWSZ - hashsz);
     --	dst->algo = src->algo;
     +-	/*
     +-	 * We write this here instead of deferring to hashcmp so that the
     +-	 * compiler can properly inline it and avoid calling memcmp.
     +-	 */
     +-	if (algop->rawsz == GIT_MAX_RAWSZ)
     +-		return !memcmp(sha1, sha2, GIT_MAX_RAWSZ);
     +-	return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
      -}
      -
     - static inline struct object_id *oiddup(const struct object_id *src)
     + static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
       {
     - 	struct object_id *dst = xmalloc(sizeof(struct object_id));
     -@@ hash.h: static inline struct object_id *oiddup(const struct object_id *src)
     - 	return dst;
     + 	return hasheq_algop(sha1, sha2, the_hash_algo);
     +@@ hash.h: static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
     + 	memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
       }
       
     --static inline void hashclr(unsigned char *hash)
     --{
     --	memset(hash, 0, the_hash_algo->rawsz);
     --}
     --
     --static inline void oidclr(struct object_id *oid)
     --{
     --	memset(oid->hash, 0, GIT_MAX_RAWSZ);
     --	oid->algo = hash_algo_by_ptr(the_hash_algo);
     --}
     --
     --static inline void oidread(struct object_id *oid, const unsigned char *hash)
     --{
     --	memcpy(oid->hash, hash, the_hash_algo->rawsz);
     --	oid->algo = hash_algo_by_ptr(the_hash_algo);
     --}
     --
     --static inline int is_empty_blob_sha1(const unsigned char *sha1)
     +-static inline void oidcpy(struct object_id *dst, const struct object_id *src)
      -{
     --	return hasheq(sha1, the_hash_algo->empty_blob->hash);
     +-	memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
     +-	dst->algo = src->algo;
      -}
      -
     --static inline int is_empty_blob_oid(const struct object_id *oid)
     + /* Like oidcpy() but zero-pads the unused bytes in dst's hash array. */
     + static inline void oidcpy_with_padding(struct object_id *dst,
     + 				       const struct object_id *src)
     +@@ hash.h: static inline void oidcpy_with_padding(struct object_id *dst,
     + 	dst->algo = src->algo;
     + }
     + 
     +-static inline struct object_id *oiddup(const struct object_id *src)
      -{
     --	return oideq(oid, the_hash_algo->empty_blob);
     +-	struct object_id *dst = xmalloc(sizeof(struct object_id));
     +-	oidcpy(dst, src);
     +-	return dst;
      -}
      -
     --static inline int is_empty_tree_sha1(const unsigned char *sha1)
     + static inline void hashclr(unsigned char *hash)
     + {
     + 	memset(hash, 0, the_hash_algo->rawsz);
     +@@ hash.h: static inline int is_empty_tree_oid(const struct object_id *oid)
     + 	return oideq(oid, the_hash_algo->empty_tree);
     + }
     + 
     +-static inline void oid_set_algo(struct object_id *oid, const struct git_hash_algo *algop)
      -{
     --	return hasheq(sha1, the_hash_algo->empty_tree->hash);
     +-	oid->algo = hash_algo_by_ptr(algop);
      -}
      -
     --static inline int is_empty_tree_oid(const struct object_id *oid)
     --{
     --	return oideq(oid, the_hash_algo->empty_tree);
     --}
     +-const char *empty_tree_oid_hex(void);
     +-const char *empty_blob_oid_hex(void);
      -
     - static inline void oid_set_algo(struct object_id *oid, const struct git_hash_algo *algop)
     - {
     - 	oid->algo = hash_algo_by_ptr(algop);
     + #endif
     +
     + ## hashmap.h ##
     +@@
     + #ifndef HASHMAP_H
     + #define HASHMAP_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + 
     + /*
     +  * Generic implementation of hash-based key-value mappings.
      
       ## hex.c ##
      @@
       #include "git-compat-util.h"
     ++#include "hash.h"
       #include "hex.h"
     -+#include "repository.h"
       
       const signed char hexval_table[256] = {
     - 	 -1, -1, -1, -1, -1, -1, -1, -1,		/* 00-07 */
     +
     + ## hex.h ##
     +@@
     + #ifndef HEX_H
     + #define HEX_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + 
     + extern const signed char hexval_table[256];
     + static inline unsigned int hexval(unsigned char c)
      
       ## hook.c ##
      @@
     @@ khash.h
       #define __AC_KHASH_H
       
       #include "hashmap.h"
     -+#include "repository.h"
     ++#include "hash.h"
       
       #define AC_VERSION_KHASH_H "0.2.8"
       
      
     + ## ls-refs.c ##
     +@@
     + #include "git-compat-util.h"
     + #include "environment.h"
     + #include "gettext.h"
     ++#include "hash.h"
     + #include "hex.h"
     + #include "repository.h"
     + #include "refs.h"
     +
       ## merge-ort-wrappers.c ##
      @@
     + #include "cache.h"
       #include "gettext.h"
     ++#include "hash.h"
       #include "merge-ort.h"
       #include "merge-ort-wrappers.h"
     -+#include "repository.h"
       
     - #include "commit.h"
     +
     + ## merge-ort.h ##
     +@@
     + #define MERGE_ORT_H
     + 
     + #include "merge-recursive.h"
     +-#include "hash.h"
     ++#include "hash-ll.h"
       
     + struct commit;
     + struct tree;
      
       ## negotiator/default.c ##
      @@
     @@ object-file.h
      
       ## object.h ##
      @@
     - #include "hash.h"
     + #ifndef OBJECT_H
     + #define OBJECT_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
       
       struct buffer_slab;
      +struct repository;
     @@ object.h
       struct parsed_object_pool {
       	struct object **obj_hash;
      
     - ## oid-array.h ##
     -@@
     - #define OID_ARRAY_H
     - 
     - #include "hash.h"
     -+#include "repository.h"
     - 
     - /**
     -  * The API provides storage and manipulation of sets of object identifiers.
     -
       ## oidmap.c ##
      @@
       #include "git-compat-util.h"
     ++#include "hash.h"
       #include "oidmap.h"
     -+#include "repository.h"
       
       static int oidmap_neq(const void *hashmap_cmp_fn_data UNUSED,
     - 		      const struct hashmap_entry *e1,
      
     - ## oidtree.c ##
     + ## oidtree.h ##
      @@
     - #include "oidtree.h"
     - #include "alloc.h"
     - #include "hash.h"
     -+#include "repository.h"
     + #define OIDTREE_H
     + 
     + #include "cbtree.h"
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + #include "mem-pool.h"
       
     - struct oidtree_iter_data {
     - 	oidtree_iter fn;
     + struct oidtree {
      
       ## parallel-checkout.c ##
      @@
     + #include "config.h"
     + #include "entry.h"
     + #include "gettext.h"
     ++#include "hash.h"
     + #include "hex.h"
       #include "parallel-checkout.h"
       #include "pkt-line.h"
     - #include "progress.h"
     -+#include "repository.h"
     - #include "run-command.h"
     - #include "sigchain.h"
     - #include "streaming.h"
      
       ## pathspec.c ##
      @@
     @@ progress.c
       #include "trace.h"
       #include "trace2.h"
      
     + ## protocol-caps.c ##
     +@@
     + #include "hex.h"
     + #include "pkt-line.h"
     + #include "strvec.h"
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + #include "hex.h"
     + #include "object.h"
     + #include "object-store.h"
     +
       ## rebase-interactive.c ##
      @@
       #include "gettext.h"
     @@ rebase-interactive.c
      
       ## refs/files-backend.c ##
      @@
     - #include "../lockfile.h"
     - #include "../object.h"
     - #include "../object-file.h"
     -+#include "../repository.h"
     - #include "../dir.h"
     - #include "../chdir-notify.h"
     - #include "../setup.h"
     + #include "../copy.h"
     + #include "../environment.h"
     + #include "../gettext.h"
     ++#include "../hash.h"
     + #include "../hex.h"
     + #include "../refs.h"
     + #include "refs-internal.h"
      
       ## refs/packed-backend.c ##
      @@
     - #include "../iterator.h"
     - #include "../lockfile.h"
     - #include "../chdir-notify.h"
     -+#include "../repository.h"
     - #include "../wrapper.h"
     - #include "../write-or-die.h"
     - 
     + #include "../alloc.h"
     + #include "../config.h"
     + #include "../gettext.h"
     ++#include "../hash.h"
     + #include "../hex.h"
     + #include "../refs.h"
     + #include "refs-internal.h"
      
       ## refs/ref-cache.c ##
      @@
     + #include "../git-compat-util.h"
     + #include "../alloc.h"
     ++#include "../hash.h"
     + #include "../refs.h"
     ++#include "../repository.h"
       #include "refs-internal.h"
       #include "ref-cache.h"
       #include "../iterator.h"
     -+#include "../repository.h"
     - 
     - void add_entry_to_dir(struct ref_dir *dir, struct ref_entry *entry)
     - {
      
       ## refs/ref-cache.h ##
      @@
     + #ifndef REFS_REF_CACHE_H
     + #define REFS_REF_CACHE_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
       
       struct ref_dir;
       struct ref_store;
     @@ refs/ref-cache.h
      
       ## refspec.c ##
      @@
     + #include "git-compat-util.h"
     + #include "alloc.h"
     + #include "gettext.h"
     ++#include "hash.h"
     + #include "hex.h"
       #include "strvec.h"
       #include "refs.h"
     - #include "refspec.h"
     -+#include "repository.h"
     +
     + ## reftable/dump.c ##
     +@@ reftable/dump.c: https://developers.google.com/open-source/licenses/bsd
     + */
       
     - static struct refspec_item s_tag_refspec = {
     - 	.force = 0,
     + #include "git-compat-util.h"
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + 
     + #include "reftable-blocksource.h"
     + #include "reftable-error.h"
      
     - ## repository.h ##
     -@@
     - #ifndef REPOSITORY_H
     - #define REPOSITORY_H
     + ## reftable/system.h ##
     +@@ reftable/system.h: https://developers.google.com/open-source/licenses/bsd
       
     -+#include "hash.h"
     - #include "path.h"
     + #include "git-compat-util.h"
     + #include "strbuf.h"
     +-#include "hash.h" /* hash ID, sizes.*/
     ++#include "hash-ll.h" /* hash ID, sizes.*/
     + #include "dir.h" /* remove_dir_recursively, for tests.*/
       
     - struct config_set;
     -@@ repository.h: void prepare_repo_settings(struct repository *r);
     -  */
     - int upgrade_repository_format(int target_version);
     + int hash_size(uint32_t id);
     +
     + ## reset.h ##
     +@@
     + #ifndef RESET_H
     + #define RESET_H
       
     -+#define the_hash_algo the_repository->hash_algo
     -+
     -+static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
     -+{
     -+	return hashcmp_algop(sha1, sha2, the_hash_algo);
     -+}
     -+
     -+static inline int oidcmp(const struct object_id *oid1, const struct object_id *oid2)
     -+{
     -+	const struct git_hash_algo *algop;
     -+	if (!oid1->algo)
     -+		algop = the_hash_algo;
     -+	else
     -+		algop = &hash_algos[oid1->algo];
     -+	return hashcmp_algop(oid1->hash, oid2->hash, algop);
     -+}
     -+
     -+static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
     -+{
     -+	return hasheq_algop(sha1, sha2, the_hash_algo);
     -+}
     -+
     -+static inline int oideq(const struct object_id *oid1, const struct object_id *oid2)
     -+{
     -+	const struct git_hash_algo *algop;
     -+	if (!oid1->algo)
     -+		algop = the_hash_algo;
     -+	else
     -+		algop = &hash_algos[oid1->algo];
     -+	return hasheq_algop(oid1->hash, oid2->hash, algop);
     -+}
     -+
     -+static inline int is_null_oid(const struct object_id *oid)
     -+{
     -+	return oideq(oid, null_oid());
     -+}
     -+
     -+static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
     -+{
     -+	memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
     -+}
     -+
     -+/* Like oidcpy() but zero-pads the unused bytes in dst's hash array. */
     -+static inline void oidcpy_with_padding(struct object_id *dst,
     -+				       const struct object_id *src)
     -+{
     -+	size_t hashsz;
     -+
     -+	if (!src->algo)
     -+		hashsz = the_hash_algo->rawsz;
     -+	else
     -+		hashsz = hash_algos[src->algo].rawsz;
     -+
     -+	memcpy(dst->hash, src->hash, hashsz);
     -+	memset(dst->hash + hashsz, 0, GIT_MAX_RAWSZ - hashsz);
     -+	dst->algo = src->algo;
     -+}
     -+
     -+static inline void hashclr(unsigned char *hash)
     -+{
     -+	memset(hash, 0, the_hash_algo->rawsz);
     -+}
     -+
     -+static inline void oidclr(struct object_id *oid)
     -+{
     -+	memset(oid->hash, 0, GIT_MAX_RAWSZ);
     -+	oid->algo = hash_algo_by_ptr(the_hash_algo);
     -+}
     -+
     -+static inline void oidread(struct object_id *oid, const unsigned char *hash)
     -+{
     -+	memcpy(oid->hash, hash, the_hash_algo->rawsz);
     -+	oid->algo = hash_algo_by_ptr(the_hash_algo);
     -+}
     -+
     -+static inline int is_empty_blob_sha1(const unsigned char *sha1)
     -+{
     -+	return hasheq(sha1, the_hash_algo->empty_blob->hash);
     -+}
     -+
     -+static inline int is_empty_blob_oid(const struct object_id *oid)
     -+{
     -+	return oideq(oid, the_hash_algo->empty_blob);
     -+}
     -+
     -+static inline int is_empty_tree_sha1(const unsigned char *sha1)
     -+{
     -+	return hasheq(sha1, the_hash_algo->empty_tree->hash);
     -+}
     -+
     -+static inline int is_empty_tree_oid(const struct object_id *oid)
     -+{
     -+	return oideq(oid, the_hash_algo->empty_tree);
     -+}
     -+
     - #endif /* REPOSITORY_H */
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + #include "repository.h"
     + 
     + #define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
      
       ## resolve-undo.c ##
      @@
       #include "cache.h"
       #include "dir.h"
     ++#include "hash.h"
       #include "resolve-undo.h"
     -+#include "repository.h"
       #include "string-list.h"
       
     - /* The only error case is to run out of memory in string-list */
     +
     + ## resolve-undo.h ##
     +@@ resolve-undo.h: struct index_state;
     + struct pathspec;
     + struct string_list;
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + 
     + struct resolve_undo_info {
     + 	unsigned int mode[3];
      
       ## split-index.c ##
      @@
     + #include "cache.h"
       #include "alloc.h"
       #include "gettext.h"
     ++#include "hash.h"
       #include "mem-pool.h"
     -+#include "repository.h"
       #include "split-index.h"
       #include "strbuf.h"
     - #include "ewah/ewok.h"
     +
     + ## split-index.h ##
     +@@
     + #ifndef SPLIT_INDEX_H
     + #define SPLIT_INDEX_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + 
     + struct index_state;
     + struct strbuf;
      
       ## strbuf.c ##
      @@
     @@ t/helper/test-cache-tree.c
      
       ## t/helper/test-dump-cache-tree.c ##
      @@
     + #define USE_THE_INDEX_VARIABLE
     + #include "test-tool.h"
     + #include "cache.h"
     ++#include "hash.h"
       #include "hex.h"
       #include "tree.h"
       #include "cache-tree.h"
     @@ t/helper/test-submodule-config.c
      @@
       #include "test-tool.h"
       #include "config.h"
     ++#include "hash.h"
       #include "object-name.h"
      +#include "repository.h"
       #include "setup.h"
     @@ trace2/tr2_tgt_perf.c
      
       ## tree-walk.h ##
      @@
     - #include "hash.h"
     + #ifndef TREE_WALK_H
     + #define TREE_WALK_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
       
       struct index_state;
      +struct repository;
     @@ wrapper.c
       #include "strbuf.h"
       #include "trace2.h"
       #include "wrapper.h"
     +
     + ## xdiff-interface.h ##
     +@@
     + #ifndef XDIFF_INTERFACE_H
     + #define XDIFF_INTERFACE_H
     + 
     +-#include "hash.h"
     ++#include "hash-ll.h"
     + #include "xdiff/xdiff.h"
     + 
     + /*
 15:  e1983d51c05 = 14:  5ef0e17d0aa cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c
 16:  c72cc0dab90 = 15:  cc286133513 cache,tree: move basic name compare functions from read-cache to tree
 17:  1edd8fd72a7 = 16:  960b5438ce4 treewide: remove cache.h inclusion due to previous changes
 18:  34c9034e8ed = 17:  b459b60de89 cache.h: remove unnecessary headers
 19:  8e747e889fb = 18:  80ebd46c862 fsmonitor: reduce includes of cache.h
 20:  c6d58573661 ! 19:  7479e72ffd6 commit.h: reduce unnecessary includes
     @@ log-tree.c
      
       ## merge-ort-wrappers.c ##
      @@
     + #include "hash.h"
       #include "merge-ort.h"
       #include "merge-ort-wrappers.h"
     - #include "repository.h"
      +#include "tree.h"
       
       #include "commit.h"
     @@ refs/debug.c
      
       ## refspec.c ##
      @@
     + #include "strvec.h"
       #include "refs.h"
       #include "refspec.h"
     - #include "repository.h"
      +#include "strbuf.h"
       
       static struct refspec_item s_tag_refspec = {
 21:  1aa36d91b59 = 20:  7705cbc2733 object-store.h: reduce unnecessary includes
 22:  d70e3b99dae = 21:  b7a96a08d14 diff.h: reduce unnecessary includes
 23:  f32d4fa3dbf = 22:  67d52c6e751 reftable: ensure git-compat-util.h is the first (indirect) include

-- 
gitgitgadget

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

* [PATCH v2 01/22] treewide: be explicit about dependence on strbuf.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 02/22] symlinks.h: move declarations for symlinks.c functions from cache.h Elijah Newren via GitGitGadget
                     ` (23 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 color.c                       | 1 +
 common-main.c                 | 1 +
 credential.c                  | 1 +
 date.c                        | 1 +
 ll-merge.c                    | 1 +
 split-index.c                 | 1 +
 t/helper/test-mergesort.c     | 1 +
 t/helper/test-oid-array.c     | 1 +
 t/helper/test-oidtree.c       | 1 +
 t/helper/test-parse-options.c | 1 +
 t/helper/test-string-list.c   | 1 +
 wrapper.c                     | 1 +
 ws.c                          | 1 +
 13 files changed, 13 insertions(+)

diff --git a/color.c b/color.c
index 6031998d3ea..f8a25ca807b 100644
--- a/color.c
+++ b/color.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "pager.h"
+#include "strbuf.h"
 
 static int git_use_color_default = GIT_COLOR_AUTO;
 int color_stdout_is_tty = -1;
diff --git a/common-main.c b/common-main.c
index f3193173535..601a875e2fb 100644
--- a/common-main.c
+++ b/common-main.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "attr.h"
 #include "setup.h"
+#include "strbuf.h"
 #include "trace2.h"
 
 /*
diff --git a/credential.c b/credential.c
index e6417bf8804..42194efc9e0 100644
--- a/credential.c
+++ b/credential.c
@@ -8,6 +8,7 @@
 #include "url.h"
 #include "prompt.h"
 #include "sigchain.h"
+#include "strbuf.h"
 #include "urlmatch.h"
 #include "git-compat-util.h"
 
diff --git a/date.c b/date.c
index e944c8905af..bc030da012f 100644
--- a/date.c
+++ b/date.c
@@ -8,6 +8,7 @@
 #include "date.h"
 #include "gettext.h"
 #include "pager.h"
+#include "strbuf.h"
 
 /*
  * This is like mktime, but without normalization of tm_wday and tm_yday.
diff --git a/ll-merge.c b/ll-merge.c
index 28bc94c45d6..85517e668e3 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -12,6 +12,7 @@
 #include "run-command.h"
 #include "ll-merge.h"
 #include "quote.h"
+#include "strbuf.h"
 #include "wrapper.h"
 
 struct ll_merge_driver;
diff --git a/split-index.c b/split-index.c
index 5602b74994b..3fc4e91485a 100644
--- a/split-index.c
+++ b/split-index.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "mem-pool.h"
 #include "split-index.h"
+#include "strbuf.h"
 #include "ewah/ewok.h"
 
 struct split_index *init_split_index(struct index_state *istate)
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
index 737e0c52358..3aabae6c1c4 100644
--- a/t/helper/test-mergesort.c
+++ b/t/helper/test-mergesort.c
@@ -2,6 +2,7 @@
 #include "cache.h"
 #include "mem-pool.h"
 #include "mergesort.h"
+#include "strbuf.h"
 
 static uint32_t minstd_rand(uint32_t *state)
 {
diff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c
index fd6f73ea03b..ea3bf278984 100644
--- a/t/helper/test-oid-array.c
+++ b/t/helper/test-oid-array.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "oid-array.h"
 #include "setup.h"
+#include "strbuf.h"
 
 static int print_oid(const struct object_id *oid, void *data)
 {
diff --git a/t/helper/test-oidtree.c b/t/helper/test-oidtree.c
index edcb7e9f448..796c9811e0f 100644
--- a/t/helper/test-oidtree.c
+++ b/t/helper/test-oidtree.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "oidtree.h"
 #include "setup.h"
+#include "strbuf.h"
 
 static enum cb_next print_oid(const struct object_id *oid, void *data)
 {
diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
index 506835521a4..20a81a1eb21 100644
--- a/t/helper/test-parse-options.c
+++ b/t/helper/test-parse-options.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "parse-options.h"
+#include "strbuf.h"
 #include "string-list.h"
 #include "trace2.h"
 
diff --git a/t/helper/test-string-list.c b/t/helper/test-string-list.c
index 2123dda85bf..959f27c74c6 100644
--- a/t/helper/test-string-list.c
+++ b/t/helper/test-string-list.c
@@ -1,5 +1,6 @@
 #include "test-tool.h"
 #include "cache.h"
+#include "strbuf.h"
 #include "string-list.h"
 
 /*
diff --git a/wrapper.c b/wrapper.c
index c130d7518bf..e80f83498d8 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "strbuf.h"
 #include "trace2.h"
 #include "wrapper.h"
 
diff --git a/ws.c b/ws.c
index da3d0e28cbb..036ccb8ee9d 100644
--- a/ws.c
+++ b/ws.c
@@ -5,6 +5,7 @@
  */
 #include "cache.h"
 #include "attr.h"
+#include "strbuf.h"
 
 static struct whitespace_rule {
 	const char *rule_name;
-- 
gitgitgadget


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

* [PATCH v2 02/22] symlinks.h: move declarations for symlinks.c functions from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 01/22] treewide: be explicit about dependence on strbuf.h Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 03/22] packfile.h: move pack_window and pack_entry " Elijah Newren via GitGitGadget
                     ` (22 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 apply.c                |  1 +
 builtin/checkout.c     |  1 +
 builtin/update-index.c |  1 +
 cache.h                | 22 ----------------------
 compat/mingw.c         |  1 +
 diff-lib.c             |  1 +
 dir.c                  |  1 +
 entry.c                |  1 +
 merge-recursive.c      |  1 +
 parallel-checkout.c    |  1 +
 pathspec.c             |  1 +
 preload-index.c        |  1 +
 read-cache.c           |  1 +
 run-command.c          |  1 +
 symlinks.c             |  3 ++-
 symlinks.h             | 28 ++++++++++++++++++++++++++++
 unpack-trees.c         |  1 +
 17 files changed, 44 insertions(+), 23 deletions(-)
 create mode 100644 symlinks.h

diff --git a/apply.c b/apply.c
index 2868cef5ddd..efe2dcb0e62 100644
--- a/apply.c
+++ b/apply.c
@@ -30,6 +30,7 @@
 #include "apply.h"
 #include "entry.h"
 #include "setup.h"
+#include "symlinks.h"
 #include "wrapper.h"
 
 struct gitdiff_data {
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 6f5d82ed3d3..715eeb5048f 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -28,6 +28,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "symlinks.h"
 #include "trace2.h"
 #include "tree.h"
 #include "tree-walk.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 33b00cef151..58bbc80db77 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -23,6 +23,7 @@
 #include "dir.h"
 #include "setup.h"
 #include "split-index.h"
+#include "symlinks.h"
 #include "fsmonitor.h"
 #include "write-or-die.h"
 
diff --git a/cache.h b/cache.h
index 71e2fe74c4f..ffec289dc5d 100644
--- a/cache.h
+++ b/cache.h
@@ -593,28 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-struct cache_def {
-	struct strbuf path;
-	int flags;
-	int track_flags;
-	int prefix_len_stat_func;
-};
-#define CACHE_DEF_INIT { \
-	.path = STRBUF_INIT, \
-}
-static inline void cache_def_clear(struct cache_def *cache)
-{
-	strbuf_release(&cache->path);
-}
-
-int has_symlink_leading_path(const char *name, int len);
-int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
-int check_leading_path(const char *name, int len, int warn_on_lstat_err);
-int has_dirs_only_path(const char *name, int len, int prefix_len);
-void invalidate_lstat_cache(void);
-void schedule_dir_for_removal(const char *name, int len);
-void remove_scheduled_dirs(void);
-
 struct pack_window {
 	struct pack_window *next;
 	unsigned char *base;
diff --git a/compat/mingw.c b/compat/mingw.c
index abbc3faf32f..d06cdc6254f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -13,6 +13,7 @@
 #include "../config.h"
 #include "../environment.h"
 #include "../trace2.h"
+#include "../symlinks.h"
 #include "../wrapper.h"
 #include "dir.h"
 #include "gettext.h"
diff --git a/diff-lib.c b/diff-lib.c
index d292405a262..60e979dc1bd 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -14,6 +14,7 @@
 #include "unpack-trees.h"
 #include "refs.h"
 #include "submodule.h"
+#include "symlinks.h"
 #include "trace.h"
 #include "dir.h"
 #include "fsmonitor.h"
diff --git a/dir.c b/dir.c
index aa840995c40..ed262fa6e43 100644
--- a/dir.c
+++ b/dir.c
@@ -25,6 +25,7 @@
 #include "fsmonitor.h"
 #include "setup.h"
 #include "submodule-config.h"
+#include "symlinks.h"
 #include "trace2.h"
 #include "wrapper.h"
 
diff --git a/entry.c b/entry.c
index d89e61fa641..91a540bd29f 100644
--- a/entry.c
+++ b/entry.c
@@ -7,6 +7,7 @@
 #include "hex.h"
 #include "streaming.h"
 #include "submodule.h"
+#include "symlinks.h"
 #include "progress.h"
 #include "fsmonitor.h"
 #include "entry.h"
diff --git a/merge-recursive.c b/merge-recursive.c
index 9875bdb11cb..d4d2ab05b2e 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -30,6 +30,7 @@
 #include "string-list.h"
 #include "submodule-config.h"
 #include "submodule.h"
+#include "symlinks.h"
 #include "tag.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 50fd7fe31ef..7f0569cc930 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -10,6 +10,7 @@
 #include "run-command.h"
 #include "sigchain.h"
 #include "streaming.h"
+#include "symlinks.h"
 #include "thread-utils.h"
 #include "trace2.h"
 #include "wrapper.h"
diff --git a/pathspec.c b/pathspec.c
index 6972d515f0c..ec335a214e2 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -8,6 +8,7 @@
 #include "attr.h"
 #include "setup.h"
 #include "strvec.h"
+#include "symlinks.h"
 #include "quote.h"
 
 /*
diff --git a/preload-index.c b/preload-index.c
index 4abf9c983b2..7a26b08c213 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "thread-utils.h"
 #include "repository.h"
+#include "symlinks.h"
 #include "trace2.h"
 
 /*
diff --git a/read-cache.c b/read-cache.c
index f225bf44cd0..206c003e558 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -30,6 +30,7 @@
 #include "trace2.h"
 #include "varint.h"
 #include "split-index.h"
+#include "symlinks.h"
 #include "utf8.h"
 #include "fsmonitor.h"
 #include "thread-utils.h"
diff --git a/run-command.c b/run-command.c
index e64bb08a5bf..d4247d5fcc6 100644
--- a/run-command.c
+++ b/run-command.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "sigchain.h"
 #include "strvec.h"
+#include "symlinks.h"
 #include "thread-utils.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/symlinks.c b/symlinks.c
index 27ecc93693b..b29e340c2da 100644
--- a/symlinks.c
+++ b/symlinks.c
@@ -1,6 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "setup.h"
+#include "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/symlinks.h
new file mode 100644
index 00000000000..7ae3d5b8569
--- /dev/null
+++ b/symlinks.h
@@ -0,0 +1,28 @@
+#ifndef SYMLINKS_H
+#define SYMLINKS_H
+
+#include "strbuf.h"
+
+struct cache_def {
+	struct strbuf path;
+	int flags;
+	int track_flags;
+	int prefix_len_stat_func;
+};
+#define CACHE_DEF_INIT { \
+	.path = STRBUF_INIT, \
+}
+static inline void cache_def_clear(struct cache_def *cache)
+{
+	strbuf_release(&cache->path);
+}
+
+int has_symlink_leading_path(const char *name, int len);
+int threaded_has_symlink_leading_path(struct cache_def *, const char *, int);
+int check_leading_path(const char *name, int len, int warn_on_lstat_err);
+int has_dirs_only_path(const char *name, int len, int prefix_len);
+void invalidate_lstat_cache(void);
+void schedule_dir_for_removal(const char *name, int len);
+void remove_scheduled_dirs(void);
+
+#endif /* SYMLINKS_H */
diff --git a/unpack-trees.c b/unpack-trees.c
index c6de2ca5a7e..e8a5295e737 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -18,6 +18,7 @@
 #include "sparse-index.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "symlinks.h"
 #include "trace2.h"
 #include "fsmonitor.h"
 #include "object-store.h"
-- 
gitgitgadget


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

* [PATCH v2 03/22] packfile.h: move pack_window and pack_entry from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 01/22] treewide: be explicit about dependence on strbuf.h Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 02/22] symlinks.h: move declarations for symlinks.c functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 04/22] server-info.h: move declarations for server-info.c functions " Elijah Newren via GitGitGadget
                     ` (21 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h                   | 14 --------------
 packfile.h                | 16 ++++++++++++++--
 t/helper/test-read-midx.c |  1 +
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/cache.h b/cache.h
index ffec289dc5d..ffb9028f015 100644
--- a/cache.h
+++ b/cache.h
@@ -593,20 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-struct pack_window {
-	struct pack_window *next;
-	unsigned char *base;
-	off_t offset;
-	size_t len;
-	unsigned int last_used;
-	unsigned int inuse_cnt;
-};
-
-struct pack_entry {
-	off_t offset;
-	struct packed_git *p;
-};
-
 /* Dumb servers support */
 int update_server_info(int);
 
diff --git a/packfile.h b/packfile.h
index 665603b696a..c3692308b8d 100644
--- a/packfile.h
+++ b/packfile.h
@@ -6,10 +6,22 @@
 
 /* in object-store.h */
 struct packed_git;
-struct pack_entry;
-struct pack_window;
 struct object_info;
 
+struct pack_window {
+	struct pack_window *next;
+	unsigned char *base;
+	off_t offset;
+	size_t len;
+	unsigned int last_used;
+	unsigned int inuse_cnt;
+};
+
+struct pack_entry {
+	off_t offset;
+	struct packed_git *p;
+};
+
 /*
  * Generate the filename to be used for a pack file with checksum "sha1" and
  * extension "ext". The result is written into the strbuf "buf", overwriting
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index 05c4f2b2625..b32abff7f11 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -5,6 +5,7 @@
 #include "repository.h"
 #include "object-store.h"
 #include "pack-bitmap.h"
+#include "packfile.h"
 #include "setup.h"
 
 static int read_midx_file(const char *object_dir, int show_objects)
-- 
gitgitgadget


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

* [PATCH v2 04/22] server-info.h: move declarations for server-info.c functions from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (2 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 03/22] packfile.h: move pack_window and pack_entry " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 05/22] copy.h: move declarations for copy.c " Elijah Newren via GitGitGadget
                     ` (20 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/receive-pack.c       | 1 +
 builtin/repack.c             | 1 +
 builtin/update-server-info.c | 1 +
 cache.h                      | 3 ---
 server-info.c                | 3 ++-
 server-info.h                | 7 +++++++
 6 files changed, 12 insertions(+), 4 deletions(-)
 create mode 100644 server-info.h

diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 7d921170f1c..dae99e4554d 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -33,6 +33,7 @@
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
+#include "server-info.h"
 #include "trace.h"
 #include "trace2.h"
 #include "worktree.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index df4d8e0f0ba..bed2c2aaafb 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -7,6 +7,7 @@
 #include "hex.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "server-info.h"
 #include "sigchain.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/builtin/update-server-info.c b/builtin/update-server-info.c
index e7bff27ae40..19dce3c0655 100644
--- a/builtin/update-server-info.c
+++ b/builtin/update-server-info.c
@@ -3,6 +3,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "server-info.h"
 
 static const char * const update_server_info_usage[] = {
 	"git update-server-info [-f | --force]",
diff --git a/cache.h b/cache.h
index ffb9028f015..2eb4546473f 100644
--- a/cache.h
+++ b/cache.h
@@ -593,9 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-/* Dumb servers support */
-int update_server_info(int);
-
 #define COPY_READ_ERROR (-2)
 #define COPY_WRITE_ERROR (-3)
 int copy_fd(int ifd, int ofd);
diff --git a/server-info.c b/server-info.c
index 68098ddd1ad..55aa04f00ab 100644
--- a/server-info.c
+++ b/server-info.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "environment.h"
@@ -11,6 +11,7 @@
 #include "packfile.h"
 #include "object-file.h"
 #include "object-store.h"
+#include "server-info.h"
 #include "strbuf.h"
 #include "wrapper.h"
 
diff --git a/server-info.h b/server-info.h
new file mode 100644
index 00000000000..13bbde2c55f
--- /dev/null
+++ b/server-info.h
@@ -0,0 +1,7 @@
+#ifndef SERVER_INFO_H
+#define SERVER_INFO_H
+
+/* Dumb servers support */
+int update_server_info(int);
+
+#endif /* SERVER_INFO_H */
-- 
gitgitgadget


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

* [PATCH v2 05/22] copy.h: move declarations for copy.c functions from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (3 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 04/22] server-info.h: move declarations for server-info.c functions " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 06/22] base85.h: move declarations for base85.c " Elijah Newren via GitGitGadget
                     ` (19 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/bisect.c     |  1 +
 builtin/clone.c      |  1 +
 builtin/difftool.c   |  1 +
 builtin/init-db.c    |  1 +
 builtin/worktree.c   |  1 +
 bundle-uri.c         |  1 +
 cache.h              |  6 ------
 convert.c            |  1 +
 copy.c               |  1 +
 copy.h               | 10 ++++++++++
 pkt-line.c           |  1 +
 refs/files-backend.c |  1 +
 rerere.c             |  1 +
 sequencer.c          |  1 +
 14 files changed, 22 insertions(+), 6 deletions(-)
 create mode 100644 copy.h

diff --git a/builtin/bisect.c b/builtin/bisect.c
index 4b2143d4557..4812450c393 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "cache.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 4ed0a1d5aad..017ebc3faa8 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -13,6 +13,7 @@
 #include "abspath.h"
 #include "advice.h"
 #include "config.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/difftool.c b/builtin/difftool.c
index 3ffb0524be7..409507983f2 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -15,6 +15,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "config.h"
+#include "copy.h"
 #include "builtin.h"
 #include "run-command.h"
 #include "environment.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index 6183f3fb3ff..cda6ee75eb5 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -6,6 +6,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "config.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "refs.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 0621f6f708e..0b411e9deee 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "checkout.h"
 #include "config.h"
+#include "copy.h"
 #include "builtin.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/bundle-uri.c b/bundle-uri.c
index 1ff1cf51dad..6d44662ee1f 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "bundle-uri.h"
 #include "bundle.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "object-store.h"
diff --git a/cache.h b/cache.h
index 2eb4546473f..2b661764794 100644
--- a/cache.h
+++ b/cache.h
@@ -593,12 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-#define COPY_READ_ERROR (-2)
-#define COPY_WRITE_ERROR (-3)
-int copy_fd(int ifd, int ofd);
-int copy_file(const char *dst, const char *src, int mode);
-int copy_file_with_time(const char *dst, const char *src, int mode);
-
 /* base85 */
 int decode_85(char *dst, const char *line, int linelen);
 void encode_85(char *buf, const unsigned char *data, int bytes);
diff --git a/convert.c b/convert.c
index 5a2ea5308d6..7cf7bd0c883 100644
--- a/convert.c
+++ b/convert.c
@@ -2,6 +2,7 @@
 #include "advice.h"
 #include "config.h"
 #include "convert.h"
+#include "copy.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/copy.c b/copy.c
index c3250f08221..db6b615c188 100644
--- a/copy.c
+++ b/copy.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "copy.h"
 #include "wrapper.h"
 
 int copy_fd(int ifd, int ofd)
diff --git a/copy.h b/copy.h
new file mode 100644
index 00000000000..2af77cba864
--- /dev/null
+++ b/copy.h
@@ -0,0 +1,10 @@
+#ifndef COPY_H
+#define COPY_H
+
+#define COPY_READ_ERROR (-2)
+#define COPY_WRITE_ERROR (-3)
+int copy_fd(int ifd, int ofd);
+int copy_file(const char *dst, const char *src, int mode);
+int copy_file_with_time(const char *dst, const char *src, int mode);
+
+#endif /* COPY_H */
diff --git a/pkt-line.c b/pkt-line.c
index 3561d853584..8b5fa788517 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "copy.h"
 #include "pkt-line.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index d0581ee41ac..1128a9af292 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1,5 +1,6 @@
 #include "../cache.h"
 #include "../config.h"
+#include "../copy.h"
 #include "../environment.h"
 #include "../gettext.h"
 #include "../hex.h"
diff --git a/rerere.c b/rerere.c
index 7abc94bf444..e968d413d65 100644
--- a/rerere.c
+++ b/rerere.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "copy.h"
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
diff --git a/sequencer.c b/sequencer.c
index fcca3b81447..c16df514434 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3,6 +3,7 @@
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
+#include "copy.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
-- 
gitgitgadget


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

* [PATCH v2 06/22] base85.h: move declarations for base85.c functions from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (4 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 05/22] copy.h: move declarations for copy.c " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 07/22] pkt-line.h: move declarations for pkt-line.c " Elijah Newren via GitGitGadget
                     ` (18 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 apply.c  | 1 +
 base85.c | 3 ++-
 base85.h | 7 +++++++
 cache.h  | 4 ----
 diff.c   | 1 +
 5 files changed, 11 insertions(+), 5 deletions(-)
 create mode 100644 base85.h

diff --git a/apply.c b/apply.c
index efe2dcb0e62..a65a354eef5 100644
--- a/apply.c
+++ b/apply.c
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "alloc.h"
+#include "base85.h"
 #include "config.h"
 #include "object-store.h"
 #include "blob.h"
diff --git a/base85.c b/base85.c
index 5ca601ee14f..bbacdca31b3 100644
--- a/base85.c
+++ b/base85.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "base85.h"
 
 #undef DEBUG_85
 
diff --git a/base85.h b/base85.h
new file mode 100644
index 00000000000..c835086e093
--- /dev/null
+++ b/base85.h
@@ -0,0 +1,7 @@
+#ifndef BASE85_H
+#define BASE85_H
+
+int decode_85(char *dst, const char *line, int linelen);
+void encode_85(char *buf, const unsigned char *data, int bytes);
+
+#endif /* BASE85_H */
diff --git a/cache.h b/cache.h
index 2b661764794..b89f4c59802 100644
--- a/cache.h
+++ b/cache.h
@@ -593,10 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-/* base85 */
-int decode_85(char *dst, const char *line, int linelen);
-void encode_85(char *buf, const unsigned char *data, int bytes);
-
 /* pkt-line.c */
 void packet_trace_identity(const char *prog);
 
diff --git a/diff.c b/diff.c
index fa86d023196..e697f78a645 100644
--- a/diff.c
+++ b/diff.c
@@ -4,6 +4,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "alloc.h"
+#include "base85.h"
 #include "config.h"
 #include "convert.h"
 #include "environment.h"
-- 
gitgitgadget


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

* [PATCH v2 07/22] pkt-line.h: move declarations for pkt-line.c functions from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (5 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 06/22] base85.h: move declarations for base85.c " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 08/22] match-trees.h: move declarations for match-trees.c " Elijah Newren via GitGitGadget
                     ` (17 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/bundle.c    | 1 +
 builtin/clone.c     | 1 +
 builtin/fetch.c     | 1 +
 builtin/ls-remote.c | 1 +
 builtin/push.c      | 1 +
 cache.h             | 3 ---
 pkt-line.h          | 2 ++
 7 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/builtin/bundle.c b/builtin/bundle.c
index e68fc83d943..584d905d965 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -4,6 +4,7 @@
 #include "setup.h"
 #include "strvec.h"
 #include "parse-options.h"
+#include "pkt-line.h"
 #include "cache.h"
 #include "bundle.h"
 
diff --git a/builtin/clone.c b/builtin/clone.c
index 017ebc3faa8..fa300f483e9 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -39,6 +39,7 @@
 #include "setup.h"
 #include "connected.h"
 #include "packfile.h"
+#include "pkt-line.h"
 #include "list-objects-filter-options.h"
 #include "hook.h"
 #include "bundle.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 61e8ac113b1..4fee2a62376 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -29,6 +29,7 @@
 #include "utf8.h"
 #include "packfile.h"
 #include "pager.h"
+#include "pkt-line.h"
 #include "list-objects-filter-options.h"
 #include "commit-reach.h"
 #include "branch.h"
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 11d9424804a..7972febf726 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "transport.h"
+#include "pkt-line.h"
 #include "ref-filter.h"
 #include "remote.h"
 #include "refs.h"
diff --git a/builtin/push.c b/builtin/push.c
index 6001e4ae0a4..7d2b0505aac 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -14,6 +14,7 @@
 #include "remote.h"
 #include "transport.h"
 #include "parse-options.h"
+#include "pkt-line.h"
 #include "submodule.h"
 #include "submodule-config.h"
 #include "send-pack.h"
diff --git a/cache.h b/cache.h
index b89f4c59802..fde782a96f0 100644
--- a/cache.h
+++ b/cache.h
@@ -593,9 +593,6 @@ int df_name_compare(const char *name1, size_t len1, int mode1,
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
 
-/* pkt-line.c */
-void packet_trace_identity(const char *prog);
-
 /* add */
 /*
  * return 0 if success, 1 - if addition of a file failed and
diff --git a/pkt-line.h b/pkt-line.h
index 8e9846f3151..7c23a4bfaf7 100644
--- a/pkt-line.h
+++ b/pkt-line.h
@@ -246,4 +246,6 @@ void packet_writer_error(struct packet_writer *writer, const char *fmt, ...);
 void packet_writer_delim(struct packet_writer *writer);
 void packet_writer_flush(struct packet_writer *writer);
 
+void packet_trace_identity(const char *prog);
+
 #endif
-- 
gitgitgadget


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

* [PATCH v2 08/22] match-trees.h: move declarations for match-trees.c functions from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (6 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 07/22] pkt-line.h: move declarations for pkt-line.c " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 09/22] ws.h: move declarations for ws.c " Elijah Newren via GitGitGadget
                     ` (16 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h                     |  4 ----
 match-trees.c               |  1 +
 match-trees.h               | 10 ++++++++++
 merge-ort.c                 |  1 +
 merge-recursive.c           |  1 +
 t/helper/test-match-trees.c |  1 +
 6 files changed, 14 insertions(+), 4 deletions(-)
 create mode 100644 match-trees.h

diff --git a/cache.h b/cache.h
index fde782a96f0..0570f9ad07d 100644
--- a/cache.h
+++ b/cache.h
@@ -603,10 +603,6 @@ int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int
 /* diff.c */
 extern int diff_auto_refresh_index;
 
-/* match-trees.c */
-void shift_tree(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, int);
-void shift_tree_by(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, const char *);
-
 /*
  * whitespace rules.
  * used by both diff and apply
diff --git a/match-trees.c b/match-trees.c
index 5877fc64a8f..9b78d99507b 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "hex.h"
+#include "match-trees.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "object-store.h"
diff --git a/match-trees.h b/match-trees.h
new file mode 100644
index 00000000000..e3877acd583
--- /dev/null
+++ b/match-trees.h
@@ -0,0 +1,10 @@
+#ifndef MATCH_TREES_H
+#define MATCH_TREES_H
+
+struct object_id;
+struct repository;
+
+void shift_tree(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, int);
+void shift_tree_by(struct repository *, const struct object_id *, const struct object_id *, struct object_id *, const char *);
+
+#endif /* MATCH_TREES_H */
diff --git a/merge-ort.c b/merge-ort.c
index 2c6a9ed9a41..65837db77f0 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -31,6 +31,7 @@
 #include "hex.h"
 #include "entry.h"
 #include "ll-merge.h"
+#include "match-trees.h"
 #include "mem-pool.h"
 #include "object-name.h"
 #include "object-store.h"
diff --git a/merge-recursive.c b/merge-recursive.c
index d4d2ab05b2e..8e87b6386d9 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -22,6 +22,7 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "match-trees.h"
 #include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 3808e1ac38b..a498fece7a3 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "hex.h"
+#include "match-trees.h"
 #include "object-name.h"
 #include "setup.h"
 #include "tree.h"
-- 
gitgitgadget


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

* [PATCH v2 09/22] ws.h: move declarations for ws.c functions from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (7 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 08/22] match-trees.h: move declarations for match-trees.c " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 10/22] versioncmp.h: move declarations for versioncmp.c " Elijah Newren via GitGitGadget
                     ` (15 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 apply.c       |  1 +
 cache.h       | 26 --------------------------
 config.c      |  1 +
 diff.c        |  1 +
 environment.c |  1 -
 ws.c          |  5 ++++-
 ws.h          | 33 +++++++++++++++++++++++++++++++++
 7 files changed, 40 insertions(+), 28 deletions(-)
 create mode 100644 ws.h

diff --git a/apply.c b/apply.c
index a65a354eef5..2de8bb203d7 100644
--- a/apply.c
+++ b/apply.c
@@ -32,6 +32,7 @@
 #include "entry.h"
 #include "setup.h"
 #include "symlinks.h"
+#include "ws.h"
 #include "wrapper.h"
 
 struct gitdiff_data {
diff --git a/cache.h b/cache.h
index 0570f9ad07d..dde275c9301 100644
--- a/cache.h
+++ b/cache.h
@@ -603,32 +603,6 @@ int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int
 /* diff.c */
 extern int diff_auto_refresh_index;
 
-/*
- * whitespace rules.
- * used by both diff and apply
- * last two digits are tab width
- */
-#define WS_BLANK_AT_EOL         0100
-#define WS_SPACE_BEFORE_TAB     0200
-#define WS_INDENT_WITH_NON_TAB  0400
-#define WS_CR_AT_EOL           01000
-#define WS_BLANK_AT_EOF        02000
-#define WS_TAB_IN_INDENT       04000
-#define WS_TRAILING_SPACE      (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF)
-#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8)
-#define WS_TAB_WIDTH_MASK        077
-/* All WS_* -- when extended, adapt diff.c emit_symbol */
-#define WS_RULE_MASK           07777
-extern unsigned whitespace_rule_cfg;
-unsigned whitespace_rule(struct index_state *, const char *);
-unsigned parse_whitespace_rule(const char *);
-unsigned ws_check(const char *line, int len, unsigned ws_rule);
-void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
-char *whitespace_error_string(unsigned ws);
-void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *);
-int ws_blank_line(const char *line, int len);
-#define ws_tab_width(rule)     ((rule) & WS_TAB_WIDTH_MASK)
-
 /* ls-files */
 void overlay_tree_on_index(struct index_state *istate,
 			   const char *tree_name, const char *prefix);
diff --git a/config.c b/config.c
index 9beba19b41c..97063a0743e 100644
--- a/config.c
+++ b/config.c
@@ -35,6 +35,7 @@
 #include "setup.h"
 #include "trace2.h"
 #include "worktree.h"
+#include "ws.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/diff.c b/diff.c
index e697f78a645..73d2ac03673 100644
--- a/diff.c
+++ b/diff.c
@@ -41,6 +41,7 @@
 #include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
+#include "ws.h"
 #include "wrapper.h"
 
 #ifdef NO_FAST_WORKING_DIRECTORY
diff --git a/environment.c b/environment.c
index 8a96997539a..541f0b19acf 100644
--- a/environment.c
+++ b/environment.c
@@ -67,7 +67,6 @@ int read_replace_refs = 1;
 enum eol core_eol = EOL_UNSET;
 int global_conv_flags_eol = CONV_EOL_RNDTRP_WARN;
 char *check_roundtrip_encoding = "SHIFT-JIS";
-unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
 enum rebase_setup_type autorebase = AUTOREBASE_NEVER;
 enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED;
diff --git a/ws.c b/ws.c
index 036ccb8ee9d..d356d4ec9ee 100644
--- a/ws.c
+++ b/ws.c
@@ -3,9 +3,12 @@
  *
  * Copyright (c) 2007 Junio C Hamano
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "attr.h"
 #include "strbuf.h"
+#include "ws.h"
+
+unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
 
 static struct whitespace_rule {
 	const char *rule_name;
diff --git a/ws.h b/ws.h
new file mode 100644
index 00000000000..5ba676c5595
--- /dev/null
+++ b/ws.h
@@ -0,0 +1,33 @@
+#ifndef WS_H
+#define WS_H
+
+struct index_state;
+struct strbuf;
+
+/*
+ * whitespace rules.
+ * used by both diff and apply
+ * last two digits are tab width
+ */
+#define WS_BLANK_AT_EOL         0100
+#define WS_SPACE_BEFORE_TAB     0200
+#define WS_INDENT_WITH_NON_TAB  0400
+#define WS_CR_AT_EOL           01000
+#define WS_BLANK_AT_EOF        02000
+#define WS_TAB_IN_INDENT       04000
+#define WS_TRAILING_SPACE      (WS_BLANK_AT_EOL|WS_BLANK_AT_EOF)
+#define WS_DEFAULT_RULE (WS_TRAILING_SPACE|WS_SPACE_BEFORE_TAB|8)
+#define WS_TAB_WIDTH_MASK        077
+/* All WS_* -- when extended, adapt diff.c emit_symbol */
+#define WS_RULE_MASK           07777
+extern unsigned whitespace_rule_cfg;
+unsigned whitespace_rule(struct index_state *, const char *);
+unsigned parse_whitespace_rule(const char *);
+unsigned ws_check(const char *line, int len, unsigned ws_rule);
+void ws_check_emit(const char *line, int len, unsigned ws_rule, FILE *stream, const char *set, const char *reset, const char *ws);
+char *whitespace_error_string(unsigned ws);
+void ws_fix_copy(struct strbuf *, const char *, int, unsigned, int *);
+int ws_blank_line(const char *line, int len);
+#define ws_tab_width(rule)     ((rule) & WS_TAB_WIDTH_MASK)
+
+#endif /* WS_H */
-- 
gitgitgadget


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

* [PATCH v2 10/22] versioncmp.h: move declarations for versioncmp.c functions from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (8 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 09/22] ws.h: move declarations for ws.c " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 11/22] dir.h: move DTYPE defines " Elijah Newren via GitGitGadget
                     ` (14 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h      | 2 --
 ref-filter.c | 1 +
 versioncmp.c | 3 ++-
 versioncmp.h | 6 ++++++
 4 files changed, 9 insertions(+), 3 deletions(-)
 create mode 100644 versioncmp.h

diff --git a/cache.h b/cache.h
index dde275c9301..6955745cccd 100644
--- a/cache.h
+++ b/cache.h
@@ -648,6 +648,4 @@ int stat_validity_check(struct stat_validity *sv, const char *path);
  */
 void stat_validity_update(struct stat_validity *sv, int fd);
 
-int versioncmp(const char *s1, const char *s2);
-
 #endif /* CACHE_H */
diff --git a/ref-filter.c b/ref-filter.c
index 57a5884aec7..5387f79be6d 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -19,6 +19,7 @@
 #include "revision.h"
 #include "utf8.h"
 #include "version.h"
+#include "versioncmp.h"
 #include "trailer.h"
 #include "wt-status.h"
 #include "commit-slab.h"
diff --git a/versioncmp.c b/versioncmp.c
index 069ee94a4d7..9b21ec142dd 100644
--- a/versioncmp.c
+++ b/versioncmp.c
@@ -1,6 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "string-list.h"
+#include "versioncmp.h"
 
 /*
  * versioncmp(): copied from string/strverscmp.c in glibc commit
diff --git a/versioncmp.h b/versioncmp.h
new file mode 100644
index 00000000000..879b510e82a
--- /dev/null
+++ b/versioncmp.h
@@ -0,0 +1,6 @@
+#ifndef VERSIONCMP_H
+#define VERSIONCMP_H
+
+int versioncmp(const char *s1, const char *s2);
+
+#endif /* VERSIONCMP_H */
-- 
gitgitgadget


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

* [PATCH v2 11/22] dir.h: move DTYPE defines from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (9 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 10/22] versioncmp.h: move declarations for versioncmp.c " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define " Elijah Newren via GitGitGadget
                     ` (13 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h | 14 --------------
 dir.h   | 15 +++++++++++++++
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/cache.h b/cache.h
index 6955745cccd..ad741e70bc2 100644
--- a/cache.h
+++ b/cache.h
@@ -10,20 +10,6 @@
 #include "object.h"
 #include "statinfo.h"
 
-#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
-#define DTYPE(de)	((de)->d_type)
-#else
-#undef DT_UNKNOWN
-#undef DT_DIR
-#undef DT_REG
-#undef DT_LNK
-#define DT_UNKNOWN	0
-#define DT_DIR		1
-#define DT_REG		2
-#define DT_LNK		3
-#define DTYPE(de)	DT_UNKNOWN
-#endif
-
 /*
  * Some mode bits are also used internally for computations.
  *
diff --git a/dir.h b/dir.h
index 3d6c87387e9..79b85a01ee4 100644
--- a/dir.h
+++ b/dir.h
@@ -640,4 +640,19 @@ static inline int starts_with_dot_dot_slash_native(const char *const path)
 
 	return path_match_flags(path, what | PATH_MATCH_NATIVE);
 }
+
+#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
+#define DTYPE(de)	((de)->d_type)
+#else
+#undef DT_UNKNOWN
+#undef DT_DIR
+#undef DT_REG
+#undef DT_LNK
+#define DT_UNKNOWN	0
+#define DT_DIR		1
+#define DT_REG		2
+#define DT_LNK		3
+#define DTYPE(de)	DT_UNKNOWN
+#endif
+
 #endif
-- 
gitgitgadget


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

* [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (10 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 11/22] dir.h: move DTYPE defines " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-05-01 16:33     ` Ævar Arnfjörð Bjarmason
  2023-04-22 20:17   ` [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h Elijah Newren via GitGitGadget
                     ` (12 subsequent siblings)
  24 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

S_DIFFTREE_IFXMIN_NEQ is *only* used in tree-diff.c, so there is no
point exposing it in cache.h.  Move it to tree-diff.c.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h     | 15 ---------------
 tree-diff.c | 13 +++++++++++++
 2 files changed, 13 insertions(+), 15 deletions(-)

diff --git a/cache.h b/cache.h
index ad741e70bc2..7a46f300d9b 100644
--- a/cache.h
+++ b/cache.h
@@ -10,21 +10,6 @@
 #include "object.h"
 #include "statinfo.h"
 
-/*
- * Some mode bits are also used internally for computations.
- *
- * They *must* not overlap with any valid modes, and they *must* not be emitted
- * to outside world - i.e. appear on disk or network. In other words, it's just
- * temporary fields, which we internally use, but they have to stay in-house.
- *
- * ( such approach is valid, as standard S_IF* fits into 16 bits, and in Git
- *   codebase mode is `unsigned int` which is assumed to be at least 32 bits )
- */
-
-/* used internally in tree-diff */
-#define S_DIFFTREE_IFXMIN_NEQ	0x80000000
-
-
 /*
  * Basic data structures for the directory cache
  */
diff --git a/tree-diff.c b/tree-diff.c
index 69031d7cbae..a76e6dae619 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -6,6 +6,19 @@
 #include "diffcore.h"
 #include "tree.h"
 
+/*
+ * Some mode bits are also used internally for computations.
+ *
+ * They *must* not overlap with any valid modes, and they *must* not be emitted
+ * to outside world - i.e. appear on disk or network. In other words, it's just
+ * temporary fields, which we internally use, but they have to stay in-house.
+ *
+ * ( such approach is valid, as standard S_IF* fits into 16 bits, and in Git
+ *   codebase mode is `unsigned int` which is assumed to be at least 32 bits )
+ */
+
+#define S_DIFFTREE_IFXMIN_NEQ	0x80000000
+
 /*
  * internal mode marker, saying a tree entry != entry of tp[imin]
  * (see ll_diff_tree_paths for what it means there)
-- 
gitgitgadget


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

* [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (11 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-24 18:51     ` Glen Choo
                       ` (2 more replies)
  2023-04-22 20:17   ` [PATCH v2 14/22] cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c Elijah Newren via GitGitGadget
                     ` (11 subsequent siblings)
  24 siblings, 3 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

hash.h depends upon and includes repository.h, due to the definition and
use of the_hash_algo (defined as the_repository->hash_algo).  However,
most headers trying to include hash.h are only interested in the layout
of the structs like object_id.  Move the parts of hash.h that do not
depend upon repository.h into a new file hash-ll.h (the "low level"
parts of hash.h), and adjust other files to use this new header where
the convenience inline functions aren't needed.

This allows hash.h and object.h to be fairly small, minimal headers.  It
also exposes a lot of hidden dependencies on both path.h (which was
brought in by repository.h) and repository.h (which was previously
implicitly brought in by object.h), so also adjust other files to be
more explicit about what they depend upon.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 alloc.c                                      |   1 +
 apply.h                                      |   2 +-
 branch.c                                     |   1 +
 builtin/apply.c                              |   1 +
 builtin/archive.c                            |   1 +
 builtin/bundle.c                             |   1 +
 builtin/check-attr.c                         |   1 +
 builtin/check-ignore.c                       |   1 +
 builtin/checkout-index.c                     |   1 +
 builtin/clean.c                              |   1 +
 builtin/config.c                             |   1 +
 builtin/credential-cache.c                   |   1 +
 builtin/credential-store.c                   |   1 +
 builtin/for-each-repo.c                      |   2 +
 builtin/help.c                               |   1 +
 builtin/init-db.c                            |   1 +
 builtin/merge-index.c                        |   1 +
 builtin/merge-recursive.c                    |   2 +
 builtin/mv.c                                 |   1 +
 builtin/push.c                               |   1 +
 builtin/read-tree.c                          |   1 +
 builtin/rerere.c                             |   1 +
 builtin/rm.c                                 |   2 +
 builtin/show-branch.c                        |   2 +
 builtin/show-index.c                         |   2 +
 builtin/update-index.c                       |   2 +
 builtin/update-ref.c                         |   2 +
 builtin/upload-archive.c                     |   1 +
 builtin/worktree.c                           |   1 +
 checkout.c                                   |   1 +
 checkout.h                                   |   2 +-
 chunk-format.c                               |   1 +
 chunk-format.h                               |   2 +-
 common-main.c                                |   1 +
 compat/fsmonitor/fsm-ipc-darwin.c            |   1 +
 compat/fsmonitor/fsm-ipc-win32.c             |   1 +
 compat/precompose_utf8.c                     |   1 +
 compat/win32/trace2_win32_process_info.c     |   1 +
 convert.h                                    |   2 +-
 copy.c                                       |   1 +
 csum-file.c                                  |   1 +
 csum-file.h                                  |   2 +-
 daemon.c                                     |   1 +
 diffcore.h                                   |   2 +-
 editor.c                                     |   1 +
 exec-cmd.c                                   |   1 +
 fsmonitor-ipc.c                              |   1 +
 gpg-interface.c                              |   1 +
 hash-ll.h                                    | 276 +++++++++++++++++++
 hash-lookup.c                                |   1 +
 hash.h                                       | 273 +-----------------
 hashmap.h                                    |   2 +-
 hex.c                                        |   1 +
 hex.h                                        |   2 +-
 hook.c                                       |   1 +
 khash.h                                      |   1 +
 ls-refs.c                                    |   1 +
 merge-ort-wrappers.c                         |   1 +
 merge-ort.h                                  |   2 +-
 negotiator/default.c                         |   1 +
 negotiator/skipping.c                        |   1 +
 object-file.h                                |   2 +
 object.h                                     |   3 +-
 oidmap.c                                     |   1 +
 oidtree.h                                    |   2 +-
 parallel-checkout.c                          |   1 +
 pathspec.c                                   |   1 +
 progress.c                                   |   1 +
 protocol-caps.c                              |   2 +-
 rebase-interactive.c                         |   1 +
 refs/files-backend.c                         |   1 +
 refs/packed-backend.c                        |   1 +
 refs/ref-cache.c                             |   2 +
 refs/ref-cache.h                             |   3 +-
 refspec.c                                    |   1 +
 reftable/dump.c                              |   2 +-
 reftable/system.h                            |   2 +-
 reset.h                                      |   2 +-
 resolve-undo.c                               |   1 +
 resolve-undo.h                               |   2 +-
 split-index.c                                |   1 +
 split-index.h                                |   2 +-
 strbuf.c                                     |   1 +
 t/helper/test-bloom.c                        |   1 +
 t/helper/test-cache-tree.c                   |   1 +
 t/helper/test-dump-cache-tree.c              |   2 +
 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                  |   1 +
 t/helper/test-oidmap.c                       |   1 +
 t/helper/test-path-utils.c                   |   1 +
 t/helper/test-read-cache.c                   |   1 +
 t/helper/test-scrap-cache-tree.c             |   1 +
 t/helper/test-submodule-config.c             |   2 +
 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-walk.h                                  |   3 +-
 tree.h                                       |   1 +
 wrapper.c                                    |   1 +
 xdiff-interface.h                            |   2 +-
 109 files changed, 398 insertions(+), 292 deletions(-)
 create mode 100644 hash-ll.h

diff --git a/alloc.c b/alloc.c
index 2886aa93543..377e80f5dda 100644
--- a/alloc.c
+++ b/alloc.c
@@ -13,6 +13,7 @@
 #include "blob.h"
 #include "tree.h"
 #include "commit.h"
+#include "repository.h"
 #include "tag.h"
 #include "alloc.h"
 
diff --git a/apply.h b/apply.h
index b9f18ce87d1..7cd38b1443c 100644
--- a/apply.h
+++ b/apply.h
@@ -1,7 +1,7 @@
 #ifndef APPLY_H
 #define APPLY_H
 
-#include "hash.h"
+#include "hash-ll.h"
 #include "lockfile.h"
 #include "string-list.h"
 #include "strmap.h"
diff --git a/branch.c b/branch.c
index 7df982693af..9415ee3f340 100644
--- a/branch.c
+++ b/branch.c
@@ -9,6 +9,7 @@
 #include "refs.h"
 #include "refspec.h"
 #include "remote.h"
+#include "repository.h"
 #include "sequencer.h"
 #include "commit.h"
 #include "worktree.h"
diff --git a/builtin/apply.c b/builtin/apply.c
index fe72c0ec3eb..e3ff02a09e3 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -2,6 +2,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "apply.h"
 
 static const char * const apply_usage[] = {
diff --git a/builtin/archive.c b/builtin/archive.c
index d13934f1a80..b0eaa3c14a3 100644
--- a/builtin/archive.c
+++ b/builtin/archive.c
@@ -9,6 +9,7 @@
 #include "transport.h"
 #include "parse-options.h"
 #include "pkt-line.h"
+#include "repository.h"
 #include "sideband.h"
 
 static void create_output_file(const char *output_file)
diff --git a/builtin/bundle.c b/builtin/bundle.c
index 584d905d965..44113389d7a 100644
--- a/builtin/bundle.c
+++ b/builtin/bundle.c
@@ -5,6 +5,7 @@
 #include "strvec.h"
 #include "parse-options.h"
 #include "pkt-line.h"
+#include "repository.h"
 #include "cache.h"
 #include "bundle.h"
 
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 037bf1aaa2a..b2b678847f5 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -7,6 +7,7 @@
 #include "gettext.h"
 #include "object-name.h"
 #include "quote.h"
+#include "repository.h"
 #include "setup.h"
 #include "parse-options.h"
 #include "write-or-die.h"
diff --git a/builtin/check-ignore.c b/builtin/check-ignore.c
index 9401dad0070..e4b78782a32 100644
--- a/builtin/check-ignore.c
+++ b/builtin/check-ignore.c
@@ -7,6 +7,7 @@
 #include "quote.h"
 #include "pathspec.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "submodule.h"
 #include "write-or-die.h"
 
diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c
index 7df673e3e70..9375a05539f 100644
--- a/builtin/checkout-index.c
+++ b/builtin/checkout-index.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "lockfile.h"
 #include "quote.h"
+#include "repository.h"
 #include "cache-tree.h"
 #include "parse-options.h"
 #include "entry.h"
diff --git a/builtin/clean.c b/builtin/clean.c
index 14c0d555eac..78852d28cec 100644
--- a/builtin/clean.c
+++ b/builtin/clean.c
@@ -14,6 +14,7 @@
 #include "dir.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "setup.h"
 #include "string-list.h"
 #include "quote.h"
diff --git a/builtin/config.c b/builtin/config.c
index 9401f1e5e3b..ff2fe8ef125 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -9,6 +9,7 @@
 #include "ident.h"
 #include "parse-options.h"
 #include "urlmatch.h"
+#include "path.h"
 #include "quote.h"
 #include "setup.h"
 #include "worktree.h"
diff --git a/builtin/credential-cache.c b/builtin/credential-cache.c
index 508da4c6e4d..0ffacfdd83c 100644
--- a/builtin/credential-cache.c
+++ b/builtin/credential-cache.c
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "path.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/builtin/credential-store.c b/builtin/credential-store.c
index 8977604eb9d..30c6ccf56c0 100644
--- a/builtin/credential-store.c
+++ b/builtin/credential-store.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "lockfile.h"
 #include "credential.h"
+#include "path.h"
 #include "string-list.h"
 #include "parse-options.h"
 #include "write-or-die.h"
diff --git a/builtin/for-each-repo.c b/builtin/for-each-repo.c
index 27425c2fc9e..c28b0b3543a 100644
--- a/builtin/for-each-repo.c
+++ b/builtin/for-each-repo.c
@@ -3,6 +3,8 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "path.h"
+#include "repository.h"
 #include "run-command.h"
 #include "string-list.h"
 
diff --git a/builtin/help.c b/builtin/help.c
index 128aa83099a..d3cf4af3f6e 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -8,6 +8,7 @@
 #include "gettext.h"
 #include "pager.h"
 #include "parse-options.h"
+#include "path.h"
 #include "run-command.h"
 #include "config-list.h"
 #include "help.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index cda6ee75eb5..aef40361052 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -14,6 +14,7 @@
 #include "exec-cmd.h"
 #include "object-file.h"
 #include "parse-options.h"
+#include "path.h"
 #include "setup.h"
 #include "worktree.h"
 #include "wrapper.h"
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index c875f5d37ee..f044382ed8f 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -1,6 +1,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "hex.h"
+#include "repository.h"
 #include "run-command.h"
 
 static const char *pgm;
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index fa1035405c3..90da9d07744 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -3,9 +3,11 @@
 #include "advice.h"
 #include "commit.h"
 #include "gettext.h"
+#include "hash.h"
 #include "tag.h"
 #include "merge-recursive.h"
 #include "object-name.h"
+#include "repository.h"
 #include "xdiff-interface.h"
 
 static const char builtin_merge_recursive_usage[] =
diff --git a/builtin/mv.c b/builtin/mv.c
index 32935af48e6..665bd274485 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -18,6 +18,7 @@
 #include "cache-tree.h"
 #include "string-list.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "setup.h"
 #include "submodule.h"
 #include "entry.h"
diff --git a/builtin/push.c b/builtin/push.c
index 7d2b0505aac..4e5780dd50d 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -15,6 +15,7 @@
 #include "transport.h"
 #include "parse-options.h"
 #include "pkt-line.h"
+#include "repository.h"
 #include "submodule.h"
 #include "submodule-config.h"
 #include "send-pack.h"
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index d61cbad96de..440f19b1b87 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "builtin.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "resolve-undo.h"
 #include "setup.h"
 #include "submodule.h"
diff --git a/builtin/rerere.c b/builtin/rerere.c
index d4a03707b1a..d4bd52797f4 100644
--- a/builtin/rerere.c
+++ b/builtin/rerere.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "gettext.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "string-list.h"
 #include "rerere.h"
 #include "wrapper.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index d36072252e7..b4589c824c0 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -12,9 +12,11 @@
 #include "dir.h"
 #include "cache-tree.h"
 #include "gettext.h"
+#include "hash.h"
 #include "tree-walk.h"
 #include "object-name.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "string-list.h"
 #include "setup.h"
 #include "submodule.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 20030b75e39..7ef4a642c17 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "hash.h"
 #include "hex.h"
 #include "pretty.h"
 #include "refs.h"
@@ -10,6 +11,7 @@
 #include "strvec.h"
 #include "object-name.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "dir.h"
 #include "commit-slab.h"
 #include "date.h"
diff --git a/builtin/show-index.c b/builtin/show-index.c
index d4bbbbcd6ce..d839e55335d 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -1,9 +1,11 @@
 #include "builtin.h"
 #include "cache.h"
 #include "gettext.h"
+#include "hash.h"
 #include "hex.h"
 #include "pack.h"
 #include "parse-options.h"
+#include "repository.h"
 
 static const char *const show_index_usage[] = {
 	"git show-index [--object-format=<hash-algorithm>]",
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 58bbc80db77..5fab9ad2ec4 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "hash.h"
 #include "hex.h"
 #include "lockfile.h"
 #include "quote.h"
@@ -21,6 +22,7 @@
 #include "parse-options.h"
 #include "pathspec.h"
 #include "dir.h"
+#include "repository.h"
 #include "setup.h"
 #include "split-index.h"
 #include "symlinks.h"
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 6ca85420c3b..0c59b1c9eff 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -1,11 +1,13 @@
 #include "cache.h"
 #include "config.h"
 #include "gettext.h"
+#include "hash.h"
 #include "refs.h"
 #include "builtin.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
+#include "repository.h"
 #include "strvec.h"
 
 static const char * const git_update_ref_usage[] = {
diff --git a/builtin/upload-archive.c b/builtin/upload-archive.c
index 945ee2b4126..5be97ca1af5 100644
--- a/builtin/upload-archive.c
+++ b/builtin/upload-archive.c
@@ -6,6 +6,7 @@
 #include "archive.h"
 #include "pkt-line.h"
 #include "sideband.h"
+#include "repository.h"
 #include "run-command.h"
 #include "strvec.h"
 
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 0b411e9deee..5d3ca819e76 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -14,6 +14,7 @@
 #include "strvec.h"
 #include "branch.h"
 #include "refs.h"
+#include "repository.h"
 #include "run-command.h"
 #include "hook.h"
 #include "sigchain.h"
diff --git a/checkout.c b/checkout.c
index 04238b27133..4256e71a7c4 100644
--- a/checkout.c
+++ b/checkout.c
@@ -2,6 +2,7 @@
 #include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
+#include "repository.h"
 #include "checkout.h"
 #include "config.h"
 #include "strbuf.h"
diff --git a/checkout.h b/checkout.h
index 1917f3b3230..3c514a5ab4f 100644
--- a/checkout.h
+++ b/checkout.h
@@ -1,7 +1,7 @@
 #ifndef CHECKOUT_H
 #define CHECKOUT_H
 
-#include "hash.h"
+#include "hash-ll.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 60a73c1b140..e7d613c907e 100644
--- a/chunk-format.c
+++ b/chunk-format.c
@@ -3,6 +3,7 @@
 #include "chunk-format.h"
 #include "csum-file.h"
 #include "gettext.h"
+#include "hash.h"
 #include "trace2.h"
 
 /*
diff --git a/chunk-format.h b/chunk-format.h
index 025c38f938e..c7794e84add 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 "hash-ll.h"
 
 struct hashfile;
 struct chunkfile;
diff --git a/common-main.c b/common-main.c
index 601a875e2fb..8ab50fa37a4 100644
--- a/common-main.c
+++ b/common-main.c
@@ -2,6 +2,7 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "attr.h"
+#include "repository.h"
 #include "setup.h"
 #include "strbuf.h"
 #include "trace2.h"
diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
index eb25123fa12..e62f093cc19 100644
--- a/compat/fsmonitor/fsm-ipc-darwin.c
+++ b/compat/fsmonitor/fsm-ipc-darwin.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "config.h"
 #include "hex.h"
+#include "repository.h"
 #include "strbuf.h"
 #include "fsmonitor.h"
 #include "fsmonitor-ipc.h"
diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c
index c9536dfb666..8928fa93ce2 100644
--- a/compat/fsmonitor/fsm-ipc-win32.c
+++ b/compat/fsmonitor/fsm-ipc-win32.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "fsmonitor-ipc.h"
+#include "path.h"
 
 const char *fsmonitor_ipc__get_path(struct repository *r) {
 	static char *ret;
diff --git a/compat/precompose_utf8.c b/compat/precompose_utf8.c
index 8a9881db077..a4d11376ba5 100644
--- a/compat/precompose_utf8.c
+++ b/compat/precompose_utf8.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "path.h"
 #include "utf8.h"
 #include "precompose_utf8.h"
 
diff --git a/compat/win32/trace2_win32_process_info.c b/compat/win32/trace2_win32_process_info.c
index e3e895c78a2..a4e33768f43 100644
--- a/compat/win32/trace2_win32_process_info.c
+++ b/compat/win32/trace2_win32_process_info.c
@@ -1,5 +1,6 @@
 #include "../../cache.h"
 #include "../../json-writer.h"
+#include "../../repository.h"
 #include "../../trace2.h"
 #include "lazyload.h"
 #include <Psapi.h>
diff --git a/convert.h b/convert.h
index 0a6e4086b8f..d925589444b 100644
--- a/convert.h
+++ b/convert.h
@@ -4,7 +4,7 @@
 #ifndef CONVERT_H
 #define CONVERT_H
 
-#include "hash.h"
+#include "hash-ll.h"
 #include "string-list.h"
 
 struct index_state;
diff --git a/copy.c b/copy.c
index db6b615c188..923d8a6dc61 100644
--- a/copy.c
+++ b/copy.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "copy.h"
+#include "path.h"
 #include "wrapper.h"
 
 int copy_fd(int ifd, int ofd)
diff --git a/csum-file.c b/csum-file.c
index 82ae2973d30..daf9b06dfff 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -10,6 +10,7 @@
 #include "git-compat-util.h"
 #include "progress.h"
 #include "csum-file.h"
+#include "hash.h"
 #include "wrapper.h"
 
 static void verify_buffer_or_die(struct hashfile *f,
diff --git a/csum-file.h b/csum-file.h
index 566e05cbd25..bc5bec27acb 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 "hash-ll.h"
 #include "write-or-die.h"
 
 struct progress;
diff --git a/daemon.c b/daemon.c
index 75c3c064574..f89f99d7ef4 100644
--- a/daemon.c
+++ b/daemon.c
@@ -3,6 +3,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
+#include "path.h"
 #include "pkt-line.h"
 #include "protocol.h"
 #include "run-command.h"
diff --git a/diffcore.h b/diffcore.h
index 1701ed50b9c..5ffe4ec788f 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -4,7 +4,7 @@
 #ifndef DIFFCORE_H
 #define DIFFCORE_H
 
-#include "hash.h"
+#include "hash-ll.h"
 
 struct diff_options;
 struct mem_pool;
diff --git a/editor.c b/editor.c
index b34e10606d2..38c5dbbb79b 100644
--- a/editor.c
+++ b/editor.c
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "pager.h"
+#include "path.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "run-command.h"
diff --git a/exec-cmd.c b/exec-cmd.c
index 6f618463896..1e34e48c0e4 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
+#include "path.h"
 #include "quote.h"
 #include "strvec.h"
 #include "trace.h"
diff --git a/fsmonitor-ipc.c b/fsmonitor-ipc.c
index 866828e2992..6a6a89764a6 100644
--- a/fsmonitor-ipc.c
+++ b/fsmonitor-ipc.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "fsmonitor-ipc.h"
+#include "repository.h"
 #include "run-command.h"
 #include "strbuf.h"
 #include "trace2.h"
diff --git a/gpg-interface.c b/gpg-interface.c
index aceeb083367..8615dcd4b4b 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -7,6 +7,7 @@
 #include "dir.h"
 #include "ident.h"
 #include "gpg-interface.h"
+#include "path.h"
 #include "sigchain.h"
 #include "tempfile.h"
 #include "alias.h"
diff --git a/hash-ll.h b/hash-ll.h
new file mode 100644
index 00000000000..80509251370
--- /dev/null
+++ b/hash-ll.h
@@ -0,0 +1,276 @@
+#ifndef HASH_LL_H
+#define HASH_LL_H
+
+#if defined(SHA1_APPLE)
+#include <CommonCrypto/CommonDigest.h>
+#elif defined(SHA1_OPENSSL)
+#include <openssl/sha.h>
+#elif defined(SHA1_DC)
+#include "sha1dc_git.h"
+#else /* SHA1_BLK */
+#include "block-sha1/sha1.h"
+#endif
+
+#if defined(SHA256_NETTLE)
+#include "sha256/nettle.h"
+#elif defined(SHA256_GCRYPT)
+#define SHA256_NEEDS_CLONE_HELPER
+#include "sha256/gcrypt.h"
+#elif defined(SHA256_OPENSSL)
+#include <openssl/sha.h>
+#else
+#include "sha256/block/sha256.h"
+#endif
+
+#ifndef platform_SHA_CTX
+/*
+ * platform's underlying implementation of SHA-1; could be OpenSSL,
+ * blk_SHA, Apple CommonCrypto, etc...  Note that the relevant
+ * SHA-1 header may have already defined platform_SHA_CTX for our
+ * own implementations like block-sha1, so we list
+ * the default for OpenSSL compatible SHA-1 implementations here.
+ */
+#define platform_SHA_CTX	SHA_CTX
+#define platform_SHA1_Init	SHA1_Init
+#define platform_SHA1_Update	SHA1_Update
+#define platform_SHA1_Final    	SHA1_Final
+#endif
+
+#define git_SHA_CTX		platform_SHA_CTX
+#define git_SHA1_Init		platform_SHA1_Init
+#define git_SHA1_Update		platform_SHA1_Update
+#define git_SHA1_Final		platform_SHA1_Final
+
+#ifndef platform_SHA256_CTX
+#define platform_SHA256_CTX	SHA256_CTX
+#define platform_SHA256_Init	SHA256_Init
+#define platform_SHA256_Update	SHA256_Update
+#define platform_SHA256_Final	SHA256_Final
+#endif
+
+#define git_SHA256_CTX		platform_SHA256_CTX
+#define git_SHA256_Init		platform_SHA256_Init
+#define git_SHA256_Update	platform_SHA256_Update
+#define git_SHA256_Final	platform_SHA256_Final
+
+#ifdef platform_SHA256_Clone
+#define git_SHA256_Clone	platform_SHA256_Clone
+#endif
+
+#ifdef SHA1_MAX_BLOCK_SIZE
+#include "compat/sha1-chunked.h"
+#undef git_SHA1_Update
+#define git_SHA1_Update		git_SHA1_Update_Chunked
+#endif
+
+static inline void git_SHA1_Clone(git_SHA_CTX *dst, const git_SHA_CTX *src)
+{
+	memcpy(dst, src, sizeof(*dst));
+}
+
+#ifndef SHA256_NEEDS_CLONE_HELPER
+static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *src)
+{
+	memcpy(dst, src, sizeof(*dst));
+}
+#endif
+
+/*
+ * Note that these constants are suitable for indexing the hash_algos array and
+ * comparing against each other, but are otherwise arbitrary, so they should not
+ * be exposed to the user or serialized to disk.  To know whether a
+ * git_hash_algo struct points to some usable hash function, test the format_id
+ * field for being non-zero.  Use the name field for user-visible situations and
+ * the format_id field for fixed-length fields on disk.
+ */
+/* An unknown hash function. */
+#define GIT_HASH_UNKNOWN 0
+/* SHA-1 */
+#define GIT_HASH_SHA1 1
+/* SHA-256  */
+#define GIT_HASH_SHA256 2
+/* Number of algorithms supported (including unknown). */
+#define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
+
+/* "sha1", big-endian */
+#define GIT_SHA1_FORMAT_ID 0x73686131
+
+/* The length in bytes and in hex digits of an object name (SHA-1 value). */
+#define GIT_SHA1_RAWSZ 20
+#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
+/* The block size of SHA-1. */
+#define GIT_SHA1_BLKSZ 64
+
+/* "s256", big-endian */
+#define GIT_SHA256_FORMAT_ID 0x73323536
+
+/* The length in bytes and in hex digits of an object name (SHA-256 value). */
+#define GIT_SHA256_RAWSZ 32
+#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
+/* The block size of SHA-256. */
+#define GIT_SHA256_BLKSZ 64
+
+/* The length in byte and in hex digits of the largest possible hash value. */
+#define GIT_MAX_RAWSZ GIT_SHA256_RAWSZ
+#define GIT_MAX_HEXSZ GIT_SHA256_HEXSZ
+/* The largest possible block size for any supported hash. */
+#define GIT_MAX_BLKSZ GIT_SHA256_BLKSZ
+
+struct object_id {
+	unsigned char hash[GIT_MAX_RAWSZ];
+	int algo;	/* XXX requires 4-byte alignment */
+};
+
+#define GET_OID_QUIETLY           01
+#define GET_OID_COMMIT            02
+#define GET_OID_COMMITTISH        04
+#define GET_OID_TREE             010
+#define GET_OID_TREEISH          020
+#define GET_OID_BLOB             040
+#define GET_OID_FOLLOW_SYMLINKS 0100
+#define GET_OID_RECORD_PATH     0200
+#define GET_OID_ONLY_TO_DIE    04000
+#define GET_OID_REQUIRE_PATH  010000
+
+#define GET_OID_DISAMBIGUATORS \
+	(GET_OID_COMMIT | GET_OID_COMMITTISH | \
+	GET_OID_TREE | GET_OID_TREEISH | \
+	GET_OID_BLOB)
+
+enum get_oid_result {
+	FOUND = 0,
+	MISSING_OBJECT = -1, /* The requested object is missing */
+	SHORT_NAME_AMBIGUOUS = -2,
+	/* The following only apply when symlinks are followed */
+	DANGLING_SYMLINK = -4, /*
+				* The initial symlink is there, but
+				* (transitively) points to a missing
+				* in-tree file
+				*/
+	SYMLINK_LOOP = -5,
+	NOT_DIR = -6, /*
+		       * Somewhere along the symlink chain, a path is
+		       * requested which contains a file as a
+		       * non-final element.
+		       */
+};
+
+/* A suitably aligned type for stack allocations of hash contexts. */
+union git_hash_ctx {
+	git_SHA_CTX sha1;
+	git_SHA256_CTX sha256;
+};
+typedef union git_hash_ctx git_hash_ctx;
+
+typedef void (*git_hash_init_fn)(git_hash_ctx *ctx);
+typedef void (*git_hash_clone_fn)(git_hash_ctx *dst, const git_hash_ctx *src);
+typedef void (*git_hash_update_fn)(git_hash_ctx *ctx, const void *in, size_t len);
+typedef void (*git_hash_final_fn)(unsigned char *hash, git_hash_ctx *ctx);
+typedef void (*git_hash_final_oid_fn)(struct object_id *oid, git_hash_ctx *ctx);
+
+struct git_hash_algo {
+	/*
+	 * The name of the algorithm, as appears in the config file and in
+	 * messages.
+	 */
+	const char *name;
+
+	/* A four-byte version identifier, used in pack indices. */
+	uint32_t format_id;
+
+	/* The length of the hash in binary. */
+	size_t rawsz;
+
+	/* The length of the hash in hex characters. */
+	size_t hexsz;
+
+	/* The block size of the hash. */
+	size_t blksz;
+
+	/* The hash initialization function. */
+	git_hash_init_fn init_fn;
+
+	/* The hash context cloning function. */
+	git_hash_clone_fn clone_fn;
+
+	/* The hash update function. */
+	git_hash_update_fn update_fn;
+
+	/* The hash finalization function. */
+	git_hash_final_fn final_fn;
+
+	/* The hash finalization function for object IDs. */
+	git_hash_final_oid_fn final_oid_fn;
+
+	/* The OID of the empty tree. */
+	const struct object_id *empty_tree;
+
+	/* The OID of the empty blob. */
+	const struct object_id *empty_blob;
+
+	/* The all-zeros OID. */
+	const struct object_id *null_oid;
+};
+extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];
+
+/*
+ * Return a GIT_HASH_* constant based on the name.  Returns GIT_HASH_UNKNOWN if
+ * the name doesn't match a known algorithm.
+ */
+int hash_algo_by_name(const char *name);
+/* Identical, except based on the format ID. */
+int hash_algo_by_id(uint32_t format_id);
+/* Identical, except based on the length. */
+int hash_algo_by_length(int len);
+/* Identical, except for a pointer to struct git_hash_algo. */
+static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
+{
+	return p - hash_algos;
+}
+
+const struct object_id *null_oid(void);
+
+static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
+{
+	/*
+	 * Teach the compiler that there are only two possibilities of hash size
+	 * here, so that it can optimize for this case as much as possible.
+	 */
+	if (algop->rawsz == GIT_MAX_RAWSZ)
+		return memcmp(sha1, sha2, GIT_MAX_RAWSZ);
+	return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
+}
+
+static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
+{
+	/*
+	 * We write this here instead of deferring to hashcmp so that the
+	 * compiler can properly inline it and avoid calling memcmp.
+	 */
+	if (algop->rawsz == GIT_MAX_RAWSZ)
+		return !memcmp(sha1, sha2, GIT_MAX_RAWSZ);
+	return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
+}
+
+static inline void oidcpy(struct object_id *dst, const struct object_id *src)
+{
+	memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
+	dst->algo = src->algo;
+}
+
+static inline struct object_id *oiddup(const struct object_id *src)
+{
+	struct object_id *dst = xmalloc(sizeof(struct object_id));
+	oidcpy(dst, src);
+	return dst;
+}
+
+static inline void oid_set_algo(struct object_id *oid, const struct git_hash_algo *algop)
+{
+	oid->algo = hash_algo_by_ptr(algop);
+}
+
+const char *empty_tree_oid_hex(void);
+const char *empty_blob_oid_hex(void);
+
+#endif
diff --git a/hash-lookup.c b/hash-lookup.c
index b98ed5e11e8..bb54dfde9c7 100644
--- a/hash-lookup.c
+++ b/hash-lookup.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "hash.h"
 #include "hash-lookup.h"
 
 static uint32_t take2(const struct object_id *oid, size_t ofs)
diff --git a/hash.h b/hash.h
index d39f73618cb..615ae0691d0 100644
--- a/hash.h
+++ b/hash.h
@@ -1,250 +1,11 @@
 #ifndef HASH_H
 #define HASH_H
 
+#include "hash-ll.h"
 #include "repository.h"
 
-#if defined(SHA1_APPLE)
-#include <CommonCrypto/CommonDigest.h>
-#elif defined(SHA1_OPENSSL)
-#include <openssl/sha.h>
-#elif defined(SHA1_DC)
-#include "sha1dc_git.h"
-#else /* SHA1_BLK */
-#include "block-sha1/sha1.h"
-#endif
-
-#if defined(SHA256_NETTLE)
-#include "sha256/nettle.h"
-#elif defined(SHA256_GCRYPT)
-#define SHA256_NEEDS_CLONE_HELPER
-#include "sha256/gcrypt.h"
-#elif defined(SHA256_OPENSSL)
-#include <openssl/sha.h>
-#else
-#include "sha256/block/sha256.h"
-#endif
-
-#ifndef platform_SHA_CTX
-/*
- * platform's underlying implementation of SHA-1; could be OpenSSL,
- * blk_SHA, Apple CommonCrypto, etc...  Note that the relevant
- * SHA-1 header may have already defined platform_SHA_CTX for our
- * own implementations like block-sha1, so we list
- * the default for OpenSSL compatible SHA-1 implementations here.
- */
-#define platform_SHA_CTX	SHA_CTX
-#define platform_SHA1_Init	SHA1_Init
-#define platform_SHA1_Update	SHA1_Update
-#define platform_SHA1_Final    	SHA1_Final
-#endif
-
-#define git_SHA_CTX		platform_SHA_CTX
-#define git_SHA1_Init		platform_SHA1_Init
-#define git_SHA1_Update		platform_SHA1_Update
-#define git_SHA1_Final		platform_SHA1_Final
-
-#ifndef platform_SHA256_CTX
-#define platform_SHA256_CTX	SHA256_CTX
-#define platform_SHA256_Init	SHA256_Init
-#define platform_SHA256_Update	SHA256_Update
-#define platform_SHA256_Final	SHA256_Final
-#endif
-
-#define git_SHA256_CTX		platform_SHA256_CTX
-#define git_SHA256_Init		platform_SHA256_Init
-#define git_SHA256_Update	platform_SHA256_Update
-#define git_SHA256_Final	platform_SHA256_Final
-
-#ifdef platform_SHA256_Clone
-#define git_SHA256_Clone	platform_SHA256_Clone
-#endif
-
-#ifdef SHA1_MAX_BLOCK_SIZE
-#include "compat/sha1-chunked.h"
-#undef git_SHA1_Update
-#define git_SHA1_Update		git_SHA1_Update_Chunked
-#endif
-
-static inline void git_SHA1_Clone(git_SHA_CTX *dst, const git_SHA_CTX *src)
-{
-	memcpy(dst, src, sizeof(*dst));
-}
-
-#ifndef SHA256_NEEDS_CLONE_HELPER
-static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *src)
-{
-	memcpy(dst, src, sizeof(*dst));
-}
-#endif
-
-/*
- * Note that these constants are suitable for indexing the hash_algos array and
- * comparing against each other, but are otherwise arbitrary, so they should not
- * be exposed to the user or serialized to disk.  To know whether a
- * git_hash_algo struct points to some usable hash function, test the format_id
- * field for being non-zero.  Use the name field for user-visible situations and
- * the format_id field for fixed-length fields on disk.
- */
-/* An unknown hash function. */
-#define GIT_HASH_UNKNOWN 0
-/* SHA-1 */
-#define GIT_HASH_SHA1 1
-/* SHA-256  */
-#define GIT_HASH_SHA256 2
-/* Number of algorithms supported (including unknown). */
-#define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
-
-/* "sha1", big-endian */
-#define GIT_SHA1_FORMAT_ID 0x73686131
-
-/* The length in bytes and in hex digits of an object name (SHA-1 value). */
-#define GIT_SHA1_RAWSZ 20
-#define GIT_SHA1_HEXSZ (2 * GIT_SHA1_RAWSZ)
-/* The block size of SHA-1. */
-#define GIT_SHA1_BLKSZ 64
-
-/* "s256", big-endian */
-#define GIT_SHA256_FORMAT_ID 0x73323536
-
-/* The length in bytes and in hex digits of an object name (SHA-256 value). */
-#define GIT_SHA256_RAWSZ 32
-#define GIT_SHA256_HEXSZ (2 * GIT_SHA256_RAWSZ)
-/* The block size of SHA-256. */
-#define GIT_SHA256_BLKSZ 64
-
-/* The length in byte and in hex digits of the largest possible hash value. */
-#define GIT_MAX_RAWSZ GIT_SHA256_RAWSZ
-#define GIT_MAX_HEXSZ GIT_SHA256_HEXSZ
-/* The largest possible block size for any supported hash. */
-#define GIT_MAX_BLKSZ GIT_SHA256_BLKSZ
-
-struct object_id {
-	unsigned char hash[GIT_MAX_RAWSZ];
-	int algo;	/* XXX requires 4-byte alignment */
-};
-
-#define GET_OID_QUIETLY           01
-#define GET_OID_COMMIT            02
-#define GET_OID_COMMITTISH        04
-#define GET_OID_TREE             010
-#define GET_OID_TREEISH          020
-#define GET_OID_BLOB             040
-#define GET_OID_FOLLOW_SYMLINKS 0100
-#define GET_OID_RECORD_PATH     0200
-#define GET_OID_ONLY_TO_DIE    04000
-#define GET_OID_REQUIRE_PATH  010000
-
-#define GET_OID_DISAMBIGUATORS \
-	(GET_OID_COMMIT | GET_OID_COMMITTISH | \
-	GET_OID_TREE | GET_OID_TREEISH | \
-	GET_OID_BLOB)
-
-enum get_oid_result {
-	FOUND = 0,
-	MISSING_OBJECT = -1, /* The requested object is missing */
-	SHORT_NAME_AMBIGUOUS = -2,
-	/* The following only apply when symlinks are followed */
-	DANGLING_SYMLINK = -4, /*
-				* The initial symlink is there, but
-				* (transitively) points to a missing
-				* in-tree file
-				*/
-	SYMLINK_LOOP = -5,
-	NOT_DIR = -6, /*
-		       * Somewhere along the symlink chain, a path is
-		       * requested which contains a file as a
-		       * non-final element.
-		       */
-};
-
-/* A suitably aligned type for stack allocations of hash contexts. */
-union git_hash_ctx {
-	git_SHA_CTX sha1;
-	git_SHA256_CTX sha256;
-};
-typedef union git_hash_ctx git_hash_ctx;
-
-typedef void (*git_hash_init_fn)(git_hash_ctx *ctx);
-typedef void (*git_hash_clone_fn)(git_hash_ctx *dst, const git_hash_ctx *src);
-typedef void (*git_hash_update_fn)(git_hash_ctx *ctx, const void *in, size_t len);
-typedef void (*git_hash_final_fn)(unsigned char *hash, git_hash_ctx *ctx);
-typedef void (*git_hash_final_oid_fn)(struct object_id *oid, git_hash_ctx *ctx);
-
-struct git_hash_algo {
-	/*
-	 * The name of the algorithm, as appears in the config file and in
-	 * messages.
-	 */
-	const char *name;
-
-	/* A four-byte version identifier, used in pack indices. */
-	uint32_t format_id;
-
-	/* The length of the hash in binary. */
-	size_t rawsz;
-
-	/* The length of the hash in hex characters. */
-	size_t hexsz;
-
-	/* The block size of the hash. */
-	size_t blksz;
-
-	/* The hash initialization function. */
-	git_hash_init_fn init_fn;
-
-	/* The hash context cloning function. */
-	git_hash_clone_fn clone_fn;
-
-	/* The hash update function. */
-	git_hash_update_fn update_fn;
-
-	/* The hash finalization function. */
-	git_hash_final_fn final_fn;
-
-	/* The hash finalization function for object IDs. */
-	git_hash_final_oid_fn final_oid_fn;
-
-	/* The OID of the empty tree. */
-	const struct object_id *empty_tree;
-
-	/* The OID of the empty blob. */
-	const struct object_id *empty_blob;
-
-	/* The all-zeros OID. */
-	const struct object_id *null_oid;
-};
-extern const struct git_hash_algo hash_algos[GIT_HASH_NALGOS];
-
-/*
- * Return a GIT_HASH_* constant based on the name.  Returns GIT_HASH_UNKNOWN if
- * the name doesn't match a known algorithm.
- */
-int hash_algo_by_name(const char *name);
-/* Identical, except based on the format ID. */
-int hash_algo_by_id(uint32_t format_id);
-/* Identical, except based on the length. */
-int hash_algo_by_length(int len);
-/* Identical, except for a pointer to struct git_hash_algo. */
-static inline int hash_algo_by_ptr(const struct git_hash_algo *p)
-{
-	return p - hash_algos;
-}
-
 #define the_hash_algo the_repository->hash_algo
 
-const struct object_id *null_oid(void);
-
-static inline int hashcmp_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
-{
-	/*
-	 * Teach the compiler that there are only two possibilities of hash size
-	 * here, so that it can optimize for this case as much as possible.
-	 */
-	if (algop->rawsz == GIT_MAX_RAWSZ)
-		return memcmp(sha1, sha2, GIT_MAX_RAWSZ);
-	return memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
-}
-
 static inline int hashcmp(const unsigned char *sha1, const unsigned char *sha2)
 {
 	return hashcmp_algop(sha1, sha2, the_hash_algo);
@@ -260,17 +21,6 @@ static inline int oidcmp(const struct object_id *oid1, const struct object_id *o
 	return hashcmp_algop(oid1->hash, oid2->hash, algop);
 }
 
-static inline int hasheq_algop(const unsigned char *sha1, const unsigned char *sha2, const struct git_hash_algo *algop)
-{
-	/*
-	 * We write this here instead of deferring to hashcmp so that the
-	 * compiler can properly inline it and avoid calling memcmp.
-	 */
-	if (algop->rawsz == GIT_MAX_RAWSZ)
-		return !memcmp(sha1, sha2, GIT_MAX_RAWSZ);
-	return !memcmp(sha1, sha2, GIT_SHA1_RAWSZ);
-}
-
 static inline int hasheq(const unsigned char *sha1, const unsigned char *sha2)
 {
 	return hasheq_algop(sha1, sha2, the_hash_algo);
@@ -296,12 +46,6 @@ static inline void hashcpy(unsigned char *sha_dst, const unsigned char *sha_src)
 	memcpy(sha_dst, sha_src, the_hash_algo->rawsz);
 }
 
-static inline void oidcpy(struct object_id *dst, const struct object_id *src)
-{
-	memcpy(dst->hash, src->hash, GIT_MAX_RAWSZ);
-	dst->algo = src->algo;
-}
-
 /* Like oidcpy() but zero-pads the unused bytes in dst's hash array. */
 static inline void oidcpy_with_padding(struct object_id *dst,
 				       const struct object_id *src)
@@ -318,13 +62,6 @@ static inline void oidcpy_with_padding(struct object_id *dst,
 	dst->algo = src->algo;
 }
 
-static inline struct object_id *oiddup(const struct object_id *src)
-{
-	struct object_id *dst = xmalloc(sizeof(struct object_id));
-	oidcpy(dst, src);
-	return dst;
-}
-
 static inline void hashclr(unsigned char *hash)
 {
 	memset(hash, 0, the_hash_algo->rawsz);
@@ -362,12 +99,4 @@ static inline int is_empty_tree_oid(const struct object_id *oid)
 	return oideq(oid, the_hash_algo->empty_tree);
 }
 
-static inline void oid_set_algo(struct object_id *oid, const struct git_hash_algo *algop)
-{
-	oid->algo = hash_algo_by_ptr(algop);
-}
-
-const char *empty_tree_oid_hex(void);
-const char *empty_blob_oid_hex(void);
-
 #endif
diff --git a/hashmap.h b/hashmap.h
index 7251687d730..9234b94477b 100644
--- a/hashmap.h
+++ b/hashmap.h
@@ -1,7 +1,7 @@
 #ifndef HASHMAP_H
 #define HASHMAP_H
 
-#include "hash.h"
+#include "hash-ll.h"
 
 /*
  * Generic implementation of hash-based key-value mappings.
diff --git a/hex.c b/hex.c
index 0a1bddc1284..7bb440e7940 100644
--- a/hex.c
+++ b/hex.c
@@ -1,4 +1,5 @@
 #include "git-compat-util.h"
+#include "hash.h"
 #include "hex.h"
 
 const signed char hexval_table[256] = {
diff --git a/hex.h b/hex.h
index e2abfc56fae..7df4b3c460e 100644
--- a/hex.h
+++ b/hex.h
@@ -1,7 +1,7 @@
 #ifndef HEX_H
 #define HEX_H
 
-#include "hash.h"
+#include "hash-ll.h"
 
 extern const signed char hexval_table[256];
 static inline unsigned int hexval(unsigned char c)
diff --git a/hook.c b/hook.c
index 76e322f5804..3ca5e60895d 100644
--- a/hook.c
+++ b/hook.c
@@ -2,6 +2,7 @@
 #include "advice.h"
 #include "gettext.h"
 #include "hook.h"
+#include "path.h"
 #include "run-command.h"
 #include "config.h"
 #include "strbuf.h"
diff --git a/khash.h b/khash.h
index 85362718c56..56241e6a5c9 100644
--- a/khash.h
+++ b/khash.h
@@ -27,6 +27,7 @@
 #define __AC_KHASH_H
 
 #include "hashmap.h"
+#include "hash.h"
 
 #define AC_VERSION_KHASH_H "0.2.8"
 
diff --git a/ls-refs.c b/ls-refs.c
index b9f3e08ec3d..f385938b64c 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
+#include "hash.h"
 #include "hex.h"
 #include "repository.h"
 #include "refs.h"
diff --git a/merge-ort-wrappers.c b/merge-ort-wrappers.c
index c00dfbab1cd..2c47c5a6237 100644
--- a/merge-ort-wrappers.c
+++ b/merge-ort-wrappers.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "gettext.h"
+#include "hash.h"
 #include "merge-ort.h"
 #include "merge-ort-wrappers.h"
 
diff --git a/merge-ort.h b/merge-ort.h
index a994c9a5fcd..ce56ec1a780 100644
--- a/merge-ort.h
+++ b/merge-ort.h
@@ -2,7 +2,7 @@
 #define MERGE_ORT_H
 
 #include "merge-recursive.h"
-#include "hash.h"
+#include "hash-ll.h"
 
 struct commit;
 struct tree;
diff --git a/negotiator/default.c b/negotiator/default.c
index f4b78eb47dd..5cb2b1d2046 100644
--- a/negotiator/default.c
+++ b/negotiator/default.c
@@ -4,6 +4,7 @@
 #include "../fetch-negotiator.h"
 #include "../prio-queue.h"
 #include "../refs.h"
+#include "../repository.h"
 #include "../tag.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index c7d6ab39bc5..97e7e1ae725 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -5,6 +5,7 @@
 #include "../hex.h"
 #include "../prio-queue.h"
 #include "../refs.h"
+#include "../repository.h"
 #include "../tag.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/object-file.h b/object-file.h
index e0cfc3a5db8..d6414610f80 100644
--- a/object-file.h
+++ b/object-file.h
@@ -4,6 +4,8 @@
 #include "git-zlib.h"
 #include "object.h"
 
+struct index_state;
+
 /*
  * Set this to 0 to prevent oid_object_info_extended() from fetching missing
  * blobs. This has a difference only if extensions.partialClone is set.
diff --git a/object.h b/object.h
index 96e52e24fb1..5871615feea 100644
--- a/object.h
+++ b/object.h
@@ -1,9 +1,10 @@
 #ifndef OBJECT_H
 #define OBJECT_H
 
-#include "hash.h"
+#include "hash-ll.h"
 
 struct buffer_slab;
+struct repository;
 
 struct parsed_object_pool {
 	struct object **obj_hash;
diff --git a/oidmap.c b/oidmap.c
index 8c1a139c974..8b1bc4dec94 100644
--- a/oidmap.c
+++ b/oidmap.c
@@ -1,4 +1,5 @@
 #include "git-compat-util.h"
+#include "hash.h"
 #include "oidmap.h"
 
 static int oidmap_neq(const void *hashmap_cmp_fn_data UNUSED,
diff --git a/oidtree.h b/oidtree.h
index 77898f510a1..55c83513fdd 100644
--- a/oidtree.h
+++ b/oidtree.h
@@ -2,7 +2,7 @@
 #define OIDTREE_H
 
 #include "cbtree.h"
-#include "hash.h"
+#include "hash-ll.h"
 #include "mem-pool.h"
 
 struct oidtree {
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 7f0569cc930..69d569f3525 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -3,6 +3,7 @@
 #include "config.h"
 #include "entry.h"
 #include "gettext.h"
+#include "hash.h"
 #include "hex.h"
 #include "parallel-checkout.h"
 #include "pkt-line.h"
diff --git a/pathspec.c b/pathspec.c
index ec335a214e2..1e57b6c667d 100644
--- a/pathspec.c
+++ b/pathspec.c
@@ -6,6 +6,7 @@
 #include "gettext.h"
 #include "pathspec.h"
 #include "attr.h"
+#include "repository.h"
 #include "setup.h"
 #include "strvec.h"
 #include "symlinks.h"
diff --git a/progress.c b/progress.c
index 72d5e0c73c1..f695798acac 100644
--- a/progress.c
+++ b/progress.c
@@ -12,6 +12,7 @@
 #include "git-compat-util.h"
 #include "pager.h"
 #include "progress.h"
+#include "repository.h"
 #include "strbuf.h"
 #include "trace.h"
 #include "trace2.h"
diff --git a/protocol-caps.c b/protocol-caps.c
index 874bc815b4f..3fe0bc61c3f 100644
--- a/protocol-caps.c
+++ b/protocol-caps.c
@@ -4,7 +4,7 @@
 #include "hex.h"
 #include "pkt-line.h"
 #include "strvec.h"
-#include "hash.h"
+#include "hash-ll.h"
 #include "hex.h"
 #include "object.h"
 #include "object-store.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 789f4073617..852a3313182 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "sequencer.h"
 #include "rebase-interactive.h"
+#include "repository.h"
 #include "strbuf.h"
 #include "commit-slab.h"
 #include "config.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index 1128a9af292..bca7b851c5a 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -3,6 +3,7 @@
 #include "../copy.h"
 #include "../environment.h"
 #include "../gettext.h"
+#include "../hash.h"
 #include "../hex.h"
 #include "../refs.h"
 #include "refs-internal.h"
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 2333ed5a1f7..704424f55c0 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -2,6 +2,7 @@
 #include "../alloc.h"
 #include "../config.h"
 #include "../gettext.h"
+#include "../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 dc1ca49c85f..2294c4564fb 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -1,6 +1,8 @@
 #include "../git-compat-util.h"
 #include "../alloc.h"
+#include "../hash.h"
 #include "../refs.h"
+#include "../repository.h"
 #include "refs-internal.h"
 #include "ref-cache.h"
 #include "../iterator.h"
diff --git a/refs/ref-cache.h b/refs/ref-cache.h
index cf4ad9070b9..95c76e27c83 100644
--- a/refs/ref-cache.h
+++ b/refs/ref-cache.h
@@ -1,10 +1,11 @@
 #ifndef REFS_REF_CACHE_H
 #define REFS_REF_CACHE_H
 
-#include "hash.h"
+#include "hash-ll.h"
 
 struct ref_dir;
 struct ref_store;
+struct repository;
 
 /*
  * If this ref_cache is filled lazily, this function is used to load
diff --git a/refspec.c b/refspec.c
index 7b5c305514d..31b61d782c7 100644
--- a/refspec.c
+++ b/refspec.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "hash.h"
 #include "hex.h"
 #include "strvec.h"
 #include "refs.h"
diff --git a/reftable/dump.c b/reftable/dump.c
index 155953d1b82..ce936b4e188 100644
--- a/reftable/dump.c
+++ b/reftable/dump.c
@@ -7,7 +7,7 @@ https://developers.google.com/open-source/licenses/bsd
 */
 
 #include "git-compat-util.h"
-#include "hash.h"
+#include "hash-ll.h"
 
 #include "reftable-blocksource.h"
 #include "reftable-error.h"
diff --git a/reftable/system.h b/reftable/system.h
index 18f9207dfee..6b74a815143 100644
--- a/reftable/system.h
+++ b/reftable/system.h
@@ -13,7 +13,7 @@ https://developers.google.com/open-source/licenses/bsd
 
 #include "git-compat-util.h"
 #include "strbuf.h"
-#include "hash.h" /* hash ID, sizes.*/
+#include "hash-ll.h" /* hash ID, sizes.*/
 #include "dir.h" /* remove_dir_recursively, for tests.*/
 
 int hash_size(uint32_t id);
diff --git a/reset.h b/reset.h
index a28f81829d8..10708d8ddc0 100644
--- a/reset.h
+++ b/reset.h
@@ -1,7 +1,7 @@
 #ifndef RESET_H
 #define RESET_H
 
-#include "hash.h"
+#include "hash-ll.h"
 #include "repository.h"
 
 #define GIT_REFLOG_ACTION_ENVIRONMENT "GIT_REFLOG_ACTION"
diff --git a/resolve-undo.c b/resolve-undo.c
index e81096e2d45..70a6db526d2 100644
--- a/resolve-undo.c
+++ b/resolve-undo.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "dir.h"
+#include "hash.h"
 #include "resolve-undo.h"
 #include "string-list.h"
 
diff --git a/resolve-undo.h b/resolve-undo.h
index d1ea9727712..c5deafc92fe 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 "hash-ll.h"
 
 struct resolve_undo_info {
 	unsigned int mode[3];
diff --git a/split-index.c b/split-index.c
index 3fc4e91485a..40e54760b35 100644
--- a/split-index.c
+++ b/split-index.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "hash.h"
 #include "mem-pool.h"
 #include "split-index.h"
 #include "strbuf.h"
diff --git a/split-index.h b/split-index.h
index 1a153f47ba3..15a29cd08c9 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 "hash-ll.h"
 
 struct index_state;
 struct strbuf;
diff --git a/strbuf.c b/strbuf.c
index 729378ec824..08eec8f1d8b 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -6,6 +6,7 @@
 #include "hex.h"
 #include "object-name.h"
 #include "refs.h"
+#include "repository.h"
 #include "string-list.h"
 #include "utf8.h"
 #include "date.h"
diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index d2b30d644da..aabe31d724b 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -2,6 +2,7 @@
 #include "bloom.h"
 #include "hex.h"
 #include "commit.h"
+#include "repository.h"
 #include "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 cdaf5046f5a..9507b356e22 100644
--- a/t/helper/test-cache-tree.c
+++ b/t/helper/test-cache-tree.c
@@ -6,6 +6,7 @@
 #include "tree.h"
 #include "cache-tree.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "setup.h"
 
 static char const * const test_cache_tree_usage[] = {
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index 715aabfbae7..4caf13c663b 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -1,9 +1,11 @@
 #define USE_THE_INDEX_VARIABLE
 #include "test-tool.h"
 #include "cache.h"
+#include "hash.h"
 #include "hex.h"
 #include "tree.h"
 #include "cache-tree.h"
+#include "repository.h"
 #include "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 7e9de296db3..6dc49583375 100644
--- a/t/helper/test-dump-fsmonitor.c
+++ b/t/helper/test-dump-fsmonitor.c
@@ -1,5 +1,6 @@
 #include "test-tool.h"
 #include "cache.h"
+#include "repository.h"
 #include "setup.h"
 
 int cmd__dump_fsmonitor(int ac, const char **av)
diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
index 415f55f31da..d1b99d21dcd 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
@@ -3,6 +3,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "hex.h"
+#include "repository.h"
 #include "setup.h"
 
 static int compare_untracked(const void *a_, const void *b_)
diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c
index 7c7fc8efc13..43707486dd4 100644
--- a/t/helper/test-example-decorate.c
+++ b/t/helper/test-example-decorate.c
@@ -2,6 +2,7 @@
 #include "git-compat-util.h"
 #include "object.h"
 #include "decorate.h"
+#include "repository.h"
 
 int cmd__example_decorate(int argc, const char **argv)
 {
diff --git a/t/helper/test-fsmonitor-client.c b/t/helper/test-fsmonitor-client.c
index a37236cd0a6..bb00e1e5d14 100644
--- a/t/helper/test-fsmonitor-client.c
+++ b/t/helper/test-fsmonitor-client.c
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "parse-options.h"
 #include "fsmonitor-ipc.h"
+#include "repository.h"
 #include "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 f23d983c118..b83a75d19f6 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -3,6 +3,7 @@
 #include "cache.h"
 #include "environment.h"
 #include "parse-options.h"
+#include "repository.h"
 #include "setup.h"
 #include "trace.h"
 
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index a498fece7a3..3c62e33ccdf 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "match-trees.h"
 #include "object-name.h"
+#include "repository.h"
 #include "setup.h"
 #include "tree.h"
 
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index de6ab77fdaa..bba4099f65f 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -2,6 +2,7 @@
 #include "hex.h"
 #include "object-name.h"
 #include "oidmap.h"
+#include "repository.h"
 #include "setup.h"
 #include "strbuf.h"
 
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 6355c9e4b6d..2ef53d5f7a2 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -2,6 +2,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "environment.h"
+#include "path.h"
 #include "setup.h"
 #include "string-list.h"
 #include "trace.h"
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index a4c24d0e421..c1ae2763954 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -2,6 +2,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "config.h"
+#include "repository.h"
 #include "setup.h"
 #include "wrapper.h"
 
diff --git a/t/helper/test-scrap-cache-tree.c b/t/helper/test-scrap-cache-tree.c
index 15b7688774c..444a4c02c8d 100644
--- a/t/helper/test-scrap-cache-tree.c
+++ b/t/helper/test-scrap-cache-tree.c
@@ -2,6 +2,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "lockfile.h"
+#include "repository.h"
 #include "setup.h"
 #include "tree.h"
 #include "cache-tree.h"
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index c7c7fdbea98..1bacd35a53e 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,6 +1,8 @@
 #include "test-tool.h"
 #include "config.h"
+#include "hash.h"
 #include "object-name.h"
+#include "repository.h"
 #include "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 d31f5e48ab5..ecd40ded995 100644
--- a/t/helper/test-submodule-nested-repo-config.c
+++ b/t/helper/test-submodule-nested-repo-config.c
@@ -1,4 +1,5 @@
 #include "test-tool.h"
+#include "repository.h"
 #include "setup.h"
 #include "submodule-config.h"
 
diff --git a/t/helper/test-submodule.c b/t/helper/test-submodule.c
index 0e34581b209..cad8b0ca681 100644
--- a/t/helper/test-submodule.c
+++ b/t/helper/test-submodule.c
@@ -2,6 +2,7 @@
 #include "test-tool-utils.h"
 #include "parse-options.h"
 #include "remote.h"
+#include "repository.h"
 #include "setup.h"
 #include "submodule-config.h"
 #include "submodule.h"
diff --git a/t/helper/test-trace2.c b/t/helper/test-trace2.c
index a476df6c6cb..ab084d6034e 100644
--- a/t/helper/test-trace2.c
+++ b/t/helper/test-trace2.c
@@ -3,6 +3,7 @@
 #include "run-command.h"
 #include "exec-cmd.h"
 #include "config.h"
+#include "repository.h"
 #include "trace2.h"
 
 typedef int(fn_unit_test)(int argc, const char **argv);
diff --git a/t/helper/test-write-cache.c b/t/helper/test-write-cache.c
index a93417ed3a9..eace08072d7 100644
--- a/t/helper/test-write-cache.c
+++ b/t/helper/test-write-cache.c
@@ -2,6 +2,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "lockfile.h"
+#include "repository.h"
 #include "setup.h"
 
 int cmd__write_cache(int argc, const char **argv)
diff --git a/trace2.c b/trace2.c
index 21264df71b7..0efc4e7b958 100644
--- a/trace2.c
+++ b/trace2.c
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "json-writer.h"
 #include "quote.h"
+#include "repository.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "thread-utils.h"
diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
index 9e7aab6d510..2af53e5d4de 100644
--- a/trace2/tr2_tgt_event.c
+++ b/trace2/tr2_tgt_event.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "json-writer.h"
+#include "repository.h"
 #include "run-command.h"
 #include "version.h"
 #include "trace2/tr2_dst.h"
diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
index 8672c2c2d04..1ebfb464d54 100644
--- a/trace2/tr2_tgt_normal.c
+++ b/trace2/tr2_tgt_normal.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "config.h"
+#include "repository.h"
 #include "run-command.h"
 #include "quote.h"
 #include "version.h"
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
index 3f2b2d53118..328e483a05e 100644
--- a/trace2/tr2_tgt_perf.c
+++ b/trace2/tr2_tgt_perf.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "config.h"
+#include "repository.h"
 #include "run-command.h"
 #include "quote.h"
 #include "version.h"
diff --git a/tree-walk.h b/tree-walk.h
index 25fe27e3529..01a9d8eb442 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -1,9 +1,10 @@
 #ifndef TREE_WALK_H
 #define TREE_WALK_H
 
-#include "hash.h"
+#include "hash-ll.h"
 
 struct index_state;
+struct repository;
 
 #define MAX_TRAVERSE_TREES 8
 
diff --git a/tree.h b/tree.h
index 6efff003e21..0499ad01aa7 100644
--- a/tree.h
+++ b/tree.h
@@ -3,6 +3,7 @@
 
 #include "object.h"
 
+struct pathspec;
 struct repository;
 struct strbuf;
 
diff --git a/wrapper.c b/wrapper.c
index e80f83498d8..5ab0460de5c 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "repository.h"
 #include "strbuf.h"
 #include "trace2.h"
 #include "wrapper.h"
diff --git a/xdiff-interface.h b/xdiff-interface.h
index 3750794afe9..733c364d26c 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 "hash-ll.h"
 #include "xdiff/xdiff.h"
 
 /*
-- 
gitgitgadget


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

* [PATCH v2 14/22] cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (12 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 15/22] cache,tree: move basic name compare functions from read-cache to tree Elijah Newren via GitGitGadget
                     ` (10 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Since cmp_cache_name_compare() was comparing cache_entry structs, it
was associated with the cache rather than with trees.  Move the
function.  As a side effect, we can make cache_name_stage_compare()
static as well.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h      |  2 +-
 read-cache.c | 13 ++++++++++++-
 tree.c       | 10 ----------
 tree.h       |  1 -
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/cache.h b/cache.h
index 7a46f300d9b..502e4c0b11a 100644
--- a/cache.h
+++ b/cache.h
@@ -562,7 +562,7 @@ int base_name_compare(const char *name1, size_t len1, int mode1,
 int df_name_compare(const char *name1, size_t len1, int mode1,
 		    const char *name2, size_t len2, int mode2);
 int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2);
+int cmp_cache_name_compare(const void *a_, const void *b_);
 
 /* add */
 /*
diff --git a/read-cache.c b/read-cache.c
index 206c003e558..8f00da4bf7a 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -567,7 +567,8 @@ int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)
 	return 0;
 }
 
-int cache_name_stage_compare(const char *name1, int len1, int stage1, const char *name2, int len2, int stage2)
+static int cache_name_stage_compare(const char *name1, int len1, int stage1,
+				    const char *name2, int len2, int stage2)
 {
 	int cmp;
 
@@ -582,6 +583,16 @@ int cache_name_stage_compare(const char *name1, int len1, int stage1, const char
 	return 0;
 }
 
+int cmp_cache_name_compare(const void *a_, const void *b_)
+{
+	const struct cache_entry *ce1, *ce2;
+
+	ce1 = *((const struct cache_entry **)a_);
+	ce2 = *((const struct cache_entry **)b_);
+	return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
+				  ce2->name, ce2->ce_namelen, ce_stage(ce2));
+}
+
 static int index_name_stage_pos(struct index_state *istate,
 				const char *name, int namelen,
 				int stage,
diff --git a/tree.c b/tree.c
index e9d51ce2e00..896b7f4776b 100644
--- a/tree.c
+++ b/tree.c
@@ -94,16 +94,6 @@ int read_tree(struct repository *r,
 	return ret;
 }
 
-int cmp_cache_name_compare(const void *a_, const void *b_)
-{
-	const struct cache_entry *ce1, *ce2;
-
-	ce1 = *((const struct cache_entry **)a_);
-	ce2 = *((const struct cache_entry **)b_);
-	return cache_name_stage_compare(ce1->name, ce1->ce_namelen, ce_stage(ce1),
-				  ce2->name, ce2->ce_namelen, ce_stage(ce2));
-}
-
 struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
 {
 	struct object *obj = lookup_object(r, oid);
diff --git a/tree.h b/tree.h
index 0499ad01aa7..8e3c6d441cc 100644
--- a/tree.h
+++ b/tree.h
@@ -29,7 +29,6 @@ void free_tree_buffer(struct tree *tree);
 /* Parses and returns the tree in the given ent, chasing tags and commits. */
 struct tree *parse_tree_indirect(const struct object_id *oid);
 
-int cmp_cache_name_compare(const void *a_, const void *b_);
 
 #define READ_TREE_RECURSIVE 1
 typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);
-- 
gitgitgadget


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

* [PATCH v2 15/22] cache,tree: move basic name compare functions from read-cache to tree
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (13 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 14/22] cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 16/22] treewide: remove cache.h inclusion due to previous changes Elijah Newren via GitGitGadget
                     ` (9 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

None of base_name_compare(), df_name_compare(), or name_compare()
depended upon a cache_entry or index_state in any way.  By moving these
functions to tree.h, half a dozen other files can stop depending upon
cache.h (though that change will be made in a later commit).

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h      |  5 ----
 read-cache.c | 68 ----------------------------------------------------
 tree.c       | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 tree.h       |  9 +++++++
 4 files changed, 77 insertions(+), 73 deletions(-)

diff --git a/cache.h b/cache.h
index 502e4c0b11a..591c67b0595 100644
--- a/cache.h
+++ b/cache.h
@@ -557,11 +557,6 @@ extern int verify_ce_order;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-int base_name_compare(const char *name1, size_t len1, int mode1,
-		      const char *name2, size_t len2, int mode2);
-int df_name_compare(const char *name1, size_t len1, int mode1,
-		    const char *name2, size_t len2, int mode2);
-int name_compare(const char *name1, size_t len1, const char *name2, size_t len2);
 int cmp_cache_name_compare(const void *a_, const void *b_);
 
 /* add */
diff --git a/read-cache.c b/read-cache.c
index 8f00da4bf7a..b3e2917ddc9 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -499,74 +499,6 @@ int ie_modified(struct index_state *istate,
 	return 0;
 }
 
-int base_name_compare(const char *name1, size_t len1, int mode1,
-		      const char *name2, size_t len2, int mode2)
-{
-	unsigned char c1, c2;
-	size_t len = len1 < len2 ? len1 : len2;
-	int cmp;
-
-	cmp = memcmp(name1, name2, len);
-	if (cmp)
-		return cmp;
-	c1 = name1[len];
-	c2 = name2[len];
-	if (!c1 && S_ISDIR(mode1))
-		c1 = '/';
-	if (!c2 && S_ISDIR(mode2))
-		c2 = '/';
-	return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
-}
-
-/*
- * df_name_compare() is identical to base_name_compare(), except it
- * compares conflicting directory/file entries as equal. Note that
- * while a directory name compares as equal to a regular file, they
- * then individually compare _differently_ to a filename that has
- * a dot after the basename (because '\0' < '.' < '/').
- *
- * This is used by routines that want to traverse the git namespace
- * but then handle conflicting entries together when possible.
- */
-int df_name_compare(const char *name1, size_t len1, int mode1,
-		    const char *name2, size_t len2, int mode2)
-{
-	unsigned char c1, c2;
-	size_t len = len1 < len2 ? len1 : len2;
-	int cmp;
-
-	cmp = memcmp(name1, name2, len);
-	if (cmp)
-		return cmp;
-	/* Directories and files compare equal (same length, same name) */
-	if (len1 == len2)
-		return 0;
-	c1 = name1[len];
-	if (!c1 && S_ISDIR(mode1))
-		c1 = '/';
-	c2 = name2[len];
-	if (!c2 && S_ISDIR(mode2))
-		c2 = '/';
-	if (c1 == '/' && !c2)
-		return 0;
-	if (c2 == '/' && !c1)
-		return 0;
-	return c1 - c2;
-}
-
-int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)
-{
-	size_t min_len = (len1 < len2) ? len1 : len2;
-	int cmp = memcmp(name1, name2, min_len);
-	if (cmp)
-		return cmp;
-	if (len1 < len2)
-		return -1;
-	if (len1 > len2)
-		return 1;
-	return 0;
-}
-
 static int cache_name_stage_compare(const char *name1, int len1, int stage1,
 				    const char *name2, int len2, int stage2)
 {
diff --git a/tree.c b/tree.c
index 896b7f4776b..f242a7ab691 100644
--- a/tree.c
+++ b/tree.c
@@ -94,6 +94,74 @@ int read_tree(struct repository *r,
 	return ret;
 }
 
+int base_name_compare(const char *name1, size_t len1, int mode1,
+		      const char *name2, size_t len2, int mode2)
+{
+	unsigned char c1, c2;
+	size_t len = len1 < len2 ? len1 : len2;
+	int cmp;
+
+	cmp = memcmp(name1, name2, len);
+	if (cmp)
+		return cmp;
+	c1 = name1[len];
+	c2 = name2[len];
+	if (!c1 && S_ISDIR(mode1))
+		c1 = '/';
+	if (!c2 && S_ISDIR(mode2))
+		c2 = '/';
+	return (c1 < c2) ? -1 : (c1 > c2) ? 1 : 0;
+}
+
+/*
+ * df_name_compare() is identical to base_name_compare(), except it
+ * compares conflicting directory/file entries as equal. Note that
+ * while a directory name compares as equal to a regular file, they
+ * then individually compare _differently_ to a filename that has
+ * a dot after the basename (because '\0' < '.' < '/').
+ *
+ * This is used by routines that want to traverse the git namespace
+ * but then handle conflicting entries together when possible.
+ */
+int df_name_compare(const char *name1, size_t len1, int mode1,
+		    const char *name2, size_t len2, int mode2)
+{
+	unsigned char c1, c2;
+	size_t len = len1 < len2 ? len1 : len2;
+	int cmp;
+
+	cmp = memcmp(name1, name2, len);
+	if (cmp)
+		return cmp;
+	/* Directories and files compare equal (same length, same name) */
+	if (len1 == len2)
+		return 0;
+	c1 = name1[len];
+	if (!c1 && S_ISDIR(mode1))
+		c1 = '/';
+	c2 = name2[len];
+	if (!c2 && S_ISDIR(mode2))
+		c2 = '/';
+	if (c1 == '/' && !c2)
+		return 0;
+	if (c2 == '/' && !c1)
+		return 0;
+	return c1 - c2;
+}
+
+int name_compare(const char *name1, size_t len1, const char *name2, size_t len2)
+{
+	size_t min_len = (len1 < len2) ? len1 : len2;
+	int cmp = memcmp(name1, name2, min_len);
+	if (cmp)
+		return cmp;
+	if (len1 < len2)
+		return -1;
+	if (len1 > len2)
+		return 1;
+	return 0;
+}
+
 struct tree *lookup_tree(struct repository *r, const struct object_id *oid)
 {
 	struct object *obj = lookup_object(r, oid);
diff --git a/tree.h b/tree.h
index 8e3c6d441cc..1b5ecbda6b3 100644
--- a/tree.h
+++ b/tree.h
@@ -29,6 +29,15 @@ void free_tree_buffer(struct tree *tree);
 /* Parses and returns the tree in the given ent, chasing tags and commits. */
 struct tree *parse_tree_indirect(const struct object_id *oid);
 
+/*
+ * Functions for comparing pathnames
+ */
+int base_name_compare(const char *name1, size_t len1, int mode1,
+		      const char *name2, size_t len2, int mode2);
+int df_name_compare(const char *name1, size_t len1, int mode1,
+		    const char *name2, size_t len2, int mode2);
+int name_compare(const char *name1, size_t len1,
+		 const char *name2, size_t len2);
 
 #define READ_TREE_RECURSIVE 1
 typedef int (*read_tree_fn_t)(const struct object_id *, struct strbuf *, const char *, unsigned int, void *);
-- 
gitgitgadget


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

* [PATCH v2 16/22] treewide: remove cache.h inclusion due to previous changes
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (14 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 15/22] cache,tree: move basic name compare functions from read-cache to tree Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-05-01 16:44     ` Ævar Arnfjörð Bjarmason
  2023-04-22 20:17   ` [PATCH v2 17/22] cache.h: remove unnecessary headers Elijah Newren via GitGitGadget
                     ` (8 subsequent siblings)
  24 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 archive-zip.c                 | 2 +-
 bundle-uri.c                  | 2 +-
 color.c                       | 2 +-
 combine-diff.c                | 2 +-
 common-main.c                 | 2 +-
 config.c                      | 2 +-
 copy.c                        | 2 +-
 credential.c                  | 2 +-
 daemon.c                      | 2 +-
 date.c                        | 2 +-
 diagnose.c                    | 2 +-
 environment.c                 | 2 +-
 ll-merge.c                    | 2 +-
 match-trees.c                 | 2 +-
 midx.c                        | 2 +-
 object-file.c                 | 2 +-
 packfile.c                    | 2 +-
 pkt-line.c                    | 2 +-
 range-diff.c                  | 2 +-
 ref-filter.c                  | 2 +-
 t/helper/test-match-trees.c   | 1 -
 t/helper/test-mergesort.c     | 1 -
 t/helper/test-oid-array.c     | 1 -
 t/helper/test-oidtree.c       | 1 -
 t/helper/test-parse-options.c | 1 -
 t/helper/test-read-midx.c     | 1 -
 t/helper/test-string-list.c   | 1 -
 tree-diff.c                   | 2 +-
 tree-walk.c                   | 2 +-
 tree.c                        | 2 +-
 wrapper.c                     | 3 ++-
 31 files changed, 25 insertions(+), 31 deletions(-)

diff --git a/archive-zip.c b/archive-zip.c
index ef538a90df4..d0d065a312e 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2006 Rene Scharfe
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "archive.h"
 #include "gettext.h"
diff --git a/bundle-uri.c b/bundle-uri.c
index 6d44662ee1f..ec1552bbca2 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "bundle-uri.h"
 #include "bundle.h"
 #include "copy.h"
diff --git a/color.c b/color.c
index f8a25ca807b..83abb11eda0 100644
--- a/color.c
+++ b/color.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "color.h"
 #include "editor.h"
diff --git a/combine-diff.c b/combine-diff.c
index f7e9fb57473..f8d61965776 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "object-store.h"
 #include "commit.h"
 #include "convert.h"
diff --git a/common-main.c b/common-main.c
index 8ab50fa37a4..033778b3c56 100644
--- a/common-main.c
+++ b/common-main.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "attr.h"
diff --git a/config.c b/config.c
index 97063a0743e..2a9ed27efe5 100644
--- a/config.c
+++ b/config.c
@@ -5,7 +5,7 @@
  * Copyright (C) Johannes Schindelin, 2005
  *
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
 #include "alloc.h"
diff --git a/copy.c b/copy.c
index 923d8a6dc61..882c79cffb0 100644
--- a/copy.c
+++ b/copy.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "copy.h"
 #include "path.h"
 #include "wrapper.h"
diff --git a/credential.c b/credential.c
index 42194efc9e0..a600d0c1ac1 100644
--- a/credential.c
+++ b/credential.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
 #include "credential.h"
diff --git a/daemon.c b/daemon.c
index f89f99d7ef4..7139cc201d7 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/date.c b/date.c
index bc030da012f..a6ca6b318bd 100644
--- a/date.c
+++ b/date.c
@@ -4,7 +4,7 @@
  * Copyright (C) Linus Torvalds, 2005
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "date.h"
 #include "gettext.h"
 #include "pager.h"
diff --git a/diagnose.c b/diagnose.c
index f9a2496c7ff..58f49f76c7a 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "diagnose.h"
 #include "compat/disk.h"
 #include "archive.h"
diff --git a/environment.c b/environment.c
index 541f0b19acf..28d18eaca8e 100644
--- a/environment.c
+++ b/environment.c
@@ -7,7 +7,7 @@
  * even if you might want to know where the git directory etc
  * are.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "branch.h"
 #include "convert.h"
diff --git a/ll-merge.c b/ll-merge.c
index 85517e668e3..1993530688e 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2007 Junio C Hamano
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "convert.h"
 #include "attr.h"
diff --git a/match-trees.c b/match-trees.c
index 9b78d99507b..6bc8eb76477 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "hex.h"
 #include "match-trees.h"
 #include "tree.h"
diff --git a/midx.c b/midx.c
index 2d0da573281..c7679c3c4f5 100644
--- a/midx.c
+++ b/midx.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/object-file.c b/object-file.c
index 8163ddbaddd..8e0df7360ae 100644
--- a/object-file.c
+++ b/object-file.c
@@ -6,7 +6,7 @@
  * This handles basic git object files - packing, unpacking,
  * creation etc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/packfile.c b/packfile.c
index 9ae2278c22e..1ee9f65242c 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/pkt-line.c b/pkt-line.c
index 8b5fa788517..62b4208b66e 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "copy.h"
 #include "pkt-line.h"
 #include "gettext.h"
diff --git a/range-diff.c b/range-diff.c
index a1e0cffb9f6..6a704e6f471 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
 #include "range-diff.h"
diff --git a/ref-filter.c b/ref-filter.c
index 5387f79be6d..594e66ad361 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 3c62e33ccdf..a0afc1b4bc8 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "match-trees.h"
 #include "object-name.h"
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
index 3aabae6c1c4..42ccc870516 100644
--- a/t/helper/test-mergesort.c
+++ b/t/helper/test-mergesort.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "mem-pool.h"
 #include "mergesort.h"
 #include "strbuf.h"
diff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c
index ea3bf278984..241e5da3157 100644
--- a/t/helper/test-oid-array.c
+++ b/t/helper/test-oid-array.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "oid-array.h"
 #include "setup.h"
diff --git a/t/helper/test-oidtree.c b/t/helper/test-oidtree.c
index 796c9811e0f..dc509fb8065 100644
--- a/t/helper/test-oidtree.c
+++ b/t/helper/test-oidtree.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "oidtree.h"
 #include "setup.h"
diff --git a/t/helper/test-parse-options.c b/t/helper/test-parse-options.c
index 20a81a1eb21..3003987ec17 100644
--- a/t/helper/test-parse-options.c
+++ b/t/helper/test-parse-options.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "parse-options.h"
 #include "strbuf.h"
 #include "string-list.h"
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index b32abff7f11..211addaa005 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "midx.h"
 #include "repository.h"
diff --git a/t/helper/test-string-list.c b/t/helper/test-string-list.c
index 959f27c74c6..042c6ff0059 100644
--- a/t/helper/test-string-list.c
+++ b/t/helper/test-string-list.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "strbuf.h"
 #include "string-list.h"
 
diff --git a/tree-diff.c b/tree-diff.c
index a76e6dae619..9ea2dd7a6c3 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -1,7 +1,7 @@
 /*
  * Helper functions for tree diff generation
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "tree.h"
diff --git a/tree-walk.c b/tree-walk.c
index 2993c48c2f3..d3c48e06df0 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tree-walk.h"
 #include "alloc.h"
 #include "dir.h"
diff --git a/tree.c b/tree.c
index f242a7ab691..0dd2029a8a2 100644
--- a/tree.c
+++ b/tree.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "cache-tree.h"
 #include "hex.h"
 #include "tree.h"
diff --git a/wrapper.c b/wrapper.c
index 5ab0460de5c..67f5f5dbe19 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -1,10 +1,11 @@
 /*
  * Various trivial helper wrappers around standard functions
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "object.h"
 #include "repository.h"
 #include "strbuf.h"
 #include "trace2.h"
-- 
gitgitgadget


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

* [PATCH v2 17/22] cache.h: remove unnecessary headers
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (15 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 16/22] treewide: remove cache.h inclusion due to previous changes Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-05-01 16:49     ` Ævar Arnfjörð Bjarmason
  2023-04-22 20:17   ` [PATCH v2 18/22] fsmonitor: reduce includes of cache.h Elijah Newren via GitGitGadget
                     ` (7 subsequent siblings)
  24 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h                              | 2 --
 compat/fsmonitor/fsm-ipc-darwin.c    | 1 +
 compat/fsmonitor/fsm-listen-darwin.c | 1 +
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/cache.h b/cache.h
index 591c67b0595..bdedb87e83b 100644
--- a/cache.h
+++ b/cache.h
@@ -4,8 +4,6 @@
 #include "git-compat-util.h"
 #include "strbuf.h"
 #include "hashmap.h"
-#include "gettext.h"
-#include "string-list.h"
 #include "pathspec.h"
 #include "object.h"
 #include "statinfo.h"
diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
index e62f093cc19..bc68dca0cae 100644
--- a/compat/fsmonitor/fsm-ipc-darwin.c
+++ b/compat/fsmonitor/fsm-ipc-darwin.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "config.h"
+#include "gettext.h"
 #include "hex.h"
 #include "repository.h"
 #include "strbuf.h"
diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c
index 5eb6402ab82..18c0e3913dc 100644
--- a/compat/fsmonitor/fsm-listen-darwin.c
+++ b/compat/fsmonitor/fsm-listen-darwin.c
@@ -29,6 +29,7 @@
 #include "fsmonitor--daemon.h"
 #include "fsmonitor-path-utils.h"
 #include "gettext.h"
+#include "string-list.h"
 
 struct fsm_listen_data
 {
-- 
gitgitgadget


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

* [PATCH v2 18/22] fsmonitor: reduce includes of cache.h
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (16 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 17/22] cache.h: remove unnecessary headers Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-22 20:17   ` [PATCH v2 19/22] commit.h: reduce unnecessary includes Elijah Newren via GitGitGadget
                     ` (6 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 compat/fsmonitor/fsm-health-darwin.c | 2 +-
 compat/fsmonitor/fsm-ipc-darwin.c    | 2 +-
 compat/fsmonitor/fsm-listen-darwin.c | 2 +-
 fsmonitor--daemon.h                  | 1 -
 4 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/compat/fsmonitor/fsm-health-darwin.c b/compat/fsmonitor/fsm-health-darwin.c
index b9f709e8548..4c291f8a066 100644
--- a/compat/fsmonitor/fsm-health-darwin.c
+++ b/compat/fsmonitor/fsm-health-darwin.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "fsmonitor.h"
 #include "fsm-health.h"
diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
index bc68dca0cae..793073aaa72 100644
--- a/compat/fsmonitor/fsm-ipc-darwin.c
+++ b/compat/fsmonitor/fsm-ipc-darwin.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c
index 18c0e3913dc..23e24b4b374 100644
--- a/compat/fsmonitor/fsm-listen-darwin.c
+++ b/compat/fsmonitor/fsm-listen-darwin.c
@@ -23,7 +23,7 @@
 #endif
 #endif
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "fsmonitor.h"
 #include "fsm-listen.h"
 #include "fsmonitor--daemon.h"
diff --git a/fsmonitor--daemon.h b/fsmonitor--daemon.h
index e24838f9a86..70d776c54f6 100644
--- a/fsmonitor--daemon.h
+++ b/fsmonitor--daemon.h
@@ -3,7 +3,6 @@
 
 #ifdef HAVE_FSMONITOR_DAEMON_BACKEND
 
-#include "cache.h"
 #include "dir.h"
 #include "run-command.h"
 #include "simple-ipc.h"
-- 
gitgitgadget


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

* [PATCH v2 19/22] commit.h: reduce unnecessary includes
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (17 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 18/22] fsmonitor: reduce includes of cache.h Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-05-01 16:52     ` Ævar Arnfjörð Bjarmason
  2023-04-22 20:17   ` [PATCH v2 20/22] object-store.h: " Elijah Newren via GitGitGadget
                     ` (5 subsequent siblings)
  24 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 add-interactive.c    |  1 +
 archive.c            |  2 ++
 bloom.c              |  1 +
 builtin/diff-tree.c  |  1 +
 builtin/diff.c       |  1 +
 builtin/gc.c         |  1 +
 builtin/log.c        |  1 +
 builtin/merge-tree.c |  1 +
 combine-diff.c       |  1 +
 commit-graph.c       |  1 +
 commit.c             |  1 +
 commit.h             | 11 ++++-------
 dir.c                |  1 +
 fetch-pack.c         |  1 +
 fsck.c               |  1 +
 gpg-interface.c      |  1 +
 grep.c               |  1 +
 http-push.c          |  1 +
 log-tree.c           |  1 +
 merge-ort-wrappers.c |  1 +
 merge.c              |  1 +
 notes-cache.c        |  1 +
 notes-utils.c        |  1 +
 object-name.c        |  1 +
 pack-bitmap-write.c  |  1 +
 parse-options-cb.c   |  1 +
 parse-options.c      |  1 +
 read-cache.c         |  1 +
 ref-filter.c         |  1 +
 reflog.c             |  1 +
 refs/debug.c         |  1 +
 refspec.c            |  1 +
 revision.h           |  1 +
 send-pack.c          |  1 +
 wt-status.c          |  1 +
 35 files changed, 39 insertions(+), 7 deletions(-)

diff --git a/add-interactive.c b/add-interactive.c
index 757a9929d41..de877ca0525 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -12,6 +12,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "prompt.h"
+#include "tree.h"
 
 static void init_color(struct repository *r, struct add_i_state *s,
 		       const char *section_and_slot, char *dst,
diff --git a/archive.c b/archive.c
index ab8966d73a5..6226e16b25e 100644
--- a/archive.c
+++ b/archive.c
@@ -6,10 +6,12 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "pretty.h"
 #include "setup.h"
 #include "refs.h"
 #include "object-store.h"
 #include "commit.h"
+#include "tree.h"
 #include "tree-walk.h"
 #include "attr.h"
 #include "archive.h"
diff --git a/bloom.c b/bloom.c
index d0730525da5..aef6b5fea2d 100644
--- a/bloom.c
+++ b/bloom.c
@@ -6,6 +6,7 @@
 #include "hashmap.h"
 #include "commit-graph.h"
 #include "commit.h"
+#include "commit-slab.h"
 
 define_commit_slab(bloom_filter_slab, struct bloom_filter);
 
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 385c2d0230c..0b02c62b85e 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -9,6 +9,7 @@
 #include "builtin.h"
 #include "submodule.h"
 #include "repository.h"
+#include "tree.h"
 
 static struct rev_info log_tree_opt;
 
diff --git a/builtin/diff.c b/builtin/diff.c
index 8f386535d61..457dee14457 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -22,6 +22,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "oid-array.h"
+#include "tree.h"
 
 #define DIFF_NO_INDEX_EXPLICIT 1
 #define DIFF_NO_INDEX_IMPLICIT 2
diff --git a/builtin/gc.c b/builtin/gc.c
index b95154fba16..d11712b1444 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -12,6 +12,7 @@
 
 #include "builtin.h"
 #include "abspath.h"
+#include "date.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/builtin/log.c b/builtin/log.c
index 95de51921f8..137b84b31ef 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -44,6 +44,7 @@
 #include "commit-reach.h"
 #include "range-diff.h"
 #include "tmp-objdir.h"
+#include "tree.h"
 #include "write-or-die.h"
 
 #define MAIL_DEFAULT_WRAP 72
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 6b9f006ec19..aa8040c2a6a 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -16,6 +16,7 @@
 #include "exec-cmd.h"
 #include "merge-blobs.h"
 #include "quote.h"
+#include "tree.h"
 
 static int line_termination = '\n';
 
diff --git a/combine-diff.c b/combine-diff.c
index f8d61965776..1e3cd7fb170 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -13,6 +13,7 @@
 #include "xdiff/xmacros.h"
 #include "log-tree.h"
 #include "refs.h"
+#include "tree.h"
 #include "userdiff.h"
 #include "oid-array.h"
 #include "revision.h"
diff --git a/commit-graph.c b/commit-graph.c
index 0c4f2266445..6f612f368ba 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -23,6 +23,7 @@
 #include "shallow.h"
 #include "json-writer.h"
 #include "trace2.h"
+#include "tree.h"
 #include "chunk-format.h"
 #include "wrapper.h"
 
diff --git a/commit.c b/commit.c
index 878b4473e4c..10676165a1d 100644
--- a/commit.c
+++ b/commit.c
@@ -26,6 +26,7 @@
 #include "run-command.h"
 #include "setup.h"
 #include "shallow.h"
+#include "tree.h"
 #include "hook.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/commit.h
index 69b2f376e9d..28928833c54 100644
--- a/commit.h
+++ b/commit.h
@@ -2,13 +2,10 @@
 #define COMMIT_H
 
 #include "object.h"
-#include "tree.h"
-#include "strbuf.h"
-#include "decorate.h"
-#include "gpg-interface.h"
-#include "string-list.h"
-#include "pretty.h"
-#include "commit-slab.h"
+
+struct signature_check;
+struct strbuf;
+struct tree;
 
 #define COMMIT_NOT_FROM_GRAPH 0xFFFFFFFF
 #define GENERATION_NUMBER_INFINITY ((1ULL << 63) - 1)
diff --git a/dir.c b/dir.c
index ed262fa6e43..a7469df3ac7 100644
--- a/dir.c
+++ b/dir.c
@@ -27,6 +27,7 @@
 #include "submodule-config.h"
 #include "symlinks.h"
 #include "trace2.h"
+#include "tree.h"
 #include "wrapper.h"
 
 /*
diff --git a/fetch-pack.c b/fetch-pack.c
index 677102465a1..a9745bd9faf 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "repository.h"
 #include "config.h"
+#include "date.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/fsck.c b/fsck.c
index adbe8bf59e7..3261ef9ec28 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "alloc.h"
+#include "date.h"
 #include "hex.h"
 #include "object-store.h"
 #include "repository.h"
diff --git a/gpg-interface.c b/gpg-interface.c
index 8615dcd4b4b..49d72c2066b 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "commit.h"
 #include "config.h"
+#include "date.h"
 #include "gettext.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/grep.c b/grep.c
index d144b374894..e620e375b1d 100644
--- a/grep.c
+++ b/grep.c
@@ -4,6 +4,7 @@
 #include "grep.h"
 #include "hex.h"
 #include "object-store.h"
+#include "pretty.h"
 #include "userdiff.h"
 #include "xdiff-interface.h"
 #include "diff.h"
diff --git a/http-push.c b/http-push.c
index 637a4e91f7a..3f184986362 100644
--- a/http-push.c
+++ b/http-push.c
@@ -15,6 +15,7 @@
 #include "setup.h"
 #include "sigchain.h"
 #include "strvec.h"
+#include "tree.h"
 #include "packfile.h"
 #include "object-store.h"
 #include "commit-reach.h"
diff --git a/log-tree.c b/log-tree.c
index b5cf3d8439c..8861900b592 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -24,6 +24,7 @@
 #include "help.h"
 #include "range-diff.h"
 #include "strmap.h"
+#include "tree.h"
 #include "write-or-die.h"
 
 static struct decoration name_decoration = { "object names" };
diff --git a/merge-ort-wrappers.c b/merge-ort-wrappers.c
index 2c47c5a6237..a5507533009 100644
--- a/merge-ort-wrappers.c
+++ b/merge-ort-wrappers.c
@@ -3,6 +3,7 @@
 #include "hash.h"
 #include "merge-ort.h"
 #include "merge-ort-wrappers.h"
+#include "tree.h"
 
 #include "commit.h"
 
diff --git a/merge.c b/merge.c
index da7fa652c27..10aaec3a6c1 100644
--- a/merge.c
+++ b/merge.c
@@ -7,6 +7,7 @@
 #include "commit.h"
 #include "run-command.h"
 #include "resolve-undo.h"
+#include "tree.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
 #include "dir.h"
diff --git a/notes-cache.c b/notes-cache.c
index fbcdfd0dfe5..14288caf98f 100644
--- a/notes-cache.c
+++ b/notes-cache.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "notes-cache.h"
 #include "object-store.h"
+#include "pretty.h"
 #include "repository.h"
 #include "commit.h"
 #include "refs.h"
diff --git a/notes-utils.c b/notes-utils.c
index cb88171b7bb..4a793eb347f 100644
--- a/notes-utils.c
+++ b/notes-utils.c
@@ -6,6 +6,7 @@
 #include "refs.h"
 #include "notes-utils.h"
 #include "repository.h"
+#include "strbuf.h"
 
 void create_notes_commit(struct repository *r,
 			 struct notes_tree *t,
diff --git a/object-name.c b/object-name.c
index 3cd5b327293..5ccbe854b60 100644
--- a/object-name.c
+++ b/object-name.c
@@ -15,6 +15,7 @@
 #include "dir.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "pretty.h"
 #include "object-store.h"
 #include "repository.h"
 #include "setup.h"
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index faf67c94d37..3d3fd380654 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -18,6 +18,7 @@
 #include "commit-reach.h"
 #include "prio-queue.h"
 #include "trace2.h"
+#include "tree.h"
 
 struct bitmapped_commit {
 	struct commit *commit;
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 26a4c7d08a9..be81158f861 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -3,6 +3,7 @@
 #include "branch.h"
 #include "commit.h"
 #include "color.h"
+#include "date.h"
 #include "environment.h"
 #include "gettext.h"
 #include "object-name.h"
diff --git a/parse-options.c b/parse-options.c
index b6803647d0e..f8a155ee13b 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -5,6 +5,7 @@
 #include "commit.h"
 #include "color.h"
 #include "gettext.h"
+#include "strbuf.h"
 #include "utf8.h"
 
 static int disallow_abbreviated_options;
diff --git a/read-cache.c b/read-cache.c
index b3e2917ddc9..d64d93bc364 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -6,6 +6,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "config.h"
+#include "date.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "hex.h"
diff --git a/ref-filter.c b/ref-filter.c
index 594e66ad361..84eee904ba3 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
+#include "gpg-interface.h"
 #include "hex.h"
 #include "parse-options.h"
 #include "refs.h"
diff --git a/reflog.c b/reflog.c
index 9c094430884..57dc7c0d051 100644
--- a/reflog.c
+++ b/reflog.c
@@ -4,6 +4,7 @@
 #include "reflog.h"
 #include "refs.h"
 #include "revision.h"
+#include "tree.h"
 #include "worktree.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/refs/debug.c b/refs/debug.c
index adc34c836fc..6f11e6de46c 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "hex.h"
 #include "refs-internal.h"
+#include "string-list.h"
 #include "trace.h"
 
 static struct trace_key trace_refs = TRACE_KEY_INIT(REFS);
diff --git a/refspec.c b/refspec.c
index 31b61d782c7..57f6c2aaf9b 100644
--- a/refspec.c
+++ b/refspec.c
@@ -6,6 +6,7 @@
 #include "strvec.h"
 #include "refs.h"
 #include "refspec.h"
+#include "strbuf.h"
 
 static struct refspec_item s_tag_refspec = {
 	.force = 0,
diff --git a/revision.h b/revision.h
index 742700504a7..6630bb2eae2 100644
--- a/revision.h
+++ b/revision.h
@@ -8,6 +8,7 @@
 #include "pretty.h"
 #include "diff.h"
 #include "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 351037b07bc..e68da24cc52 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -1,6 +1,7 @@
 #include "git-compat-util.h"
 #include "config.h"
 #include "commit.h"
+#include "date.h"
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
diff --git a/wt-status.c b/wt-status.c
index 97b9c1c0359..068b76ef6d9 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -22,6 +22,7 @@
 #include "strbuf.h"
 #include "trace.h"
 #include "trace2.h"
+#include "tree.h"
 #include "utf8.h"
 #include "worktree.h"
 #include "lockfile.h"
-- 
gitgitgadget


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

* [PATCH v2 20/22] object-store.h: reduce unnecessary includes
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (18 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 19/22] commit.h: reduce unnecessary includes Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-05-01 17:00     ` Ævar Arnfjörð Bjarmason
  2023-04-22 20:17   ` [PATCH v2 21/22] diff.h: " Elijah Newren via GitGitGadget
                     ` (4 subsequent siblings)
  24 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 object-file.c      | 1 +
 object-name.c      | 1 +
 object-store.h     | 8 ++++----
 submodule-config.c | 1 +
 4 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/object-file.c b/object-file.c
index 8e0df7360ae..921a717d8a5 100644
--- a/object-file.c
+++ b/object-file.c
@@ -38,6 +38,7 @@
 #include "packfile.h"
 #include "object-file.h"
 #include "object-store.h"
+#include "oidtree.h"
 #include "promisor-remote.h"
 #include "setup.h"
 #include "submodule.h"
diff --git a/object-name.c b/object-name.c
index 5ccbe854b60..88d839f70bc 100644
--- a/object-name.c
+++ b/object-name.c
@@ -14,6 +14,7 @@
 #include "remote.h"
 #include "dir.h"
 #include "oid-array.h"
+#include "oidtree.h"
 #include "packfile.h"
 #include "pretty.h"
 #include "object-store.h"
diff --git a/object-store.h b/object-store.h
index f9d225783ae..23ea86d3702 100644
--- a/object-store.h
+++ b/object-store.h
@@ -2,16 +2,16 @@
 #define OBJECT_STORE_H
 
 #include "object.h"
-#include "oidmap.h"
 #include "list.h"
-#include "oid-array.h"
-#include "strbuf.h"
 #include "thread-utils.h"
 #include "khash.h"
 #include "dir.h"
-#include "oidtree.h"
 #include "oidset.h"
 
+struct oidmap;
+struct oidtree;
+struct strbuf;
+
 struct object_directory {
 	struct object_directory *next;
 
diff --git a/submodule-config.c b/submodule-config.c
index 7fc0812b644..58dfbde9ae5 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -12,6 +12,7 @@
 #include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
+#include "thread-utils.h"
 #include "tree-walk.h"
 
 /*
-- 
gitgitgadget


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

* [PATCH v2 21/22] diff.h: reduce unnecessary includes
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (19 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 20/22] object-store.h: " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-05-01 17:11     ` Ævar Arnfjörð Bjarmason
  2023-04-22 20:17   ` [PATCH v2 22/22] reftable: ensure git-compat-util.h is the first (indirect) include Elijah Newren via GitGitGadget
                     ` (3 subsequent siblings)
  24 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 attr.c              | 1 +
 diff.h              | 1 -
 http-push.c         | 1 +
 line-log.c          | 1 +
 pack-bitmap-write.c | 1 +
 reflog.c            | 1 +
 tree-diff.c         | 1 +
 7 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/attr.c b/attr.c
index 2d8aeb8b58c..ddf2b0cbc2e 100644
--- a/attr.c
+++ b/attr.c
@@ -20,6 +20,7 @@
 #include "object-store.h"
 #include "setup.h"
 #include "thread-utils.h"
+#include "tree-walk.h"
 
 const char git_attr__true[] = "(builtin)true";
 const char git_attr__false[] = "\0(builtin)false";
diff --git a/diff.h b/diff.h
index 53aeb02a54b..69e574f4315 100644
--- a/diff.h
+++ b/diff.h
@@ -4,7 +4,6 @@
 #ifndef DIFF_H
 #define DIFF_H
 
-#include "tree-walk.h"
 #include "pathspec.h"
 #include "oidset.h"
 #include "strbuf.h"
diff --git a/http-push.c b/http-push.c
index 3f184986362..866ba243a89 100644
--- a/http-push.c
+++ b/http-push.c
@@ -16,6 +16,7 @@
 #include "sigchain.h"
 #include "strvec.h"
 #include "tree.h"
+#include "tree-walk.h"
 #include "packfile.h"
 #include "object-store.h"
 #include "commit-reach.h"
diff --git a/line-log.c b/line-log.c
index 10c19daec4a..6a7ac312a43 100644
--- a/line-log.c
+++ b/line-log.c
@@ -18,6 +18,7 @@
 #include "setup.h"
 #include "strvec.h"
 #include "bloom.h"
+#include "tree-walk.h"
 
 static void range_set_grow(struct range_set *rs, size_t extra)
 {
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 3d3fd380654..cdffe2ce47d 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -19,6 +19,7 @@
 #include "prio-queue.h"
 #include "trace2.h"
 #include "tree.h"
+#include "tree-walk.h"
 
 struct bitmapped_commit {
 	struct commit *commit;
diff --git a/reflog.c b/reflog.c
index 57dc7c0d051..ee1bf5d032c 100644
--- a/reflog.c
+++ b/reflog.c
@@ -5,6 +5,7 @@
 #include "refs.h"
 #include "revision.h"
 #include "tree.h"
+#include "tree-walk.h"
 #include "worktree.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/tree-diff.c b/tree-diff.c
index 9ea2dd7a6c3..20bb15f38d9 100644
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -5,6 +5,7 @@
 #include "diff.h"
 #include "diffcore.h"
 #include "tree.h"
+#include "tree-walk.h"
 
 /*
  * Some mode bits are also used internally for computations.
-- 
gitgitgadget


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

* [PATCH v2 22/22] reftable: ensure git-compat-util.h is the first (indirect) include
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (20 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 21/22] diff.h: " Elijah Newren via GitGitGadget
@ 2023-04-22 20:17   ` Elijah Newren via GitGitGadget
  2023-04-24 15:19   ` [PATCH v2 00/22] Header cleanups (more splitting of cache.h and simplifying a few other deps) Derrick Stolee
                     ` (2 subsequent siblings)
  24 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-22 20:17 UTC (permalink / raw)
  To: git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo,
	Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 reftable/error.c         | 1 +
 reftable/publicbasics.c  | 2 +-
 reftable/tree.c          | 2 +-
 reftable/tree_test.c     | 1 +
 t/helper/test-reftable.c | 1 +
 5 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/reftable/error.c b/reftable/error.c
index 93941f21457..0d1766735e8 100644
--- a/reftable/error.c
+++ b/reftable/error.c
@@ -6,6 +6,7 @@ license that can be found in the LICENSE file or at
 https://developers.google.com/open-source/licenses/bsd
 */
 
+#include "system.h"
 #include "reftable-error.h"
 
 #include <stdio.h>
diff --git a/reftable/publicbasics.c b/reftable/publicbasics.c
index 0ad7d5c0ff2..bcb82530d6c 100644
--- a/reftable/publicbasics.c
+++ b/reftable/publicbasics.c
@@ -6,10 +6,10 @@ license that can be found in the LICENSE file or at
 https://developers.google.com/open-source/licenses/bsd
 */
 
+#include "system.h"
 #include "reftable-malloc.h"
 
 #include "basics.h"
-#include "system.h"
 
 static void *(*reftable_malloc_ptr)(size_t sz);
 static void *(*reftable_realloc_ptr)(void *, size_t);
diff --git a/reftable/tree.c b/reftable/tree.c
index b8899e060ab..a5bf8809854 100644
--- a/reftable/tree.c
+++ b/reftable/tree.c
@@ -6,10 +6,10 @@ license that can be found in the LICENSE file or at
 https://developers.google.com/open-source/licenses/bsd
 */
 
+#include "system.h"
 #include "tree.h"
 
 #include "basics.h"
-#include "system.h"
 
 struct tree_node *tree_search(void *key, struct tree_node **rootp,
 			      int (*compare)(const void *, const void *),
diff --git a/reftable/tree_test.c b/reftable/tree_test.c
index cbff1255886..ac3a045ad4a 100644
--- a/reftable/tree_test.c
+++ b/reftable/tree_test.c
@@ -6,6 +6,7 @@ license that can be found in the LICENSE file or at
 https://developers.google.com/open-source/licenses/bsd
 */
 
+#include "system.h"
 #include "tree.h"
 
 #include "basics.h"
diff --git a/t/helper/test-reftable.c b/t/helper/test-reftable.c
index 1f0a28cbb64..00237ef0d9e 100644
--- a/t/helper/test-reftable.c
+++ b/t/helper/test-reftable.c
@@ -1,3 +1,4 @@
+#include "reftable/system.h"
 #include "reftable/reftable-tests.h"
 #include "test-tool.h"
 
-- 
gitgitgadget

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

* Re: [PATCH v2 00/22] Header cleanups (more splitting of cache.h and simplifying a few other deps)
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (21 preceding siblings ...)
  2023-04-22 20:17   ` [PATCH v2 22/22] reftable: ensure git-compat-util.h is the first (indirect) include Elijah Newren via GitGitGadget
@ 2023-04-24 15:19   ` Derrick Stolee
  2023-04-24 19:49   ` Junio C Hamano
  2023-04-26 17:54   ` Glen Choo
  24 siblings, 0 replies; 81+ messages in thread
From: Derrick Stolee @ 2023-04-24 15:19 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget, git; +Cc: Calvin Wan, Elijah Newren, Glen Choo

On 4/22/2023 4:17 PM, Elijah Newren via GitGitGadget wrote:
> Changes since v1:
> 
>  * dropped the 3rd patch (it was pulled into the series this one depends
>    upon to fix an issue in it)
>  * redid the old patch 14 (new patch 13); moved the parts of hash.h not
>    depending on repository.h into hash-ll.h so that other headers and files
>    could depend upon just that part. (Are people happy with the hash-ll.h
>    name or have alternate suggestions?)

Thank you for this change. I looked at patch 13 and was pleased to see
several uses of hash-ll.h (more than I expected). I'm also happy with the
name.

v2 LGTM.

Thanks,
-Stolee

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

* Re: [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h
  2023-04-22 20:17   ` [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h Elijah Newren via GitGitGadget
@ 2023-04-24 18:51     ` Glen Choo
  2023-04-26  3:54       ` Elijah Newren
  2023-04-24 19:52     ` Junio C Hamano
  2023-05-01 17:17     ` Ævar Arnfjörð Bjarmason
  2 siblings, 1 reply; 81+ messages in thread
From: Glen Choo @ 2023-04-24 18:51 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget, git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

>                                 Move the parts of hash.h that do not
> depend upon repository.h into a new file hash-ll.h (the "low level"
> parts of hash.h), and adjust other files to use this new header where
> the convenience inline functions aren't needed.

Suggestion: To maintain this property, it might be helpful to capture
the rules of hash-ll.h vs hash.h in a top-level comment.

> diff --git a/hash-ll.h b/hash-ll.h
> new file mode 100644
> index 00000000000..80509251370
> --- /dev/null
> +++ b/hash-ll.h
> +const struct object_id *null_oid(void);
> [...]
> +const char *empty_tree_oid_hex(void);
> +const char *empty_blob_oid_hex(void);

hash-ll.h doesn't depend on repository.h, but these functions' bodies
use the_hash_algo. Does it matter?

Moving the functions to hash.h requires changing 8 files to #include
"hash.h", all of which seem to be because they were getting hash-ll.h
indirectly via object-name.h.

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

* Re: [PATCH v2 00/22] Header cleanups (more splitting of cache.h and simplifying a few other deps)
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (22 preceding siblings ...)
  2023-04-24 15:19   ` [PATCH v2 00/22] Header cleanups (more splitting of cache.h and simplifying a few other deps) Derrick Stolee
@ 2023-04-24 19:49   ` Junio C Hamano
  2023-04-26 17:54   ` Glen Choo
  24 siblings, 0 replies; 81+ messages in thread
From: Junio C Hamano @ 2023-04-24 19:49 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget
  Cc: git, Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> Changes since v1:
>
>  * dropped the 3rd patch (it was pulled into the series this one depends
>    upon to fix an issue in it)

Thanks.

>  * redid the old patch 14 (new patch 13); moved the parts of hash.h not
>    depending on repository.h into hash-ll.h so that other headers and files
>    could depend upon just that part. (Are people happy with the hash-ll.h
>    name or have alternate suggestions?)

We have precedence of abbreviating low-level to ll in ll-merge.c already.

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

* Re: [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h
  2023-04-22 20:17   ` [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h Elijah Newren via GitGitGadget
  2023-04-24 18:51     ` Glen Choo
@ 2023-04-24 19:52     ` Junio C Hamano
  2023-05-01 17:17     ` Ævar Arnfjörð Bjarmason
  2 siblings, 0 replies; 81+ messages in thread
From: Junio C Hamano @ 2023-04-24 19:52 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget
  Cc: git, Calvin Wan, Derrick Stolee, Elijah Newren, Glen Choo

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> This allows hash.h and object.h to be fairly small, minimal headers.  It
> also exposes a lot of hidden dependencies on both path.h (which was
> brought in by repository.h) and repository.h (which was previously
> implicitly brought in by object.h), so also adjust other files to be
> more explicit about what they depend upon.

Yeah, <hash.h> becomes pleasantly small.

Will queue.

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

* Re: [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h
  2023-04-24 18:51     ` Glen Choo
@ 2023-04-26  3:54       ` Elijah Newren
  2023-04-26 17:50         ` Glen Choo
  0 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren @ 2023-04-26  3:54 UTC (permalink / raw)
  To: Glen Choo; +Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee

On Mon, Apr 24, 2023 at 11:51 AM Glen Choo <chooglen@google.com> wrote:
>
> "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> >                                 Move the parts of hash.h that do not
> > depend upon repository.h into a new file hash-ll.h (the "low level"
> > parts of hash.h), and adjust other files to use this new header where
> > the convenience inline functions aren't needed.
>
> Suggestion: To maintain this property, it might be helpful to capture
> the rules of hash-ll.h vs hash.h in a top-level comment.
>
> > diff --git a/hash-ll.h b/hash-ll.h
> > new file mode 100644
> > index 00000000000..80509251370
> > --- /dev/null
> > +++ b/hash-ll.h
> > +const struct object_id *null_oid(void);
> > [...]
> > +const char *empty_tree_oid_hex(void);
> > +const char *empty_blob_oid_hex(void);
>
> hash-ll.h doesn't depend on repository.h, but these functions' bodies
> use the_hash_algo. Does it matter?

That's a good point.  I think eventually moving these functions from
hash-ll.h to hash.h on this basis makes sense.  But I kind of view
this series (and its predecessors) as focusing on cleaning up header
dependencies, with the idea that hopefully we'd go through and do
further cleanup of dependencies of C files that would likely result in
further changes to some of the headers.  I suspect this isn't the only
change we'd need to make for that kind of consistency, which might
lengthen this already sizable series, and I've probably missed a few
similar cases in my previous series as well.

> Moving the functions to hash.h requires changing 8 files to #include
> "hash.h", all of which seem to be because they were getting hash-ll.h
> indirectly via object-name.h.

Yeah, seems like a reasonable further change.  Are you okay with that
being in a future series, or do you think it should be included in
this one?

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

* Re: [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h
  2023-04-26  3:54       ` Elijah Newren
@ 2023-04-26 17:50         ` Glen Choo
  0 siblings, 0 replies; 81+ messages in thread
From: Glen Choo @ 2023-04-26 17:50 UTC (permalink / raw)
  To: Elijah Newren
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee

Elijah Newren <newren@gmail.com> writes:

>> hash-ll.h doesn't depend on repository.h, but these functions' bodies
>> use the_hash_algo. Does it matter?
>
> That's a good point.  I think eventually moving these functions from
> hash-ll.h to hash.h on this basis makes sense.  But I kind of view
> this series (and its predecessors) as focusing on cleaning up header
> dependencies, with the idea that hopefully we'd go through and do
> further cleanup of dependencies of C files that would likely result in
> further changes to some of the headers.

Yeah, for simplicity, keeping this series header-only makes sense.

>> Moving the functions to hash.h requires changing 8 files to #include
>> "hash.h", all of which seem to be because they were getting hash-ll.h
>> indirectly via object-name.h.
>
> Yeah, seems like a reasonable further change.  Are you okay with that
> being in a future series, or do you think it should be included in
> this one?

Let's do this in a later series. As you mentioned, there are probably a
lot of other clean ups that make sense, but this series is already a
good step forward, and keeping those clean ups out makes this easier to
review.

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

* Re: [PATCH v2 00/22] Header cleanups (more splitting of cache.h and simplifying a few other deps)
  2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
                     ` (23 preceding siblings ...)
  2023-04-24 19:49   ` Junio C Hamano
@ 2023-04-26 17:54   ` Glen Choo
  2023-04-26 18:14     ` Junio C Hamano
  24 siblings, 1 reply; 81+ messages in thread
From: Glen Choo @ 2023-04-26 17:54 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget, git
  Cc: Calvin Wan, Derrick Stolee, Elijah Newren

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:

> 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.

I looked over all of the patches briefly and didn't spot any issues,
though not deeply enough for a Reviewed-by.

FWIW I am quite happy with the direction of this series. I find the
result much easier to understand compared to the cache.h status quo.

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

* Re: [PATCH v2 00/22] Header cleanups (more splitting of cache.h and simplifying a few other deps)
  2023-04-26 17:54   ` Glen Choo
@ 2023-04-26 18:14     ` Junio C Hamano
  0 siblings, 0 replies; 81+ messages in thread
From: Junio C Hamano @ 2023-04-26 18:14 UTC (permalink / raw)
  To: Glen Choo
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Elijah Newren

Glen Choo <chooglen@google.com> writes:

> "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
>> 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.
>
> I looked over all of the patches briefly and didn't spot any issues,
> though not deeply enough for a Reviewed-by.
>
> FWIW I am quite happy with the direction of this series. I find the
> result much easier to understand compared to the cache.h status quo.

Anything that shrinks the kitchen-sinks would be good ;-)

Thanks.

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

* Re: [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  2023-04-22 20:17   ` [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define " Elijah Newren via GitGitGadget
@ 2023-05-01 16:33     ` Ævar Arnfjörð Bjarmason
  2023-05-01 16:46       ` Junio C Hamano
  2023-05-02  1:06       ` Elijah Newren
  0 siblings, 2 replies; 81+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-05-01 16:33 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget
  Cc: git, Calvin Wan, Derrick Stolee, Glen Choo, Elijah Newren


On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:

> From: Elijah Newren <newren@gmail.com>
>
> S_DIFFTREE_IFXMIN_NEQ is *only* used in tree-diff.c, so there is no
> point exposing it in cache.h.  Move it to tree-diff.c.
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  cache.h     | 15 ---------------
>  tree-diff.c | 13 +++++++++++++
>  2 files changed, 13 insertions(+), 15 deletions(-)
>
> diff --git a/cache.h b/cache.h
> index ad741e70bc2..7a46f300d9b 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -10,21 +10,6 @@
>  #include "object.h"
>  #include "statinfo.h"
>  
> -/*
> - * Some mode bits are also used internally for computations.
> - *
> - * They *must* not overlap with any valid modes, and they *must* not be emitted
> - * to outside world - i.e. appear on disk or network. In other words, it's just
> - * temporary fields, which we internally use, but they have to stay in-house.
> - *
> - * ( such approach is valid, as standard S_IF* fits into 16 bits, and in Git
> - *   codebase mode is `unsigned int` which is assumed to be at least 32 bits )
> - */
> -
> -/* used internally in tree-diff */
> -#define S_DIFFTREE_IFXMIN_NEQ	0x80000000
> -
> -
>  /*
>   * Basic data structures for the directory cache
>   */
> diff --git a/tree-diff.c b/tree-diff.c
> index 69031d7cbae..a76e6dae619 100644
> --- a/tree-diff.c
> +++ b/tree-diff.c
> @@ -6,6 +6,19 @@
>  #include "diffcore.h"
>  #include "tree.h"
>  
> +/*
> + * Some mode bits are also used internally for computations.
> + *
> + * They *must* not overlap with any valid modes, and they *must* not be emitted
> + * to outside world - i.e. appear on disk or network. In other words, it's just
> + * temporary fields, which we internally use, but they have to stay in-house.
> + *
> + * ( such approach is valid, as standard S_IF* fits into 16 bits, and in Git
> + *   codebase mode is `unsigned int` which is assumed to be at least 32 bits )
> + */
> +
> +#define S_DIFFTREE_IFXMIN_NEQ	0x80000000
> +
>  /*
>   * internal mode marker, saying a tree entry != entry of tp[imin]
>   * (see ll_diff_tree_paths for what it means there)

As it's only used in tree-diff.c, should this change not be instead
changing how we define S_IFXMIN_NEQ itself, and combining the two
comments seen here (the latter only partially, in the context).

Not that this makes things worse or anything...

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

* Re: [PATCH v2 16/22] treewide: remove cache.h inclusion due to previous changes
  2023-04-22 20:17   ` [PATCH v2 16/22] treewide: remove cache.h inclusion due to previous changes Elijah Newren via GitGitGadget
@ 2023-05-01 16:44     ` Ævar Arnfjörð Bjarmason
  2023-05-02  1:25       ` Elijah Newren
  0 siblings, 1 reply; 81+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-05-01 16:44 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget
  Cc: git, Calvin Wan, Derrick Stolee, Glen Choo, Elijah Newren


On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:

The "Subject" says "due to previous changes", but...

> From: Elijah Newren <newren@gmail.com>
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  archive-zip.c                 | 2 +-
>  bundle-uri.c                  | 2 +-
>  color.c                       | 2 +-
>  combine-diff.c                | 2 +-
>  common-main.c                 | 2 +-
>  config.c                      | 2 +-
>  copy.c                        | 2 +-
>  credential.c                  | 2 +-
>  daemon.c                      | 2 +-
>  date.c                        | 2 +-
>  diagnose.c                    | 2 +-
>  environment.c                 | 2 +-
>  ll-merge.c                    | 2 +-
>  match-trees.c                 | 2 +-
>  midx.c                        | 2 +-
>  object-file.c                 | 2 +-
>  packfile.c                    | 2 +-
>  pkt-line.c                    | 2 +-
>  range-diff.c                  | 2 +-
>  ref-filter.c                  | 2 +-
>  t/helper/test-match-trees.c   | 1 -
>  t/helper/test-mergesort.c     | 1 -
>  t/helper/test-oid-array.c     | 1 -
>  t/helper/test-oidtree.c       | 1 -
>  t/helper/test-parse-options.c | 1 -
>  t/helper/test-read-midx.c     | 1 -
>  t/helper/test-string-list.c   | 1 -
>  tree-diff.c                   | 2 +-
>  tree-walk.c                   | 2 +-
>  tree.c                        | 2 +-
>  wrapper.c                     | 3 ++-
>  31 files changed, 25 insertions(+), 31 deletions(-)
>
> diff --git a/archive-zip.c b/archive-zip.c
> index ef538a90df4..d0d065a312e 100644
> --- a/archive-zip.c
> +++ b/archive-zip.c
> @@ -1,7 +1,7 @@
>  /*
>   * Copyright (c) 2006 Rene Scharfe
>   */
> -#include "cache.h"
> +#include "git-compat-util.h"
>  #include "config.h"
>  #include "archive.h"
>  #include "gettext.h"

I tried making this change before this series was applied, and
everything compiled...

> diff --git a/bundle-uri.c b/bundle-uri.c
> index 6d44662ee1f..ec1552bbca2 100644
> --- a/bundle-uri.c
> +++ b/bundle-uri.c
> @@ -1,4 +1,4 @@
> -#include "cache.h"
> +#include "git-compat-util.h"
>  #include "bundle-uri.h"
>  #include "bundle.h"
>  #include "copy.h"

That's not the case here, but this could instead be squashed into the
05/22 in this series, i.e. as soon as we add this copy.h, we don't need
cache.h anymore.

> diff --git a/color.c b/color.c
> index f8a25ca807b..83abb11eda0 100644
> --- a/color.c
> +++ b/color.c
> @@ -1,4 +1,4 @@
> -#include "cache.h"
> +#include "git-compat-util.h"
>  #include "config.h"
>  #include "color.h"
>  #include "editor.h"

I did not look further, but all of the rest of these look like they'd be
better off squashed into the respective "split this out" commit. I don't
think keeping the "move declarations for ..." as "move-only" commits is
worth it, as opposed to getting rid of this one, and making those
atomic.

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

* Re: [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  2023-05-01 16:33     ` Ævar Arnfjörð Bjarmason
@ 2023-05-01 16:46       ` Junio C Hamano
  2023-05-02  1:06       ` Elijah Newren
  1 sibling, 0 replies; 81+ messages in thread
From: Junio C Hamano @ 2023-05-01 16:46 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo, Elijah Newren

Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:

>> +#define S_DIFFTREE_IFXMIN_NEQ	0x80000000
>> +
>>  /*
>>   * internal mode marker, saying a tree entry != entry of tp[imin]
>>   * (see ll_diff_tree_paths for what it means there)
>
> As it's only used in tree-diff.c, should this change not be instead
> changing how we define S_IFXMIN_NEQ itself, and combining the two
> comments seen here (the latter only partially, in the context).

Yup, the end result should look cleaner with this extra bit of
tweak.  Thanks for carefully reading the patch.


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

* Re: [PATCH v2 17/22] cache.h: remove unnecessary headers
  2023-04-22 20:17   ` [PATCH v2 17/22] cache.h: remove unnecessary headers Elijah Newren via GitGitGadget
@ 2023-05-01 16:49     ` Ævar Arnfjörð Bjarmason
  2023-05-02  1:43       ` Elijah Newren
  0 siblings, 1 reply; 81+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-05-01 16:49 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget
  Cc: git, Calvin Wan, Derrick Stolee, Glen Choo, Elijah Newren


On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:

> From: Elijah Newren <newren@gmail.com>
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  cache.h                              | 2 --
>  compat/fsmonitor/fsm-ipc-darwin.c    | 1 +
>  compat/fsmonitor/fsm-listen-darwin.c | 1 +
>  3 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/cache.h b/cache.h
> index 591c67b0595..bdedb87e83b 100644
> --- a/cache.h
> +++ b/cache.h
> @@ -4,8 +4,6 @@
>  #include "git-compat-util.h"
>  #include "strbuf.h"
>  #include "hashmap.h"
> -#include "gettext.h"
> -#include "string-list.h"
>  #include "pathspec.h"
>  #include "object.h"
>  #include "statinfo.h"
> diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
> index e62f093cc19..bc68dca0cae 100644
> --- a/compat/fsmonitor/fsm-ipc-darwin.c
> +++ b/compat/fsmonitor/fsm-ipc-darwin.c
> @@ -1,5 +1,6 @@
>  #include "cache.h"
>  #include "config.h"
> +#include "gettext.h"
>  #include "hex.h"
>  #include "repository.h"
>  #include "strbuf.h"
> diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c
> index 5eb6402ab82..18c0e3913dc 100644
> --- a/compat/fsmonitor/fsm-listen-darwin.c
> +++ b/compat/fsmonitor/fsm-listen-darwin.c
> @@ -29,6 +29,7 @@
>  #include "fsmonitor--daemon.h"
>  #include "fsmonitor-path-utils.h"
>  #include "gettext.h"
> +#include "string-list.h"
>  
>  struct fsm_listen_data
>  {

If I rebase this topic to make this the first commit everything
compiles, i.e. nothing here relies on what came before.

Given the extensive earlier moves I think it would be better to first
remove unnecessary includes from cache.h, before starting to split it
up.

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

* Re: [PATCH v2 19/22] commit.h: reduce unnecessary includes
  2023-04-22 20:17   ` [PATCH v2 19/22] commit.h: reduce unnecessary includes Elijah Newren via GitGitGadget
@ 2023-05-01 16:52     ` Ævar Arnfjörð Bjarmason
  2023-05-02  1:53       ` Elijah Newren
  0 siblings, 1 reply; 81+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-05-01 16:52 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget
  Cc: git, Calvin Wan, Derrick Stolee, Glen Choo, Elijah Newren


On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:

> From: Elijah Newren <newren@gmail.com>

Re earlier comments: If I rebase to make this the first commit
everything compiles, i.e. nothing here relied on the earlier split-offs
of cache.h into other headers.

You need to make a choice of whether to first split out cache.h, and
then do commits like these, or the other way around.

I'm not sure whether it's better to do it the other way around. If you
do that it's clear e.g. add-interactive.c's implicit dependency on
tree.h via commit.h has nothing to do with what would be the subsequent
split-up of cache.h.

Or maybe this is fine. I'm just trying to get some picture of what
depends on what in this series...

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

* Re: [PATCH v2 20/22] object-store.h: reduce unnecessary includes
  2023-04-22 20:17   ` [PATCH v2 20/22] object-store.h: " Elijah Newren via GitGitGadget
@ 2023-05-01 17:00     ` Ævar Arnfjörð Bjarmason
  2023-05-02  2:28       ` Elijah Newren
  0 siblings, 1 reply; 81+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-05-01 17:00 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget
  Cc: git, Calvin Wan, Derrick Stolee, Glen Choo, Elijah Newren


On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:

> From: Elijah Newren <newren@gmail.com>
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  object-file.c      | 1 +
>  object-name.c      | 1 +
>  object-store.h     | 8 ++++----
>  submodule-config.c | 1 +
>  4 files changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/object-file.c b/object-file.c
> index 8e0df7360ae..921a717d8a5 100644
> --- a/object-file.c
> +++ b/object-file.c
> @@ -38,6 +38,7 @@
>  #include "packfile.h"
>  #include "object-file.h"
>  #include "object-store.h"
> +#include "oidtree.h"
>  #include "promisor-remote.h"
>  #include "setup.h"
>  #include "submodule.h"
> diff --git a/object-name.c b/object-name.c
> index 5ccbe854b60..88d839f70bc 100644
> --- a/object-name.c
> +++ b/object-name.c
> @@ -14,6 +14,7 @@
>  #include "remote.h"
>  #include "dir.h"
>  #include "oid-array.h"
> +#include "oidtree.h"
>  #include "packfile.h"
>  #include "pretty.h"
>  #include "object-store.h"
> diff --git a/object-store.h b/object-store.h
> index f9d225783ae..23ea86d3702 100644
> --- a/object-store.h
> +++ b/object-store.h
> @@ -2,16 +2,16 @@
>  #define OBJECT_STORE_H
>  
>  #include "object.h"
> -#include "oidmap.h"
>  #include "list.h"
> -#include "oid-array.h"

It seems to me that this should be split up, there does seem to be an
unnecessary include here, as the subject claims, at least the
"oid-array.h include in object-store.h seems to qualify.

Maybe the same applies to thread-utils.h below?

> -#include "strbuf.h"
>  #include "thread-utils.h"
>  #include "khash.h"
>  #include "dir.h"
> -#include "oidtree.h"
>  #include "oidset.h"
>  
> +struct oidmap;
> +struct oidtree;
> +struct strbuf;

But as this shows at least three of these weren't unnecessary, you're
just replacing them with forward-decls.

I think that's probably sensible, but I think it should at least be
discussed.

It's also not clear why we want to just stop at forward-declaring
structs, maybe replacing the dir.h include with:

	int fspatheq(const char *a, const char *b);
	unsigned int fspathhash(const char *str);

Would be too verbose, but if we did that we'd spot that
e.g. match-trees.c is relying on this header to get its "struct strbuf"
definition.

I'm perfectly fine to leave that can of worms for some later date
though...

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

* Re: [PATCH v2 21/22] diff.h: reduce unnecessary includes
  2023-04-22 20:17   ` [PATCH v2 21/22] diff.h: " Elijah Newren via GitGitGadget
@ 2023-05-01 17:11     ` Ævar Arnfjörð Bjarmason
  0 siblings, 0 replies; 81+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-05-01 17:11 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget
  Cc: git, Calvin Wan, Derrick Stolee, Glen Choo, Elijah Newren


On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:

> From: Elijah Newren <newren@gmail.com>
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  attr.c              | 1 +
>  diff.h              | 1 -
>  http-push.c         | 1 +
>  line-log.c          | 1 +
>  pack-bitmap-write.c | 1 +
>  reflog.c            | 1 +
>  tree-diff.c         | 1 +
>  7 files changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/attr.c b/attr.c
> index 2d8aeb8b58c..ddf2b0cbc2e 100644
> --- a/attr.c
> +++ b/attr.c
> @@ -20,6 +20,7 @@
>  #include "object-store.h"
>  #include "setup.h"
>  #include "thread-utils.h"
> +#include "tree-walk.h"
>  
>  const char git_attr__true[] = "(builtin)true";
>  const char git_attr__false[] = "\0(builtin)false";
> diff --git a/diff.h b/diff.h
> index 53aeb02a54b..69e574f4315 100644
> --- a/diff.h
> +++ b/diff.h
> @@ -4,7 +4,6 @@
>  #ifndef DIFF_H
>  #define DIFF_H
>  
> -#include "tree-walk.h"
>  #include "pathspec.h"
>  #include "oidset.h"
>  #include "strbuf.h"
> diff --git a/http-push.c b/http-push.c
> index 3f184986362..866ba243a89 100644
> --- a/http-push.c
> +++ b/http-push.c
> @@ -16,6 +16,7 @@
>  #include "sigchain.h"
>  #include "strvec.h"
>  #include "tree.h"
> +#include "tree-walk.h"
>  #include "packfile.h"
>  #include "object-store.h"
>  #include "commit-reach.h"
> diff --git a/line-log.c b/line-log.c
> index 10c19daec4a..6a7ac312a43 100644
> --- a/line-log.c
> +++ b/line-log.c
> @@ -18,6 +18,7 @@
>  #include "setup.h"
>  #include "strvec.h"
>  #include "bloom.h"
> +#include "tree-walk.h"
>  
>  static void range_set_grow(struct range_set *rs, size_t extra)
>  {
> diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
> index 3d3fd380654..cdffe2ce47d 100644
> --- a/pack-bitmap-write.c
> +++ b/pack-bitmap-write.c
> @@ -19,6 +19,7 @@
>  #include "prio-queue.h"
>  #include "trace2.h"
>  #include "tree.h"
> +#include "tree-walk.h"
>  
>  struct bitmapped_commit {
>  	struct commit *commit;
> diff --git a/reflog.c b/reflog.c
> index 57dc7c0d051..ee1bf5d032c 100644
> --- a/reflog.c
> +++ b/reflog.c
> @@ -5,6 +5,7 @@
>  #include "refs.h"
>  #include "revision.h"
>  #include "tree.h"
> +#include "tree-walk.h"
>  #include "worktree.h"
>  
>  /* Remember to update object flag allocation in object.h */
> diff --git a/tree-diff.c b/tree-diff.c
> index 9ea2dd7a6c3..20bb15f38d9 100644
> --- a/tree-diff.c
> +++ b/tree-diff.c
> @@ -5,6 +5,7 @@
>  #include "diff.h"
>  #include "diffcore.h"
>  #include "tree.h"
> +#include "tree-walk.h"
>  
>  /*
>   * Some mode bits are also used internally for computations.

This, unlike the preceding 20/22 really does seem to strictly match its
$subject, i.e. diff.h didn't need tree-walk.h, but some stuff using it
needed it, so we're moving the include to those users themselves.

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

* Re: [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h
  2023-04-22 20:17   ` [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h Elijah Newren via GitGitGadget
  2023-04-24 18:51     ` Glen Choo
  2023-04-24 19:52     ` Junio C Hamano
@ 2023-05-01 17:17     ` Ævar Arnfjörð Bjarmason
  2023-05-02  2:53       ` Elijah Newren
  2 siblings, 1 reply; 81+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2023-05-01 17:17 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget
  Cc: git, Calvin Wan, Derrick Stolee, Glen Choo, Elijah Newren


On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:

> From: Elijah Newren <newren@gmail.com>
>
> [...]
> diff --git a/checkout.h b/checkout.h
> index 1917f3b3230..3c514a5ab4f 100644
> --- a/checkout.h
> +++ b/checkout.h
> @@ -1,7 +1,7 @@
>  #ifndef CHECKOUT_H
>  #define CHECKOUT_H
>  
> -#include "hash.h"
> +#include "hash-ll.h"

The end-state of this topic is oddly inconsistent in when it uses
includes, and when it uses forward declarations.

As I note in a reply to 20/22 you're adding forward declares there, I
think that's fine, but if you opdet for that why not do that here. The
body of this header only defines one function, which takes a pointer to
a "struct object_id".

Whereas above you did this change:

> diff --git a/apply.h b/apply.h
> index b9f18ce87d1..7cd38b1443c 100644
> --- a/apply.h
> +++ b/apply.h
> @@ -1,7 +1,7 @@
>  #ifndef APPLY_H
>  #define APPLY_H
>  
> -#include "hash.h"
> +#include "hash-ll.h"
>  #include "lockfile.h"
>  #include "string-list.h"
>  #include "strmap.h"

There we really should include it, as we're not dealing with a pointer
to the "struct object_id", but the struct itself, so we need its
definition, and don't want to find it implicitly.

> diff --git a/chunk-format.h b/chunk-format.h
> index 025c38f938e..c7794e84add 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 "hash-ll.h"
>  
>  struct hashfile;
>  struct chunkfile;

Then we have this, where we seemingly could avoid the include as well,
and just add a:

	struct git_hash_algo;

Anyway, I'm not saying one is better than the other, I'm just wondering
why you're picking one, but not the other.

Is it because you know that hash-ll.h doesn't bring in other headers, so
its inclusion is OK, whereas later in e.g. 20/22 you avoid including
strbuf.h, because you know that'll bring in string-list.h?

If that's the case maybe we should just move
strbuf_add_separated_string_list() into some "used by merge-ort.c and
merge-recursive.c" file, remove the string-list.h includion from
strbuf.h, and then include "strbuf.h" without fearing the side-effects
elsewhere?

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

* Re: [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  2023-05-01 16:33     ` Ævar Arnfjörð Bjarmason
  2023-05-01 16:46       ` Junio C Hamano
@ 2023-05-02  1:06       ` Elijah Newren
  2023-05-02  5:00         ` Elijah Newren
  1 sibling, 1 reply; 81+ messages in thread
From: Elijah Newren @ 2023-05-02  1:06 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo

On Mon, May 1, 2023 at 9:35 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
> On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:
[...]
> > --- a/tree-diff.c
> > +++ b/tree-diff.c
> > @@ -6,6 +6,19 @@
> >  #include "diffcore.h"
> >  #include "tree.h"
> >
> > +/*
> > + * Some mode bits are also used internally for computations.
> > + *
> > + * They *must* not overlap with any valid modes, and they *must* not be emitted
> > + * to outside world - i.e. appear on disk or network. In other words, it's just
> > + * temporary fields, which we internally use, but they have to stay in-house.
> > + *
> > + * ( such approach is valid, as standard S_IF* fits into 16 bits, and in Git
> > + *   codebase mode is `unsigned int` which is assumed to be at least 32 bits )
> > + */
> > +
> > +#define S_DIFFTREE_IFXMIN_NEQ        0x80000000
> > +
> >  /*
> >   * internal mode marker, saying a tree entry != entry of tp[imin]
> >   * (see ll_diff_tree_paths for what it means there)
>
> As it's only used in tree-diff.c, should this change not be instead
> changing how we define S_IFXMIN_NEQ itself, and combining the two
> comments seen here (the latter only partially, in the context).
>
> Not that this makes things worse or anything...

Hmm, that makes sense; I'll make the tweak.  Thanks for the suggestion.

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

* Re: [PATCH v2 16/22] treewide: remove cache.h inclusion due to previous changes
  2023-05-01 16:44     ` Ævar Arnfjörð Bjarmason
@ 2023-05-02  1:25       ` Elijah Newren
  0 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren @ 2023-05-02  1:25 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo

On Mon, May 1, 2023 at 9:48 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
> On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:
>
> The "Subject" says "due to previous changes", but...
>
> > From: Elijah Newren <newren@gmail.com>
> >
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
> >  archive-zip.c                 | 2 +-
> >  bundle-uri.c                  | 2 +-
> >  color.c                       | 2 +-
> >  combine-diff.c                | 2 +-
> >  common-main.c                 | 2 +-
> >  config.c                      | 2 +-
> >  copy.c                        | 2 +-
> >  credential.c                  | 2 +-
> >  daemon.c                      | 2 +-
> >  date.c                        | 2 +-
> >  diagnose.c                    | 2 +-
> >  environment.c                 | 2 +-
> >  ll-merge.c                    | 2 +-
> >  match-trees.c                 | 2 +-
> >  midx.c                        | 2 +-
> >  object-file.c                 | 2 +-
> >  packfile.c                    | 2 +-
> >  pkt-line.c                    | 2 +-
> >  range-diff.c                  | 2 +-
> >  ref-filter.c                  | 2 +-
> >  t/helper/test-match-trees.c   | 1 -
> >  t/helper/test-mergesort.c     | 1 -
> >  t/helper/test-oid-array.c     | 1 -
> >  t/helper/test-oidtree.c       | 1 -
> >  t/helper/test-parse-options.c | 1 -
> >  t/helper/test-read-midx.c     | 1 -
> >  t/helper/test-string-list.c   | 1 -
> >  tree-diff.c                   | 2 +-
> >  tree-walk.c                   | 2 +-
> >  tree.c                        | 2 +-
> >  wrapper.c                     | 3 ++-
> >  31 files changed, 25 insertions(+), 31 deletions(-)
> >
> > diff --git a/archive-zip.c b/archive-zip.c
> > index ef538a90df4..d0d065a312e 100644
> > --- a/archive-zip.c
> > +++ b/archive-zip.c
> > @@ -1,7 +1,7 @@
> >  /*
> >   * Copyright (c) 2006 Rene Scharfe
> >   */
> > -#include "cache.h"
> > +#include "git-compat-util.h"
> >  #include "config.h"
> >  #include "archive.h"
> >  #include "gettext.h"
>
> I tried making this change before this series was applied, and
> everything compiled...

Yeah, this actually could have been done as part of b7b189cd5ae
("treewide: reduce includes of cache.h in other headers", 2023-04-11),
which was from the series before this one.

> > diff --git a/bundle-uri.c b/bundle-uri.c
> > index 6d44662ee1f..ec1552bbca2 100644
> > --- a/bundle-uri.c
> > +++ b/bundle-uri.c
> > @@ -1,4 +1,4 @@
> > -#include "cache.h"
> > +#include "git-compat-util.h"
> >  #include "bundle-uri.h"
> >  #include "bundle.h"
> >  #include "copy.h"
>
> That's not the case here, but this could instead be squashed into the
> 05/22 in this series, i.e. as soon as we add this copy.h, we don't need
> cache.h anymore.
>
> > diff --git a/color.c b/color.c
> > index f8a25ca807b..83abb11eda0 100644
> > --- a/color.c
> > +++ b/color.c
> > @@ -1,4 +1,4 @@
> > -#include "cache.h"
> > +#include "git-compat-util.h"
> >  #include "config.h"
> >  #include "color.h"
> >  #include "editor.h"
>
> I did not look further, but all of the rest of these look like they'd be
> better off squashed into the respective "split this out" commit. I don't
> think keeping the "move declarations for ..." as "move-only" commits is
> worth it, as opposed to getting rid of this one, and making those
> atomic.

So, while that could be done, I found it harder to review my own
changes personally, and thought others would as well.  If you're
looking through several dozen files for a single change (add one new
header), it's easy to fly through and be confident you didn't miss
anything, but when there are sometimes two changes (also replace
cache.h with git-compat-util.h, or just outright remove it if
git-compat-util.h is already included), then that slows review down
dramatically.

In the previous series, I addressed this by splitting each patch into
two -- (1) move declarations to new header and add new relevant
include, (2) remove the cache.h includes that was allowed by that
change.  See patches 7-18 at
https://lore.kernel.org/git/pull.1509.git.1680361837.gitgitgadget@gmail.com/#r
.

But having half a dozen commits labelled "treewide: remove cache.h
inclusion due to header changes in previous patch", seemed like a bit
of a pain too.  So I instead batched them up and did them all at once.
I could revert back to how I did it in the previous series, but I
think I'd want to keep the commits that are adding a new header
separate from the ones that remove includes of cache.h.

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

* Re: [PATCH v2 17/22] cache.h: remove unnecessary headers
  2023-05-01 16:49     ` Ævar Arnfjörð Bjarmason
@ 2023-05-02  1:43       ` Elijah Newren
  0 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren @ 2023-05-02  1:43 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo

On Mon, May 1, 2023 at 9:50 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
> On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:
>
> > From: Elijah Newren <newren@gmail.com>
> >
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
> >  cache.h                              | 2 --
> >  compat/fsmonitor/fsm-ipc-darwin.c    | 1 +
> >  compat/fsmonitor/fsm-listen-darwin.c | 1 +
> >  3 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/cache.h b/cache.h
> > index 591c67b0595..bdedb87e83b 100644
> > --- a/cache.h
> > +++ b/cache.h
> > @@ -4,8 +4,6 @@
> >  #include "git-compat-util.h"
> >  #include "strbuf.h"
> >  #include "hashmap.h"
> > -#include "gettext.h"
> > -#include "string-list.h"
> >  #include "pathspec.h"
> >  #include "object.h"
> >  #include "statinfo.h"
> > diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
> > index e62f093cc19..bc68dca0cae 100644
> > --- a/compat/fsmonitor/fsm-ipc-darwin.c
> > +++ b/compat/fsmonitor/fsm-ipc-darwin.c
> > @@ -1,5 +1,6 @@
> >  #include "cache.h"
> >  #include "config.h"
> > +#include "gettext.h"
> >  #include "hex.h"
> >  #include "repository.h"
> >  #include "strbuf.h"
> > diff --git a/compat/fsmonitor/fsm-listen-darwin.c b/compat/fsmonitor/fsm-listen-darwin.c
> > index 5eb6402ab82..18c0e3913dc 100644
> > --- a/compat/fsmonitor/fsm-listen-darwin.c
> > +++ b/compat/fsmonitor/fsm-listen-darwin.c
> > @@ -29,6 +29,7 @@
> >  #include "fsmonitor--daemon.h"
> >  #include "fsmonitor-path-utils.h"
> >  #include "gettext.h"
> > +#include "string-list.h"
> >
> >  struct fsm_listen_data
> >  {
>
> If I rebase this topic to make this the first commit everything
> compiles, i.e. nothing here relies on what came before.
>
> Given the extensive earlier moves I think it would be better to first
> remove unnecessary includes from cache.h, before starting to split it
> up.

Interesting.  I originally had this patch earlier as you proposed, but
in writing the cover letter found it made it simpler to explain the
high level overview by moving it.  It's really nice to be able to say,
"this series continues to focus on splitting declarations from cache.h
to separate headers...and then makes other cleanups I found while
doing that", which naturally suggested the opposite ordering from what
I originally had.

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

* Re: [PATCH v2 19/22] commit.h: reduce unnecessary includes
  2023-05-01 16:52     ` Ævar Arnfjörð Bjarmason
@ 2023-05-02  1:53       ` Elijah Newren
  0 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren @ 2023-05-02  1:53 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo

On Mon, May 1, 2023 at 9:59 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
> On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:
>
> > From: Elijah Newren <newren@gmail.com>
>
> Re earlier comments: If I rebase to make this the first commit
> everything compiles, i.e. nothing here relied on the earlier split-offs
> of cache.h into other headers.
>
> You need to make a choice of whether to first split out cache.h, and
> then do commits like these, or the other way around.
>
> I'm not sure whether it's better to do it the other way around. If you
> do that it's clear e.g. add-interactive.c's implicit dependency on
> tree.h via commit.h has nothing to do with what would be the subsequent
> split-up of cache.h.
>
> Or maybe this is fine. I'm just trying to get some picture of what
> depends on what in this series...

Yes, there is some freedom about the ordering of patches, and I had to
make a choice.

I found a number of the cleanups like this one for commit.h
interspersed with the other changes, but I intentionally grouped them
at the end to get a good high level overview, namely:

(A) Continue splitting declarations from cache.h to separate headers
(B) Do other header cleanups found during that work

I could have reversed the order, but since the series was motivated
and organized around (A), it made more sense to me to put those
patches first.

Besides, the last time I moved a few miscellaneous cleanup patches to
the front of the series, someone else responded thinking the purpose
and motivation was about those first few patches[1], so I wanted to
avoid a repeat of that problem.  ;-)

[1] https://lore.kernel.org/git/CABPp-BFZBWTG1VF6N8teVMYxoUdOeciKGwPq1g-G1K5--My5uQ@mail.gmail.com/

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

* Re: [PATCH v2 20/22] object-store.h: reduce unnecessary includes
  2023-05-01 17:00     ` Ævar Arnfjörð Bjarmason
@ 2023-05-02  2:28       ` Elijah Newren
  0 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren @ 2023-05-02  2:28 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo

On Mon, May 1, 2023 at 10:10 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:
>
> > From: Elijah Newren <newren@gmail.com>
> >
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
> >  object-file.c      | 1 +
> >  object-name.c      | 1 +
> >  object-store.h     | 8 ++++----
> >  submodule-config.c | 1 +
> >  4 files changed, 7 insertions(+), 4 deletions(-)
> >
> > diff --git a/object-file.c b/object-file.c
> > index 8e0df7360ae..921a717d8a5 100644
> > --- a/object-file.c
> > +++ b/object-file.c
> > @@ -38,6 +38,7 @@
> >  #include "packfile.h"
> >  #include "object-file.h"
> >  #include "object-store.h"
> > +#include "oidtree.h"
> >  #include "promisor-remote.h"
> >  #include "setup.h"
> >  #include "submodule.h"
> > diff --git a/object-name.c b/object-name.c
> > index 5ccbe854b60..88d839f70bc 100644
> > --- a/object-name.c
> > +++ b/object-name.c
> > @@ -14,6 +14,7 @@
> >  #include "remote.h"
> >  #include "dir.h"
> >  #include "oid-array.h"
> > +#include "oidtree.h"
> >  #include "packfile.h"
> >  #include "pretty.h"
> >  #include "object-store.h"
> > diff --git a/object-store.h b/object-store.h
> > index f9d225783ae..23ea86d3702 100644
> > --- a/object-store.h
> > +++ b/object-store.h
> > @@ -2,16 +2,16 @@
> >  #define OBJECT_STORE_H
> >
> >  #include "object.h"
> > -#include "oidmap.h"
> >  #include "list.h"
> > -#include "oid-array.h"
>
> It seems to me that this should be split up, there does seem to be an
> unnecessary include here, as the subject claims, at least the
> "oid-array.h include in object-store.h seems to qualify.
>
> Maybe the same applies to thread-utils.h below?

Removing the thread-utils.h inclusion from object-store.h will break
compilation on non-linux platforms; that header is needed for the
definition of pthread_mutex_t used later in the file.

> > -#include "strbuf.h"
> >  #include "thread-utils.h"
> >  #include "khash.h"
> >  #include "dir.h"
> > -#include "oidtree.h"
> >  #include "oidset.h"
> >
> > +struct oidmap;
> > +struct oidtree;
> > +struct strbuf;
>
> But as this shows at least three of these weren't unnecessary, you're
> just replacing them with forward-decls.

Something was necessary, yes, but an #include statement certainly
wasn't.  Here, nothing would need to be recompiled if those other
headers changed, so the include is unnecessary.

> I think that's probably sensible, but I think it should at least be
> discussed.

We have now discussed it.  :-)

Did you want a simple call-out in the commit message, e.g. "Replace
the includes with simple forward declarations of the relevant
structs." ?

> It's also not clear why we want to just stop at forward-declaring
> structs, maybe replacing the dir.h include with:
>
>         int fspatheq(const char *a, const char *b);
>         unsigned int fspathhash(const char *str);

I don't like the idea of having to update function signatures in 3 or
more places when we need to make changes.  In contrast, forward
declarations of structs aren't susceptible to the same need to
update while making other changes.

We have hundreds of forward declarations of structs in the code;
everyone seems to be fine with them.

Whenever we've had duplicate declarations of functions, it's been
treated as a code smell that we've gotten rid of when possible.  In
fact, in v2.40.0, by my search we only had two of these --
xdl_emit_diff() and read_in_full().  And we've since gotten rid of one
of those (namely, read_in_full()).

> Would be too verbose, but if we did that we'd spot that
> e.g. match-trees.c is relying on this header to get its "struct strbuf"
> definition.
>
> I'm perfectly fine to leave that can of worms for some later date
> though...

That's a good find; I also found it separately later in some follow-on
patches so I'll also vote for leaving that can of worms for a later
date.  :-)


And thanks for carefully reading through this series!

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

* Re: [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h
  2023-05-01 17:17     ` Ævar Arnfjörð Bjarmason
@ 2023-05-02  2:53       ` Elijah Newren
  0 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren @ 2023-05-02  2:53 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo

On Mon, May 1, 2023 at 10:24 AM Ævar Arnfjörð Bjarmason
<avarab@gmail.com> wrote:
>
> On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:
>
> > From: Elijah Newren <newren@gmail.com>
> >
> > [...]
> > diff --git a/checkout.h b/checkout.h
> > index 1917f3b3230..3c514a5ab4f 100644
> > --- a/checkout.h
> > +++ b/checkout.h
> > @@ -1,7 +1,7 @@
> >  #ifndef CHECKOUT_H
> >  #define CHECKOUT_H
> >
> > -#include "hash.h"
> > +#include "hash-ll.h"
>
> The end-state of this topic is oddly inconsistent in when it uses
> includes, and when it uses forward declarations.
>
> As I note in a reply to 20/22 you're adding forward declares there, I
> think that's fine, but if you opdet for that why not do that here. The
> body of this header only defines one function, which takes a pointer to
> a "struct object_id".
>
> Whereas above you did this change:
>
> > diff --git a/apply.h b/apply.h
> > index b9f18ce87d1..7cd38b1443c 100644
> > --- a/apply.h
> > +++ b/apply.h
> > @@ -1,7 +1,7 @@
> >  #ifndef APPLY_H
> >  #define APPLY_H
> >
> > -#include "hash.h"
> > +#include "hash-ll.h"
> >  #include "lockfile.h"
> >  #include "string-list.h"
> >  #include "strmap.h"
>
> There we really should include it, as we're not dealing with a pointer
> to the "struct object_id", but the struct itself, so we need its
> definition, and don't want to find it implicitly.
>
> > diff --git a/chunk-format.h b/chunk-format.h
> > index 025c38f938e..c7794e84add 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 "hash-ll.h"
> >
> >  struct hashfile;
> >  struct chunkfile;
>
> Then we have this, where we seemingly could avoid the include as well,
> and just add a:
>
>         struct git_hash_algo;
>
> Anyway, I'm not saying one is better than the other, I'm just wondering
> why you're picking one, but not the other.

Basically, just because I updated all the includes through:
   $ git grep include..hash.h | xargs sed -i s/hash.h/hash-ll.h/
and then tried to compile and fixed up the files that had errors
(usually by making it include hash.h rather than hash-ll.h).  Every
once in a while I might have noticed that a simpler forward-declare
was sufficient but I didn't always look for it.

Anyway, thanks for looking closely and pointing this one out!
Switching this to a forward declaration is another nice cleanup to add
(though perhaps to a future series, as this one is long enough).

> Is it because you know that hash-ll.h doesn't bring in other headers, so
> its inclusion is OK, whereas later in e.g. 20/22 you avoid including
> strbuf.h, because you know that'll bring in string-list.h?

No, it's more "we gotta start somewhere, and stop well short of
complete for the series to be reviewable".

It's really easy to look at pieces of this series and notice all kinds
of additional cleanups that are possible:
  * Emily pointed out that if we're moving a global to a new header,
why not update the code to just delete the global?
  * Calvin pointed out that git-compat-util.h had become a dumping
ground too and needed cleaning.
  * Glen pointed out that some of my reasons for splitting between
hash-ll.h and hash.h would suggest, based on function definitions,
that 2 of the declarations should move back to hash.h.
  * You've pointed out multiple good additional cleanups in your review so far
  * I had an ongoing list of dozens of types of changes to make while
working on this and prior series.

Anyone who looks at this series is going to spot additional "what
about this?" things.  They're all great.  But I picked some cleanups
to make, and carried those through.  Because of how I did those
cleanups (note my grep & sed command above, followed by
recompile/edit/repeat cycle), I noticed some additional cleanups that
are likely different than what someone else reviewing them will
notice.  Some of the additional cleanups I noticed are in this series,
but most are delayed for some future series.

> If that's the case maybe we should just move
> strbuf_add_separated_string_list() into some "used by merge-ort.c and
> merge-recursive.c" file, remove the string-list.h includion from
> strbuf.h, and then include "strbuf.h" without fearing the side-effects
> elsewhere?

Ooh, nice catch.  If that function is only used by those two files, it
should be moved to merge-recursive.h (merge-ort.c includes that
currently).  However, Calvin is doing a bunch of work refactoring
strbuf.[ch], and I told him I'd avoid touching it to reduce conflicts
with his in-progress work.  So, I'll let him tackle this one in his
series.

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

* Re: [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  2023-05-02  1:06       ` Elijah Newren
@ 2023-05-02  5:00         ` Elijah Newren
  2023-05-02 15:56           ` Junio C Hamano
  0 siblings, 1 reply; 81+ messages in thread
From: Elijah Newren @ 2023-05-02  5:00 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason
  Cc: Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo

On Mon, May 1, 2023 at 6:06 PM Elijah Newren <newren@gmail.com> wrote:
>
> On Mon, May 1, 2023 at 9:35 AM Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
> >
> > On Sat, Apr 22 2023, Elijah Newren via GitGitGadget wrote:
> [...]
> > > --- a/tree-diff.c
> > > +++ b/tree-diff.c
> > > @@ -6,6 +6,19 @@
> > >  #include "diffcore.h"
> > >  #include "tree.h"
> > >
> > > +/*
> > > + * Some mode bits are also used internally for computations.
> > > + *
> > > + * They *must* not overlap with any valid modes, and they *must* not be emitted
> > > + * to outside world - i.e. appear on disk or network. In other words, it's just
> > > + * temporary fields, which we internally use, but they have to stay in-house.
> > > + *
> > > + * ( such approach is valid, as standard S_IF* fits into 16 bits, and in Git
> > > + *   codebase mode is `unsigned int` which is assumed to be at least 32 bits )
> > > + */
> > > +
> > > +#define S_DIFFTREE_IFXMIN_NEQ        0x80000000
> > > +
> > >  /*
> > >   * internal mode marker, saying a tree entry != entry of tp[imin]
> > >   * (see ll_diff_tree_paths for what it means there)
> >
> > As it's only used in tree-diff.c, should this change not be instead
> > changing how we define S_IFXMIN_NEQ itself, and combining the two
> > comments seen here (the latter only partially, in the context).
> >
> > Not that this makes things worse or anything...
>
> Hmm, that makes sense; I'll make the tweak.  Thanks for the suggestion.

Although maybe I'll have to do it in a follow-on series?  Junio merged
the series to next today, so...I guess I'll just add it to my "header
cleanups" notes.

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

* Re: [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  2023-05-02  5:00         ` Elijah Newren
@ 2023-05-02 15:56           ` Junio C Hamano
  2023-05-02 15:59             ` Elijah Newren
  0 siblings, 1 reply; 81+ messages in thread
From: Junio C Hamano @ 2023-05-02 15:56 UTC (permalink / raw)
  To: Elijah Newren
  Cc: Ævar Arnfjörð Bjarmason,
	Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo

Elijah Newren <newren@gmail.com> writes:

> Although maybe I'll have to do it in a follow-on series?  Junio merged
> the series to next today, so...I guess I'll just add it to my "header
> cleanups" notes.

I am not Ævar, but it is so small a thing that is local to a single
file, we can wait until the dust settles to avoid distraction.

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

* Re: [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define from cache.h
  2023-05-02 15:56           ` Junio C Hamano
@ 2023-05-02 15:59             ` Elijah Newren
  0 siblings, 0 replies; 81+ messages in thread
From: Elijah Newren @ 2023-05-02 15:59 UTC (permalink / raw)
  To: Junio C Hamano
  Cc: Ævar Arnfjörð Bjarmason,
	Elijah Newren via GitGitGadget, git, Calvin Wan, Derrick Stolee,
	Glen Choo

On Tue, May 2, 2023 at 8:56 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Elijah Newren <newren@gmail.com> writes:
>
> > Although maybe I'll have to do it in a follow-on series?  Junio merged
> > the series to next today, so...I guess I'll just add it to my "header
> > cleanups" notes.
>
> I am not Ævar, but it is so small a thing that is local to a single
> file, we can wait until the dust settles to avoid distraction.

Yup, sounds good to me.  :-)

I've got it on my todo list for continued cleanups.

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

end of thread, other threads:[~2023-05-02 16:00 UTC | newest]

Thread overview: 81+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-16  3:03 [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 01/23] treewide: be explicit about dependence on strbuf.h Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 02/23] symlinks.h: move declarations for symlinks.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 03/23] protocol.h: move definition of DEFAULT_GIT_PORT " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 04/23] packfile.h: move pack_window and pack_entry " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 05/23] server-info.h: move declarations for server-info.c functions " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 06/23] copy.h: move declarations for copy.c " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 07/23] base85.h: move declarations for base85.c " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 08/23] pkt-line.h: move declarations for pkt-line.c " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 09/23] match-trees.h: move declarations for match-trees.c " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 10/23] ws.h: move declarations for ws.c " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 11/23] versioncmp.h: move declarations for versioncmp.c " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 12/23] dir.h: move DTYPE defines " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 13/23] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 14/23] hash.h, repository.h: reverse the order of these dependencies Elijah Newren via GitGitGadget
2023-04-17 20:59   ` Derrick Stolee
2023-04-18  2:36     ` Elijah Newren
2023-04-18 23:29     ` Junio C Hamano
2023-04-20  5:06       ` Elijah Newren
2023-04-20 13:14         ` Derrick Stolee
2023-04-20 15:54           ` Junio C Hamano
2023-04-20 19:54             ` Glen Choo
2023-04-16  3:03 ` [PATCH 15/23] cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 16/23] cache,tree: move basic name compare functions from read-cache to tree Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 17/23] treewide: remove cache.h inclusion due to previous changes Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 18/23] cache.h: remove unnecessary headers Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 19/23] fsmonitor: reduce includes of cache.h Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 20/23] commit.h: reduce unnecessary includes Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 21/23] object-store.h: " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 22/23] diff.h: " Elijah Newren via GitGitGadget
2023-04-16  3:03 ` [PATCH 23/23] reftable: ensure git-compat-util.h is the first (indirect) include Elijah Newren via GitGitGadget
2023-04-17 21:07 ` [PATCH 00/23] Header cleanups (more splitting of cache.h and simplifying a few other deps) Derrick Stolee
2023-04-18  2:41   ` Elijah Newren
2023-04-22 20:17 ` [PATCH v2 00/22] " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 01/22] treewide: be explicit about dependence on strbuf.h Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 02/22] symlinks.h: move declarations for symlinks.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 03/22] packfile.h: move pack_window and pack_entry " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 04/22] server-info.h: move declarations for server-info.c functions " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 05/22] copy.h: move declarations for copy.c " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 06/22] base85.h: move declarations for base85.c " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 07/22] pkt-line.h: move declarations for pkt-line.c " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 08/22] match-trees.h: move declarations for match-trees.c " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 09/22] ws.h: move declarations for ws.c " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 10/22] versioncmp.h: move declarations for versioncmp.c " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 11/22] dir.h: move DTYPE defines " Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 12/22] tree-diff.c: move S_DIFFTREE_IFXMIN_NEQ define " Elijah Newren via GitGitGadget
2023-05-01 16:33     ` Ævar Arnfjörð Bjarmason
2023-05-01 16:46       ` Junio C Hamano
2023-05-02  1:06       ` Elijah Newren
2023-05-02  5:00         ` Elijah Newren
2023-05-02 15:56           ` Junio C Hamano
2023-05-02 15:59             ` Elijah Newren
2023-04-22 20:17   ` [PATCH v2 13/22] hash-ll.h: split out of hash.h to remove dependency on repository.h Elijah Newren via GitGitGadget
2023-04-24 18:51     ` Glen Choo
2023-04-26  3:54       ` Elijah Newren
2023-04-26 17:50         ` Glen Choo
2023-04-24 19:52     ` Junio C Hamano
2023-05-01 17:17     ` Ævar Arnfjörð Bjarmason
2023-05-02  2:53       ` Elijah Newren
2023-04-22 20:17   ` [PATCH v2 14/22] cache,tree: move cmp_cache_name_compare from tree.[ch] to read-cache.c Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 15/22] cache,tree: move basic name compare functions from read-cache to tree Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 16/22] treewide: remove cache.h inclusion due to previous changes Elijah Newren via GitGitGadget
2023-05-01 16:44     ` Ævar Arnfjörð Bjarmason
2023-05-02  1:25       ` Elijah Newren
2023-04-22 20:17   ` [PATCH v2 17/22] cache.h: remove unnecessary headers Elijah Newren via GitGitGadget
2023-05-01 16:49     ` Ævar Arnfjörð Bjarmason
2023-05-02  1:43       ` Elijah Newren
2023-04-22 20:17   ` [PATCH v2 18/22] fsmonitor: reduce includes of cache.h Elijah Newren via GitGitGadget
2023-04-22 20:17   ` [PATCH v2 19/22] commit.h: reduce unnecessary includes Elijah Newren via GitGitGadget
2023-05-01 16:52     ` Ævar Arnfjörð Bjarmason
2023-05-02  1:53       ` Elijah Newren
2023-04-22 20:17   ` [PATCH v2 20/22] object-store.h: " Elijah Newren via GitGitGadget
2023-05-01 17:00     ` Ævar Arnfjörð Bjarmason
2023-05-02  2:28       ` Elijah Newren
2023-04-22 20:17   ` [PATCH v2 21/22] diff.h: " Elijah Newren via GitGitGadget
2023-05-01 17:11     ` Ævar Arnfjörð Bjarmason
2023-04-22 20:17   ` [PATCH v2 22/22] reftable: ensure git-compat-util.h is the first (indirect) include Elijah Newren via GitGitGadget
2023-04-24 15:19   ` [PATCH v2 00/22] Header cleanups (more splitting of cache.h and simplifying a few other deps) Derrick Stolee
2023-04-24 19:49   ` Junio C Hamano
2023-04-26 17:54   ` Glen Choo
2023-04-26 18:14     ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).