git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 00/24] Header cleanups (splitting up cache.h)
@ 2023-04-01 15:10 Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
                   ` (25 more replies)
  0 siblings, 26 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren

Maintainer notes: (1) This series is based on a merge of
en/header-split-cleanup and ab/remove-implicit-use-of-the-repository (both
in next). (2) Although I've tweaked the series to minimize conflicts (and
this series merges syntactically cleanly with next and seen), there is a
semantic conflict with ja/worktree-orphan in seen; to correct, simply add an
include of advice.h in builtin/worktree.c.

This series builds on en/header-cleanup
(https://lore.kernel.org/git/pull.1485.v2.git.1677197376.gitgitgadget@gmail.com/)
and en/header-split-cleanup
(https://lore.kernel.org/git/pull.1493.v2.git.1679379968.gitgitgadget@gmail.com/),
and continues to focus on splitting declarations from cache.h to separate
headers.

The series may appear to be long at first glance, but is repetitive and
simple. It should be relatively easy to review, and falls into roughly 3
categories. An overview:

 * Patches 1-6: Being more explicit about dependencies. This was motivated
   by the fact that trying to find unnecessary dependencies on cache.h were
   being made harder by implicit dependencies on trace.h, trace2.h, and
   advice.h that were included via cache.h. (Similar to gettext.h handling
   in the previous series.) So I simply try to make dependencies more
   explicit, for both these headers and a few others. To make review easy, I
   split it into half a dozen patches, one header per patch (well, except
   that I handle trace.h and trace2.h together).
 * Patch 7: Remove several includes of cache.h that are no longer needed due
   to patches 1-6.
 * Patches 8-18: For several choices of FOO, move declarations of functions
   for FOO.c from cache.h to FOO.h. To simplify reviewing, each case is
   split into two patches, with the second patch cleaning up unnecessary
   includes of cache.h in other source files. (Patch 14 is a slight
   exception that wasn't split into two patches since the movement was
   otherwise so small)
 * Patches 19-24: Other small manual cleanups noticed while doing above work

Since patches 1-14 & 16-18 are just more of the same types of patches
already reviewed in the last two series, it probably makes more sense for
reviewers to focus on the other patches: 15 + 19-24 (which also happen to be
smaller). I would particularly most like review of patches 15, 21, & 24
since they are the least like any previously reviewed patches.

There are more changes I plan to make after this series graduates (still
focused around splitting up cache.h), but this series was long enough.

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 (24):
  treewide: be explicit about dependence on trace.h & trace2.h
  treewide: be explicit about dependence on advice.h
  treewide: be explicit about dependence on convert.h
  treewide: be explicit about dependence on pack-revindex.h
  treewide: be explicit about dependence on oid-array.h
  treewide: be explicit about dependence on mem-pool.h
  treewide: remove unnecessary cache.h inclusion
  object-name.h: move declarations for object-name.c functions from
    cache.h
  treewide: remove cache.h inclusion due to object-name.h changes
  git-zlib: move declarations for git-zlib functions from cache.h
  treewide: remove cache.h inclusion due to git-zlib changes
  object-file.h: move declarations for object-file.c functions from
    cache.h
  treewide: remove cache.h inclusion due to object-file.h changes
  object.h: move an inline function and some defines from cache.h
  editor: move editor-related functions and declarations into common
    file
  treewide: remove cache.h inclusion due to editor.h changes
  pager.h: move declarations for pager.c functions from cache.h
  treewide: remove cache.h inclusion due to pager.h changes
  cache.h: remove unnecessary includes
  strbuf: move forward declarations to beginning of file
  treewide: remove double forward declaration of read_in_full
  treewide: reduce includes of cache.h in other headers
  chdir-notify, quote: replace cache.h include with path.h
  mailmap, quote: move declarations of global vars to correct unit

 Makefile                                 |   2 +-
 add-patch.c                              |   3 +
 apply.c                                  |   2 +
 archive-tar.c                            |   1 +
 archive-zip.c                            |   1 +
 archive.c                                |   1 +
 archive.h                                |   3 +-
 blame.c                                  |   2 +
 branch.c                                 |   4 +-
 builtin/add.c                            |   2 +
 builtin/am.c                             |   4 +
 builtin/bisect.c                         |   2 +
 builtin/blame.c                          |   2 +
 builtin/branch.c                         |   2 +
 builtin/bugreport.c                      |   2 +
 builtin/cat-file.c                       |   3 +
 builtin/check-attr.c                     |   1 +
 builtin/checkout.c                       |   3 +
 builtin/clone.c                          |   3 +
 builtin/commit-graph.c                   |   1 +
 builtin/commit-tree.c                    |   1 +
 builtin/commit.c                         |   3 +
 builtin/config.c                         |   1 +
 builtin/credential-cache--daemon.c       |   1 +
 builtin/describe.c                       |   1 +
 builtin/diagnose.c                       |   1 +
 builtin/difftool.c                       |   1 +
 builtin/fast-export.c                    |   1 +
 builtin/fast-import.c                    |   2 +
 builtin/fetch.c                          |   6 +
 builtin/fsck.c                           |   2 +
 builtin/fsmonitor--daemon.c              |   1 +
 builtin/gc.c                             |   2 +
 builtin/grep.c                           |   3 +
 builtin/hash-object.c                    |   1 +
 builtin/help.c                           |   1 +
 builtin/index-pack.c                     |   3 +
 builtin/init-db.c                        |   1 +
 builtin/log.c                            |   4 +
 builtin/ls-files.c                       |   2 +
 builtin/ls-tree.c                        |   1 +
 builtin/merge-base.c                     |   1 +
 builtin/merge-recursive.c                |   2 +
 builtin/merge-tree.c                     |   1 +
 builtin/merge.c                          |   3 +
 builtin/mktag.c                          |   1 +
 builtin/mv.c                             |   2 +
 builtin/name-rev.c                       |   2 +
 builtin/notes.c                          |   2 +
 builtin/pack-objects.c                   |   1 +
 builtin/prune.c                          |   1 +
 builtin/pull.c                           |   2 +
 builtin/push.c                           |   2 +
 builtin/range-diff.c                     |   1 +
 builtin/read-tree.c                      |   1 +
 builtin/rebase.c                         |   3 +
 builtin/receive-pack.c                   |   3 +
 builtin/replace.c                        |   3 +
 builtin/reset.c                          |   4 +
 builtin/rev-list.c                       |   1 +
 builtin/rev-parse.c                      |   1 +
 builtin/rm.c                             |   1 +
 builtin/show-branch.c                    |   1 +
 builtin/show-ref.c                       |   1 +
 builtin/sparse-checkout.c                |   2 +
 builtin/stash.c                          |   1 +
 builtin/submodule--helper.c              |   2 +
 builtin/tag.c                            |   3 +
 builtin/unpack-file.c                    |   1 +
 builtin/unpack-objects.c                 |   1 +
 builtin/update-index.c                   |   1 +
 builtin/update-ref.c                     |   1 +
 builtin/var.c                            |   2 +
 builtin/verify-commit.c                  |   1 +
 builtin/verify-tag.c                     |   1 +
 builtin/worktree.c                       |   2 +
 bulk-checkin.c                           |   4 +-
 bundle.c                                 |   2 +-
 cache-tree.c                             |   3 +
 cache.h                                  | 279 +----------------------
 chdir-notify.c                           |   4 +-
 checkout.c                               |   4 +-
 color.c                                  |   2 +
 column.c                                 |   3 +-
 combine-diff.c                           |   3 +
 commit-graph.c                           |   4 +-
 commit.c                                 |   1 +
 common-main.c                            |   1 +
 compat/fsmonitor/fsm-listen-win32.c      |   1 +
 compat/mingw.c                           |   1 +
 compat/pread.c                           |   1 +
 compat/simple-ipc/ipc-unix-socket.c      |   3 +-
 compat/simple-ipc/ipc-win32.c            |   2 +
 compat/win32/trace2_win32_process_info.c |   1 +
 config.c                                 |   6 +
 connect.c                                |   3 +-
 convert.c                                |   3 +
 date.c                                   |   1 +
 delta-islands.c                          |   2 +-
 diff-lib.c                               |   2 +
 diff.c                                   |   5 +
 dir.c                                    |   3 +
 editor.c                                 |  34 ++-
 editor.h                                 |  34 +++
 environment.c                            |   4 +-
 exec-cmd.c                               |   2 +
 fetch-pack.c                             |   3 +-
 fmt-merge-msg.c                          |   3 +-
 fsck.c                                   |   2 +-
 fsmonitor.c                              |   1 +
 fsmonitor.h                              |   1 +
 git-compat-util.h                        |   6 -
 zlib.c => git-zlib.c                     |   3 +-
 git-zlib.h                               |  28 +++
 git.c                                    |   3 +
 grep.c                                   |   1 +
 http-backend.c                           |   3 +-
 http-fetch.c                             |   2 +-
 http-push.c                              |   2 +-
 http-walker.c                            |   2 +-
 http.c                                   |   2 +
 http.h                                   |   4 +-
 list-objects-filter.c                    |   1 +
 list-objects.c                           |   2 +-
 ll-merge.c                               |   1 +
 log-tree.c                               |   1 +
 mailmap.c                                |   3 +-
 mailmap.h                                |   3 +
 merge-ort.c                              |   4 +
 merge-recursive.c                        |   1 +
 midx.c                                   |   1 +
 name-hash.c                              |   1 +
 notes-merge.c                            |   6 +-
 notes.c                                  |   3 +-
 object-file.c                            |   2 +
 object-file.h                            | 121 ++++++++++
 object-name.c                            |   2 +
 object-name.h                            |  99 ++++++++
 object.c                                 |   1 +
 object.h                                 |  21 ++
 pack-bitmap-write.c                      |   2 +-
 pack-bitmap.c                            |   4 +-
 pack-check.c                             |   3 +-
 pack-mtimes.c                            |   3 +-
 pack-revindex.c                          |   4 +-
 pack-write.c                             |   4 +-
 packfile.c                               |   3 +
 pager.c                                  |   6 +-
 pager.h                                  |  17 ++
 parse-options-cb.c                       |   1 +
 path.c                                   |   1 +
 pkt-line.c                               |   1 +
 preload-index.c                          |   1 +
 pretty.c                                 |   3 +-
 progress.c                               |   4 +-
 promisor-remote.c                        |   3 +-
 protocol.c                               |   3 +-
 quote.c                                  |   3 +-
 quote.h                                  |   2 +
 range-diff.c                             |   2 +
 read-cache.c                             |   5 +
 rebase-interactive.c                     |   2 +
 ref-filter.c                             |   2 +
 refs.c                                   |   4 +-
 refs/files-backend.c                     |   1 +
 refs/packed-backend.c                    |   1 +
 refs/ref-cache.h                         |   2 +-
 remote-curl.c                            |   1 +
 remote.c                                 |   3 +-
 repository.c                             |   1 +
 rerere.c                                 |   3 +-
 reset.c                                  |   1 +
 resolve-undo.h                           |   7 +-
 revision.c                               |   4 +-
 run-command.c                            |   2 +
 scalar.c                                 |   3 +-
 send-pack.c                              |   1 +
 sequencer.c                              |   4 +
 server-info.c                            |   1 +
 setup.c                                  |   5 +-
 shallow.c                                |   1 +
 sideband.c                               |   3 +-
 split-index.c                            |   1 +
 split-index.h                            |   2 +-
 strbuf.c                                 |  31 +--
 strbuf.h                                 |  33 +--
 streaming.c                              |   4 +-
 submodule-config.c                       |   3 +-
 submodule.c                              |   3 +
 t/helper/test-date.c                     |   2 +-
 t/helper/test-fast-rebase.c              |   1 +
 t/helper/test-lazy-init-name-hash.c      |   1 +
 t/helper/test-match-trees.c              |   1 +
 t/helper/test-mergesort.c                |   1 +
 t/helper/test-oidmap.c                   |   2 +-
 t/helper/test-path-utils.c               |   1 +
 t/helper/test-reach.c                    |   2 +-
 t/helper/test-submodule-config.c         |   2 +-
 tag.c                                    |   1 +
 tmp-objdir.c                             |   3 +-
 trace.c                                  |   3 +-
 trace2.c                                 |   1 +
 transport-helper.c                       |   3 +-
 transport.c                              |   3 +
 tree-walk.c                              |   2 +
 tree.c                                   |   1 +
 unpack-trees.c                           |   2 +
 unpack-trees.h                           |   1 +
 upload-pack.c                            |   5 +-
 walker.c                                 |   2 +-
 wrapper.c                                |   1 +
 wt-status.c                              |   4 +
 212 files changed, 743 insertions(+), 404 deletions(-)
 create mode 100644 editor.h
 rename zlib.c => git-zlib.c (99%)
 create mode 100644 git-zlib.h
 create mode 100644 object-file.h
 create mode 100644 object-name.h
 create mode 100644 pager.h


base-commit: dc1c48a4a2bce29542f330137106c01daa728f9e
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1509%2Fnewren%2Fheader-cleanup-3-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1509/newren/header-cleanup-3-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1509
-- 
gitgitgadget

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

* [PATCH 01/24] treewide: be explicit about dependence on trace.h & trace2.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 02/24] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
                   ` (24 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Dozens of files made use of trace and trace2 functions, without
explicitly including trace.h or trace2.h.  This made it more difficult
to find which files could remove a dependence on cache.h.  Make C files
explicitly include trace.h or trace2.h if they are using them.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 blame.c                                  | 1 +
 builtin/checkout.c                       | 1 +
 builtin/commit-graph.c                   | 1 +
 builtin/fetch.c                          | 2 ++
 builtin/fsmonitor--daemon.c              | 1 +
 builtin/gc.c                             | 1 +
 builtin/push.c                           | 1 +
 builtin/rebase.c                         | 1 +
 builtin/receive-pack.c                   | 2 ++
 builtin/reset.c                          | 2 ++
 cache-tree.c                             | 2 ++
 cache.h                                  | 2 --
 chdir-notify.c                           | 1 +
 common-main.c                            | 1 +
 compat/fsmonitor/fsm-listen-win32.c      | 1 +
 compat/mingw.c                           | 1 +
 compat/simple-ipc/ipc-unix-socket.c      | 1 +
 compat/simple-ipc/ipc-win32.c            | 2 ++
 compat/win32/trace2_win32_process_info.c | 1 +
 config.c                                 | 1 +
 connect.c                                | 1 +
 convert.c                                | 1 +
 diff-lib.c                               | 1 +
 dir.c                                    | 1 +
 environment.c                            | 1 +
 exec-cmd.c                               | 2 ++
 fetch-pack.c                             | 1 +
 fsmonitor.c                              | 1 +
 fsmonitor.h                              | 1 +
 git.c                                    | 2 ++
 http.c                                   | 1 +
 merge-ort.c                              | 1 +
 name-hash.c                              | 1 +
 notes-merge.c                            | 1 +
 pack-bitmap.c                            | 1 +
 pack-revindex.c                          | 1 +
 packfile.c                               | 1 +
 pkt-line.c                               | 1 +
 preload-index.c                          | 1 +
 progress.c                               | 1 +
 promisor-remote.c                        | 1 +
 protocol.c                               | 1 +
 read-cache.c                             | 1 +
 remote-curl.c                            | 1 +
 repository.c                             | 1 +
 revision.c                               | 1 +
 run-command.c                            | 2 ++
 scalar.c                                 | 1 +
 setup.c                                  | 1 +
 shallow.c                                | 1 +
 submodule.c                              | 1 +
 t/helper/test-date.c                     | 1 +
 t/helper/test-lazy-init-name-hash.c      | 1 +
 t/helper/test-path-utils.c               | 1 +
 trace.c                                  | 1 +
 trace2.c                                 | 1 +
 transport.c                              | 1 +
 tree-walk.c                              | 1 +
 unpack-trees.c                           | 1 +
 upload-pack.c                            | 1 +
 wrapper.c                                | 1 +
 wt-status.c                              | 2 ++
 62 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/blame.c b/blame.c
index 62db9807640..3455f6a5ea3 100644
--- a/blame.c
+++ b/blame.c
@@ -9,6 +9,7 @@
 #include "hex.h"
 #include "setup.h"
 #include "tag.h"
+#include "trace2.h"
 #include "blame.h"
 #include "alloc.h"
 #include "commit-slab.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 38a8cd6a965..422ea768404 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 90114269761..a3d00fa232b 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -12,6 +12,7 @@
 #include "progress.h"
 #include "replace-object.h"
 #include "tag.h"
+#include "trace2.h"
 
 #define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \
 	N_("git commit-graph verify [--object-dir <dir>] [--shallow] [--[no-]progress]")
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 6a6a58d49c9..ffe0e214592 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -31,6 +31,8 @@
 #include "promisor-remote.h"
 #include "commit-graph.h"
 #include "shallow.h"
+#include "trace.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "bundle-uri.h"
 
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index a280d8bb14f..df876b41d65 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -14,6 +14,7 @@
 #include "simple-ipc.h"
 #include "khash.h"
 #include "pkt-line.h"
+#include "trace2.h"
 
 static const char * const builtin_fsmonitor__daemon_usage[] = {
 	N_("git fsmonitor--daemon start [<options>]"),
diff --git a/builtin/gc.c b/builtin/gc.c
index b291e23b13d..000a2ef5e11 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -37,6 +37,7 @@
 #include "gettext.h"
 #include "hook.h"
 #include "setup.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 #define FAILED_RUN "failed to run %s"
diff --git a/builtin/push.c b/builtin/push.c
index fa550b8f80a..a99ba38a368 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -16,6 +16,7 @@
 #include "submodule.h"
 #include "submodule-config.h"
 #include "send-pack.h"
+#include "trace2.h"
 #include "color.h"
 
 static const char * const push_usage[] = {
diff --git a/builtin/rebase.c b/builtin/rebase.c
index dbc8f90ef04..fb859f93a30 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -32,6 +32,7 @@
 #include "sequencer.h"
 #include "rebase-interactive.h"
 #include "reset.h"
+#include "trace2.h"
 #include "hook.h"
 #include "wrapper.h"
 
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 2ba5a74ba7b..aa5b6fe861f 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -32,6 +32,8 @@
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
+#include "trace.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "shallow.h"
 #include "wrapper.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 0ed329236c8..4d639ec6b37 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -29,6 +29,8 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace.h"
+#include "trace2.h"
 #include "dir.h"
 #include "add-interactive.h"
 
diff --git a/cache-tree.c b/cache-tree.c
index ff14b527da3..39f0c744727 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -11,6 +11,8 @@
 #include "replace-object.h"
 #include "promisor-remote.h"
 #include "sparse-index.h"
+#include "trace.h"
+#include "trace2.h"
 
 #ifndef DEBUG_CACHE_TREE
 #define DEBUG_CACHE_TREE 0
diff --git a/cache.h b/cache.h
index 82d7b112b4e..c8ae80fded3 100644
--- a/cache.h
+++ b/cache.h
@@ -8,8 +8,6 @@
 #include "advice.h"
 #include "gettext.h"
 #include "convert.h"
-#include "trace.h"
-#include "trace2.h"
 #include "string-list.h"
 #include "pack-revindex.h"
 #include "hash.h"
diff --git a/chdir-notify.c b/chdir-notify.c
index 929ec01b3a2..8e38cd6f3ae 100644
--- a/chdir-notify.c
+++ b/chdir-notify.c
@@ -3,6 +3,7 @@
 #include "chdir-notify.h"
 #include "list.h"
 #include "strbuf.h"
+#include "trace.h"
 
 struct chdir_notify_entry {
 	const char *name;
diff --git a/common-main.c b/common-main.c
index b83cb5cf066..f3193173535 100644
--- a/common-main.c
+++ b/common-main.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "attr.h"
 #include "setup.h"
+#include "trace2.h"
 
 /*
  * Many parts of Git have subprograms communicate via pipe, expect the
diff --git a/compat/fsmonitor/fsm-listen-win32.c b/compat/fsmonitor/fsm-listen-win32.c
index 7b07b74ba5b..677b1bbdeca 100644
--- a/compat/fsmonitor/fsm-listen-win32.c
+++ b/compat/fsmonitor/fsm-listen-win32.c
@@ -4,6 +4,7 @@
 #include "fsm-listen.h"
 #include "fsmonitor--daemon.h"
 #include "gettext.h"
+#include "trace2.h"
 
 /*
  * The documentation of ReadDirectoryChangesW() states that the maximum
diff --git a/compat/mingw.c b/compat/mingw.c
index 94c5a1daa40..abbc3faf32f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -12,6 +12,7 @@
 #include "win32/lazyload.h"
 #include "../config.h"
 #include "../environment.h"
+#include "../trace2.h"
 #include "../wrapper.h"
 #include "dir.h"
 #include "gettext.h"
diff --git a/compat/simple-ipc/ipc-unix-socket.c b/compat/simple-ipc/ipc-unix-socket.c
index 152db60a311..7064475b39f 100644
--- a/compat/simple-ipc/ipc-unix-socket.c
+++ b/compat/simple-ipc/ipc-unix-socket.c
@@ -4,6 +4,7 @@
 #include "strbuf.h"
 #include "pkt-line.h"
 #include "thread-utils.h"
+#include "trace2.h"
 #include "unix-socket.h"
 #include "unix-stream-server.h"
 
diff --git a/compat/simple-ipc/ipc-win32.c b/compat/simple-ipc/ipc-win32.c
index 997f6144344..6adce3c650e 100644
--- a/compat/simple-ipc/ipc-win32.c
+++ b/compat/simple-ipc/ipc-win32.c
@@ -5,6 +5,8 @@
 #include "strbuf.h"
 #include "pkt-line.h"
 #include "thread-utils.h"
+#include "trace.h"
+#include "trace2.h"
 #include "accctrl.h"
 #include "aclapi.h"
 
diff --git a/compat/win32/trace2_win32_process_info.c b/compat/win32/trace2_win32_process_info.c
index a53fd924340..e3e895c78a2 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 "../../trace2.h"
 #include "lazyload.h"
 #include <Psapi.h>
 #include <tlHelp32.h>
diff --git a/config.c b/config.c
index 5ad9ae91436..e5c2e477319 100644
--- a/config.c
+++ b/config.c
@@ -28,6 +28,7 @@
 #include "replace-object.h"
 #include "refs.h"
 #include "setup.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "wrapper.h"
 #include "write-or-die.h"
diff --git a/connect.c b/connect.c
index 737dd906f72..929f72ec5d7 100644
--- a/connect.c
+++ b/connect.c
@@ -14,6 +14,7 @@
 #include "string-list.h"
 #include "oid-array.h"
 #include "transport.h"
+#include "trace2.h"
 #include "strbuf.h"
 #include "version.h"
 #include "protocol.h"
diff --git a/convert.c b/convert.c
index da06e2f51cb..126036ec330 100644
--- a/convert.c
+++ b/convert.c
@@ -9,6 +9,7 @@
 #include "sigchain.h"
 #include "pkt-line.h"
 #include "sub-process.h"
+#include "trace.h"
 #include "utf8.h"
 #include "ll-merge.h"
 #include "wrapper.h"
diff --git a/diff-lib.c b/diff-lib.c
index 4169dd8cb13..8b5cca96ace 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -13,6 +13,7 @@
 #include "unpack-trees.h"
 #include "refs.h"
 #include "submodule.h"
+#include "trace.h"
 #include "dir.h"
 #include "fsmonitor.h"
 #include "commit-reach.h"
diff --git a/dir.c b/dir.c
index 18fd14c46b2..10f6c38b930 100644
--- a/dir.c
+++ b/dir.c
@@ -23,6 +23,7 @@
 #include "fsmonitor.h"
 #include "setup.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 /*
diff --git a/environment.c b/environment.c
index 63c697e7e97..2254595e4a8 100644
--- a/environment.c
+++ b/environment.c
@@ -24,6 +24,7 @@
 #include "chdir-notify.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/exec-cmd.c b/exec-cmd.c
index fae0d4b244a..6f618463896 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -5,6 +5,8 @@
 #include "gettext.h"
 #include "quote.h"
 #include "strvec.h"
+#include "trace.h"
+#include "trace2.h"
 
 #if defined(RUNTIME_PREFIX)
 
diff --git a/fetch-pack.c b/fetch-pack.c
index 368f2ed25a1..7d4f190fb1d 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -17,6 +17,7 @@
 #include "remote.h"
 #include "run-command.h"
 #include "connect.h"
+#include "trace2.h"
 #include "transport.h"
 #include "version.h"
 #include "oid-array.h"
diff --git a/fsmonitor.c b/fsmonitor.c
index c956a347a27..28c083d4d84 100644
--- a/fsmonitor.c
+++ b/fsmonitor.c
@@ -7,6 +7,7 @@
 #include "fsmonitor-ipc.h"
 #include "run-command.h"
 #include "strbuf.h"
+#include "trace2.h"
 
 #define INDEX_EXTENSION_VERSION1	(1)
 #define INDEX_EXTENSION_VERSION2	(2)
diff --git a/fsmonitor.h b/fsmonitor.h
index edf7ce5203b..67faf592e12 100644
--- a/fsmonitor.h
+++ b/fsmonitor.h
@@ -4,6 +4,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "fsmonitor-settings.h"
+#include "trace.h"
 
 extern struct trace_key trace_fsmonitor;
 
diff --git a/git.c b/git.c
index 77f920a6f6f..d2bb86e0d32 100644
--- a/git.c
+++ b/git.c
@@ -9,6 +9,8 @@
 #include "replace-object.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace.h"
+#include "trace2.h"
 
 #define RUN_SETUP		(1<<0)
 #define RUN_SETUP_GENTLY	(1<<1)
diff --git a/http.c b/http.c
index dbe4d29ef7a..0212c0ad3b2 100644
--- a/http.c
+++ b/http.c
@@ -12,6 +12,7 @@
 #include "version.h"
 #include "pkt-line.h"
 #include "gettext.h"
+#include "trace.h"
 #include "transport.h"
 #include "packfile.h"
 #include "protocol.h"
diff --git a/merge-ort.c b/merge-ort.c
index 5bf64354d16..ad7367179d9 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -37,6 +37,7 @@
 #include "strmap.h"
 #include "submodule-config.h"
 #include "submodule.h"
+#include "trace2.h"
 #include "tree.h"
 #include "unpack-trees.h"
 #include "xdiff-interface.h"
diff --git a/name-hash.c b/name-hash.c
index 2c2861efd1c..fb13716e430 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -9,6 +9,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "thread-utils.h"
+#include "trace.h"
 #include "trace2.h"
 #include "sparse-index.h"
 
diff --git a/notes-merge.c b/notes-merge.c
index c40107c3aa0..19405ec71ac 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -13,6 +13,7 @@
 #include "notes.h"
 #include "notes-merge.h"
 #include "strbuf.h"
+#include "trace.h"
 #include "notes-utils.h"
 #include "commit-reach.h"
 #include "wrapper.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 23d87e71bd9..eba838d24ee 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -15,6 +15,7 @@
 #include "pack-objects.h"
 #include "packfile.h"
 #include "repository.h"
+#include "trace2.h"
 #include "object-store.h"
 #include "list-objects-filter-options.h"
 #include "midx.h"
diff --git a/pack-revindex.c b/pack-revindex.c
index 03c7e81f9da..9f9927d9471 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -3,6 +3,7 @@
 #include "pack-revindex.h"
 #include "object-store.h"
 #include "packfile.h"
+#include "trace2.h"
 #include "config.h"
 #include "midx.h"
 
diff --git a/packfile.c b/packfile.c
index b120405ccc8..2d3dabb1aee 100644
--- a/packfile.c
+++ b/packfile.c
@@ -15,6 +15,7 @@
 #include "commit.h"
 #include "object.h"
 #include "tag.h"
+#include "trace.h"
 #include "tree-walk.h"
 #include "tree.h"
 #include "object-store.h"
diff --git a/pkt-line.c b/pkt-line.c
index 36ae0fea4a3..3561d853584 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "run-command.h"
+#include "trace.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/preload-index.c b/preload-index.c
index 52544d004e7..4abf9c983b2 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "thread-utils.h"
 #include "repository.h"
+#include "trace2.h"
 
 /*
  * Mostly randomly chosen maximum thread counts: we
diff --git a/progress.c b/progress.c
index 44c784d75f1..c5c8514737a 100644
--- a/progress.c
+++ b/progress.c
@@ -13,6 +13,7 @@
 #include "progress.h"
 #include "strbuf.h"
 #include "trace.h"
+#include "trace2.h"
 #include "utf8.h"
 #include "config.h"
 
diff --git a/promisor-remote.c b/promisor-remote.c
index a8dbb788e8f..9d83d2f4b9c 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -4,6 +4,7 @@
 #include "object-store.h"
 #include "promisor-remote.h"
 #include "config.h"
+#include "trace2.h"
 #include "transport.h"
 #include "strvec.h"
 #include "packfile.h"
diff --git a/protocol.c b/protocol.c
index bdb32e1eeb6..4d8eb887e82 100644
--- a/protocol.c
+++ b/protocol.c
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "environment.h"
 #include "protocol.h"
+#include "trace2.h"
 
 static enum protocol_version parse_protocol_version(const char *value)
 {
diff --git a/read-cache.c b/read-cache.c
index e5e72169047..a744eb89e4e 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -23,6 +23,7 @@
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
+#include "trace2.h"
 #include "varint.h"
 #include "split-index.h"
 #include "utf8.h"
diff --git a/remote-curl.c b/remote-curl.c
index 0f2410da8e7..0ada1dd8026 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -21,6 +21,7 @@
 #include "setup.h"
 #include "protocol.h"
 #include "quote.h"
+#include "trace2.h"
 #include "transport.h"
 #include "write-or-die.h"
 
diff --git a/repository.c b/repository.c
index f6d9f5db08e..c53e480e326 100644
--- a/repository.c
+++ b/repository.c
@@ -14,6 +14,7 @@
 #include "setup.h"
 #include "submodule-config.h"
 #include "sparse-index.h"
+#include "trace2.h"
 #include "promisor-remote.h"
 
 /* The main repository */
diff --git a/revision.c b/revision.c
index cd3e841433a..7c34c93885e 100644
--- a/revision.c
+++ b/revision.c
@@ -31,6 +31,7 @@
 #include "worktree.h"
 #include "setup.h"
 #include "strvec.h"
+#include "trace2.h"
 #include "commit-reach.h"
 #include "commit-graph.h"
 #include "prio-queue.h"
diff --git a/run-command.c b/run-command.c
index 614d48fa9a2..e64bb08a5bf 100644
--- a/run-command.c
+++ b/run-command.c
@@ -8,6 +8,8 @@
 #include "thread-utils.h"
 #include "strbuf.h"
 #include "string-list.h"
+#include "trace.h"
+#include "trace2.h"
 #include "quote.h"
 #include "config.h"
 #include "packfile.h"
diff --git a/scalar.c b/scalar.c
index 27635658c01..f7680463e1b 100644
--- a/scalar.c
+++ b/scalar.c
@@ -16,6 +16,7 @@
 #include "packfile.h"
 #include "help.h"
 #include "setup.h"
+#include "trace2.h"
 
 static void setup_enlistment_directory(int argc, const char **argv,
 				       const char * const *usagestr,
diff --git a/setup.c b/setup.c
index 6c5b85e96c1..3bb7a9fff62 100644
--- a/setup.c
+++ b/setup.c
@@ -10,6 +10,7 @@
 #include "chdir-notify.h"
 #include "promisor-remote.h"
 #include "quote.h"
+#include "trace2.h"
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
diff --git a/shallow.c b/shallow.c
index b4d726bd595..128f56179ed 100644
--- a/shallow.c
+++ b/shallow.c
@@ -17,6 +17,7 @@
 #include "list-objects.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "trace.h"
 #include "wrapper.h"
 
 void set_alternate_shallow_file(struct repository *r, const char *path, int override)
diff --git a/submodule.c b/submodule.c
index d7d0a8a0834..58c9d5e5673 100644
--- a/submodule.c
+++ b/submodule.c
@@ -28,6 +28,7 @@
 #include "commit-reach.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace2.h"
 
 static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
 static int initialized_fetch_ref_tips;
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index 45951b1df87..a01eec99f35 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "date.h"
+#include "trace.h"
 
 static const char *usage_msg = "\n"
 "  test-tool date relative [time_t]...\n"
diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c
index 06ce3a47ccf..f23d983c118 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "parse-options.h"
 #include "setup.h"
+#include "trace.h"
 
 static int single;
 static int multi;
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 4f5ac2fadce..6355c9e4b6d 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "setup.h"
 #include "string-list.h"
+#include "trace.h"
 #include "utf8.h"
 
 /*
diff --git a/trace.c b/trace.c
index 81318a2455d..d8eaa0a786a 100644
--- a/trace.c
+++ b/trace.c
@@ -26,6 +26,7 @@
 #include "environment.h"
 #include "quote.h"
 #include "setup.h"
+#include "trace.h"
 #include "wrapper.h"
 
 struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
diff --git a/trace2.c b/trace2.c
index e8ba62c0c3d..21264df71b7 100644
--- a/trace2.c
+++ b/trace2.c
@@ -7,6 +7,7 @@
 #include "thread-utils.h"
 #include "version.h"
 #include "trace.h"
+#include "trace2.h"
 #include "trace2/tr2_cfg.h"
 #include "trace2/tr2_cmd_name.h"
 #include "trace2/tr2_ctr.h"
diff --git a/transport.c b/transport.c
index d2a1af43b5c..11b38d16dcf 100644
--- a/transport.c
+++ b/transport.c
@@ -22,6 +22,7 @@
 #include "string-list.h"
 #include "oid-array.h"
 #include "sigchain.h"
+#include "trace2.h"
 #include "transport-internal.h"
 #include "protocol.h"
 #include "object-store.h"
diff --git a/tree-walk.c b/tree-walk.c
index 38b6556478d..59add24c8e9 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
+#include "trace2.h"
 #include "tree.h"
 #include "pathspec.h"
 #include "json-writer.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index 4a5522bdb26..d41489b4adb 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -17,6 +17,7 @@
 #include "sparse-index.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "fsmonitor.h"
 #include "object-store.h"
 #include "promisor-remote.h"
diff --git a/upload-pack.c b/upload-pack.c
index e23f16dfdd2..71440c63806 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -22,6 +22,7 @@
 #include "version.h"
 #include "string-list.h"
 #include "strvec.h"
+#include "trace2.h"
 #include "prio-queue.h"
 #include "protocol.h"
 #include "quote.h"
diff --git a/wrapper.c b/wrapper.c
index ee837575902..c130d7518bf 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 static intmax_t count_fsync_writeout_only;
diff --git a/wt-status.c b/wt-status.c
index 4bef09de1ca..ccbfd9cc6de 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -18,6 +18,8 @@
 #include "column.h"
 #include "setup.h"
 #include "strbuf.h"
+#include "trace.h"
+#include "trace2.h"
 #include "utf8.h"
 #include "worktree.h"
 #include "lockfile.h"
-- 
gitgitgadget


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

* [PATCH 02/24] treewide: be explicit about dependence on advice.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 03/24] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
                   ` (23 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Dozens of files made use of advice functions, without explicitly
including advice.h.  This made it more difficult to find which files
could remove a dependence on cache.h.  Make C files explicitly include
advice.h if they are using it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 add-patch.c               | 1 +
 branch.c                  | 1 +
 builtin/add.c             | 1 +
 builtin/am.c              | 1 +
 builtin/clone.c           | 1 +
 builtin/commit.c          | 1 +
 builtin/fetch.c           | 1 +
 builtin/merge-recursive.c | 1 +
 builtin/merge.c           | 1 +
 builtin/mv.c              | 1 +
 builtin/pull.c            | 1 +
 builtin/push.c            | 1 +
 builtin/reset.c           | 1 +
 builtin/tag.c             | 1 +
 cache.h                   | 1 -
 config.c                  | 1 +
 convert.c                 | 1 +
 editor.c                  | 1 +
 notes-merge.c             | 1 +
 object-name.c             | 1 +
 refs.c                    | 1 +
 sequencer.c               | 1 +
 transport.c               | 1 +
 unpack-trees.c            | 1 +
 wt-status.c               | 1 +
 25 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/add-patch.c b/add-patch.c
index 1e1ee2df596..b381f14a7de 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "add-interactive.h"
+#include "advice.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/branch.c b/branch.c
index 99a0e7889e4..3a087b8b4c1 100644
--- a/branch.c
+++ b/branch.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "branch.h"
 #include "environment.h"
diff --git a/builtin/add.c b/builtin/add.c
index f12054d9be1..d3c51e28142 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -5,6 +5,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "lockfile.h"
diff --git a/builtin/am.c b/builtin/am.c
index cd1e20f24e5..8d876f31546 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -6,6 +6,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "environment.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index c171def1f3e..f1e8aa3f27e 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -11,6 +11,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 9d8e1ea91a3..b09017e04f9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -7,6 +7,7 @@
 
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "lockfile.h"
 #include "cache-tree.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index ffe0e214592..f2b80987751 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2,6 +2,7 @@
  * "git fetch"
  */
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "gettext.h"
 #include "environment.h"
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 8ea9dc78aa1..25f42f2be7e 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "builtin.h"
+#include "advice.h"
 #include "commit.h"
 #include "gettext.h"
 #include "tag.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index a99be9610e9..225b7064066 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -9,6 +9,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index b7c5ffbd8c7..8f7770aa32b 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -6,6 +6,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/builtin/pull.c b/builtin/pull.c
index 5405d09f22f..636ce12c94d 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -7,6 +7,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "gettext.h"
diff --git a/builtin/push.c b/builtin/push.c
index a99ba38a368..6001e4ae0a4 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -2,6 +2,7 @@
  * "git push"
  */
 #include "cache.h"
+#include "advice.h"
 #include "branch.h"
 #include "config.h"
 #include "environment.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 4d639ec6b37..d8c52cc6edf 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -9,6 +9,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index bfd51389571..3e801f54a07 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -7,6 +7,7 @@
  */
 
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "environment.h"
diff --git a/cache.h b/cache.h
index c8ae80fded3..d9ca2688d8c 100644
--- a/cache.h
+++ b/cache.h
@@ -5,7 +5,6 @@
 #include "strbuf.h"
 #include "hashmap.h"
 #include "list.h"
-#include "advice.h"
 #include "gettext.h"
 #include "convert.h"
 #include "string-list.h"
diff --git a/config.c b/config.c
index e5c2e477319..3cee6538f3f 100644
--- a/config.c
+++ b/config.c
@@ -7,6 +7,7 @@
  */
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "date.h"
 #include "branch.h"
diff --git a/convert.c b/convert.c
index 126036ec330..59127706448 100644
--- a/convert.c
+++ b/convert.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/editor.c b/editor.c
index d632d790660..3bea3ef72f7 100644
--- a/editor.c
+++ b/editor.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/notes-merge.c b/notes-merge.c
index 19405ec71ac..0258f87d21f 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
diff --git a/object-name.c b/object-name.c
index 53f9d359ee8..ff647d6c7b5 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/refs.c b/refs.c
index 0f369dbde7a..cfced6f174a 100644
--- a/refs.c
+++ b/refs.c
@@ -3,6 +3,7 @@
  */
 
 #include "cache.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/sequencer.c b/sequencer.c
index 1a315ac13c9..eaba379e3ad 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/transport.c b/transport.c
index 11b38d16dcf..82bf2496ba7 100644
--- a/transport.c
+++ b/transport.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index d41489b4adb..c6de2ca5a7e 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "strvec.h"
 #include "repository.h"
 #include "config.h"
diff --git a/wt-status.c b/wt-status.c
index ccbfd9cc6de..47f223c0f8d 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "wt-status.h"
 #include "object.h"
 #include "dir.h"
-- 
gitgitgadget


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

* [PATCH 03/24] treewide: be explicit about dependence on convert.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 02/24] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 04/24] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
                   ` (22 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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.c          | 1 +
 blame.c            | 1 +
 builtin/cat-file.c | 1 +
 builtin/ls-files.c | 1 +
 cache.h            | 1 -
 combine-diff.c     | 1 +
 config.c           | 1 +
 convert.c          | 1 +
 diff.c             | 1 +
 dir.c              | 1 +
 environment.c      | 1 +
 ll-merge.c         | 1 +
 object-file.c      | 1 +
 streaming.c        | 1 +
 unpack-trees.h     | 1 +
 15 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/archive.c b/archive.c
index f1b8e9ce486..ab8966d73a5 100644
--- a/archive.c
+++ b/archive.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/blame.c b/blame.c
index 3455f6a5ea3..ff2a6c49125 100644
--- a/blame.c
+++ b/blame.c
@@ -3,6 +3,7 @@
 #include "object-store.h"
 #include "cache-tree.h"
 #include "mergesort.h"
+#include "convert.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "gettext.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 04d4bb6c777..1e4b4798f40 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "builtin.h"
 #include "diff.h"
 #include "environment.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 68532f3e51a..7f228353feb 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -8,6 +8,7 @@
 #include "cache.h"
 #include "repository.h"
 #include "config.h"
+#include "convert.h"
 #include "quote.h"
 #include "dir.h"
 #include "builtin.h"
diff --git a/cache.h b/cache.h
index d9ca2688d8c..415f0f85670 100644
--- a/cache.h
+++ b/cache.h
@@ -6,7 +6,6 @@
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
-#include "convert.h"
 #include "string-list.h"
 #include "pack-revindex.h"
 #include "hash.h"
diff --git a/combine-diff.c b/combine-diff.c
index 44ef6a1a812..6586e4508d6 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "object-store.h"
 #include "commit.h"
+#include "convert.h"
 #include "blob.h"
 #include "diff.h"
 #include "diffcore.h"
diff --git a/config.c b/config.c
index 3cee6538f3f..9e74b5aec7f 100644
--- a/config.c
+++ b/config.c
@@ -12,6 +12,7 @@
 #include "date.h"
 #include "branch.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "ident.h"
diff --git a/convert.c b/convert.c
index 59127706448..5a2ea5308d6 100644
--- a/convert.c
+++ b/convert.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "advice.h"
 #include "config.h"
+#include "convert.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/diff.c b/diff.c
index e55a015cfd0..47c1973a504 100644
--- a/diff.c
+++ b/diff.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "tempfile.h"
diff --git a/dir.c b/dir.c
index 10f6c38b930..d1f1b1ef768 100644
--- a/dir.c
+++ b/dir.c
@@ -9,6 +9,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/environment.c b/environment.c
index 2254595e4a8..e57292eccc9 100644
--- a/environment.c
+++ b/environment.c
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "branch.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "repository.h"
diff --git a/ll-merge.c b/ll-merge.c
index 8be38d3bd41..28bc94c45d6 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -6,6 +6,7 @@
 
 #include "cache.h"
 #include "config.h"
+#include "convert.h"
 #include "attr.h"
 #include "xdiff-interface.h"
 #include "run-command.h"
diff --git a/object-file.c b/object-file.c
index 76b22ca75cd..a4331e0da61 100644
--- a/object-file.c
+++ b/object-file.c
@@ -10,6 +10,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/streaming.c b/streaming.c
index 024fd796b7d..27e014d8b23 100644
--- a/streaming.c
+++ b/streaming.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2011, Google Inc.
  */
 #include "cache.h"
+#include "convert.h"
 #include "environment.h"
 #include "streaming.h"
 #include "repository.h"
diff --git a/unpack-trees.h b/unpack-trees.h
index 61c06eb7c50..30622aeebff 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -2,6 +2,7 @@
 #define UNPACK_TREES_H
 
 #include "cache.h"
+#include "convert.h"
 #include "strvec.h"
 #include "string-list.h"
 #include "tree-walk.h"
-- 
gitgitgadget


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

* [PATCH 04/24] treewide: be explicit about dependence on pack-revindex.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (2 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 03/24] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 05/24] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
                   ` (21 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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/index-pack.c | 1 +
 cache.h              | 1 -
 pack-write.c         | 1 +
 packfile.c           | 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index b17e79cd40f..ceb0f120ede 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -17,6 +17,7 @@
 #include "streaming.h"
 #include "thread-utils.h"
 #include "packfile.h"
+#include "pack-revindex.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/cache.h b/cache.h
index 415f0f85670..5f1279454a8 100644
--- a/cache.h
+++ b/cache.h
@@ -7,7 +7,6 @@
 #include "list.h"
 #include "gettext.h"
 #include "string-list.h"
-#include "pack-revindex.h"
 #include "hash.h"
 #include "path.h"
 #include "pathspec.h"
diff --git a/pack-write.c b/pack-write.c
index f1714054951..152c14aa7aa 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -9,6 +9,7 @@
 #include "pack-mtimes.h"
 #include "oidmap.h"
 #include "pack-objects.h"
+#include "pack-revindex.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
 {
diff --git a/packfile.c b/packfile.c
index 2d3dabb1aee..02afbe77137 100644
--- a/packfile.c
+++ b/packfile.c
@@ -21,6 +21,7 @@
 #include "object-store.h"
 #include "midx.h"
 #include "commit-graph.h"
+#include "pack-revindex.h"
 #include "promisor-remote.h"
 #include "wrapper.h"
 
-- 
gitgitgadget


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

* [PATCH 05/24] treewide: be explicit about dependence on oid-array.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (3 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 04/24] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 06/24] treewide: be explicit about dependence on mem-pool.h Elijah Newren via GitGitGadget
                   ` (20 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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/fetch.c      | 1 +
 builtin/index-pack.c | 1 +
 builtin/log.c        | 1 +
 cache.h              | 1 -
 commit-graph.c       | 1 +
 diff.c               | 1 +
 merge-ort.c          | 1 +
 read-cache.c         | 1 +
 ref-filter.c         | 1 +
 upload-pack.c        | 1 +
 11 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/builtin/bisect.c b/builtin/bisect.c
index 26f07357a03..7dc175c6570 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -9,6 +9,7 @@
 #include "dir.h"
 #include "strvec.h"
 #include "run-command.h"
+#include "oid-array.h"
 #include "prompt.h"
 #include "quote.h"
 #include "revision.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index f2b80987751..e0936629213 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -12,6 +12,7 @@
 #include "refspec.h"
 #include "object-store.h"
 #include "oidset.h"
+#include "oid-array.h"
 #include "commit.h"
 #include "builtin.h"
 #include "string-list.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index ceb0f120ede..5adfb2521cd 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -19,6 +19,7 @@
 #include "packfile.h"
 #include "pack-revindex.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
 #include "setup.h"
diff --git a/builtin/log.c b/builtin/log.c
index 2ce645eee97..094897df236 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -20,6 +20,7 @@
 #include "revision.h"
 #include "log-tree.h"
 #include "builtin.h"
+#include "oid-array.h"
 #include "tag.h"
 #include "reflog-walk.h"
 #include "patch-ids.h"
diff --git a/cache.h b/cache.h
index 5f1279454a8..6eac3134a22 100644
--- a/cache.h
+++ b/cache.h
@@ -11,7 +11,6 @@
 #include "path.h"
 #include "pathspec.h"
 #include "object.h"
-#include "oid-array.h"
 #include "repository.h"
 #include "statinfo.h"
 #include "mem-pool.h"
diff --git a/commit-graph.c b/commit-graph.c
index 1bf673b1345..fe9a8b2342f 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -12,6 +12,7 @@
 #include "hash-lookup.h"
 #include "commit-graph.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "alloc.h"
 #include "hashmap.h"
 #include "replace-object.h"
diff --git a/diff.c b/diff.c
index 47c1973a504..89cd0b17da5 100644
--- a/diff.c
+++ b/diff.c
@@ -29,6 +29,7 @@
 #include "string-list.h"
 #include "strvec.h"
 #include "graph.h"
+#include "oid-array.h"
 #include "packfile.h"
 #include "parse-options.h"
 #include "help.h"
diff --git a/merge-ort.c b/merge-ort.c
index ad7367179d9..9b0b184b130 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -32,6 +32,7 @@
 #include "entry.h"
 #include "ll-merge.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "promisor-remote.h"
 #include "revision.h"
 #include "strmap.h"
diff --git a/read-cache.c b/read-cache.c
index a744eb89e4e..1b585ce8424 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -15,6 +15,7 @@
 #include "refs.h"
 #include "dir.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "tree.h"
 #include "commit.h"
 #include "blob.h"
diff --git a/ref-filter.c b/ref-filter.c
index df84bb71643..1c6174c8aed 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -7,6 +7,7 @@
 #include "refs.h"
 #include "wildmatch.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "repository.h"
 #include "commit.h"
 #include "remote.h"
diff --git a/upload-pack.c b/upload-pack.c
index 71440c63806..e17545a834a 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -8,6 +8,7 @@
 #include "sideband.h"
 #include "repository.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "tag.h"
 #include "object.h"
 #include "commit.h"
-- 
gitgitgadget


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

* [PATCH 06/24] treewide: be explicit about dependence on mem-pool.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (4 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 05/24] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 07/24] treewide: remove unnecessary cache.h inclusion Elijah Newren via GitGitGadget
                   ` (19 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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/checkout.c        | 1 +
 cache.h                   | 1 -
 merge-ort.c               | 1 +
 read-cache.c              | 1 +
 split-index.c             | 1 +
 t/helper/test-mergesort.c | 1 +
 6 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 422ea768404..65988fd8a3b 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -15,6 +15,7 @@
 #include "hook.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "mem-pool.h"
 #include "merge-recursive.h"
 #include "object-store.h"
 #include "parse-options.h"
diff --git a/cache.h b/cache.h
index 6eac3134a22..66705dd469e 100644
--- a/cache.h
+++ b/cache.h
@@ -13,7 +13,6 @@
 #include "object.h"
 #include "repository.h"
 #include "statinfo.h"
-#include "mem-pool.h"
 
 typedef struct git_zstream {
 	z_stream z;
diff --git a/merge-ort.c b/merge-ort.c
index 9b0b184b130..1008684fbbc 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -31,6 +31,7 @@
 #include "hex.h"
 #include "entry.h"
 #include "ll-merge.h"
+#include "mem-pool.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "promisor-remote.h"
diff --git a/read-cache.c b/read-cache.c
index 1b585ce8424..4ada6d62b90 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -21,6 +21,7 @@
 #include "blob.h"
 #include "environment.h"
 #include "gettext.h"
+#include "mem-pool.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/split-index.c b/split-index.c
index c98807c655b..5602b74994b 100644
--- a/split-index.c
+++ b/split-index.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "mem-pool.h"
 #include "split-index.h"
 #include "ewah/ewok.h"
 
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
index 335e5bb3a90..737e0c52358 100644
--- a/t/helper/test-mergesort.c
+++ b/t/helper/test-mergesort.c
@@ -1,5 +1,6 @@
 #include "test-tool.h"
 #include "cache.h"
+#include "mem-pool.h"
 #include "mergesort.h"
 
 static uint32_t minstd_rand(uint32_t *state)
-- 
gitgitgadget


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

* [PATCH 07/24] treewide: remove unnecessary cache.h inclusion
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (5 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 06/24] treewide: be explicit about dependence on mem-pool.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 08/24] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren via GitGitGadget
                   ` (18 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Several files were including cache.h solely to get other headers, such
as trace.h and trace2.h.  Since the last few commits have modified
files to make these dependencies more explicit, the inclusion of cache.h
is no longer needed in several cases.  Remove it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 compat/simple-ipc/ipc-unix-socket.c | 2 +-
 connect.c                           | 2 +-
 fetch-pack.c                        | 2 +-
 pack-write.c                        | 2 +-
 promisor-remote.c                   | 2 +-
 protocol.c                          | 2 +-
 scalar.c                            | 2 +-
 t/helper/test-date.c                | 1 -
 trace.c                             | 2 +-
 upload-pack.c                       | 2 +-
 10 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/compat/simple-ipc/ipc-unix-socket.c b/compat/simple-ipc/ipc-unix-socket.c
index 7064475b39f..b2f4f22ce44 100644
--- a/compat/simple-ipc/ipc-unix-socket.c
+++ b/compat/simple-ipc/ipc-unix-socket.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "strbuf.h"
diff --git a/connect.c b/connect.c
index 929f72ec5d7..cf4dd3084e0 100644
--- a/connect.c
+++ b/connect.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/fetch-pack.c b/fetch-pack.c
index 7d4f190fb1d..677102465a1 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "repository.h"
 #include "config.h"
diff --git a/pack-write.c b/pack-write.c
index 152c14aa7aa..d9b460fab4c 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/promisor-remote.c b/promisor-remote.c
index 9d83d2f4b9c..1adcd6fb0a5 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/protocol.c b/protocol.c
index 4d8eb887e82..079ba75acf4 100644
--- a/protocol.c
+++ b/protocol.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "protocol.h"
diff --git a/scalar.c b/scalar.c
index f7680463e1b..af64f75ca66 100644
--- a/scalar.c
+++ b/scalar.c
@@ -2,7 +2,7 @@
  * The Scalar command-line interface.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "gettext.h"
 #include "parse-options.h"
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index a01eec99f35..7adadd41e0b 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "date.h"
 #include "trace.h"
 
diff --git a/trace.c b/trace.c
index d8eaa0a786a..592c141d785 100644
--- a/trace.c
+++ b/trace.c
@@ -21,7 +21,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
 #include "quote.h"
diff --git a/upload-pack.c b/upload-pack.c
index e17545a834a..0305fb2fbdc 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-- 
gitgitgadget


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

* [PATCH 08/24] object-name.h: move declarations for object-name.c functions from cache.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (6 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 07/24] treewide: remove unnecessary cache.h inclusion Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 09/24] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren via GitGitGadget
                   ` (17 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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-patch.c                      |  1 +
 apply.c                          |  1 +
 archive.h                        |  1 +
 branch.c                         |  1 +
 builtin/am.c                     |  1 +
 builtin/bisect.c                 |  1 +
 builtin/blame.c                  |  1 +
 builtin/branch.c                 |  1 +
 builtin/cat-file.c               |  1 +
 builtin/check-attr.c             |  1 +
 builtin/checkout.c               |  1 +
 builtin/commit-tree.c            |  1 +
 builtin/commit.c                 |  1 +
 builtin/describe.c               |  1 +
 builtin/fast-import.c            |  1 +
 builtin/fetch.c                  |  1 +
 builtin/fsck.c                   |  1 +
 builtin/grep.c                   |  1 +
 builtin/log.c                    |  1 +
 builtin/ls-files.c               |  1 +
 builtin/ls-tree.c                |  1 +
 builtin/merge-base.c             |  1 +
 builtin/merge-recursive.c        |  1 +
 builtin/merge-tree.c             |  1 +
 builtin/merge.c                  |  1 +
 builtin/name-rev.c               |  1 +
 builtin/notes.c                  |  1 +
 builtin/prune.c                  |  1 +
 builtin/pull.c                   |  1 +
 builtin/range-diff.c             |  1 +
 builtin/read-tree.c              |  1 +
 builtin/rebase.c                 |  1 +
 builtin/receive-pack.c           |  1 +
 builtin/replace.c                |  1 +
 builtin/reset.c                  |  1 +
 builtin/rev-list.c               |  1 +
 builtin/rev-parse.c              |  1 +
 builtin/rm.c                     |  1 +
 builtin/show-branch.c            |  1 +
 builtin/show-ref.c               |  1 +
 builtin/sparse-checkout.c        |  1 +
 builtin/stash.c                  |  1 +
 builtin/submodule--helper.c      |  1 +
 builtin/tag.c                    |  1 +
 builtin/unpack-file.c            |  1 +
 builtin/update-ref.c             |  1 +
 builtin/verify-commit.c          |  1 +
 builtin/verify-tag.c             |  1 +
 builtin/worktree.c               |  1 +
 cache.h                          | 88 ----------------------------
 checkout.c                       |  1 +
 combine-diff.c                   |  1 +
 commit.c                         |  1 +
 config.c                         |  1 +
 diff-lib.c                       |  1 +
 diff.c                           |  1 +
 fmt-merge-msg.c                  |  1 +
 list-objects-filter.c            |  1 +
 log-tree.c                       |  1 +
 mailmap.c                        |  1 +
 merge-ort.c                      |  1 +
 notes-merge.c                    |  1 +
 notes.c                          |  1 +
 object-name.c                    |  1 +
 object-name.h                    | 99 ++++++++++++++++++++++++++++++++
 parse-options-cb.c               |  1 +
 range-diff.c                     |  1 +
 read-cache.c                     |  1 +
 rebase-interactive.c             |  1 +
 ref-filter.c                     |  1 +
 refs.c                           |  1 +
 remote.c                         |  1 +
 reset.c                          |  1 +
 revision.c                       |  1 +
 sequencer.c                      |  1 +
 setup.c                          |  1 +
 strbuf.c                         |  1 +
 submodule-config.c               |  1 +
 submodule.c                      |  1 +
 t/helper/test-fast-rebase.c      |  1 +
 t/helper/test-match-trees.c      |  1 +
 t/helper/test-oidmap.c           |  1 +
 t/helper/test-reach.c            |  1 +
 t/helper/test-submodule-config.c |  1 +
 tag.c                            |  1 +
 transport-helper.c               |  1 +
 transport.c                      |  1 +
 tree.c                           |  1 +
 wt-status.c                      |  1 +
 89 files changed, 186 insertions(+), 88 deletions(-)
 create mode 100644 object-name.h

diff --git a/add-patch.c b/add-patch.c
index b381f14a7de..b01ba8fa81d 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -4,6 +4,7 @@
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "run-command.h"
 #include "strvec.h"
diff --git a/apply.c b/apply.c
index 9b7288bc927..7e40f53ec4c 100644
--- a/apply.c
+++ b/apply.c
@@ -22,6 +22,7 @@
 #include "xdiff-interface.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "rerere.h"
diff --git a/archive.h b/archive.h
index 7178e2a9a2d..f96839ef383 100644
--- a/archive.h
+++ b/archive.h
@@ -2,6 +2,7 @@
 #define ARCHIVE_H
 
 #include "cache.h"
+#include "object-name.h"
 #include "pathspec.h"
 
 struct repository;
diff --git a/branch.c b/branch.c
index 3a087b8b4c1..f29743b1619 100644
--- a/branch.c
+++ b/branch.c
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "refspec.h"
 #include "remote.h"
diff --git a/builtin/am.c b/builtin/am.c
index 8d876f31546..0d7ee28bddc 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -27,6 +27,7 @@
 #include "diffcore.h"
 #include "unpack-trees.h"
 #include "branch.h"
+#include "object-name.h"
 #include "sequencer.h"
 #include "revision.h"
 #include "merge-recursive.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 7dc175c6570..4b2143d4557 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "bisect.h"
 #include "refs.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index a8d2114adc9..a628388c2ce 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -28,6 +28,7 @@
 #include "line-log.h"
 #include "dir.h"
 #include "progress.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blame.h"
 #include "refs.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index 5706eb00974..7c1c872708f 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -13,6 +13,7 @@
 #include "commit.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "remote.h"
 #include "parse-options.h"
 #include "branch.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 1e4b4798f40..60b7a55dfc1 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -20,6 +20,7 @@
 #include "tree-walk.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 1dbe9d6ca88..037bf1aaa2a 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -5,6 +5,7 @@
 #include "attr.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "quote.h"
 #include "setup.h"
 #include "parse-options.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 65988fd8a3b..6f5d82ed3d3 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -17,6 +17,7 @@
 #include "lockfile.h"
 #include "mem-pool.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "refs.h"
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 15be167f87a..d1d251c3ded 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index b09017e04f9..682f47c8d5a 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -27,6 +27,7 @@
 #include "log-tree.h"
 #include "strbuf.h"
 #include "utf8.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "rerere.h"
diff --git a/builtin/describe.c b/builtin/describe.c
index 0125d4ddbac..d360b1d12af 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "revision.h"
 #include "diff.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 68b1a539870..31b8732128d 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "mem-pool.h"
 #include "commit-reach.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index e0936629213..8a8ab6799e8 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -10,6 +10,7 @@
 #include "repository.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oidset.h"
 #include "oid-array.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 095b39d3980..04bc71d148c 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -19,6 +19,7 @@
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "resolve-undo.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index a1b68d90bdb..f66e14389e1 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
 #include "write-or-die.h"
diff --git a/builtin/log.c b/builtin/log.c
index 094897df236..5cdc2276cc4 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -12,6 +12,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "color.h"
 #include "commit.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 7f228353feb..ce083cb8efd 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -13,6 +13,7 @@
 #include "dir.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "tree.h"
 #include "cache-tree.h"
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index f32e6be2198..077977a4610 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 3f22273b400..854019a32dc 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -7,6 +7,7 @@
 #include "refs.h"
 #include "diff.h"
 #include "revision.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "repository.h"
 #include "commit-reach.h"
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 25f42f2be7e..fa1035405c3 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "tag.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "xdiff-interface.h"
 
 static const char builtin_merge_recursive_usage[] =
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 803e380856e..6b9f006ec19 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -8,6 +8,7 @@
 #include "commit.h"
 #include "commit-reach.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "repository.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 225b7064066..693f185d4d3 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -15,6 +15,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "builtin.h"
 #include "lockfile.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 831d360a78a..41fd56b9ba9 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -8,6 +8,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "refs.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "hash-lookup.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 4ff44f1e3d0..896140b9055 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -13,6 +13,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "blob.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index 5c0952f5c64..09891832fb3 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "prune-packed.h"
 #include "replace-object.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "shallow.h"
 
diff --git a/builtin/pull.c b/builtin/pull.c
index 636ce12c94d..967368ebc65 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -12,6 +12,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "exec-cmd.h"
 #include "run-command.h"
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index b72af527f08..04339a92ea5 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "range-diff.h"
 #include "config.h"
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 600d4f748fc..d61cbad96de 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -11,6 +11,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "object.h"
+#include "object-name.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "cache-tree.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index fb859f93a30..ff5dd77608d 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -21,6 +21,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index aa5b6fe861f..7d921170f1c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -29,6 +29,7 @@
 #include "tmp-objdir.h"
 #include "oidset.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index d2adc8ab613..134f738a450 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -17,6 +17,7 @@
 #include "refs.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "repository.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index d8c52cc6edf..f99f32d5802 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -24,6 +24,7 @@
 #include "diffcore.h"
 #include "tree.h"
 #include "branch.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "unpack-trees.h"
 #include "cache-tree.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index a3dbbb6338e..c17f0282ae8 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -10,6 +10,7 @@
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
 #include "object.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-bitmap.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 1af2089f9bd..852e49e3403 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -15,6 +15,7 @@
 #include "refs.h"
 #include "quote.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "diff.h"
 #include "revision.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index 6be92817429..d36072252e7 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -13,6 +13,7 @@
 #include "cache-tree.h"
 #include "gettext.h"
 #include "tree-walk.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "setup.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 463a8d11c31..20030b75e39 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -8,6 +8,7 @@
 #include "builtin.h"
 #include "color.h"
 #include "strvec.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "dir.h"
 #include "commit-slab.h"
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 138d30a005e..a2243b42195 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -4,6 +4,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 090bf33510a..34b9d92fb13 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "pathspec.h"
 #include "repository.h"
diff --git a/builtin/stash.c b/builtin/stash.c
index 14194b13bd1..6442b5e20a6 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -5,6 +5,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "refs.h"
 #include "lockfile.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 83377037155..1f087d7bed2 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -24,6 +24,7 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "advice.h"
 #include "branch.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 3e801f54a07..88a25902309 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -14,6 +14,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "run-command.h"
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 314761b0b4d..21082ceb601 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "config.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "wrapper.h"
 
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 3ffd75b3e78..6ca85420c3b 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "refs.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "strvec.h"
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 4d10aa98b10..5d99b82a64f 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 28d0da68454..c6019a0ad8c 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "tag.h"
 #include "run-command.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "gpg-interface.h"
 #include "ref-filter.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 944dd40f94d..69132bba319 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "strvec.h"
 #include "branch.h"
diff --git a/cache.h b/cache.h
index 66705dd469e..dfae7d02c55 100644
--- a/cache.h
+++ b/cache.h
@@ -687,24 +687,6 @@ extern int quote_path_fully;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-/*
- * Return an abbreviated sha1 unique within this repository's object database.
- * The result will be at least `len` characters long, and will be NUL
- * terminated.
- *
- * The non-`_r` version returns a static buffer which remains valid until 4
- * more calls to repo_find_unique_abbrev are made.
- *
- * The `_r` variant writes to a buffer supplied by the caller, which must be at
- * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
- * written (excluding the NUL terminator).
- *
- * Note that while this version avoids the static buffer, it is not fully
- * reentrant, as it calls into other non-reentrant git code.
- */
-const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
-int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
-
 /*
  * Create the directory containing the named path, using care to be
  * somewhat safe against races. Return one of the scld_error values to
@@ -828,72 +810,6 @@ struct object_context {
 	char *path;
 };
 
-int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
-__attribute__((format (printf, 2, 3)))
-int get_oidf(struct object_id *oid, const char *fmt, ...);
-int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
-void maybe_die_on_misspelt_object_name(struct repository *repo,
-				       const char *name,
-				       const char *prefix);
-enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
-					 unsigned flags, struct object_id *oid,
-					 struct object_context *oc);
-
-typedef int each_abbrev_fn(const struct object_id *oid, void *);
-int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
-
-int set_disambiguate_hint_config(const char *var, const char *value);
-
-/*
- * This reads short-hand syntax that not only evaluates to a commit
- * object name, but also can act as if the end user spelled the name
- * of the branch from the command line.
- *
- * - "@{-N}" finds the name of the Nth previous branch we were on, and
- *   places the name of the branch in the given buf and returns the
- *   number of characters parsed if successful.
- *
- * - "<branch>@{upstream}" finds the name of the other ref that
- *   <branch> is configured to merge with (missing <branch> defaults
- *   to the current branch), and places the name of the branch in the
- *   given buf and returns the number of characters parsed if
- *   successful.
- *
- * If the input is not of the accepted format, it returns a negative
- * number to signal an error.
- *
- * If the input was ok but there are not N branch switches in the
- * reflog, it returns 0.
- */
-#define INTERPRET_BRANCH_LOCAL (1<<0)
-#define INTERPRET_BRANCH_REMOTE (1<<1)
-#define INTERPRET_BRANCH_HEAD (1<<2)
-struct interpret_branch_name_options {
-	/*
-	 * If "allowed" is non-zero, it is a treated as a bitfield of allowable
-	 * expansions: local branches ("refs/heads/"), remote branches
-	 * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
-	 * allowed, even ones to refs outside of those namespaces.
-	 */
-	unsigned allowed;
-
-	/*
-	 * If ^{upstream} or ^{push} (or equivalent) is requested, and the
-	 * branch in question does not have such a reference, return -1 instead
-	 * of die()-ing.
-	 */
-	unsigned nonfatal_dangling_mark : 1;
-};
-int repo_interpret_branch_name(struct repository *r,
-			       const char *str, int len,
-			       struct strbuf *buf,
-			       const struct interpret_branch_name_options *options);
-
 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,
@@ -907,10 +823,6 @@ void *read_object_with_reference(struct repository *r,
 				 unsigned long *size,
 				 struct object_id *oid_ret);
 
-struct object *repo_peel_to_type(struct repository *r,
-				 const char *name, int namelen,
-				 struct object *o, enum object_type);
-
 const char *git_editor(void);
 const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
diff --git a/checkout.c b/checkout.c
index 1247b882248..9235073fc0d 100644
--- a/checkout.c
+++ b/checkout.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
 #include "checkout.h"
diff --git a/combine-diff.c b/combine-diff.c
index 6586e4508d6..cd5f39f22f4 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -7,6 +7,7 @@
 #include "diffcore.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "quote.h"
 #include "xdiff-interface.h"
 #include "xdiff/xmacros.h"
diff --git a/commit.c b/commit.c
index 6d844da9a6b..bad31c423a4 100644
--- a/commit.c
+++ b/commit.c
@@ -6,6 +6,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "repository.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "pkt-line.h"
 #include "utf8.h"
diff --git a/config.c b/config.c
index 9e74b5aec7f..aac439530e9 100644
--- a/config.c
+++ b/config.c
@@ -23,6 +23,7 @@
 #include "quote.h"
 #include "hashmap.h"
 #include "string-list.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "utf8.h"
 #include "dir.h"
diff --git a/diff-lib.c b/diff-lib.c
index 8b5cca96ace..d292405a262 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -8,6 +8,7 @@
 #include "diffcore.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
diff --git a/diff.c b/diff.c
index 89cd0b17da5..9e6ad94bc66 100644
--- a/diff.c
+++ b/diff.c
@@ -35,6 +35,7 @@
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
+#include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
 #include "wrapper.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 1886c92ddb9..21019c932b3 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -3,6 +3,7 @@
 #include "config.h"
 #include "environment.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "diff.h"
 #include "diff-merges.h"
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 298ca08711e..8b2a45e507d 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -15,6 +15,7 @@
 #include "list-objects-filter-options.h"
 #include "oidmap.h"
 #include "oidset.h"
+#include "object-name.h"
 #include "object-store.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/log-tree.c b/log-tree.c
index 627c711f707..f0e885635e0 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -4,6 +4,7 @@
 #include "diff.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "tmp-objdir.h"
diff --git a/mailmap.c b/mailmap.c
index 14f2c0f62ae..d62d7bf0e7f 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -2,6 +2,7 @@
 #include "environment.h"
 #include "string-list.h"
 #include "mailmap.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "setup.h"
 
diff --git a/merge-ort.c b/merge-ort.c
index 1008684fbbc..2c6a9ed9a41 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -32,6 +32,7 @@
 #include "entry.h"
 #include "ll-merge.h"
 #include "mem-pool.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "promisor-remote.h"
diff --git a/notes-merge.c b/notes-merge.c
index 0258f87d21f..b496b77d9db 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -3,6 +3,7 @@
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "diff.h"
diff --git a/notes.c b/notes.c
index 45fb7f22d1d..c07bcbe3486 100644
--- a/notes.c
+++ b/notes.c
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/object-name.c b/object-name.c
index ff647d6c7b5..3cd5b327293 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-name.h"
 #include "advice.h"
 #include "config.h"
 #include "environment.h"
diff --git a/object-name.h b/object-name.h
new file mode 100644
index 00000000000..65cb9a77b01
--- /dev/null
+++ b/object-name.h
@@ -0,0 +1,99 @@
+#ifndef OBJECT_NAME_H
+#define OBJECT_NAME_H
+
+#include "object.h"
+
+struct object_context;
+struct object_id;
+struct repository;
+struct strbuf;
+
+/*
+ * Return an abbreviated sha1 unique within this repository's object database.
+ * The result will be at least `len` characters long, and will be NUL
+ * terminated.
+ *
+ * The non-`_r` version returns a static buffer which remains valid until 4
+ * more calls to repo_find_unique_abbrev are made.
+ *
+ * The `_r` variant writes to a buffer supplied by the caller, which must be at
+ * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
+ * written (excluding the NUL terminator).
+ *
+ * Note that while this version avoids the static buffer, it is not fully
+ * reentrant, as it calls into other non-reentrant git code.
+ */
+const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
+int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
+
+int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
+__attribute__((format (printf, 2, 3)))
+int get_oidf(struct object_id *oid, const char *fmt, ...);
+int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
+void maybe_die_on_misspelt_object_name(struct repository *repo,
+				       const char *name,
+				       const char *prefix);
+enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
+					 unsigned flags, struct object_id *oid,
+					 struct object_context *oc);
+
+
+typedef int each_abbrev_fn(const struct object_id *oid, void *);
+int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
+
+int set_disambiguate_hint_config(const char *var, const char *value);
+
+/*
+ * This reads short-hand syntax that not only evaluates to a commit
+ * object name, but also can act as if the end user spelled the name
+ * of the branch from the command line.
+ *
+ * - "@{-N}" finds the name of the Nth previous branch we were on, and
+ *   places the name of the branch in the given buf and returns the
+ *   number of characters parsed if successful.
+ *
+ * - "<branch>@{upstream}" finds the name of the other ref that
+ *   <branch> is configured to merge with (missing <branch> defaults
+ *   to the current branch), and places the name of the branch in the
+ *   given buf and returns the number of characters parsed if
+ *   successful.
+ *
+ * If the input is not of the accepted format, it returns a negative
+ * number to signal an error.
+ *
+ * If the input was ok but there are not N branch switches in the
+ * reflog, it returns 0.
+ */
+#define INTERPRET_BRANCH_LOCAL (1<<0)
+#define INTERPRET_BRANCH_REMOTE (1<<1)
+#define INTERPRET_BRANCH_HEAD (1<<2)
+struct interpret_branch_name_options {
+	/*
+	 * If "allowed" is non-zero, it is a treated as a bitfield of allowable
+	 * expansions: local branches ("refs/heads/"), remote branches
+	 * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
+	 * allowed, even ones to refs outside of those namespaces.
+	 */
+	unsigned allowed;
+
+	/*
+	 * If ^{upstream} or ^{push} (or equivalent) is requested, and the
+	 * branch in question does not have such a reference, return -1 instead
+	 * of die()-ing.
+	 */
+	unsigned nonfatal_dangling_mark : 1;
+};
+int repo_interpret_branch_name(struct repository *r,
+			       const char *str, int len,
+			       struct strbuf *buf,
+			       const struct interpret_branch_name_options *options);
+
+struct object *repo_peel_to_type(struct repository *r,
+				 const char *name, int namelen,
+				 struct object *o, enum object_type);
+#endif /* OBJECT_NAME_H */
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 666c2129797..b4df4bcebed 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -6,6 +6,7 @@
 #include "color.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "oid-array.h"
diff --git a/range-diff.c b/range-diff.c
index d1ed3b8ee56..a2994331a14 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -2,6 +2,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "range-diff.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "run-command.h"
 #include "strvec.h"
diff --git a/read-cache.c b/read-cache.c
index 4ada6d62b90..cbbfc030da7 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -22,6 +22,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "mem-pool.h"
+#include "object-name.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 79ed61b9fa4..48467a7bc4a 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -8,6 +8,7 @@
 #include "commit-slab.h"
 #include "config.h"
 #include "dir.h"
+#include "object-name.h"
 #include "wrapper.h"
 
 static const char edit_todo_list_advice[] =
diff --git a/ref-filter.c b/ref-filter.c
index 1c6174c8aed..57a5884aec7 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -6,6 +6,7 @@
 #include "parse-options.h"
 #include "refs.h"
 #include "wildmatch.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "repository.h"
diff --git a/refs.c b/refs.c
index cfced6f174a..979ed3fbedc 100644
--- a/refs.c
+++ b/refs.c
@@ -16,6 +16,7 @@
 #include "refs/refs-internal.h"
 #include "run-command.h"
 #include "hook.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
diff --git a/remote.c b/remote.c
index 6599d52de20..3afedce593e 100644
--- a/remote.c
+++ b/remote.c
@@ -9,6 +9,7 @@
 #include "urlmatch.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/reset.c b/reset.c
index ab300923e04..48da0adf851 100644
--- a/reset.c
+++ b/reset.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "refs.h"
 #include "reset.h"
 #include "run-command.h"
diff --git a/revision.c b/revision.c
index 7c34c93885e..7438b50e267 100644
--- a/revision.c
+++ b/revision.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "blob.h"
diff --git a/sequencer.c b/sequencer.c
index eaba379e3ad..22b287be984 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "commit.h"
diff --git a/setup.c b/setup.c
index 3bb7a9fff62..8a297b3cb5c 100644
--- a/setup.c
+++ b/setup.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "repository.h"
 #include "config.h"
 #include "dir.h"
diff --git a/strbuf.c b/strbuf.c
index 70a83e7980e..1b93d9d3c47 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "string-list.h"
 #include "utf8.h"
diff --git a/submodule-config.c b/submodule-config.c
index ecf0fcf0074..252b90aa439 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -9,6 +9,7 @@
 #include "submodule-config.h"
 #include "submodule.h"
 #include "strbuf.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "tree-walk.h"
diff --git a/submodule.c b/submodule.c
index 58c9d5e5673..4f403b9eeff 100644
--- a/submodule.c
+++ b/submodule.c
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit-reach.h"
 #include "setup.h"
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index fd48e0ee2c8..d1d63feaa9e 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -20,6 +20,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "refs.h"
 #include "revision.h"
 #include "sequencer.h"
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 7066f3c71d2..3808e1ac38b 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 "object-name.h"
 #include "setup.h"
 #include "tree.h"
 
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index e2eb25ecdea..bf4fcfe6efb 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "hex.h"
+#include "object-name.h"
 #include "oidmap.h"
 #include "setup.h"
 #include "strbuf.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index b0deaa106a2..d4fa33ae751 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -6,6 +6,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "ref-filter.h"
 #include "setup.h"
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 66063b58ded..4758c8654e0 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "config.h"
+#include "object-name.h"
 #include "setup.h"
 #include "submodule-config.h"
 #include "submodule.h"
diff --git a/tag.c b/tag.c
index 01ed67d6fa6..b9fc2fc9929 100644
--- a/tag.c
+++ b/tag.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "environment.h"
 #include "tag.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "tree.h"
diff --git a/transport-helper.c b/transport-helper.c
index 76d146ee88b..ca8bec04bb3 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "remote.h"
 #include "string-list.h"
diff --git a/transport.c b/transport.c
index 82bf2496ba7..7374cfd1fa9 100644
--- a/transport.c
+++ b/transport.c
@@ -26,6 +26,7 @@
 #include "trace2.h"
 #include "transport-internal.h"
 #include "protocol.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "color.h"
 #include "bundle-uri.h"
diff --git a/tree.c b/tree.c
index 2b78708766b..e9d51ce2e00 100644
--- a/tree.c
+++ b/tree.c
@@ -2,6 +2,7 @@
 #include "cache-tree.h"
 #include "hex.h"
 #include "tree.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "commit.h"
diff --git a/wt-status.c b/wt-status.c
index 47f223c0f8d..97b9c1c0359 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -8,6 +8,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "diffcore.h"
 #include "quote.h"
-- 
gitgitgadget


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

* [PATCH 09/24] treewide: remove cache.h inclusion due to object-name.h changes
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (7 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 08/24] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 10/24] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren via GitGitGadget
                   ` (16 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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>
---
 branch.c                         | 2 +-
 checkout.c                       | 3 ++-
 fmt-merge-msg.c                  | 2 +-
 mailmap.c                        | 2 +-
 notes.c                          | 2 +-
 refs.c                           | 2 +-
 remote.c                         | 2 +-
 setup.c                          | 2 +-
 strbuf.c                         | 2 +-
 t/helper/test-oidmap.c           | 1 -
 t/helper/test-reach.c            | 1 -
 t/helper/test-submodule-config.c | 1 -
 transport-helper.c               | 2 +-
 13 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/branch.c b/branch.c
index f29743b1619..7b71d195dc8 100644
--- a/branch.c
+++ b/branch.c
@@ -1,5 +1,5 @@
 #include "git-compat-util.h"
-#include "cache.h"
+#include "git-compat-util.h"
 #include "advice.h"
 #include "config.h"
 #include "branch.h"
diff --git a/checkout.c b/checkout.c
index 9235073fc0d..04238b27133 100644
--- a/checkout.c
+++ b/checkout.c
@@ -1,9 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
 #include "checkout.h"
 #include "config.h"
+#include "strbuf.h"
 
 struct tracking_name_data {
 	/* const */ char *src_ref;
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 21019c932b3..5af0d4715ba 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/mailmap.c b/mailmap.c
index d62d7bf0e7f..28d389c1f94 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "string-list.h"
 #include "mailmap.h"
diff --git a/notes.c b/notes.c
index c07bcbe3486..02f1aa39ae1 100644
--- a/notes.c
+++ b/notes.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "hex.h"
diff --git a/refs.c b/refs.c
index 979ed3fbedc..d2a98e1c21f 100644
--- a/refs.c
+++ b/refs.c
@@ -2,7 +2,7 @@
  * The backend-independent part of the reference module.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/remote.c b/remote.c
index 3afedce593e..2947743d60a 100644
--- a/remote.c
+++ b/remote.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/setup.c b/setup.c
index 8a297b3cb5c..a546da755f1 100644
--- a/setup.c
+++ b/setup.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/strbuf.c b/strbuf.c
index 1b93d9d3c47..b2e3735ba8a 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "environment.h"
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index bf4fcfe6efb..de6ab77fdaa 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "object-name.h"
 #include "oidmap.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index d4fa33ae751..5b6f2174418 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "alloc.h"
 #include "commit.h"
 #include "commit-reach.h"
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 4758c8654e0..c7c7fdbea98 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "config.h"
 #include "object-name.h"
 #include "setup.h"
diff --git a/transport-helper.c b/transport-helper.c
index ca8bec04bb3..6b816940dc6 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "transport.h"
 #include "quote.h"
 #include "run-command.h"
-- 
gitgitgadget


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

* [PATCH 10/24] git-zlib: move declarations for git-zlib functions from cache.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (8 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 09/24] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 11/24] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren via GitGitGadget
                   ` (15 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Move functions from cache.h for zlib.c into a new header file.  Since
adding a "zlib.h" would cause issues with the real zlib, rename zlib.c
to git-zlib.c while we are at it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 Makefile                 |  2 +-
 archive-tar.c            |  1 +
 archive-zip.c            |  1 +
 builtin/unpack-objects.c |  1 +
 cache.h                  | 25 +------------------------
 zlib.c => git-zlib.c     |  3 ++-
 git-zlib.h               | 28 ++++++++++++++++++++++++++++
 http-backend.c           |  1 +
 http.h                   |  3 +++
 9 files changed, 39 insertions(+), 26 deletions(-)
 rename zlib.c => git-zlib.c (99%)
 create mode 100644 git-zlib.h

diff --git a/Makefile b/Makefile
index 50ee51fde32..0c367881bff 100644
--- a/Makefile
+++ b/Makefile
@@ -1036,6 +1036,7 @@ LIB_OBJS += fsmonitor.o
 LIB_OBJS += fsmonitor-ipc.o
 LIB_OBJS += fsmonitor-settings.o
 LIB_OBJS += gettext.o
+LIB_OBJS += git-zlib.o
 LIB_OBJS += gpg-interface.o
 LIB_OBJS += graph.o
 LIB_OBJS += grep.o
@@ -1196,7 +1197,6 @@ LIB_OBJS += write-or-die.o
 LIB_OBJS += ws.o
 LIB_OBJS += wt-status.o
 LIB_OBJS += xdiff-interface.o
-LIB_OBJS += zlib.o
 
 BUILTIN_OBJS += builtin/add.o
 BUILTIN_OBJS += builtin/am.o
diff --git a/archive-tar.c b/archive-tar.c
index 497dad0b3af..4cd81d8161e 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -5,6 +5,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "tar.h"
 #include "archive.h"
diff --git a/archive-zip.c b/archive-zip.c
index e6f5c10a14f..ef538a90df4 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -5,6 +5,7 @@
 #include "config.h"
 #include "archive.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "streaming.h"
 #include "utf8.h"
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index f2c1323e661..ddbdb3dd226 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -4,6 +4,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "object-store.h"
 #include "object.h"
diff --git a/cache.h b/cache.h
index dfae7d02c55..769b2ec545a 100644
--- a/cache.h
+++ b/cache.h
@@ -3,6 +3,7 @@
 
 #include "git-compat-util.h"
 #include "strbuf.h"
+#include "git-zlib.h"
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
@@ -14,30 +15,6 @@
 #include "repository.h"
 #include "statinfo.h"
 
-typedef struct git_zstream {
-	z_stream z;
-	unsigned long avail_in;
-	unsigned long avail_out;
-	unsigned long total_in;
-	unsigned long total_out;
-	unsigned char *next_in;
-	unsigned char *next_out;
-} git_zstream;
-
-void git_inflate_init(git_zstream *);
-void git_inflate_init_gzip_only(git_zstream *);
-void git_inflate_end(git_zstream *);
-int git_inflate(git_zstream *, int flush);
-
-void git_deflate_init(git_zstream *, int level);
-void git_deflate_init_gzip(git_zstream *, int level);
-void git_deflate_init_raw(git_zstream *, int level);
-void git_deflate_end(git_zstream *);
-int git_deflate_abort(git_zstream *);
-int git_deflate_end_gently(git_zstream *);
-int git_deflate(git_zstream *, int flush);
-unsigned long git_deflate_bound(git_zstream *, unsigned long);
-
 #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
 #define DTYPE(de)	((de)->d_type)
 #else
diff --git a/zlib.c b/git-zlib.c
similarity index 99%
rename from zlib.c
rename to git-zlib.c
index d594cba3fc9..d43bbeb6daa 100644
--- a/zlib.c
+++ b/git-zlib.c
@@ -2,7 +2,8 @@
  * zlib wrappers to make sure we don't silently miss errors
  * at init time.
  */
-#include "cache.h"
+#include "git-compat-util.h"
+#include "git-zlib.h"
 
 static const char *zerr_to_string(int status)
 {
diff --git a/git-zlib.h b/git-zlib.h
new file mode 100644
index 00000000000..d8a670aff9f
--- /dev/null
+++ b/git-zlib.h
@@ -0,0 +1,28 @@
+#ifndef GIT_ZLIB_H
+#define GIT_ZLIB_H
+
+typedef struct git_zstream {
+	z_stream z;
+	unsigned long avail_in;
+	unsigned long avail_out;
+	unsigned long total_in;
+	unsigned long total_out;
+	unsigned char *next_in;
+	unsigned char *next_out;
+} git_zstream;
+
+void git_inflate_init(git_zstream *);
+void git_inflate_init_gzip_only(git_zstream *);
+void git_inflate_end(git_zstream *);
+int git_inflate(git_zstream *, int flush);
+
+void git_deflate_init(git_zstream *, int level);
+void git_deflate_init_gzip(git_zstream *, int level);
+void git_deflate_init_raw(git_zstream *, int level);
+void git_deflate_end(git_zstream *);
+int git_deflate_abort(git_zstream *);
+int git_deflate_end_gently(git_zstream *);
+int git_deflate(git_zstream *, int flush);
+unsigned long git_deflate_bound(git_zstream *, unsigned long);
+
+#endif /* GIT_ZLIB_H */
diff --git a/http-backend.c b/http-backend.c
index 89aad1b42c7..d41b3b9e1e7 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "repository.h"
 #include "refs.h"
diff --git a/http.h b/http.h
index 77c042706c6..783b2b09b8b 100644
--- a/http.h
+++ b/http.h
@@ -1,7 +1,10 @@
 #ifndef HTTP_H
 #define HTTP_H
 
+struct packed_git;
+
 #include "cache.h"
+#include "git-zlib.h"
 
 #include <curl/curl.h>
 #include <curl/easy.h>
-- 
gitgitgadget


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

* [PATCH 11/24] treewide: remove cache.h inclusion due to git-zlib changes
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (9 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 10/24] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 12/24] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren via GitGitGadget
                   ` (14 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

This actually only affects http-backend.c, but the git-zlib changes
are going to be instrumental in pulling out an object-file.h which
will help with several more files.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 http-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/http-backend.c b/http-backend.c
index d41b3b9e1e7..ac146d85c54 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
-- 
gitgitgadget


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

* [PATCH 12/24] object-file.h: move declarations for object-file.c functions from cache.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (10 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 11/24] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 13/24] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren via GitGitGadget
                   ` (13 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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/bugreport.c                |   1 +
 builtin/cat-file.c                 |   1 +
 builtin/clone.c                    |   1 +
 builtin/credential-cache--daemon.c |   1 +
 builtin/diagnose.c                 |   1 +
 builtin/difftool.c                 |   1 +
 builtin/fast-export.c              |   1 +
 builtin/fast-import.c              |   1 +
 builtin/fsck.c                     |   1 +
 builtin/gc.c                       |   1 +
 builtin/grep.c                     |   1 +
 builtin/hash-object.c              |   1 +
 builtin/index-pack.c               |   1 +
 builtin/init-db.c                  |   1 +
 builtin/log.c                      |   1 +
 builtin/mktag.c                    |   1 +
 builtin/mv.c                       |   1 +
 builtin/pack-objects.c             |   1 +
 builtin/rebase.c                   |   1 +
 builtin/replace.c                  |   1 +
 builtin/sparse-checkout.c          |   1 +
 builtin/submodule--helper.c        |   1 +
 builtin/update-index.c             |   1 +
 builtin/worktree.c                 |   1 +
 bulk-checkin.c                     |   1 +
 cache-tree.c                       |   1 +
 cache.h                            | 114 ---------------------------
 commit-graph.c                     |   1 +
 diff.c                             |   1 +
 dir.c                              |   1 +
 environment.c                      |   1 +
 http.c                             |   1 +
 merge-recursive.c                  |   1 +
 midx.c                             |   1 +
 notes-merge.c                      |   1 +
 object-file.c                      |   1 +
 object-file.h                      | 121 +++++++++++++++++++++++++++++
 object.c                           |   1 +
 pack-bitmap.c                      |   1 +
 pack-check.c                       |   1 +
 pack-mtimes.c                      |   1 +
 pack-revindex.c                    |   1 +
 packfile.c                         |   1 +
 read-cache.c                       |   1 +
 refs/files-backend.c               |   1 +
 rerere.c                           |   1 +
 sequencer.c                        |   1 +
 server-info.c                      |   1 +
 streaming.c                        |   1 +
 submodule.c                        |   1 +
 tmp-objdir.c                       |   1 +
 tree-walk.c                        |   1 +
 53 files changed, 172 insertions(+), 114 deletions(-)
 create mode 100644 object-file.h

diff --git a/apply.c b/apply.c
index 7e40f53ec4c..2868cef5ddd 100644
--- a/apply.c
+++ b/apply.c
@@ -23,6 +23,7 @@
 #include "ll-merge.h"
 #include "lockfile.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "rerere.h"
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index 52955e1d389..03fb0536911 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -8,6 +8,7 @@
 #include "hook.h"
 #include "hook-list.h"
 #include "diagnose.h"
+#include "object-file.h"
 #include "setup.h"
 #include "wrapper.h"
 
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 60b7a55dfc1..0bafc14e6c0 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -20,6 +20,7 @@
 #include "tree-walk.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index f1e8aa3f27e..c7fdffb484c 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -21,6 +21,7 @@
 #include "fetch-pack.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "tree.h"
 #include "tree-walk.h"
diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index 62c09a271d6..4e571d9951b 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 
 #ifndef NO_UNIX_SOCKETS
diff --git a/builtin/diagnose.c b/builtin/diagnose.c
index 0f8b64994c4..4f22eb2b55d 100644
--- a/builtin/diagnose.c
+++ b/builtin/diagnose.c
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "diagnose.h"
 
diff --git a/builtin/difftool.c b/builtin/difftool.c
index e010a21bfbc..3ffb0524be7 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -25,6 +25,7 @@
 #include "strvec.h"
 #include "strbuf.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "dir.h"
 #include "entry.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 0bb779deb69..c7835ea0791 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -10,6 +10,7 @@
 #include "hex.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "commit.h"
 #include "object.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 31b8732128d..9f90f5b9e41 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "mem-pool.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 04bc71d148c..35a6de3cdb5 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -19,6 +19,7 @@
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index 000a2ef5e11..b95154fba16 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -25,6 +25,7 @@
 #include "commit.h"
 #include "commit-graph.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-objects.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index f66e14389e1..fb11be6075a 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index a15fe4fd3f4..a3801211666 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "quote.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 5adfb2521cd..0f59cf8aa08 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -18,6 +18,7 @@
 #include "thread-utils.h"
 #include "packfile.h"
 #include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "replace-object.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index ba6e0b20fa5..6183f3fb3ff 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "setup.h"
 #include "worktree.h"
diff --git a/builtin/log.c b/builtin/log.c
index 5cdc2276cc4..b6246c7042c 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -12,6 +12,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "color.h"
diff --git a/builtin/mktag.c b/builtin/mktag.c
index f9d9a38452b..f33d267fcb6 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -4,6 +4,7 @@
 #include "parse-options.h"
 #include "tag.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "fsck.h"
 #include "config.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index 8f7770aa32b..32935af48e6 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -11,6 +11,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "pathspec.h"
 #include "lockfile.h"
 #include "dir.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 69c65428614..68c914a8e1a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -33,6 +33,7 @@
 #include "strvec.h"
 #include "list.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "dir.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index ff5dd77608d..34fea4d8220 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -21,6 +21,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "commit.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index 134f738a450..f4b3a8efb23 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -17,6 +17,7 @@
 #include "refs.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 34b9d92fb13..4de37d07fd9 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "pathspec.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1f087d7bed2..5d999f814e0 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -24,6 +24,7 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "advice.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 03cda5e60d2..33b00cef151 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -15,6 +15,7 @@
 #include "cache-tree.h"
 #include "tree-walk.h"
 #include "builtin.h"
+#include "object-file.h"
 #include "refs.h"
 #include "resolve-undo.h"
 #include "parse-options.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 69132bba319..0621f6f708e 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "strvec.h"
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 6362b6aabc7..af15f8a9af4 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -15,6 +15,7 @@
 #include "string-list.h"
 #include "tmp-objdir.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 static int odb_transaction_nesting;
diff --git a/cache-tree.c b/cache-tree.c
index 39f0c744727..ebfe649b330 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -7,6 +7,7 @@
 #include "tree-walk.h"
 #include "cache-tree.h"
 #include "bulk-checkin.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/cache.h b/cache.h
index 769b2ec545a..f02c7c9609d 100644
--- a/cache.h
+++ b/cache.h
@@ -596,13 +596,6 @@ int has_racy_timestamp(struct index_state *istate);
 int ie_match_stat(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 int ie_modified(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 
-#define HASH_WRITE_OBJECT 1
-#define HASH_FORMAT_CHECK 2
-#define HASH_RENORMALIZE  4
-#define HASH_SILENT 8
-int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
-int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
-
 /*
  * Record to sd the data from st that we use to check whether a file
  * might have changed.
@@ -664,107 +657,6 @@ extern int quote_path_fully;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-/*
- * Create the directory containing the named path, using care to be
- * somewhat safe against races. Return one of the scld_error values to
- * indicate success/failure. On error, set errno to describe the
- * problem.
- *
- * SCLD_VANISHED indicates that one of the ancestor directories of the
- * path existed at one point during the function call and then
- * suddenly vanished, probably because another process pruned the
- * directory while we were working.  To be robust against this kind of
- * race, callers might want to try invoking the function again when it
- * returns SCLD_VANISHED.
- *
- * safe_create_leading_directories() temporarily changes path while it
- * is working but restores it before returning.
- * safe_create_leading_directories_const() doesn't modify path, even
- * temporarily. Both these variants adjust the permissions of the
- * created directories to honor core.sharedRepository, so they are best
- * suited for files inside the git dir. For working tree files, use
- * safe_create_leading_directories_no_share() instead, as it ignores
- * the core.sharedRepository setting.
- */
-enum scld_error {
-	SCLD_OK = 0,
-	SCLD_FAILED = -1,
-	SCLD_PERMS = -2,
-	SCLD_EXISTS = -3,
-	SCLD_VANISHED = -4
-};
-enum scld_error safe_create_leading_directories(char *path);
-enum scld_error safe_create_leading_directories_const(const char *path);
-enum scld_error safe_create_leading_directories_no_share(char *path);
-
-int mkdir_in_gitdir(const char *path);
-
-int git_open_cloexec(const char *name, int flags);
-#define git_open(name) git_open_cloexec(name, O_RDONLY)
-
-/**
- * unpack_loose_header() initializes the data stream needed to unpack
- * a loose object header.
- *
- * Returns:
- *
- * - ULHR_OK on success
- * - ULHR_BAD on error
- * - ULHR_TOO_LONG if the header was too long
- *
- * It will only parse up to MAX_HEADER_LEN bytes unless an optional
- * "hdrbuf" argument is non-NULL. This is intended for use with
- * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
- * reporting. The full header will be extracted to "hdrbuf" for use
- * with parse_loose_header(), ULHR_TOO_LONG will still be returned
- * from this function to indicate that the header was too long.
- */
-enum unpack_loose_header_result {
-	ULHR_OK,
-	ULHR_BAD,
-	ULHR_TOO_LONG,
-};
-enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
-						    unsigned char *map,
-						    unsigned long mapsize,
-						    void *buffer,
-						    unsigned long bufsiz,
-						    struct strbuf *hdrbuf);
-
-/**
- * parse_loose_header() parses the starting "<type> <len>\0" of an
- * object. If it doesn't follow that format -1 is returned. To check
- * the validity of the <type> populate the "typep" in the "struct
- * object_info". It will be OBJ_BAD if the object type is unknown. The
- * parsed <len> can be retrieved via "oi->sizep", and from there
- * passed to unpack_loose_rest().
- */
-struct object_info;
-int parse_loose_header(const char *hdr, struct object_info *oi);
-
-/**
- * With in-core object data in "buf", rehash it to make sure the
- * object name actually matches "oid" to detect object corruption.
- *
- * A negative value indicates an error, usually that the OID is not
- * what we expected, but it might also indicate another error.
- */
-int check_object_signature(struct repository *r, const struct object_id *oid,
-			   void *map, unsigned long size,
-			   enum object_type type);
-
-/**
- * A streaming version of check_object_signature().
- * Try reading the object named with "oid" using
- * the streaming interface and rehash it to do the same.
- */
-int stream_object_signature(struct repository *r, const struct object_id *oid);
-
-int finalize_object_file(const char *tmpfile, const char *filename);
-
-/* Helper to check and "touch" a file */
-int check_and_freshen_file(const char *fn, int freshen);
-
 /* Convert to/from hex/sha1 representation */
 #define MINIMUM_ABBREV minimum_abbrev
 #define DEFAULT_ABBREV default_abbrev
@@ -794,12 +686,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);
 
-void *read_object_with_reference(struct repository *r,
-				 const struct object_id *oid,
-				 enum object_type required_type,
-				 unsigned long *size,
-				 struct object_id *oid_ret);
-
 const char *git_editor(void);
 const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
diff --git a/commit-graph.c b/commit-graph.c
index fe9a8b2342f..c20e73ceebf 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -11,6 +11,7 @@
 #include "revision.h"
 #include "hash-lookup.h"
 #include "commit-graph.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "alloc.h"
diff --git a/diff.c b/diff.c
index 9e6ad94bc66..f8e0d3b5c59 100644
--- a/diff.c
+++ b/diff.c
@@ -35,6 +35,7 @@
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
diff --git a/dir.c b/dir.c
index d1f1b1ef768..aa840995c40 100644
--- a/dir.c
+++ b/dir.c
@@ -13,6 +13,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "attr.h"
 #include "refs.h"
diff --git a/environment.c b/environment.c
index e57292eccc9..39efa49fe31 100644
--- a/environment.c
+++ b/environment.c
@@ -19,6 +19,7 @@
 #include "fmt-merge-msg.h"
 #include "commit.h"
 #include "strvec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "tmp-objdir.h"
diff --git a/http.c b/http.c
index 0212c0ad3b2..c3916ceb4d8 100644
--- a/http.c
+++ b/http.c
@@ -17,6 +17,7 @@
 #include "packfile.h"
 #include "protocol.h"
 #include "string-list.h"
+#include "object-file.h"
 #include "object-store.h"
 
 static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
diff --git a/merge-recursive.c b/merge-recursive.c
index ed5534eb57d..b22bf7097c8 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -22,6 +22,7 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "repository.h"
 #include "revision.h"
diff --git a/midx.c b/midx.c
index 9af3e5de889..2d0da573281 100644
--- a/midx.c
+++ b/midx.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "midx.h"
diff --git a/notes-merge.c b/notes-merge.c
index b496b77d9db..cc9538ac5c0 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -3,6 +3,7 @@
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
diff --git a/object-file.c b/object-file.c
index a4331e0da61..8163ddbaddd 100644
--- a/object-file.c
+++ b/object-file.c
@@ -36,6 +36,7 @@
 #include "mergesort.h"
 #include "quote.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "promisor-remote.h"
 #include "setup.h"
diff --git a/object-file.h b/object-file.h
new file mode 100644
index 00000000000..e2ae70c83a4
--- /dev/null
+++ b/object-file.h
@@ -0,0 +1,121 @@
+#ifndef OBJECT_FILE_H
+#define OBJECT_FILE_H
+
+#include "git-zlib.h"
+#include "object.h"
+
+#define HASH_WRITE_OBJECT 1
+#define HASH_FORMAT_CHECK 2
+#define HASH_RENORMALIZE  4
+#define HASH_SILENT 8
+int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
+int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
+
+/*
+ * Create the directory containing the named path, using care to be
+ * somewhat safe against races. Return one of the scld_error values to
+ * indicate success/failure. On error, set errno to describe the
+ * problem.
+ *
+ * SCLD_VANISHED indicates that one of the ancestor directories of the
+ * path existed at one point during the function call and then
+ * suddenly vanished, probably because another process pruned the
+ * directory while we were working.  To be robust against this kind of
+ * race, callers might want to try invoking the function again when it
+ * returns SCLD_VANISHED.
+ *
+ * safe_create_leading_directories() temporarily changes path while it
+ * is working but restores it before returning.
+ * safe_create_leading_directories_const() doesn't modify path, even
+ * temporarily. Both these variants adjust the permissions of the
+ * created directories to honor core.sharedRepository, so they are best
+ * suited for files inside the git dir. For working tree files, use
+ * safe_create_leading_directories_no_share() instead, as it ignores
+ * the core.sharedRepository setting.
+ */
+enum scld_error {
+	SCLD_OK = 0,
+	SCLD_FAILED = -1,
+	SCLD_PERMS = -2,
+	SCLD_EXISTS = -3,
+	SCLD_VANISHED = -4
+};
+enum scld_error safe_create_leading_directories(char *path);
+enum scld_error safe_create_leading_directories_const(const char *path);
+enum scld_error safe_create_leading_directories_no_share(char *path);
+
+int mkdir_in_gitdir(const char *path);
+
+int git_open_cloexec(const char *name, int flags);
+#define git_open(name) git_open_cloexec(name, O_RDONLY)
+
+/**
+ * unpack_loose_header() initializes the data stream needed to unpack
+ * a loose object header.
+ *
+ * Returns:
+ *
+ * - ULHR_OK on success
+ * - ULHR_BAD on error
+ * - ULHR_TOO_LONG if the header was too long
+ *
+ * It will only parse up to MAX_HEADER_LEN bytes unless an optional
+ * "hdrbuf" argument is non-NULL. This is intended for use with
+ * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
+ * reporting. The full header will be extracted to "hdrbuf" for use
+ * with parse_loose_header(), ULHR_TOO_LONG will still be returned
+ * from this function to indicate that the header was too long.
+ */
+enum unpack_loose_header_result {
+	ULHR_OK,
+	ULHR_BAD,
+	ULHR_TOO_LONG,
+};
+enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
+						    unsigned char *map,
+						    unsigned long mapsize,
+						    void *buffer,
+						    unsigned long bufsiz,
+						    struct strbuf *hdrbuf);
+
+/**
+ * parse_loose_header() parses the starting "<type> <len>\0" of an
+ * object. If it doesn't follow that format -1 is returned. To check
+ * the validity of the <type> populate the "typep" in the "struct
+ * object_info". It will be OBJ_BAD if the object type is unknown. The
+ * parsed <len> can be retrieved via "oi->sizep", and from there
+ * passed to unpack_loose_rest().
+ */
+struct object_info;
+int parse_loose_header(const char *hdr, struct object_info *oi);
+
+/**
+ * With in-core object data in "buf", rehash it to make sure the
+ * object name actually matches "oid" to detect object corruption.
+ *
+ * A negative value indicates an error, usually that the OID is not
+ * what we expected, but it might also indicate another error.
+ */
+int check_object_signature(struct repository *r, const struct object_id *oid,
+			   void *map, unsigned long size,
+			   enum object_type type);
+
+/**
+ * A streaming version of check_object_signature().
+ * Try reading the object named with "oid" using
+ * the streaming interface and rehash it to do the same.
+ */
+int stream_object_signature(struct repository *r, const struct object_id *oid);
+
+int finalize_object_file(const char *tmpfile, const char *filename);
+
+/* Helper to check and "touch" a file */
+int check_and_freshen_file(const char *fn, int freshen);
+
+void *read_object_with_reference(struct repository *r,
+				 const struct object_id *oid,
+				 enum object_type required_type,
+				 unsigned long *size,
+				 struct object_id *oid_ret);
+
+#endif /* OBJECT_FILE_H */
diff --git a/object.c b/object.c
index 45c9721b8c8..6d4ef1524de 100644
--- a/object.c
+++ b/object.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "object.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index eba838d24ee..1371f17d22f 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -16,6 +16,7 @@
 #include "packfile.h"
 #include "repository.h"
 #include "trace2.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "list-objects-filter-options.h"
 #include "midx.h"
diff --git a/pack-check.c b/pack-check.c
index 6974e40a958..40d88bc5ebe 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -6,6 +6,7 @@
 #include "pack-revindex.h"
 #include "progress.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 struct idx_entry {
diff --git a/pack-mtimes.c b/pack-mtimes.c
index afed6321906..0096ace080b 100644
--- a/pack-mtimes.c
+++ b/pack-mtimes.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "gettext.h"
 #include "pack-mtimes.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
 
diff --git a/pack-revindex.c b/pack-revindex.c
index 9f9927d9471..22a1958a1fc 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "gettext.h"
 #include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
 #include "trace2.h"
diff --git a/packfile.c b/packfile.c
index 02afbe77137..9ae2278c22e 100644
--- a/packfile.c
+++ b/packfile.c
@@ -18,6 +18,7 @@
 #include "trace.h"
 #include "tree-walk.h"
 #include "tree.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "midx.h"
 #include "commit-graph.h"
diff --git a/read-cache.c b/read-cache.c
index cbbfc030da7..f225bf44cd0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -14,6 +14,7 @@
 #include "cache-tree.h"
 #include "refs.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "tree.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index e6a6971381e..d0581ee41ac 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -12,6 +12,7 @@
 #include "../dir-iterator.h"
 #include "../lockfile.h"
 #include "../object.h"
+#include "../object-file.h"
 #include "../dir.h"
 #include "../chdir-notify.h"
 #include "../setup.h"
diff --git a/rerere.c b/rerere.c
index 5516e336d01..093c0f6f993 100644
--- a/rerere.c
+++ b/rerere.c
@@ -13,6 +13,7 @@
 #include "ll-merge.h"
 #include "attr.h"
 #include "pathspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "strmap.h"
diff --git a/sequencer.c b/sequencer.c
index 22b287be984..be10249fd0a 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "object.h"
diff --git a/server-info.c b/server-info.c
index 355b6e01a52..68098ddd1ad 100644
--- a/server-info.c
+++ b/server-info.c
@@ -9,6 +9,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "strbuf.h"
 #include "wrapper.h"
diff --git a/streaming.c b/streaming.c
index 27e014d8b23..b3415724ee4 100644
--- a/streaming.c
+++ b/streaming.c
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "streaming.h"
 #include "repository.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "packfile.h"
diff --git a/submodule.c b/submodule.c
index 4f403b9eeff..d09bc22d4b6 100644
--- a/submodule.c
+++ b/submodule.c
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "commit-reach.h"
diff --git a/tmp-objdir.c b/tmp-objdir.c
index 5adad1925d1..fff7ff42db7 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -4,6 +4,7 @@
 #include "chdir-notify.h"
 #include "dir.h"
 #include "environment.h"
+#include "object-file.h"
 #include "sigchain.h"
 #include "string-list.h"
 #include "strbuf.h"
diff --git a/tree-walk.c b/tree-walk.c
index 59add24c8e9..2993c48c2f3 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "trace2.h"
 #include "tree.h"
-- 
gitgitgadget


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

* [PATCH 13/24] treewide: remove cache.h inclusion due to object-file.h changes
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (11 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 12/24] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 14/24] object.h: move an inline function and some defines from cache.h Elijah Newren via GitGitGadget
                   ` (12 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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>
---
 bulk-checkin.c  | 2 +-
 commit-graph.c  | 2 +-
 http-fetch.c    | 2 +-
 http-walker.c   | 2 +-
 http.h          | 1 -
 notes-merge.c   | 2 +-
 pack-bitmap.c   | 2 +-
 pack-check.c    | 2 +-
 pack-mtimes.c   | 2 +-
 pack-revindex.c | 2 +-
 streaming.c     | 2 +-
 tmp-objdir.c    | 2 +-
 12 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/bulk-checkin.c b/bulk-checkin.c
index af15f8a9af4..9192298db6a 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "bulk-checkin.h"
 #include "environment.h"
diff --git a/commit-graph.c b/commit-graph.c
index c20e73ceebf..0c4f2266445 100644
--- a/commit-graph.c
+++ b/commit-graph.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/http-fetch.c b/http-fetch.c
index c874d3402dd..fffda592670 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "exec-cmd.h"
 #include "gettext.h"
diff --git a/http-walker.c b/http-walker.c
index 4588e6a340a..3b41f5654b3 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "repository.h"
 #include "commit.h"
 #include "hex.h"
diff --git a/http.h b/http.h
index 783b2b09b8b..3a409bccd4e 100644
--- a/http.h
+++ b/http.h
@@ -3,7 +3,6 @@
 
 struct packed_git;
 
-#include "cache.h"
 #include "git-zlib.h"
 
 #include <curl/curl.h>
diff --git a/notes-merge.c b/notes-merge.c
index cc9538ac5c0..233e49e3195 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "advice.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 1371f17d22f..48fc2ec76de 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/pack-check.c b/pack-check.c
index 40d88bc5ebe..049f2f0bfc0 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/pack-mtimes.c b/pack-mtimes.c
index 0096ace080b..020a37f8fe3 100644
--- a/pack-mtimes.c
+++ b/pack-mtimes.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-mtimes.h"
 #include "object-file.h"
diff --git a/pack-revindex.c b/pack-revindex.c
index 22a1958a1fc..4d9bb41b4db 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-revindex.h"
 #include "object-file.h"
diff --git a/streaming.c b/streaming.c
index b3415724ee4..21e39585e89 100644
--- a/streaming.c
+++ b/streaming.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "convert.h"
 #include "environment.h"
 #include "streaming.h"
diff --git a/tmp-objdir.c b/tmp-objdir.c
index fff7ff42db7..c33a554f921 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tmp-objdir.h"
 #include "abspath.h"
 #include "chdir-notify.h"
-- 
gitgitgadget


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

* [PATCH 14/24] object.h: move an inline function and some defines from cache.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (12 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 13/24] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 15/24] editor: move editor-related functions and declarations into common file Elijah Newren via GitGitGadget
                   ` (11 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

The object_type() inline function is very tied to the enum object_type
declaration within object.h, and just seemed to make more sense to live
there.  Move it, and as a side-effect, remove a bunch of dependencies
on cache.h that are no longer needed.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 bundle.c            |  2 +-
 cache.h             | 21 ---------------------
 delta-islands.c     |  2 +-
 fsck.c              |  2 +-
 http-push.c         |  2 +-
 list-objects.c      |  2 +-
 object.h            | 21 +++++++++++++++++++++
 pack-bitmap-write.c |  2 +-
 submodule-config.c  |  2 +-
 walker.c            |  2 +-
 10 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/bundle.c b/bundle.c
index 6471489975a..a5505368de5 100644
--- a/bundle.c
+++ b/bundle.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "lockfile.h"
 #include "bundle.h"
 #include "environment.h"
diff --git a/cache.h b/cache.h
index f02c7c9609d..f5eaea341c2 100644
--- a/cache.h
+++ b/cache.h
@@ -29,18 +29,6 @@
 #define DTYPE(de)	DT_UNKNOWN
 #endif
 
-/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
-#define S_IFINVALID     0030000
-
-/*
- * A "directory link" is a link to another git directory.
- *
- * The value 0160000 is not normally a valid mode, and
- * also just happens to be S_IFDIR + S_IFLNK
- */
-#define S_IFGITLINK	0160000
-#define S_ISGITLINK(m)	(((m) & S_IFMT) == S_IFGITLINK)
-
 /*
  * Some mode bits are also used internally for computations.
  *
@@ -156,8 +144,6 @@ struct cache_entry {
 #error "CE_EXTENDED_FLAGS out of range"
 #endif
 
-#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
-
 /* Forward structure decls */
 struct pathspec;
 struct child_process;
@@ -415,13 +401,6 @@ void prefetch_cache_entries(const struct index_state *istate,
 extern struct index_state the_index;
 #endif
 
-static inline enum object_type object_type(unsigned int mode)
-{
-	return S_ISDIR(mode) ? OBJ_TREE :
-		S_ISGITLINK(mode) ? OBJ_COMMIT :
-		OBJ_BLOB;
-}
-
 #define INIT_DB_QUIET 0x0001
 #define INIT_DB_EXIST_OK 0x0002
 
diff --git a/delta-islands.c b/delta-islands.c
index 40f2ccfb550..c824a5f6a42 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "attr.h"
 #include "object.h"
diff --git a/fsck.c b/fsck.c
index 8ef1b022346..adbe8bf59e7 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/http-push.c b/http-push.c
index a8af6c0f690..637a4e91f7a 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/list-objects.c b/list-objects.c
index df18d103063..eecca721ac0 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/object.h b/object.h
index fc45b158da0..568cddfc2b4 100644
--- a/object.h
+++ b/object.h
@@ -101,6 +101,27 @@ enum object_type {
 	OBJ_MAX
 };
 
+/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
+#define S_IFINVALID     0030000
+
+/*
+ * A "directory link" is a link to another git directory.
+ *
+ * The value 0160000 is not normally a valid mode, and
+ * also just happens to be S_IFDIR + S_IFLNK
+ */
+#define S_IFGITLINK	0160000
+#define S_ISGITLINK(m)	(((m) & S_IFMT) == S_IFGITLINK)
+
+#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
+
+static inline enum object_type object_type(unsigned int mode)
+{
+	return S_ISDIR(mode) ? OBJ_TREE :
+		S_ISGITLINK(mode) ? OBJ_COMMIT :
+		OBJ_BLOB;
+}
+
 /*
  * The object type is stored in 3 bits.
  */
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 7f5f489beb0..faf67c94d37 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.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/submodule-config.c b/submodule-config.c
index 252b90aa439..7fc0812b644 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/walker.c b/walker.c
index cfbd257fdba..24ff7dfdc28 100644
--- a/walker.c
+++ b/walker.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "walker.h"
-- 
gitgitgadget


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

* [PATCH 15/24] editor: move editor-related functions and declarations into common file
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (13 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 14/24] object.h: move an inline function and some defines from cache.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 16/24] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren via GitGitGadget
                   ` (10 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

cache.h and strbuf.[ch] had editor-related functions.  Move these into
editor.[ch].

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 add-patch.c          |  1 +
 builtin/add.c        |  1 +
 builtin/am.c         |  1 +
 builtin/branch.c     |  1 +
 builtin/bugreport.c  |  1 +
 builtin/commit.c     |  1 +
 builtin/config.c     |  1 +
 builtin/merge.c      |  1 +
 builtin/notes.c      |  1 +
 builtin/replace.c    |  1 +
 builtin/tag.c        |  1 +
 builtin/var.c        |  1 +
 cache.h              |  3 ---
 color.c              |  1 +
 editor.c             | 30 ++++++++++++++++++++++++++++++
 editor.h             | 34 ++++++++++++++++++++++++++++++++++
 pager.c              |  1 +
 rebase-interactive.c |  1 +
 sideband.c           |  1 +
 strbuf.c             | 28 ----------------------------
 strbuf.h             | 24 ------------------------
 21 files changed, 80 insertions(+), 55 deletions(-)
 create mode 100644 editor.h

diff --git a/add-patch.c b/add-patch.c
index b01ba8fa81d..8d770d203ff 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -2,6 +2,7 @@
 #include "add-interactive.h"
 #include "advice.h"
 #include "alloc.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "object-name.h"
diff --git a/builtin/add.c b/builtin/add.c
index d3c51e28142..76cc026a68a 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "builtin.h"
 #include "lockfile.h"
+#include "editor.h"
 #include "dir.h"
 #include "gettext.h"
 #include "pathspec.h"
diff --git a/builtin/am.c b/builtin/am.c
index 0d7ee28bddc..f7a065e5290 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -9,6 +9,7 @@
 #include "advice.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index 7c1c872708f..1fb11d55e65 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -8,6 +8,7 @@
 #include "cache.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "environment.h"
 #include "refs.h"
 #include "commit.h"
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index 03fb0536911..daf6c236577 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "abspath.h"
+#include "editor.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "strbuf.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 682f47c8d5a..e67c4be2211 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -13,6 +13,7 @@
 #include "cache-tree.h"
 #include "color.h"
 #include "dir.h"
+#include "editor.h"
 #include "environment.h"
 #include "builtin.h"
 #include "diff.h"
diff --git a/builtin/config.c b/builtin/config.c
index fe79fb60c43..9401f1e5e3b 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -3,6 +3,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "ident.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 693f185d4d3..8da3e46abb0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -12,6 +12,7 @@
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 896140b9055..d5788352b6e 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index f4b3a8efb23..981f1894436 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -11,6 +11,7 @@
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 88a25902309..7d189a4a5d4 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -10,6 +10,7 @@
 #include "advice.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/var.c b/builtin/var.c
index d9943be9afd..90616cf65a2 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -5,6 +5,7 @@
  */
 #include "builtin.h"
 #include "config.h"
+#include "editor.h"
 #include "ident.h"
 #include "refs.h"
 
diff --git a/cache.h b/cache.h
index f5eaea341c2..f469e250f30 100644
--- a/cache.h
+++ b/cache.h
@@ -665,10 +665,7 @@ 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);
 
-const char *git_editor(void);
-const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
-int is_terminal_dumb(void);
 
 struct cache_def {
 	struct strbuf path;
diff --git a/color.c b/color.c
index 672dcbb73a6..a8e8d5202ab 100644
--- a/color.c
+++ b/color.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "gettext.h"
 #include "hex.h"
 
diff --git a/editor.c b/editor.c
index 3bea3ef72f7..12025dfec37 100644
--- a/editor.c
+++ b/editor.c
@@ -2,12 +2,14 @@
 #include "abspath.h"
 #include "advice.h"
 #include "config.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "run-command.h"
 #include "sigchain.h"
+#include "wrapper.h"
 
 #ifndef DEFAULT_EDITOR
 #define DEFAULT_EDITOR "vi"
@@ -130,3 +132,31 @@ int launch_sequence_editor(const char *path, struct strbuf *buffer,
 {
 	return launch_specified_editor(git_sequence_editor(), path, buffer, env);
 }
+
+int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
+			      const char *const *env)
+{
+	char *path2 = NULL;
+	int fd, res = 0;
+
+	if (!is_absolute_path(path))
+		path = path2 = xstrdup(git_path("%s", path));
+
+	fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+	if (fd < 0)
+		res = error_errno(_("could not open '%s' for writing"), path);
+	else if (write_in_full(fd, buffer->buf, buffer->len) < 0) {
+		res = error_errno(_("could not write to '%s'"), path);
+		close(fd);
+	} else if (close(fd) < 0)
+		res = error_errno(_("could not close '%s'"), path);
+	else {
+		strbuf_reset(buffer);
+		if (launch_editor(path, buffer, env) < 0)
+			res = error_errno(_("could not edit '%s'"), path);
+		unlink(path);
+	}
+
+	free(path2);
+	return res;
+}
diff --git a/editor.h b/editor.h
new file mode 100644
index 00000000000..8016bb5e00b
--- /dev/null
+++ b/editor.h
@@ -0,0 +1,34 @@
+#ifndef EDITOR_H
+#define EDITOR_H
+
+struct strbuf;
+
+const char *git_editor(void);
+const char *git_sequence_editor(void);
+int is_terminal_dumb(void);
+
+/**
+ * Launch the user preferred editor to edit a file and fill the buffer
+ * with the file's contents upon the user completing their editing. The
+ * third argument can be used to set the environment which the editor is
+ * run in. If the buffer is NULL the editor is launched as usual but the
+ * file's contents are not read into the buffer upon completion.
+ */
+int launch_editor(const char *path, struct strbuf *buffer,
+		  const char *const *env);
+
+int launch_sequence_editor(const char *path, struct strbuf *buffer,
+			   const char *const *env);
+
+/*
+ * In contrast to `launch_editor()`, this function writes out the contents
+ * of the specified file first, then clears the `buffer`, then launches
+ * the editor and reads back in the file contents into the `buffer`.
+ * Finally, it deletes the temporary file.
+ *
+ * If `path` is relative, it refers to a file in the `.git` directory.
+ */
+int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
+			      const char *const *env);
+
+#endif
diff --git a/pager.c b/pager.c
index b66bbff2785..6367e8ef867 100644
--- a/pager.c
+++ b/pager.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "config.h"
+#include "editor.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "alias.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 48467a7bc4a..8a8fafa9231 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "commit.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "sequencer.h"
diff --git a/sideband.c b/sideband.c
index 0af582858bf..25e2a185716 100644
--- a/sideband.c
+++ b/sideband.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "color.h"
 #include "config.h"
+#include "editor.h"
 #include "gettext.h"
 #include "sideband.h"
 #include "help.h"
diff --git a/strbuf.c b/strbuf.c
index b2e3735ba8a..729378ec824 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1180,34 +1180,6 @@ int strbuf_normalize_path(struct strbuf *src)
 	return 0;
 }
 
-int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
-			      const char *const *env)
-{
-	char *path2 = NULL;
-	int fd, res = 0;
-
-	if (!is_absolute_path(path))
-		path = path2 = xstrdup(git_path("%s", path));
-
-	fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
-	if (fd < 0)
-		res = error_errno(_("could not open '%s' for writing"), path);
-	else if (write_in_full(fd, buffer->buf, buffer->len) < 0) {
-		res = error_errno(_("could not write to '%s'"), path);
-		close(fd);
-	} else if (close(fd) < 0)
-		res = error_errno(_("could not close '%s'"), path);
-	else {
-		strbuf_reset(buffer);
-		if (launch_editor(path, buffer, env) < 0)
-			res = error_errno(_("could not edit '%s'"), path);
-		unlink(path);
-	}
-
-	free(path2);
-	return res;
-}
-
 void strbuf_strip_file_from_path(struct strbuf *sb)
 {
 	char *path_sep = find_last_dir_sep(sb->buf);
diff --git a/strbuf.h b/strbuf.h
index b980f9edc6d..3dfeadb44c2 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -640,30 +640,6 @@ void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
 void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
 			      int abbrev_len);
 
-/**
- * Launch the user preferred editor to edit a file and fill the buffer
- * with the file's contents upon the user completing their editing. The
- * third argument can be used to set the environment which the editor is
- * run in. If the buffer is NULL the editor is launched as usual but the
- * file's contents are not read into the buffer upon completion.
- */
-int launch_editor(const char *path, struct strbuf *buffer,
-		  const char *const *env);
-
-int launch_sequence_editor(const char *path, struct strbuf *buffer,
-			   const char *const *env);
-
-/*
- * In contrast to `launch_editor()`, this function writes out the contents
- * of the specified file first, then clears the `buffer`, then launches
- * the editor and reads back in the file contents into the `buffer`.
- * Finally, it deletes the temporary file.
- *
- * If `path` is relative, it refers to a file in the `.git` directory.
- */
-int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
-			      const char *const *env);
-
 /*
  * Remove the filename from the provided path string. If the path
  * contains a trailing separator, then the path is considered a directory
-- 
gitgitgadget


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

* [PATCH 16/24] treewide: remove cache.h inclusion due to editor.h changes
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (14 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 15/24] editor: move editor-related functions and declarations into common file Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 17/24] pager.h: move declarations for pager.c functions from cache.h Elijah Newren via GitGitGadget
                   ` (9 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

This actually only affects sideband.c, but helps towards removing
cache.h inclusion in conjunction with some of the upcoming patches
that will be applied.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 sideband.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sideband.c b/sideband.c
index 25e2a185716..6cbfd391c47 100644
--- a/sideband.c
+++ b/sideband.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "color.h"
 #include "config.h"
 #include "editor.h"
-- 
gitgitgadget


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

* [PATCH 17/24] pager.h: move declarations for pager.c functions from cache.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (15 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 16/24] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 18/24] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren via GitGitGadget
                   ` (8 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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/am.c       |  1 +
 builtin/blame.c    |  1 +
 builtin/fetch.c    |  1 +
 builtin/grep.c     |  1 +
 builtin/help.c     |  1 +
 builtin/log.c      |  1 +
 builtin/name-rev.c |  1 +
 builtin/var.c      |  1 +
 cache.h            | 12 ------------
 color.c            |  1 +
 column.c           |  1 +
 config.c           |  1 +
 date.c             |  1 +
 diff.c             |  1 +
 editor.c           |  1 +
 environment.c      |  1 -
 git.c              |  1 +
 pager.c            |  3 +++
 pager.h            | 17 +++++++++++++++++
 pretty.c           |  1 +
 progress.c         |  1 +
 range-diff.c       |  1 +
 sequencer.c        |  1 +
 23 files changed, 39 insertions(+), 13 deletions(-)
 create mode 100644 pager.h

diff --git a/builtin/am.c b/builtin/am.c
index f7a065e5290..5c83f2e003f 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -40,6 +40,7 @@
 #include "apply.h"
 #include "string-list.h"
 #include "packfile.h"
+#include "pager.h"
 #include "repository.h"
 #include "pretty.h"
 #include "wrapper.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index a628388c2ce..2df6039a6e0 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -30,6 +30,7 @@
 #include "progress.h"
 #include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "blame.h"
 #include "refs.h"
 #include "setup.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 8a8ab6799e8..61e8ac113b1 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -28,6 +28,7 @@
 #include "strvec.h"
 #include "utf8.h"
 #include "packfile.h"
+#include "pager.h"
 #include "list-objects-filter-options.h"
 #include "commit-reach.h"
 #include "branch.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index fb11be6075a..b86c754defb 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -30,6 +30,7 @@
 #include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
+#include "pager.h"
 #include "write-or-die.h"
 
 static const char *grep_prefix;
diff --git a/builtin/help.c b/builtin/help.c
index 87333a02ec4..128aa83099a 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -6,6 +6,7 @@
 #include "builtin.h"
 #include "exec-cmd.h"
 #include "gettext.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "run-command.h"
 #include "config-list.h"
diff --git a/builtin/log.c b/builtin/log.c
index b6246c7042c..95de51921f8 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -15,6 +15,7 @@
 #include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "color.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 41fd56b9ba9..593f0506a10 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -9,6 +9,7 @@
 #include "tag.h"
 #include "refs.h"
 #include "object-name.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "hash-lookup.h"
diff --git a/builtin/var.c b/builtin/var.c
index 90616cf65a2..aa8150fa92e 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "editor.h"
 #include "ident.h"
+#include "pager.h"
 #include "refs.h"
 
 static const char var_usage[] = "git var (-l | <variable>)";
diff --git a/cache.h b/cache.h
index f469e250f30..b136b0c51ef 100644
--- a/cache.h
+++ b/cache.h
@@ -665,8 +665,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);
 
-const char *git_pager(int stdout_is_tty);
-
 struct cache_def {
 	struct strbuf path;
 	int flags;
@@ -723,16 +721,6 @@ 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);
 
-/* pager.c */
-void setup_pager(void);
-int pager_in_use(void);
-extern int pager_use_color;
-int term_columns(void);
-void term_clear_line(void);
-int decimal_width(uintmax_t);
-int check_pager_config(const char *cmd);
-void prepare_pager_args(struct child_process *, const char *pager);
-
 /* 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/color.c b/color.c
index a8e8d5202ab..6031998d3ea 100644
--- a/color.c
+++ b/color.c
@@ -4,6 +4,7 @@
 #include "editor.h"
 #include "gettext.h"
 #include "hex.h"
+#include "pager.h"
 
 static int git_use_color_default = GIT_COLOR_AUTO;
 int color_stdout_is_tty = -1;
diff --git a/column.c b/column.c
index fbf88639aae..c89c90328a6 100644
--- a/column.c
+++ b/column.c
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "column.h"
 #include "string-list.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "run-command.h"
 #include "utf8.h"
diff --git a/config.c b/config.c
index aac439530e9..11e3295419b 100644
--- a/config.c
+++ b/config.c
@@ -25,6 +25,7 @@
 #include "string-list.h"
 #include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "utf8.h"
 #include "dir.h"
 #include "color.h"
diff --git a/date.c b/date.c
index 1fb2cd1b538..e944c8905af 100644
--- a/date.c
+++ b/date.c
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "date.h"
 #include "gettext.h"
+#include "pager.h"
 
 /*
  * This is like mktime, but without normalization of tm_wday and tm_yday.
diff --git a/diff.c b/diff.c
index f8e0d3b5c59..fa86d023196 100644
--- a/diff.c
+++ b/diff.c
@@ -31,6 +31,7 @@
 #include "graph.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "help.h"
 #include "promisor-remote.h"
diff --git a/editor.c b/editor.c
index 12025dfec37..7c796385493 100644
--- a/editor.c
+++ b/editor.c
@@ -5,6 +5,7 @@
 #include "editor.h"
 #include "environment.h"
 #include "gettext.h"
+#include "pager.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "run-command.h"
diff --git a/environment.c b/environment.c
index 39efa49fe31..8a96997539a 100644
--- a/environment.c
+++ b/environment.c
@@ -59,7 +59,6 @@ size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 size_t delta_base_cache_limit = 96 * 1024 * 1024;
 unsigned long big_file_threshold = 512 * 1024 * 1024;
-int pager_use_color = 1;
 const char *editor_program;
 const char *askpass_program;
 const char *excludes_file;
diff --git a/git.c b/git.c
index d2bb86e0d32..0241d2cf913 100644
--- a/git.c
+++ b/git.c
@@ -4,6 +4,7 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "help.h"
+#include "pager.h"
 #include "run-command.h"
 #include "alias.h"
 #include "replace-object.h"
diff --git a/pager.c b/pager.c
index 6367e8ef867..be78c706644 100644
--- a/pager.c
+++ b/pager.c
@@ -1,10 +1,13 @@
 #include "cache.h"
 #include "config.h"
 #include "editor.h"
+#include "pager.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "alias.h"
 
+int pager_use_color = 1;
+
 #ifndef DEFAULT_PAGER
 #define DEFAULT_PAGER "less"
 #endif
diff --git a/pager.h b/pager.h
new file mode 100644
index 00000000000..b77433026dc
--- /dev/null
+++ b/pager.h
@@ -0,0 +1,17 @@
+#ifndef PAGER_H
+#define PAGER_H
+
+struct child_process;
+
+const char *git_pager(int stdout_is_tty);
+void setup_pager(void);
+int pager_in_use(void);
+int term_columns(void);
+void term_clear_line(void);
+int decimal_width(uintmax_t);
+int check_pager_config(const char *cmd);
+void prepare_pager_args(struct child_process *, const char *pager);
+
+extern int pager_use_color;
+
+#endif /* PAGER_H */
diff --git a/pretty.c b/pretty.c
index 76fc4f61e40..c4671603b56 100644
--- a/pretty.c
+++ b/pretty.c
@@ -7,6 +7,7 @@
 #include "hex.h"
 #include "utf8.h"
 #include "diff.h"
+#include "pager.h"
 #include "revision.h"
 #include "string-list.h"
 #include "mailmap.h"
diff --git a/progress.c b/progress.c
index c5c8514737a..96a8e36a52f 100644
--- a/progress.c
+++ b/progress.c
@@ -10,6 +10,7 @@
 
 #define GIT_TEST_PROGRESS_ONLY
 #include "cache.h"
+#include "pager.h"
 #include "progress.h"
 #include "strbuf.h"
 #include "trace.h"
diff --git a/range-diff.c b/range-diff.c
index a2994331a14..a1e0cffb9f6 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -11,6 +11,7 @@
 #include "linear-assignment.h"
 #include "diffcore.h"
 #include "commit.h"
+#include "pager.h"
 #include "pretty.h"
 #include "userdiff.h"
 #include "apply.h"
diff --git a/sequencer.c b/sequencer.c
index be10249fd0a..fcca3b81447 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -12,6 +12,7 @@
 #include "object-name.h"
 #include "object-store.h"
 #include "object.h"
+#include "pager.h"
 #include "commit.h"
 #include "sequencer.h"
 #include "tag.h"
-- 
gitgitgadget


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

* [PATCH 18/24] treewide: remove cache.h inclusion due to pager.h changes
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (16 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 17/24] pager.h: move declarations for pager.c functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 19/24] cache.h: remove unnecessary includes Elijah Newren via GitGitGadget
                   ` (7 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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>
---
 column.c   | 2 +-
 editor.c   | 2 +-
 pager.c    | 2 +-
 pretty.c   | 2 +-
 progress.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/column.c b/column.c
index c89c90328a6..ff2f0abf399 100644
--- a/column.c
+++ b/column.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "column.h"
 #include "string-list.h"
diff --git a/editor.c b/editor.c
index 7c796385493..b34e10606d2 100644
--- a/editor.c
+++ b/editor.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
 #include "config.h"
diff --git a/pager.c b/pager.c
index be78c706644..63055d0873f 100644
--- a/pager.c
+++ b/pager.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "editor.h"
 #include "pager.h"
diff --git a/pretty.c b/pretty.c
index c4671603b56..0bb938021ba 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "commit.h"
diff --git a/progress.c b/progress.c
index 96a8e36a52f..72d5e0c73c1 100644
--- a/progress.c
+++ b/progress.c
@@ -9,7 +9,7 @@
  */
 
 #define GIT_TEST_PROGRESS_ONLY
-#include "cache.h"
+#include "git-compat-util.h"
 #include "pager.h"
 #include "progress.h"
 #include "strbuf.h"
-- 
gitgitgadget


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

* [PATCH 19/24] cache.h: remove unnecessary includes
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (17 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 18/24] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 20/24] strbuf: move forward declarations to beginning of file Elijah Newren via GitGitGadget
                   ` (6 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

cache.h did not need any of these headers, and nothing that depended
upon cache.h needed them either.  Simply expunge these includes.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/cache.h b/cache.h
index b136b0c51ef..3c3e40b52e8 100644
--- a/cache.h
+++ b/cache.h
@@ -5,14 +5,10 @@
 #include "strbuf.h"
 #include "git-zlib.h"
 #include "hashmap.h"
-#include "list.h"
 #include "gettext.h"
 #include "string-list.h"
-#include "hash.h"
-#include "path.h"
 #include "pathspec.h"
 #include "object.h"
-#include "repository.h"
 #include "statinfo.h"
 
 #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
-- 
gitgitgadget


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

* [PATCH 20/24] strbuf: move forward declarations to beginning of file
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (18 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 19/24] cache.h: remove unnecessary includes Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 21/24] treewide: remove double forward declaration of read_in_full Elijah Newren via GitGitGadget
                   ` (5 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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>
---
 strbuf.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/strbuf.h b/strbuf.h
index 3dfeadb44c2..547696fb233 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -1,6 +1,8 @@
 #ifndef STRBUF_H
 #define STRBUF_H
 
+struct object_id;
+struct repository;
 struct string_list;
 
 /**
@@ -72,12 +74,6 @@ struct strbuf {
 extern char strbuf_slopbuf[];
 #define STRBUF_INIT  { .buf = strbuf_slopbuf }
 
-/*
- * Predeclare this here, since cache.h includes this file before it defines the
- * struct.
- */
-struct object_id;
-
 /**
  * Life Cycle Functions
  * --------------------
@@ -634,7 +630,6 @@ void strbuf_list_free(struct strbuf **list);
  * Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
  * the strbuf `sb`.
  */
-struct repository;
 void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
 				   const struct object_id *oid, int abbrev_len);
 void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
-- 
gitgitgadget


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

* [PATCH 21/24] treewide: remove double forward declaration of read_in_full
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (19 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 20/24] strbuf: move forward declarations to beginning of file Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 22/24] treewide: reduce includes of cache.h in other headers Elijah Newren via GitGitGadget
                   ` (4 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

cache.h's nature of a dumping ground of includes prevented it from
being included in some compat/ files, forcing us into a workaround
of having a double forward declaration of the read_in_full() function
(see commit 14086b0a13 ("compat/pread.c: Add a forward declaration to
fix a warning", 2007-11-17)).  Now that we have moved functions like
read_in_full() from cache.h to wrapper.h, and wrapper.h isn't littered
with unrelated and scary #defines, get rid of the extra forward
declaration and just have compat/pread.c include wrapper.h.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/clone.c       | 1 +
 bulk-checkin.c        | 1 +
 combine-diff.c        | 1 +
 compat/pread.c        | 1 +
 git-compat-util.h     | 6 ------
 grep.c                | 1 +
 pack-write.c          | 1 +
 path.c                | 1 +
 refs/packed-backend.c | 1 +
 send-pack.c           | 1 +
 setup.c               | 1 +
 upload-pack.c         | 1 +
 12 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index c7fdffb484c..4ed0a1d5aad 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -42,6 +42,7 @@
 #include "hook.h"
 #include "bundle.h"
 #include "bundle-uri.h"
+#include "wrapper.h"
 
 /*
  * Overall FIXMEs:
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 9192298db6a..d843279715c 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -17,6 +17,7 @@
 #include "packfile.h"
 #include "object-file.h"
 #include "object-store.h"
+#include "wrapper.h"
 
 static int odb_transaction_nesting;
 
diff --git a/combine-diff.c b/combine-diff.c
index cd5f39f22f4..f7e9fb57473 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -16,6 +16,7 @@
 #include "userdiff.h"
 #include "oid-array.h"
 #include "revision.h"
+#include "wrapper.h"
 
 static int compare_paths(const struct combine_diff_path *one,
 			  const struct diff_filespec *two)
diff --git a/compat/pread.c b/compat/pread.c
index 978cac4ec91..484e6d4c716 100644
--- a/compat/pread.c
+++ b/compat/pread.c
@@ -1,4 +1,5 @@
 #include "../git-compat-util.h"
+#include "../wrapper.h"
 
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
 {
diff --git a/git-compat-util.h b/git-compat-util.h
index 1e6592624d0..4fb771f42a5 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -859,12 +859,6 @@ int git_lstat(const char *, struct stat *);
 #define pread git_pread
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
 #endif
-/*
- * Forward decl that will remind us if its twin in cache.h changes.
- * This function is used in compat/pread.c.  But we can't include
- * cache.h there.
- */
-ssize_t read_in_full(int fd, void *buf, size_t count);
 
 #ifdef NO_SETENV
 #define setenv gitsetenv
diff --git a/grep.c b/grep.c
index bb8796a829f..d144b374894 100644
--- a/grep.c
+++ b/grep.c
@@ -11,6 +11,7 @@
 #include "commit.h"
 #include "quote.h"
 #include "help.h"
+#include "wrapper.h"
 
 static int grep_source_load(struct grep_source *gs);
 static int grep_source_is_binary(struct grep_source *gs,
diff --git a/pack-write.c b/pack-write.c
index d9b460fab4c..9c37121be31 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -10,6 +10,7 @@
 #include "oidmap.h"
 #include "pack-objects.h"
 #include "pack-revindex.h"
+#include "wrapper.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
 {
diff --git a/path.c b/path.c
index dff215ac693..7c1cd8182a8 100644
--- a/path.c
+++ b/path.c
@@ -18,6 +18,7 @@
 #include "object-store.h"
 #include "lockfile.h"
 #include "exec-cmd.h"
+#include "wrapper.h"
 
 static int get_st_mode_bits(const char *path, int *mode)
 {
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 1eba1015dd5..2333ed5a1f7 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 "../wrapper.h"
 #include "../write-or-die.h"
 
 enum mmap_strategy {
diff --git a/send-pack.c b/send-pack.c
index 72ebb7b61ae..351037b07bc 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -14,6 +14,7 @@
 #include "quote.h"
 #include "transport.h"
 #include "version.h"
+#include "wrapper.h"
 #include "oid-array.h"
 #include "gpg-interface.h"
 #include "shallow.h"
diff --git a/setup.c b/setup.c
index a546da755f1..59abc16ba6d 100644
--- a/setup.c
+++ b/setup.c
@@ -12,6 +12,7 @@
 #include "promisor-remote.h"
 #include "quote.h"
 #include "trace2.h"
+#include "wrapper.h"
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
diff --git a/upload-pack.c b/upload-pack.c
index 0305fb2fbdc..e16dee783dd 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -32,6 +32,7 @@
 #include "commit-graph.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "wrapper.h"
 #include "write-or-die.h"
 
 /* Remember to update object flag allocation in object.h */
-- 
gitgitgadget


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

* [PATCH 22/24] treewide: reduce includes of cache.h in other headers
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (20 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 21/24] treewide: remove double forward declaration of read_in_full Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 23/24] chdir-notify, quote: replace cache.h include with path.h Elijah Newren via GitGitGadget
                   ` (3 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

We had a handful of headers including cache.h that didn't need to
anymore.  Drop those includes and replace them with includes of
smaller files, or forward declarations.  However, note that two .c
files now need to directly include cache.h, though they should have
been including it all along given they are directly using structs
defined in it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 archive.h        | 2 +-
 refs/ref-cache.h | 2 +-
 rerere.c         | 2 +-
 resolve-undo.h   | 7 ++++++-
 revision.c       | 2 +-
 split-index.h    | 2 +-
 6 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/archive.h b/archive.h
index f96839ef383..3a4bdfbd078 100644
--- a/archive.h
+++ b/archive.h
@@ -1,9 +1,9 @@
 #ifndef ARCHIVE_H
 #define ARCHIVE_H
 
-#include "cache.h"
 #include "object-name.h"
 #include "pathspec.h"
+#include "string-list.h"
 
 struct repository;
 struct pretty_print_context;
diff --git a/refs/ref-cache.h b/refs/ref-cache.h
index 850d9d3744e..cf4ad9070b9 100644
--- a/refs/ref-cache.h
+++ b/refs/ref-cache.h
@@ -1,7 +1,7 @@
 #ifndef REFS_REF_CACHE_H
 #define REFS_REF_CACHE_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct ref_dir;
 struct ref_store;
diff --git a/rerere.c b/rerere.c
index 093c0f6f993..7abc94bf444 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/resolve-undo.h b/resolve-undo.h
index 2b3f0f901e6..d1ea9727712 100644
--- a/resolve-undo.h
+++ b/resolve-undo.h
@@ -1,7 +1,12 @@
 #ifndef RESOLVE_UNDO_H
 #define RESOLVE_UNDO_H
 
-#include "cache.h"
+struct cache_entry;
+struct index_state;
+struct pathspec;
+struct string_list;
+
+#include "hash.h"
 
 struct resolve_undo_info {
 	unsigned int mode[3];
diff --git a/revision.c b/revision.c
index 7438b50e267..bea401992e3 100644
--- a/revision.c
+++ b/revision.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/split-index.h b/split-index.h
index 7a435ca2c97..1a153f47ba3 100644
--- a/split-index.h
+++ b/split-index.h
@@ -1,7 +1,7 @@
 #ifndef SPLIT_INDEX_H
 #define SPLIT_INDEX_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct index_state;
 struct strbuf;
-- 
gitgitgadget


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

* [PATCH 23/24] chdir-notify, quote: replace cache.h include with path.h
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (21 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 22/24] treewide: reduce includes of cache.h in other headers Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-01 15:10 ` [PATCH 24/24] mailmap, quote: move declarations of global vars to correct unit Elijah Newren via GitGitGadget
                   ` (2 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 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>
---
 chdir-notify.c | 3 ++-
 quote.c        | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/chdir-notify.c b/chdir-notify.c
index 8e38cd6f3ae..0d7bc046074 100644
--- a/chdir-notify.c
+++ b/chdir-notify.c
@@ -1,7 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "chdir-notify.h"
 #include "list.h"
+#include "path.h"
 #include "strbuf.h"
 #include "trace.h"
 
diff --git a/quote.c b/quote.c
index 7ccb5a06cd1..43c739671ed 100644
--- a/quote.c
+++ b/quote.c
@@ -1,5 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
+#include "path.h"
 #include "quote.h"
 #include "strbuf.h"
 #include "strvec.h"
-- 
gitgitgadget


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

* [PATCH 24/24] mailmap, quote: move declarations of global vars to correct unit
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (22 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 23/24] chdir-notify, quote: replace cache.h include with path.h Elijah Newren via GitGitGadget
@ 2023-04-01 15:10 ` Elijah Newren via GitGitGadget
  2023-04-03 16:23 ` [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-01 15:10 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Since earlier commits removed the inclusion of cache.h from mailmap.c
and quote.c, it feels odd to have the extern declarations of
global variables in cache.h rather than the actual header included
by the source file.  Move these global variable extern declarations
from cache.h to mailmap.c and quote.c.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h   | 5 -----
 config.c  | 1 +
 mailmap.h | 3 +++
 quote.h   | 2 ++
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/cache.h b/cache.h
index 3c3e40b52e8..4d64ec95dc6 100644
--- a/cache.h
+++ b/cache.h
@@ -622,8 +622,6 @@ void set_alternate_index_output(const char *);
 extern int verify_index_checksum;
 extern int verify_ce_order;
 
-extern int quote_path_fully;
-
 #define MTIME_CHANGED	0x0001
 #define CTIME_CHANGED	0x0002
 #define OWNER_CHANGED	0x0004
@@ -708,9 +706,6 @@ extern int fetch_if_missing;
 /* Dumb servers support */
 int update_server_info(int);
 
-extern const char *git_mailmap_file;
-extern const char *git_mailmap_blob;
-
 #define COPY_READ_ERROR (-2)
 #define COPY_WRITE_ERROR (-3)
 int copy_fd(int ifd, int ofd);
diff --git a/config.c b/config.c
index 11e3295419b..9beba19b41c 100644
--- a/config.c
+++ b/config.c
@@ -18,6 +18,7 @@
 #include "ident.h"
 #include "repository.h"
 #include "lockfile.h"
+#include "mailmap.h"
 #include "exec-cmd.h"
 #include "strbuf.h"
 #include "quote.h"
diff --git a/mailmap.h b/mailmap.h
index 7e99fccb46c..0f8fd2c586f 100644
--- a/mailmap.h
+++ b/mailmap.h
@@ -3,6 +3,9 @@
 
 struct string_list;
 
+extern const char *git_mailmap_file;
+extern const char *git_mailmap_blob;
+
 int read_mailmap(struct string_list *map);
 void clear_mailmap(struct string_list *map);
 
diff --git a/quote.h b/quote.h
index 87ff458b06d..0300c291041 100644
--- a/quote.h
+++ b/quote.h
@@ -3,6 +3,8 @@
 
 struct strbuf;
 
+extern int quote_path_fully;
+
 /* Help to copy the thing properly quoted for the shell safety.
  * any single quote is replaced with '\'', any exclamation point
  * is replaced with '\!', and the whole thing is enclosed in a
-- 
gitgitgadget

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

* Re: [PATCH 00/24] Header cleanups (splitting up cache.h)
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (23 preceding siblings ...)
  2023-04-01 15:10 ` [PATCH 24/24] mailmap, quote: move declarations of global vars to correct unit Elijah Newren via GitGitGadget
@ 2023-04-03 16:23 ` Elijah Newren
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-03 16:23 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget; +Cc: git, Calvin Wan

On Sat, Apr 1, 2023 at 8:10 AM Elijah Newren via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
[...]
> This series builds on en/header-cleanup
> (https://lore.kernel.org/git/pull.1485.v2.git.1677197376.gitgitgadget@gmail.com/)
> and en/header-split-cleanup
> (https://lore.kernel.org/git/pull.1493.v2.git.1679379968.gitgitgadget@gmail.com/),
> and continues to focus on splitting declarations from cache.h to separate
> headers.
[...]
>
> There are more changes I plan to make after this series graduates (still
> focused around splitting up cache.h), but this series was long enough.

While preparing some of those additional splits of cache.h, I found a
few small tweaks that make more sense being squashed into this series.
I'll send out a re-roll tonight.

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

* [PATCH v2 00/24] Header cleanups (splitting up cache.h)
  2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
                   ` (24 preceding siblings ...)
  2023-04-03 16:23 ` [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren
@ 2023-04-04  1:22 ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
                     ` (25 more replies)
  25 siblings, 26 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

Maintainer notes: (1) This series is based on a merge of
en/header-split-cleanup and ab/remove-implicit-use-of-the-repository (both
in next). (2) Although I've tweaked the series to minimize conflicts (and
this series merges syntactically cleanly with next and seen), there is a
semantic conflict with each of ja/worktree-orphan and
ab/tag-object-type-errors in seen; to correct, simply add an include of
advice.h in builtin/worktree.c and an include of gettext.h in tag.c,
respectively.

This series builds on en/header-cleanup
(https://lore.kernel.org/git/pull.1485.v2.git.1677197376.gitgitgadget@gmail.com/)
and en/header-split-cleanup
(https://lore.kernel.org/git/pull.1493.v2.git.1679379968.gitgitgadget@gmail.com/),
and continues to focus on splitting declarations from cache.h to separate
headers. This series continues dropping the number of cache.h includes; in
this series we go from 254 such includes to 190.

The series may appear to be long at first glance, but is repetitive and
simple. It should be relatively easy to review, and falls into roughly 3
categories. An overview:

 * Patches 1-6, 7: Being more explicit about dependencies. This was
   motivated by the fact that trying to find unnecessary dependencies on
   cache.h were being made harder by implicit dependencies on trace.h,
   trace2.h, and advice.h that were included via cache.h. (Similar to
   gettext.h handling in the previous series.) So I simply try to make
   dependencies more explicit, for both these headers and a few others. To
   make review easy, I split it into half a dozen patches, one header per
   patch (well, except that I handle trace.h and trace2.h together). Patch 7
   then removes several includes of cache.h that are no longer needed due to
   patches 1-6.
 * Patches 8-19: For several choices of FOO, move declarations of functions
   for FOO.c from cache.h to FOO.h. To simplify reviewing, each case is
   split into two patches, with the second patch cleaning up unnecessary
   includes of cache.h in other source files.
 * Patches 20-24: Other small manual cleanups noticed while doing above work

Since patches 1-15 & 17-19 are just more of the same types of patches
already reviewed in the last two series, it probably makes more sense for
reviewers to focus on the other patches: 16 + 20-24 (which also happen to be
smaller). I would particularly most like review of patches 16, 22, & 24
since they are the least like any previously reviewed patches.

Changes since v1:

 * Moved a few more things from cache.h to object.h, object-file.h, and
   object-name.h
 * Split the object.h changes into two patches to be more like all the other
   patches in 8-19
 * Squashed patches 22 & 23, since both were just manual replacements of
   cache.h inclusion with some other header
 * Removed a couple cases of duplicate inclusions of git-compat-util.h

There are more changes I plan to make after this series graduates (still
focused around splitting up cache.h), but this series was long enough.

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 (24):
  treewide: be explicit about dependence on trace.h & trace2.h
  treewide: be explicit about dependence on advice.h
  treewide: be explicit about dependence on convert.h
  treewide: be explicit about dependence on pack-revindex.h
  treewide: be explicit about dependence on oid-array.h
  treewide: be explicit about dependence on mem-pool.h
  treewide: remove unnecessary cache.h inclusion
  object-name.h: move declarations for object-name.c functions from
    cache.h
  treewide: remove cache.h inclusion due to object-name.h changes
  git-zlib: move declarations for git-zlib functions from cache.h
  treewide: remove cache.h inclusion due to git-zlib changes
  object-file.h: move declarations for object-file.c functions from
    cache.h
  treewide: remove cache.h inclusion due to object-file.h changes
  object.h: move some inline functions and defines from cache.h
  treewide: remove cache.h inclusion due to object.h changes
  editor: move editor-related functions and declarations into common
    file
  treewide: remove cache.h inclusion due to editor.h changes
  pager.h: move declarations for pager.c functions from cache.h
  treewide: remove cache.h inclusion due to pager.h changes
  cache.h: remove unnecessary includes
  strbuf: move forward declarations to beginning of file
  treewide: remove double forward declaration of read_in_full
  treewide: reduce includes of cache.h in other headers
  mailmap, quote: move declarations of global vars to correct unit

 Makefile                                 |   2 +-
 add-patch.c                              |   3 +
 apply.c                                  |   2 +
 archive-tar.c                            |   1 +
 archive-zip.c                            |   1 +
 archive.c                                |   1 +
 archive.h                                |   3 +-
 bisect.c                                 |   3 +-
 blame.c                                  |   2 +
 branch.c                                 |   3 +-
 builtin/add.c                            |   2 +
 builtin/am.c                             |   4 +
 builtin/bisect.c                         |   2 +
 builtin/blame.c                          |   2 +
 builtin/branch.c                         |   2 +
 builtin/bugreport.c                      |   2 +
 builtin/cat-file.c                       |   3 +
 builtin/check-attr.c                     |   1 +
 builtin/checkout.c                       |   3 +
 builtin/clone.c                          |   3 +
 builtin/commit-graph.c                   |   1 +
 builtin/commit-tree.c                    |   1 +
 builtin/commit.c                         |   3 +
 builtin/config.c                         |   1 +
 builtin/credential-cache--daemon.c       |   1 +
 builtin/describe.c                       |   1 +
 builtin/diagnose.c                       |   1 +
 builtin/difftool.c                       |   1 +
 builtin/fast-export.c                    |   1 +
 builtin/fast-import.c                    |   2 +
 builtin/fetch-pack.c                     |   1 +
 builtin/fetch.c                          |   6 +
 builtin/fsck.c                           |   2 +
 builtin/fsmonitor--daemon.c              |   1 +
 builtin/gc.c                             |   2 +
 builtin/grep.c                           |   3 +
 builtin/hash-object.c                    |   1 +
 builtin/help.c                           |   1 +
 builtin/index-pack.c                     |   3 +
 builtin/init-db.c                        |   1 +
 builtin/log.c                            |   4 +
 builtin/ls-files.c                       |   2 +
 builtin/ls-tree.c                        |   1 +
 builtin/merge-base.c                     |   1 +
 builtin/merge-recursive.c                |   2 +
 builtin/merge-tree.c                     |   1 +
 builtin/merge.c                          |   3 +
 builtin/mktag.c                          |   1 +
 builtin/mv.c                             |   2 +
 builtin/name-rev.c                       |   2 +
 builtin/notes.c                          |   2 +
 builtin/pack-objects.c                   |   1 +
 builtin/prune.c                          |   2 +
 builtin/pull.c                           |   2 +
 builtin/push.c                           |   2 +
 builtin/range-diff.c                     |   1 +
 builtin/read-tree.c                      |   1 +
 builtin/rebase.c                         |   3 +
 builtin/receive-pack.c                   |   3 +
 builtin/replace.c                        |   3 +
 builtin/reset.c                          |   4 +
 builtin/rev-list.c                       |   2 +
 builtin/rev-parse.c                      |   1 +
 builtin/rm.c                             |   1 +
 builtin/show-branch.c                    |   1 +
 builtin/show-ref.c                       |   1 +
 builtin/sparse-checkout.c                |   2 +
 builtin/stash.c                          |   1 +
 builtin/submodule--helper.c              |   2 +
 builtin/tag.c                            |   3 +
 builtin/unpack-file.c                    |   1 +
 builtin/unpack-objects.c                 |   1 +
 builtin/update-index.c                   |   1 +
 builtin/update-ref.c                     |   1 +
 builtin/var.c                            |   2 +
 builtin/verify-commit.c                  |   1 +
 builtin/verify-tag.c                     |   1 +
 builtin/worktree.c                       |   2 +
 bulk-checkin.c                           |   4 +-
 bundle.c                                 |   2 +-
 cache-tree.c                             |   3 +
 cache.h                                  | 330 -----------------------
 chdir-notify.c                           |   4 +-
 checkout.c                               |   4 +-
 color.c                                  |   2 +
 column.c                                 |   3 +-
 combine-diff.c                           |   3 +
 commit-graph.c                           |   4 +-
 commit.c                                 |   3 +-
 common-main.c                            |   1 +
 compat/fsmonitor/fsm-listen-win32.c      |   1 +
 compat/mingw.c                           |   1 +
 compat/pread.c                           |   1 +
 compat/simple-ipc/ipc-unix-socket.c      |   3 +-
 compat/simple-ipc/ipc-win32.c            |   2 +
 compat/win32/trace2_win32_process_info.c |   1 +
 config.c                                 |   6 +
 connect.c                                |   2 +-
 convert.c                                |   3 +
 date.c                                   |   1 +
 delta-islands.c                          |   2 +-
 diff-lib.c                               |   2 +
 diff-no-index.c                          |   2 +-
 diff.c                                   |   5 +
 dir.c                                    |   3 +
 editor.c                                 |  34 ++-
 editor.h                                 |  34 +++
 environment.c                            |   4 +-
 exec-cmd.c                               |   2 +
 fetch-pack.c                             |   3 +-
 fmt-merge-msg.c                          |   3 +-
 fsck.c                                   |   2 +-
 fsmonitor.c                              |   1 +
 fsmonitor.h                              |   1 +
 git-compat-util.h                        |   6 -
 zlib.c => git-zlib.c                     |   3 +-
 git-zlib.h                               |  28 ++
 git.c                                    |   3 +
 grep.c                                   |   1 +
 http-backend.c                           |   3 +-
 http-fetch.c                             |   2 +-
 http-push.c                              |   2 +-
 http-walker.c                            |   2 +-
 http.c                                   |   2 +
 http.h                                   |   4 +-
 list-objects-filter.c                    |   3 +-
 list-objects.c                           |   2 +-
 ll-merge.c                               |   1 +
 log-tree.c                               |   3 +-
 mailmap.c                                |   3 +-
 mailmap.h                                |   3 +
 merge-ort.c                              |   4 +
 merge-recursive.c                        |   2 +
 midx.c                                   |   1 +
 name-hash.c                              |   1 +
 notes-merge.c                            |   6 +-
 notes.c                                  |   3 +-
 object-file.c                            |   2 +
 object-file.h                            | 129 +++++++++
 object-name.c                            |   2 +
 object-name.h                            | 121 +++++++++
 object.c                                 |   1 +
 object.h                                 |  44 +++
 pack-bitmap-write.c                      |   2 +-
 pack-bitmap.c                            |   4 +-
 pack-check.c                             |   3 +-
 pack-mtimes.c                            |   3 +-
 pack-revindex.c                          |   4 +-
 pack-write.c                             |   4 +-
 packfile.c                               |   3 +
 pager.c                                  |   6 +-
 pager.h                                  |  17 ++
 parse-options-cb.c                       |   2 +-
 path.c                                   |   1 +
 pkt-line.c                               |   1 +
 preload-index.c                          |   1 +
 pretty.c                                 |   3 +-
 progress.c                               |   4 +-
 promisor-remote.c                        |   3 +-
 protocol.c                               |   3 +-
 quote.c                                  |   3 +-
 quote.h                                  |   2 +
 range-diff.c                             |   2 +
 read-cache.c                             |   5 +
 rebase-interactive.c                     |   4 +-
 ref-filter.c                             |   2 +
 refs.c                                   |   4 +-
 refs/files-backend.c                     |   1 +
 refs/packed-backend.c                    |   1 +
 refs/ref-cache.h                         |   2 +-
 remote-curl.c                            |   1 +
 remote.c                                 |   3 +-
 repository.c                             |   1 +
 rerere.c                                 |   3 +-
 reset.c                                  |   1 +
 resolve-undo.h                           |   7 +-
 revision.c                               |   5 +-
 run-command.c                            |   2 +
 scalar.c                                 |   3 +-
 send-pack.c                              |   1 +
 sequencer.c                              |   4 +
 server-info.c                            |   1 +
 setup.c                                  |   5 +-
 shallow.c                                |   1 +
 sideband.c                               |   3 +-
 split-index.c                            |   1 +
 split-index.h                            |   2 +-
 strbuf.c                                 |  31 +--
 strbuf.h                                 |  33 +--
 streaming.c                              |   4 +-
 submodule-config.c                       |   3 +-
 submodule.c                              |   3 +
 t/helper/test-date.c                     |   2 +-
 t/helper/test-fast-rebase.c              |   1 +
 t/helper/test-lazy-init-name-hash.c      |   1 +
 t/helper/test-match-trees.c              |   1 +
 t/helper/test-mergesort.c                |   1 +
 t/helper/test-oidmap.c                   |   2 +-
 t/helper/test-path-utils.c               |   1 +
 t/helper/test-reach.c                    |   2 +-
 t/helper/test-submodule-config.c         |   2 +-
 tag.c                                    |   3 +-
 tmp-objdir.c                             |   3 +-
 trace.c                                  |   3 +-
 trace2.c                                 |   1 +
 transport-helper.c                       |   3 +-
 transport.c                              |   5 +-
 tree-walk.c                              |   2 +
 tree.c                                   |   1 +
 unpack-trees.c                           |   2 +
 unpack-trees.h                           |   1 +
 upload-pack.c                            |   5 +-
 walker.c                                 |   2 +-
 wrapper.c                                |   1 +
 wt-status.c                              |   4 +
 215 files changed, 807 insertions(+), 465 deletions(-)
 create mode 100644 editor.h
 rename zlib.c => git-zlib.c (99%)
 create mode 100644 git-zlib.h
 create mode 100644 object-file.h
 create mode 100644 object-name.h
 create mode 100644 pager.h


base-commit: dc1c48a4a2bce29542f330137106c01daa728f9e
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1509%2Fnewren%2Fheader-cleanup-3-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1509/newren/header-cleanup-3-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1509

Range-diff vs v1:

  1:  6acf4eb2c77 =  1:  6acf4eb2c77 treewide: be explicit about dependence on trace.h & trace2.h
  2:  e163bed61ff =  2:  e163bed61ff treewide: be explicit about dependence on advice.h
  3:  4ef4ee9daf3 =  3:  4ef4ee9daf3 treewide: be explicit about dependence on convert.h
  4:  86b47be1776 =  4:  86b47be1776 treewide: be explicit about dependence on pack-revindex.h
  5:  81a9378be43 =  5:  81a9378be43 treewide: be explicit about dependence on oid-array.h
  6:  c6a561cf433 =  6:  c6a561cf433 treewide: be explicit about dependence on mem-pool.h
  7:  22709819107 !  7:  3c12d5ba6c3 treewide: remove unnecessary cache.h inclusion
     @@ connect.c
      @@
       #include "git-compat-util.h"
      -#include "cache.h"
     -+#include "git-compat-util.h"
       #include "config.h"
       #include "environment.h"
       #include "gettext.h"
  8:  b513a6711ff !  8:  1e2e60bffc7 object-name.h: move declarations for object-name.c functions from cache.h
     @@ archive.h
       
       struct repository;
      
     + ## bisect.c ##
     +@@
     + #include "strvec.h"
     + #include "commit-slab.h"
     + #include "commit-reach.h"
     ++#include "object-name.h"
     + #include "object-store.h"
     + #include "dir.h"
     + 
     +
       ## branch.c ##
      @@
       #include "environment.h"
     @@ cache.h: extern int quote_path_fully;
       /*
        * Create the directory containing the named path, using care to be
        * somewhat safe against races. Return one of the scld_error values to
     -@@ cache.h: struct object_context {
     - 	char *path;
     - };
     +@@ cache.h: int finalize_object_file(const char *tmpfile, const char *filename);
     + /* Helper to check and "touch" a file */
     + int check_and_freshen_file(const char *fn, int freshen);
       
     +-/* Convert to/from hex/sha1 representation */
     +-#define MINIMUM_ABBREV minimum_abbrev
     +-#define DEFAULT_ABBREV default_abbrev
     +-
     +-/* used when the code does not know or care what the default abbrev is */
     +-#define FALLBACK_DEFAULT_ABBREV 7
     +-
     +-struct object_context {
     +-	unsigned short mode;
     +-	/*
     +-	 * symlink_path is only used by get_tree_entry_follow_symlinks,
     +-	 * and only for symlinks that point outside the repository.
     +-	 */
     +-	struct strbuf symlink_path;
     +-	/*
     +-	 * If GET_OID_RECORD_PATH is set, this will record path (if any)
     +-	 * found when resolving the name. The caller is responsible for
     +-	 * releasing the memory.
     +-	 */
     +-	char *path;
     +-};
     +-
      -int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
      -__attribute__((format (printf, 2, 3)))
      -int get_oidf(struct object_id *oid, const char *fmt, ...);
     @@ merge-ort.c
       #include "oid-array.h"
       #include "promisor-remote.h"
      
     + ## merge-recursive.c ##
     +@@
     + #include "hex.h"
     + #include "ll-merge.h"
     + #include "lockfile.h"
     ++#include "object-name.h"
     + #include "object-store.h"
     + #include "repository.h"
     + #include "revision.h"
     +
       ## notes-merge.c ##
      @@
       #include "commit.h"
     @@ object-name.h (new)
      +#define OBJECT_NAME_H
      +
      +#include "object.h"
     ++#include "strbuf.h"
      +
     -+struct object_context;
      +struct object_id;
      +struct repository;
     -+struct strbuf;
     ++
     ++struct object_context {
     ++	unsigned short mode;
     ++	/*
     ++	 * symlink_path is only used by get_tree_entry_follow_symlinks,
     ++	 * and only for symlinks that point outside the repository.
     ++	 */
     ++	struct strbuf symlink_path;
     ++	/*
     ++	 * If GET_OID_RECORD_PATH is set, this will record path (if any)
     ++	 * found when resolving the name. The caller is responsible for
     ++	 * releasing the memory.
     ++	 */
     ++	char *path;
     ++};
      +
      +/*
      + * Return an abbreviated sha1 unique within this repository's object database.
     @@ object-name.h (new)
      +struct object *repo_peel_to_type(struct repository *r,
      +				 const char *name, int namelen,
      +				 struct object *o, enum object_type);
     ++
     ++/* Convert to/from hex/sha1 representation */
     ++#define MINIMUM_ABBREV minimum_abbrev
     ++#define DEFAULT_ABBREV default_abbrev
     ++
     ++/* used when the code does not know or care what the default abbrev is */
     ++#define FALLBACK_DEFAULT_ABBREV 7
     ++
      +#endif /* OBJECT_NAME_H */
      
       ## parse-options-cb.c ##
  9:  e3ec14f90a5 !  9:  62f61514e2f treewide: remove cache.h inclusion due to object-name.h changes
     @@ branch.c
      @@
       #include "git-compat-util.h"
      -#include "cache.h"
     -+#include "git-compat-util.h"
       #include "advice.h"
       #include "config.h"
       #include "branch.h"
 10:  2f240f07551 = 10:  54545bbb02c git-zlib: move declarations for git-zlib functions from cache.h
 11:  7c969dc801d = 11:  dbfe03129e3 treewide: remove cache.h inclusion due to git-zlib changes
 12:  7cd3acfdb86 ! 12:  5efd49df148 object-file.h: move declarations for object-file.c functions from cache.h
     @@ builtin/fast-import.c
       #include "object-store.h"
       #include "mem-pool.h"
      
     + ## builtin/fetch-pack.c ##
     +@@
     + #include "alloc.h"
     + #include "gettext.h"
     + #include "hex.h"
     ++#include "object-file.h"
     + #include "pkt-line.h"
     + #include "fetch-pack.h"
     + #include "remote.h"
     +
       ## builtin/fsck.c ##
      @@
       #include "streaming.h"
     @@ builtin/pack-objects.c
       #include "replace-object.h"
       #include "dir.h"
      
     + ## builtin/prune.c ##
     +@@
     + #include "progress.h"
     + #include "prune-packed.h"
     + #include "replace-object.h"
     ++#include "object-file.h"
     + #include "object-name.h"
     + #include "object-store.h"
     + #include "shallow.h"
     +
       ## builtin/rebase.c ##
      @@
       #include "cache-tree.h"
     @@ builtin/replace.c
       #include "object-store.h"
       #include "replace-object.h"
      
     + ## builtin/rev-list.c ##
     +@@
     + #include "list-objects-filter-options.h"
     + #include "object.h"
     + #include "object-name.h"
     ++#include "object-file.h"
     + #include "object-store.h"
     + #include "pack.h"
     + #include "pack-bitmap.h"
     +
       ## builtin/sparse-checkout.c ##
      @@
       #include "dir.h"
     @@ cache-tree.c
       #include "promisor-remote.h"
      
       ## cache.h ##
     +@@
     + 
     + #include "git-compat-util.h"
     + #include "strbuf.h"
     +-#include "git-zlib.h"
     + #include "hashmap.h"
     + #include "list.h"
     + #include "gettext.h"
      @@ cache.h: int has_racy_timestamp(struct index_state *istate);
       int ie_match_stat(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
       int ie_modified(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
     @@ cache.h: extern int quote_path_fully;
      -/* Helper to check and "touch" a file */
      -int check_and_freshen_file(const char *fn, int freshen);
      -
     - /* Convert to/from hex/sha1 representation */
     - #define MINIMUM_ABBREV minimum_abbrev
     - #define DEFAULT_ABBREV default_abbrev
     + 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,
      @@ cache.h: 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);
     @@ cache.h: int df_name_compare(const char *name1, size_t len1, int mode1,
       const char *git_editor(void);
       const char *git_sequence_editor(void);
       const char *git_pager(int stdout_is_tty);
     +@@ cache.h: struct pack_entry {
     + 	struct packed_git *p;
     + };
     + 
     +-/*
     +- * Set this to 0 to prevent oid_object_info_extended() from fetching missing
     +- * blobs. This has a difference only if extensions.partialClone is set.
     +- *
     +- * Its default value is 1.
     +- */
     +-extern int fetch_if_missing;
     +-
     + /* Dumb servers support */
     + int update_server_info(int);
     + 
      
       ## commit-graph.c ##
      @@
     @@ merge-recursive.c
       #include "ll-merge.h"
       #include "lockfile.h"
      +#include "object-file.h"
     + #include "object-name.h"
       #include "object-store.h"
       #include "repository.h"
     - #include "revision.h"
      
       ## midx.c ##
      @@
     @@ object-file.h (new)
      +#include "git-zlib.h"
      +#include "object.h"
      +
     ++/*
     ++ * Set this to 0 to prevent oid_object_info_extended() from fetching missing
     ++ * blobs. This has a difference only if extensions.partialClone is set.
     ++ *
     ++ * Its default value is 1.
     ++ */
     ++extern int fetch_if_missing;
     ++
      +#define HASH_WRITE_OBJECT 1
      +#define HASH_FORMAT_CHECK 2
      +#define HASH_RENORMALIZE  4
     @@ rerere.c
       #include "hash-lookup.h"
       #include "strmap.h"
      
     + ## revision.c ##
     +@@
     + #include "gettext.h"
     + #include "hex.h"
     + #include "object-name.h"
     ++#include "object-file.h"
     + #include "object-store.h"
     + #include "tag.h"
     + #include "blob.h"
     +
       ## sequencer.c ##
      @@
       #include "hex.h"
 13:  c103d486b2a = 13:  1827ecb4d1d treewide: remove cache.h inclusion due to object-file.h changes
 14:  fa58cf82c66 ! 14:  8937f6d5ac5 object.h: move an inline function and some defines from cache.h
     @@ Metadata
      Author: Elijah Newren <newren@gmail.com>
      
       ## Commit message ##
     -    object.h: move an inline function and some defines from cache.h
     +    object.h: move some inline functions and defines from cache.h
      
          The object_type() inline function is very tied to the enum object_type
          declaration within object.h, and just seemed to make more sense to live
     -    there.  Move it, and as a side-effect, remove a bunch of dependencies
     -    on cache.h that are no longer needed.
     +    there.  That makes S_ISGITLINK and some other defines make sense to go
     +    with it, as well as the create_ce_mode() and canon_mode() inline
     +    functions.  Move all these inline functions and defines from cache.h to
     +    object.h.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
      
     - ## bundle.c ##
     -@@
     --#include "cache.h"
     -+#include "git-compat-util.h"
     - #include "lockfile.h"
     - #include "bundle.h"
     - #include "environment.h"
     -
       ## cache.h ##
      @@
       #define DTYPE(de)	DT_UNKNOWN
     @@ cache.h: struct cache_entry {
       /* Forward structure decls */
       struct pathspec;
       struct child_process;
     +@@ cache.h: static inline unsigned create_ce_flags(unsigned stage)
     + #define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
     + #define ce_intent_to_add(ce) ((ce)->ce_flags & CE_INTENT_TO_ADD)
     + 
     +-#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
     +-static inline unsigned int create_ce_mode(unsigned int mode)
     +-{
     +-	if (S_ISLNK(mode))
     +-		return S_IFLNK;
     +-	if (S_ISSPARSEDIR(mode))
     +-		return S_IFDIR;
     +-	if (S_ISDIR(mode) || S_ISGITLINK(mode))
     +-		return S_IFGITLINK;
     +-	return S_IFREG | ce_permissions(mode);
     +-}
     + static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,
     + 					     unsigned int mode)
     + {
     +@@ cache.h: static inline int ce_to_dtype(const struct cache_entry *ce)
     + 	else
     + 		return DT_UNKNOWN;
     + }
     +-static inline unsigned int canon_mode(unsigned int mode)
     +-{
     +-	if (S_ISREG(mode))
     +-		return S_IFREG | ce_permissions(mode);
     +-	if (S_ISLNK(mode))
     +-		return S_IFLNK;
     +-	if (S_ISDIR(mode))
     +-		return S_IFDIR;
     +-	return S_IFGITLINK;
     +-}
     + 
     + static inline int ce_path_match(struct index_state *istate,
     + 				const struct cache_entry *ce,
      @@ cache.h: void prefetch_cache_entries(const struct index_state *istate,
       extern struct index_state the_index;
       #endif
     @@ cache.h: void prefetch_cache_entries(const struct index_state *istate,
       #define INIT_DB_EXIST_OK 0x0002
       
      
     - ## delta-islands.c ##
     -@@
     --#include "cache.h"
     -+#include "git-compat-util.h"
     - #include "alloc.h"
     - #include "attr.h"
     - #include "object.h"
     -
     - ## fsck.c ##
     -@@
     --#include "cache.h"
     -+#include "git-compat-util.h"
     - #include "alloc.h"
     - #include "hex.h"
     - #include "object-store.h"
     -
     - ## http-push.c ##
     -@@
     --#include "cache.h"
     -+#include "git-compat-util.h"
     - #include "environment.h"
     - #include "hex.h"
     - #include "repository.h"
     -
     - ## list-objects.c ##
     -@@
     --#include "cache.h"
     -+#include "git-compat-util.h"
     - #include "tag.h"
     - #include "commit.h"
     - #include "gettext.h"
     -
       ## object.h ##
      @@ object.h: enum object_type {
       	OBJ_MAX
     @@ object.h: enum object_type {
      +		S_ISGITLINK(mode) ? OBJ_COMMIT :
      +		OBJ_BLOB;
      +}
     ++
     ++#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
     ++static inline unsigned int create_ce_mode(unsigned int mode)
     ++{
     ++	if (S_ISLNK(mode))
     ++		return S_IFLNK;
     ++	if (S_ISSPARSEDIR(mode))
     ++		return S_IFDIR;
     ++	if (S_ISDIR(mode) || S_ISGITLINK(mode))
     ++		return S_IFGITLINK;
     ++	return S_IFREG | ce_permissions(mode);
     ++}
     ++
     ++static inline unsigned int canon_mode(unsigned int mode)
     ++{
     ++	if (S_ISREG(mode))
     ++		return S_IFREG | ce_permissions(mode);
     ++	if (S_ISLNK(mode))
     ++		return S_IFLNK;
     ++	if (S_ISDIR(mode))
     ++		return S_IFDIR;
     ++	return S_IFGITLINK;
     ++}
      +
       /*
        * The object type is stored in 3 bits.
        */
     -
     - ## pack-bitmap-write.c ##
     -@@
     --#include "cache.h"
     -+#include "git-compat-util.h"
     - #include "alloc.h"
     - #include "environment.h"
     - #include "gettext.h"
     -
     - ## submodule-config.c ##
     -@@
     --#include "cache.h"
     -+#include "git-compat-util.h"
     - #include "alloc.h"
     - #include "dir.h"
     - #include "environment.h"
     -
     - ## walker.c ##
     -@@
     --#include "cache.h"
     -+#include "git-compat-util.h"
     - #include "gettext.h"
     - #include "hex.h"
     - #include "walker.h"
  -:  ----------- > 15:  c85f9baed8c treewide: remove cache.h inclusion due to object.h changes
 15:  1e0a9441e73 ! 16:  0ac095731a7 editor: move editor-related functions and declarations into common file
     @@ pager.c
      
       ## rebase-interactive.c ##
      @@
     - #include "cache.h"
     + #include "git-compat-util.h"
       #include "commit.h"
      +#include "editor.h"
       #include "environment.h"
 16:  4b41942a24e = 17:  9550d976141 treewide: remove cache.h inclusion due to editor.h changes
 17:  be8c5229baa ! 18:  d658ee210d9 pager.h: move declarations for pager.c functions from cache.h
     @@ builtin/var.c
       static const char var_usage[] = "git var (-l | <variable>)";
      
       ## cache.h ##
     +@@ cache.h: struct cache_entry {
     + 
     + /* Forward structure decls */
     + struct pathspec;
     +-struct child_process;
     + struct tree;
     + 
     + /*
      @@ cache.h: 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);
 18:  ec79da0235e = 19:  07d1a65a0ec treewide: remove cache.h inclusion due to pager.h changes
 19:  c8f7559553f ! 20:  23e0a81e788 cache.h: remove unnecessary includes
     @@ Commit message
      
       ## cache.h ##
      @@
     + #include "git-compat-util.h"
       #include "strbuf.h"
     - #include "git-zlib.h"
       #include "hashmap.h"
      -#include "list.h"
       #include "gettext.h"
 20:  7c3235c7943 = 21:  47afc6a6c87 strbuf: move forward declarations to beginning of file
 21:  3a0d78e2f93 = 22:  6079c470cd1 treewide: remove double forward declaration of read_in_full
 22:  c4808cf9578 ! 23:  538d95833a2 treewide: reduce includes of cache.h in other headers
     @@ archive.h
       struct repository;
       struct pretty_print_context;
      
     + ## chdir-notify.c ##
     +@@
     +-#include "cache.h"
     ++#include "git-compat-util.h"
     + #include "abspath.h"
     + #include "chdir-notify.h"
     + #include "list.h"
     ++#include "path.h"
     + #include "strbuf.h"
     + #include "trace.h"
     + 
     +
     + ## quote.c ##
     +@@
     +-#include "cache.h"
     ++#include "git-compat-util.h"
     + #include "alloc.h"
     ++#include "path.h"
     + #include "quote.h"
     + #include "strbuf.h"
     + #include "strvec.h"
     +
       ## refs/ref-cache.h ##
      @@
       #ifndef REFS_REF_CACHE_H
 23:  50cbcacaad1 <  -:  ----------- chdir-notify, quote: replace cache.h include with path.h
 24:  2421bb380b1 ! 24:  30e37a37c12 mailmap, quote: move declarations of global vars to correct unit
     @@ cache.h: void set_alternate_index_output(const char *);
       #define MTIME_CHANGED	0x0001
       #define CTIME_CHANGED	0x0002
       #define OWNER_CHANGED	0x0004
     -@@ cache.h: extern int fetch_if_missing;
     +@@ cache.h: struct pack_entry {
       /* Dumb servers support */
       int update_server_info(int);
       

-- 
gitgitgadget

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

* [PATCH v2 01/24] treewide: be explicit about dependence on trace.h & trace2.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 02/24] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
                     ` (24 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Dozens of files made use of trace and trace2 functions, without
explicitly including trace.h or trace2.h.  This made it more difficult
to find which files could remove a dependence on cache.h.  Make C files
explicitly include trace.h or trace2.h if they are using them.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 blame.c                                  | 1 +
 builtin/checkout.c                       | 1 +
 builtin/commit-graph.c                   | 1 +
 builtin/fetch.c                          | 2 ++
 builtin/fsmonitor--daemon.c              | 1 +
 builtin/gc.c                             | 1 +
 builtin/push.c                           | 1 +
 builtin/rebase.c                         | 1 +
 builtin/receive-pack.c                   | 2 ++
 builtin/reset.c                          | 2 ++
 cache-tree.c                             | 2 ++
 cache.h                                  | 2 --
 chdir-notify.c                           | 1 +
 common-main.c                            | 1 +
 compat/fsmonitor/fsm-listen-win32.c      | 1 +
 compat/mingw.c                           | 1 +
 compat/simple-ipc/ipc-unix-socket.c      | 1 +
 compat/simple-ipc/ipc-win32.c            | 2 ++
 compat/win32/trace2_win32_process_info.c | 1 +
 config.c                                 | 1 +
 connect.c                                | 1 +
 convert.c                                | 1 +
 diff-lib.c                               | 1 +
 dir.c                                    | 1 +
 environment.c                            | 1 +
 exec-cmd.c                               | 2 ++
 fetch-pack.c                             | 1 +
 fsmonitor.c                              | 1 +
 fsmonitor.h                              | 1 +
 git.c                                    | 2 ++
 http.c                                   | 1 +
 merge-ort.c                              | 1 +
 name-hash.c                              | 1 +
 notes-merge.c                            | 1 +
 pack-bitmap.c                            | 1 +
 pack-revindex.c                          | 1 +
 packfile.c                               | 1 +
 pkt-line.c                               | 1 +
 preload-index.c                          | 1 +
 progress.c                               | 1 +
 promisor-remote.c                        | 1 +
 protocol.c                               | 1 +
 read-cache.c                             | 1 +
 remote-curl.c                            | 1 +
 repository.c                             | 1 +
 revision.c                               | 1 +
 run-command.c                            | 2 ++
 scalar.c                                 | 1 +
 setup.c                                  | 1 +
 shallow.c                                | 1 +
 submodule.c                              | 1 +
 t/helper/test-date.c                     | 1 +
 t/helper/test-lazy-init-name-hash.c      | 1 +
 t/helper/test-path-utils.c               | 1 +
 trace.c                                  | 1 +
 trace2.c                                 | 1 +
 transport.c                              | 1 +
 tree-walk.c                              | 1 +
 unpack-trees.c                           | 1 +
 upload-pack.c                            | 1 +
 wrapper.c                                | 1 +
 wt-status.c                              | 2 ++
 62 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/blame.c b/blame.c
index 62db9807640..3455f6a5ea3 100644
--- a/blame.c
+++ b/blame.c
@@ -9,6 +9,7 @@
 #include "hex.h"
 #include "setup.h"
 #include "tag.h"
+#include "trace2.h"
 #include "blame.h"
 #include "alloc.h"
 #include "commit-slab.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 38a8cd6a965..422ea768404 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 90114269761..a3d00fa232b 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -12,6 +12,7 @@
 #include "progress.h"
 #include "replace-object.h"
 #include "tag.h"
+#include "trace2.h"
 
 #define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \
 	N_("git commit-graph verify [--object-dir <dir>] [--shallow] [--[no-]progress]")
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 6a6a58d49c9..ffe0e214592 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -31,6 +31,8 @@
 #include "promisor-remote.h"
 #include "commit-graph.h"
 #include "shallow.h"
+#include "trace.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "bundle-uri.h"
 
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index a280d8bb14f..df876b41d65 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -14,6 +14,7 @@
 #include "simple-ipc.h"
 #include "khash.h"
 #include "pkt-line.h"
+#include "trace2.h"
 
 static const char * const builtin_fsmonitor__daemon_usage[] = {
 	N_("git fsmonitor--daemon start [<options>]"),
diff --git a/builtin/gc.c b/builtin/gc.c
index b291e23b13d..000a2ef5e11 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -37,6 +37,7 @@
 #include "gettext.h"
 #include "hook.h"
 #include "setup.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 #define FAILED_RUN "failed to run %s"
diff --git a/builtin/push.c b/builtin/push.c
index fa550b8f80a..a99ba38a368 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -16,6 +16,7 @@
 #include "submodule.h"
 #include "submodule-config.h"
 #include "send-pack.h"
+#include "trace2.h"
 #include "color.h"
 
 static const char * const push_usage[] = {
diff --git a/builtin/rebase.c b/builtin/rebase.c
index dbc8f90ef04..fb859f93a30 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -32,6 +32,7 @@
 #include "sequencer.h"
 #include "rebase-interactive.h"
 #include "reset.h"
+#include "trace2.h"
 #include "hook.h"
 #include "wrapper.h"
 
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 2ba5a74ba7b..aa5b6fe861f 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -32,6 +32,8 @@
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
+#include "trace.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "shallow.h"
 #include "wrapper.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 0ed329236c8..4d639ec6b37 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -29,6 +29,8 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace.h"
+#include "trace2.h"
 #include "dir.h"
 #include "add-interactive.h"
 
diff --git a/cache-tree.c b/cache-tree.c
index ff14b527da3..39f0c744727 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -11,6 +11,8 @@
 #include "replace-object.h"
 #include "promisor-remote.h"
 #include "sparse-index.h"
+#include "trace.h"
+#include "trace2.h"
 
 #ifndef DEBUG_CACHE_TREE
 #define DEBUG_CACHE_TREE 0
diff --git a/cache.h b/cache.h
index 82d7b112b4e..c8ae80fded3 100644
--- a/cache.h
+++ b/cache.h
@@ -8,8 +8,6 @@
 #include "advice.h"
 #include "gettext.h"
 #include "convert.h"
-#include "trace.h"
-#include "trace2.h"
 #include "string-list.h"
 #include "pack-revindex.h"
 #include "hash.h"
diff --git a/chdir-notify.c b/chdir-notify.c
index 929ec01b3a2..8e38cd6f3ae 100644
--- a/chdir-notify.c
+++ b/chdir-notify.c
@@ -3,6 +3,7 @@
 #include "chdir-notify.h"
 #include "list.h"
 #include "strbuf.h"
+#include "trace.h"
 
 struct chdir_notify_entry {
 	const char *name;
diff --git a/common-main.c b/common-main.c
index b83cb5cf066..f3193173535 100644
--- a/common-main.c
+++ b/common-main.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "attr.h"
 #include "setup.h"
+#include "trace2.h"
 
 /*
  * Many parts of Git have subprograms communicate via pipe, expect the
diff --git a/compat/fsmonitor/fsm-listen-win32.c b/compat/fsmonitor/fsm-listen-win32.c
index 7b07b74ba5b..677b1bbdeca 100644
--- a/compat/fsmonitor/fsm-listen-win32.c
+++ b/compat/fsmonitor/fsm-listen-win32.c
@@ -4,6 +4,7 @@
 #include "fsm-listen.h"
 #include "fsmonitor--daemon.h"
 #include "gettext.h"
+#include "trace2.h"
 
 /*
  * The documentation of ReadDirectoryChangesW() states that the maximum
diff --git a/compat/mingw.c b/compat/mingw.c
index 94c5a1daa40..abbc3faf32f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -12,6 +12,7 @@
 #include "win32/lazyload.h"
 #include "../config.h"
 #include "../environment.h"
+#include "../trace2.h"
 #include "../wrapper.h"
 #include "dir.h"
 #include "gettext.h"
diff --git a/compat/simple-ipc/ipc-unix-socket.c b/compat/simple-ipc/ipc-unix-socket.c
index 152db60a311..7064475b39f 100644
--- a/compat/simple-ipc/ipc-unix-socket.c
+++ b/compat/simple-ipc/ipc-unix-socket.c
@@ -4,6 +4,7 @@
 #include "strbuf.h"
 #include "pkt-line.h"
 #include "thread-utils.h"
+#include "trace2.h"
 #include "unix-socket.h"
 #include "unix-stream-server.h"
 
diff --git a/compat/simple-ipc/ipc-win32.c b/compat/simple-ipc/ipc-win32.c
index 997f6144344..6adce3c650e 100644
--- a/compat/simple-ipc/ipc-win32.c
+++ b/compat/simple-ipc/ipc-win32.c
@@ -5,6 +5,8 @@
 #include "strbuf.h"
 #include "pkt-line.h"
 #include "thread-utils.h"
+#include "trace.h"
+#include "trace2.h"
 #include "accctrl.h"
 #include "aclapi.h"
 
diff --git a/compat/win32/trace2_win32_process_info.c b/compat/win32/trace2_win32_process_info.c
index a53fd924340..e3e895c78a2 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 "../../trace2.h"
 #include "lazyload.h"
 #include <Psapi.h>
 #include <tlHelp32.h>
diff --git a/config.c b/config.c
index 5ad9ae91436..e5c2e477319 100644
--- a/config.c
+++ b/config.c
@@ -28,6 +28,7 @@
 #include "replace-object.h"
 #include "refs.h"
 #include "setup.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "wrapper.h"
 #include "write-or-die.h"
diff --git a/connect.c b/connect.c
index 737dd906f72..929f72ec5d7 100644
--- a/connect.c
+++ b/connect.c
@@ -14,6 +14,7 @@
 #include "string-list.h"
 #include "oid-array.h"
 #include "transport.h"
+#include "trace2.h"
 #include "strbuf.h"
 #include "version.h"
 #include "protocol.h"
diff --git a/convert.c b/convert.c
index da06e2f51cb..126036ec330 100644
--- a/convert.c
+++ b/convert.c
@@ -9,6 +9,7 @@
 #include "sigchain.h"
 #include "pkt-line.h"
 #include "sub-process.h"
+#include "trace.h"
 #include "utf8.h"
 #include "ll-merge.h"
 #include "wrapper.h"
diff --git a/diff-lib.c b/diff-lib.c
index 4169dd8cb13..8b5cca96ace 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -13,6 +13,7 @@
 #include "unpack-trees.h"
 #include "refs.h"
 #include "submodule.h"
+#include "trace.h"
 #include "dir.h"
 #include "fsmonitor.h"
 #include "commit-reach.h"
diff --git a/dir.c b/dir.c
index 18fd14c46b2..10f6c38b930 100644
--- a/dir.c
+++ b/dir.c
@@ -23,6 +23,7 @@
 #include "fsmonitor.h"
 #include "setup.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 /*
diff --git a/environment.c b/environment.c
index 63c697e7e97..2254595e4a8 100644
--- a/environment.c
+++ b/environment.c
@@ -24,6 +24,7 @@
 #include "chdir-notify.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/exec-cmd.c b/exec-cmd.c
index fae0d4b244a..6f618463896 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -5,6 +5,8 @@
 #include "gettext.h"
 #include "quote.h"
 #include "strvec.h"
+#include "trace.h"
+#include "trace2.h"
 
 #if defined(RUNTIME_PREFIX)
 
diff --git a/fetch-pack.c b/fetch-pack.c
index 368f2ed25a1..7d4f190fb1d 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -17,6 +17,7 @@
 #include "remote.h"
 #include "run-command.h"
 #include "connect.h"
+#include "trace2.h"
 #include "transport.h"
 #include "version.h"
 #include "oid-array.h"
diff --git a/fsmonitor.c b/fsmonitor.c
index c956a347a27..28c083d4d84 100644
--- a/fsmonitor.c
+++ b/fsmonitor.c
@@ -7,6 +7,7 @@
 #include "fsmonitor-ipc.h"
 #include "run-command.h"
 #include "strbuf.h"
+#include "trace2.h"
 
 #define INDEX_EXTENSION_VERSION1	(1)
 #define INDEX_EXTENSION_VERSION2	(2)
diff --git a/fsmonitor.h b/fsmonitor.h
index edf7ce5203b..67faf592e12 100644
--- a/fsmonitor.h
+++ b/fsmonitor.h
@@ -4,6 +4,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "fsmonitor-settings.h"
+#include "trace.h"
 
 extern struct trace_key trace_fsmonitor;
 
diff --git a/git.c b/git.c
index 77f920a6f6f..d2bb86e0d32 100644
--- a/git.c
+++ b/git.c
@@ -9,6 +9,8 @@
 #include "replace-object.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace.h"
+#include "trace2.h"
 
 #define RUN_SETUP		(1<<0)
 #define RUN_SETUP_GENTLY	(1<<1)
diff --git a/http.c b/http.c
index dbe4d29ef7a..0212c0ad3b2 100644
--- a/http.c
+++ b/http.c
@@ -12,6 +12,7 @@
 #include "version.h"
 #include "pkt-line.h"
 #include "gettext.h"
+#include "trace.h"
 #include "transport.h"
 #include "packfile.h"
 #include "protocol.h"
diff --git a/merge-ort.c b/merge-ort.c
index 5bf64354d16..ad7367179d9 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -37,6 +37,7 @@
 #include "strmap.h"
 #include "submodule-config.h"
 #include "submodule.h"
+#include "trace2.h"
 #include "tree.h"
 #include "unpack-trees.h"
 #include "xdiff-interface.h"
diff --git a/name-hash.c b/name-hash.c
index 2c2861efd1c..fb13716e430 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -9,6 +9,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "thread-utils.h"
+#include "trace.h"
 #include "trace2.h"
 #include "sparse-index.h"
 
diff --git a/notes-merge.c b/notes-merge.c
index c40107c3aa0..19405ec71ac 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -13,6 +13,7 @@
 #include "notes.h"
 #include "notes-merge.h"
 #include "strbuf.h"
+#include "trace.h"
 #include "notes-utils.h"
 #include "commit-reach.h"
 #include "wrapper.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 23d87e71bd9..eba838d24ee 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -15,6 +15,7 @@
 #include "pack-objects.h"
 #include "packfile.h"
 #include "repository.h"
+#include "trace2.h"
 #include "object-store.h"
 #include "list-objects-filter-options.h"
 #include "midx.h"
diff --git a/pack-revindex.c b/pack-revindex.c
index 03c7e81f9da..9f9927d9471 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -3,6 +3,7 @@
 #include "pack-revindex.h"
 #include "object-store.h"
 #include "packfile.h"
+#include "trace2.h"
 #include "config.h"
 #include "midx.h"
 
diff --git a/packfile.c b/packfile.c
index b120405ccc8..2d3dabb1aee 100644
--- a/packfile.c
+++ b/packfile.c
@@ -15,6 +15,7 @@
 #include "commit.h"
 #include "object.h"
 #include "tag.h"
+#include "trace.h"
 #include "tree-walk.h"
 #include "tree.h"
 #include "object-store.h"
diff --git a/pkt-line.c b/pkt-line.c
index 36ae0fea4a3..3561d853584 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "run-command.h"
+#include "trace.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/preload-index.c b/preload-index.c
index 52544d004e7..4abf9c983b2 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "thread-utils.h"
 #include "repository.h"
+#include "trace2.h"
 
 /*
  * Mostly randomly chosen maximum thread counts: we
diff --git a/progress.c b/progress.c
index 44c784d75f1..c5c8514737a 100644
--- a/progress.c
+++ b/progress.c
@@ -13,6 +13,7 @@
 #include "progress.h"
 #include "strbuf.h"
 #include "trace.h"
+#include "trace2.h"
 #include "utf8.h"
 #include "config.h"
 
diff --git a/promisor-remote.c b/promisor-remote.c
index a8dbb788e8f..9d83d2f4b9c 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -4,6 +4,7 @@
 #include "object-store.h"
 #include "promisor-remote.h"
 #include "config.h"
+#include "trace2.h"
 #include "transport.h"
 #include "strvec.h"
 #include "packfile.h"
diff --git a/protocol.c b/protocol.c
index bdb32e1eeb6..4d8eb887e82 100644
--- a/protocol.c
+++ b/protocol.c
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "environment.h"
 #include "protocol.h"
+#include "trace2.h"
 
 static enum protocol_version parse_protocol_version(const char *value)
 {
diff --git a/read-cache.c b/read-cache.c
index e5e72169047..a744eb89e4e 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -23,6 +23,7 @@
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
+#include "trace2.h"
 #include "varint.h"
 #include "split-index.h"
 #include "utf8.h"
diff --git a/remote-curl.c b/remote-curl.c
index 0f2410da8e7..0ada1dd8026 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -21,6 +21,7 @@
 #include "setup.h"
 #include "protocol.h"
 #include "quote.h"
+#include "trace2.h"
 #include "transport.h"
 #include "write-or-die.h"
 
diff --git a/repository.c b/repository.c
index f6d9f5db08e..c53e480e326 100644
--- a/repository.c
+++ b/repository.c
@@ -14,6 +14,7 @@
 #include "setup.h"
 #include "submodule-config.h"
 #include "sparse-index.h"
+#include "trace2.h"
 #include "promisor-remote.h"
 
 /* The main repository */
diff --git a/revision.c b/revision.c
index cd3e841433a..7c34c93885e 100644
--- a/revision.c
+++ b/revision.c
@@ -31,6 +31,7 @@
 #include "worktree.h"
 #include "setup.h"
 #include "strvec.h"
+#include "trace2.h"
 #include "commit-reach.h"
 #include "commit-graph.h"
 #include "prio-queue.h"
diff --git a/run-command.c b/run-command.c
index 614d48fa9a2..e64bb08a5bf 100644
--- a/run-command.c
+++ b/run-command.c
@@ -8,6 +8,8 @@
 #include "thread-utils.h"
 #include "strbuf.h"
 #include "string-list.h"
+#include "trace.h"
+#include "trace2.h"
 #include "quote.h"
 #include "config.h"
 #include "packfile.h"
diff --git a/scalar.c b/scalar.c
index 27635658c01..f7680463e1b 100644
--- a/scalar.c
+++ b/scalar.c
@@ -16,6 +16,7 @@
 #include "packfile.h"
 #include "help.h"
 #include "setup.h"
+#include "trace2.h"
 
 static void setup_enlistment_directory(int argc, const char **argv,
 				       const char * const *usagestr,
diff --git a/setup.c b/setup.c
index 6c5b85e96c1..3bb7a9fff62 100644
--- a/setup.c
+++ b/setup.c
@@ -10,6 +10,7 @@
 #include "chdir-notify.h"
 #include "promisor-remote.h"
 #include "quote.h"
+#include "trace2.h"
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
diff --git a/shallow.c b/shallow.c
index b4d726bd595..128f56179ed 100644
--- a/shallow.c
+++ b/shallow.c
@@ -17,6 +17,7 @@
 #include "list-objects.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "trace.h"
 #include "wrapper.h"
 
 void set_alternate_shallow_file(struct repository *r, const char *path, int override)
diff --git a/submodule.c b/submodule.c
index d7d0a8a0834..58c9d5e5673 100644
--- a/submodule.c
+++ b/submodule.c
@@ -28,6 +28,7 @@
 #include "commit-reach.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace2.h"
 
 static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
 static int initialized_fetch_ref_tips;
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index 45951b1df87..a01eec99f35 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "date.h"
+#include "trace.h"
 
 static const char *usage_msg = "\n"
 "  test-tool date relative [time_t]...\n"
diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c
index 06ce3a47ccf..f23d983c118 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "parse-options.h"
 #include "setup.h"
+#include "trace.h"
 
 static int single;
 static int multi;
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 4f5ac2fadce..6355c9e4b6d 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "setup.h"
 #include "string-list.h"
+#include "trace.h"
 #include "utf8.h"
 
 /*
diff --git a/trace.c b/trace.c
index 81318a2455d..d8eaa0a786a 100644
--- a/trace.c
+++ b/trace.c
@@ -26,6 +26,7 @@
 #include "environment.h"
 #include "quote.h"
 #include "setup.h"
+#include "trace.h"
 #include "wrapper.h"
 
 struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
diff --git a/trace2.c b/trace2.c
index e8ba62c0c3d..21264df71b7 100644
--- a/trace2.c
+++ b/trace2.c
@@ -7,6 +7,7 @@
 #include "thread-utils.h"
 #include "version.h"
 #include "trace.h"
+#include "trace2.h"
 #include "trace2/tr2_cfg.h"
 #include "trace2/tr2_cmd_name.h"
 #include "trace2/tr2_ctr.h"
diff --git a/transport.c b/transport.c
index d2a1af43b5c..11b38d16dcf 100644
--- a/transport.c
+++ b/transport.c
@@ -22,6 +22,7 @@
 #include "string-list.h"
 #include "oid-array.h"
 #include "sigchain.h"
+#include "trace2.h"
 #include "transport-internal.h"
 #include "protocol.h"
 #include "object-store.h"
diff --git a/tree-walk.c b/tree-walk.c
index 38b6556478d..59add24c8e9 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
+#include "trace2.h"
 #include "tree.h"
 #include "pathspec.h"
 #include "json-writer.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index 4a5522bdb26..d41489b4adb 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -17,6 +17,7 @@
 #include "sparse-index.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "fsmonitor.h"
 #include "object-store.h"
 #include "promisor-remote.h"
diff --git a/upload-pack.c b/upload-pack.c
index e23f16dfdd2..71440c63806 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -22,6 +22,7 @@
 #include "version.h"
 #include "string-list.h"
 #include "strvec.h"
+#include "trace2.h"
 #include "prio-queue.h"
 #include "protocol.h"
 #include "quote.h"
diff --git a/wrapper.c b/wrapper.c
index ee837575902..c130d7518bf 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 static intmax_t count_fsync_writeout_only;
diff --git a/wt-status.c b/wt-status.c
index 4bef09de1ca..ccbfd9cc6de 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -18,6 +18,8 @@
 #include "column.h"
 #include "setup.h"
 #include "strbuf.h"
+#include "trace.h"
+#include "trace2.h"
 #include "utf8.h"
 #include "worktree.h"
 #include "lockfile.h"
-- 
gitgitgadget


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

* [PATCH v2 02/24] treewide: be explicit about dependence on advice.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 03/24] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
                     ` (23 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Dozens of files made use of advice functions, without explicitly
including advice.h.  This made it more difficult to find which files
could remove a dependence on cache.h.  Make C files explicitly include
advice.h if they are using it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 add-patch.c               | 1 +
 branch.c                  | 1 +
 builtin/add.c             | 1 +
 builtin/am.c              | 1 +
 builtin/clone.c           | 1 +
 builtin/commit.c          | 1 +
 builtin/fetch.c           | 1 +
 builtin/merge-recursive.c | 1 +
 builtin/merge.c           | 1 +
 builtin/mv.c              | 1 +
 builtin/pull.c            | 1 +
 builtin/push.c            | 1 +
 builtin/reset.c           | 1 +
 builtin/tag.c             | 1 +
 cache.h                   | 1 -
 config.c                  | 1 +
 convert.c                 | 1 +
 editor.c                  | 1 +
 notes-merge.c             | 1 +
 object-name.c             | 1 +
 refs.c                    | 1 +
 sequencer.c               | 1 +
 transport.c               | 1 +
 unpack-trees.c            | 1 +
 wt-status.c               | 1 +
 25 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/add-patch.c b/add-patch.c
index 1e1ee2df596..b381f14a7de 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "add-interactive.h"
+#include "advice.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/branch.c b/branch.c
index 99a0e7889e4..3a087b8b4c1 100644
--- a/branch.c
+++ b/branch.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "branch.h"
 #include "environment.h"
diff --git a/builtin/add.c b/builtin/add.c
index f12054d9be1..d3c51e28142 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -5,6 +5,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "lockfile.h"
diff --git a/builtin/am.c b/builtin/am.c
index cd1e20f24e5..8d876f31546 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -6,6 +6,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "environment.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index c171def1f3e..f1e8aa3f27e 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -11,6 +11,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 9d8e1ea91a3..b09017e04f9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -7,6 +7,7 @@
 
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "lockfile.h"
 #include "cache-tree.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index ffe0e214592..f2b80987751 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2,6 +2,7 @@
  * "git fetch"
  */
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "gettext.h"
 #include "environment.h"
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 8ea9dc78aa1..25f42f2be7e 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "builtin.h"
+#include "advice.h"
 #include "commit.h"
 #include "gettext.h"
 #include "tag.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index a99be9610e9..225b7064066 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -9,6 +9,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index b7c5ffbd8c7..8f7770aa32b 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -6,6 +6,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/builtin/pull.c b/builtin/pull.c
index 5405d09f22f..636ce12c94d 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -7,6 +7,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "gettext.h"
diff --git a/builtin/push.c b/builtin/push.c
index a99ba38a368..6001e4ae0a4 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -2,6 +2,7 @@
  * "git push"
  */
 #include "cache.h"
+#include "advice.h"
 #include "branch.h"
 #include "config.h"
 #include "environment.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 4d639ec6b37..d8c52cc6edf 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -9,6 +9,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index bfd51389571..3e801f54a07 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -7,6 +7,7 @@
  */
 
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "environment.h"
diff --git a/cache.h b/cache.h
index c8ae80fded3..d9ca2688d8c 100644
--- a/cache.h
+++ b/cache.h
@@ -5,7 +5,6 @@
 #include "strbuf.h"
 #include "hashmap.h"
 #include "list.h"
-#include "advice.h"
 #include "gettext.h"
 #include "convert.h"
 #include "string-list.h"
diff --git a/config.c b/config.c
index e5c2e477319..3cee6538f3f 100644
--- a/config.c
+++ b/config.c
@@ -7,6 +7,7 @@
  */
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "date.h"
 #include "branch.h"
diff --git a/convert.c b/convert.c
index 126036ec330..59127706448 100644
--- a/convert.c
+++ b/convert.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/editor.c b/editor.c
index d632d790660..3bea3ef72f7 100644
--- a/editor.c
+++ b/editor.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/notes-merge.c b/notes-merge.c
index 19405ec71ac..0258f87d21f 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
diff --git a/object-name.c b/object-name.c
index 53f9d359ee8..ff647d6c7b5 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/refs.c b/refs.c
index 0f369dbde7a..cfced6f174a 100644
--- a/refs.c
+++ b/refs.c
@@ -3,6 +3,7 @@
  */
 
 #include "cache.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/sequencer.c b/sequencer.c
index 1a315ac13c9..eaba379e3ad 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/transport.c b/transport.c
index 11b38d16dcf..82bf2496ba7 100644
--- a/transport.c
+++ b/transport.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index d41489b4adb..c6de2ca5a7e 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "strvec.h"
 #include "repository.h"
 #include "config.h"
diff --git a/wt-status.c b/wt-status.c
index ccbfd9cc6de..47f223c0f8d 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "wt-status.h"
 #include "object.h"
 #include "dir.h"
-- 
gitgitgadget


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

* [PATCH v2 03/24] treewide: be explicit about dependence on convert.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 02/24] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 04/24] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
                     ` (22 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 archive.c          | 1 +
 blame.c            | 1 +
 builtin/cat-file.c | 1 +
 builtin/ls-files.c | 1 +
 cache.h            | 1 -
 combine-diff.c     | 1 +
 config.c           | 1 +
 convert.c          | 1 +
 diff.c             | 1 +
 dir.c              | 1 +
 environment.c      | 1 +
 ll-merge.c         | 1 +
 object-file.c      | 1 +
 streaming.c        | 1 +
 unpack-trees.h     | 1 +
 15 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/archive.c b/archive.c
index f1b8e9ce486..ab8966d73a5 100644
--- a/archive.c
+++ b/archive.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/blame.c b/blame.c
index 3455f6a5ea3..ff2a6c49125 100644
--- a/blame.c
+++ b/blame.c
@@ -3,6 +3,7 @@
 #include "object-store.h"
 #include "cache-tree.h"
 #include "mergesort.h"
+#include "convert.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "gettext.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 04d4bb6c777..1e4b4798f40 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "builtin.h"
 #include "diff.h"
 #include "environment.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 68532f3e51a..7f228353feb 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -8,6 +8,7 @@
 #include "cache.h"
 #include "repository.h"
 #include "config.h"
+#include "convert.h"
 #include "quote.h"
 #include "dir.h"
 #include "builtin.h"
diff --git a/cache.h b/cache.h
index d9ca2688d8c..415f0f85670 100644
--- a/cache.h
+++ b/cache.h
@@ -6,7 +6,6 @@
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
-#include "convert.h"
 #include "string-list.h"
 #include "pack-revindex.h"
 #include "hash.h"
diff --git a/combine-diff.c b/combine-diff.c
index 44ef6a1a812..6586e4508d6 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "object-store.h"
 #include "commit.h"
+#include "convert.h"
 #include "blob.h"
 #include "diff.h"
 #include "diffcore.h"
diff --git a/config.c b/config.c
index 3cee6538f3f..9e74b5aec7f 100644
--- a/config.c
+++ b/config.c
@@ -12,6 +12,7 @@
 #include "date.h"
 #include "branch.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "ident.h"
diff --git a/convert.c b/convert.c
index 59127706448..5a2ea5308d6 100644
--- a/convert.c
+++ b/convert.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "advice.h"
 #include "config.h"
+#include "convert.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/diff.c b/diff.c
index e55a015cfd0..47c1973a504 100644
--- a/diff.c
+++ b/diff.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "tempfile.h"
diff --git a/dir.c b/dir.c
index 10f6c38b930..d1f1b1ef768 100644
--- a/dir.c
+++ b/dir.c
@@ -9,6 +9,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/environment.c b/environment.c
index 2254595e4a8..e57292eccc9 100644
--- a/environment.c
+++ b/environment.c
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "branch.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "repository.h"
diff --git a/ll-merge.c b/ll-merge.c
index 8be38d3bd41..28bc94c45d6 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -6,6 +6,7 @@
 
 #include "cache.h"
 #include "config.h"
+#include "convert.h"
 #include "attr.h"
 #include "xdiff-interface.h"
 #include "run-command.h"
diff --git a/object-file.c b/object-file.c
index 76b22ca75cd..a4331e0da61 100644
--- a/object-file.c
+++ b/object-file.c
@@ -10,6 +10,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/streaming.c b/streaming.c
index 024fd796b7d..27e014d8b23 100644
--- a/streaming.c
+++ b/streaming.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2011, Google Inc.
  */
 #include "cache.h"
+#include "convert.h"
 #include "environment.h"
 #include "streaming.h"
 #include "repository.h"
diff --git a/unpack-trees.h b/unpack-trees.h
index 61c06eb7c50..30622aeebff 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -2,6 +2,7 @@
 #define UNPACK_TREES_H
 
 #include "cache.h"
+#include "convert.h"
 #include "strvec.h"
 #include "string-list.h"
 #include "tree-walk.h"
-- 
gitgitgadget


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

* [PATCH v2 04/24] treewide: be explicit about dependence on pack-revindex.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (2 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 03/24] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 05/24] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
                     ` (21 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/index-pack.c | 1 +
 cache.h              | 1 -
 pack-write.c         | 1 +
 packfile.c           | 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index b17e79cd40f..ceb0f120ede 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -17,6 +17,7 @@
 #include "streaming.h"
 #include "thread-utils.h"
 #include "packfile.h"
+#include "pack-revindex.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/cache.h b/cache.h
index 415f0f85670..5f1279454a8 100644
--- a/cache.h
+++ b/cache.h
@@ -7,7 +7,6 @@
 #include "list.h"
 #include "gettext.h"
 #include "string-list.h"
-#include "pack-revindex.h"
 #include "hash.h"
 #include "path.h"
 #include "pathspec.h"
diff --git a/pack-write.c b/pack-write.c
index f1714054951..152c14aa7aa 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -9,6 +9,7 @@
 #include "pack-mtimes.h"
 #include "oidmap.h"
 #include "pack-objects.h"
+#include "pack-revindex.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
 {
diff --git a/packfile.c b/packfile.c
index 2d3dabb1aee..02afbe77137 100644
--- a/packfile.c
+++ b/packfile.c
@@ -21,6 +21,7 @@
 #include "object-store.h"
 #include "midx.h"
 #include "commit-graph.h"
+#include "pack-revindex.h"
 #include "promisor-remote.h"
 #include "wrapper.h"
 
-- 
gitgitgadget


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

* [PATCH v2 05/24] treewide: be explicit about dependence on oid-array.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (3 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 04/24] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 06/24] treewide: be explicit about dependence on mem-pool.h Elijah Newren via GitGitGadget
                     ` (20 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/bisect.c     | 1 +
 builtin/fetch.c      | 1 +
 builtin/index-pack.c | 1 +
 builtin/log.c        | 1 +
 cache.h              | 1 -
 commit-graph.c       | 1 +
 diff.c               | 1 +
 merge-ort.c          | 1 +
 read-cache.c         | 1 +
 ref-filter.c         | 1 +
 upload-pack.c        | 1 +
 11 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/builtin/bisect.c b/builtin/bisect.c
index 26f07357a03..7dc175c6570 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -9,6 +9,7 @@
 #include "dir.h"
 #include "strvec.h"
 #include "run-command.h"
+#include "oid-array.h"
 #include "prompt.h"
 #include "quote.h"
 #include "revision.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index f2b80987751..e0936629213 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -12,6 +12,7 @@
 #include "refspec.h"
 #include "object-store.h"
 #include "oidset.h"
+#include "oid-array.h"
 #include "commit.h"
 #include "builtin.h"
 #include "string-list.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index ceb0f120ede..5adfb2521cd 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -19,6 +19,7 @@
 #include "packfile.h"
 #include "pack-revindex.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
 #include "setup.h"
diff --git a/builtin/log.c b/builtin/log.c
index 2ce645eee97..094897df236 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -20,6 +20,7 @@
 #include "revision.h"
 #include "log-tree.h"
 #include "builtin.h"
+#include "oid-array.h"
 #include "tag.h"
 #include "reflog-walk.h"
 #include "patch-ids.h"
diff --git a/cache.h b/cache.h
index 5f1279454a8..6eac3134a22 100644
--- a/cache.h
+++ b/cache.h
@@ -11,7 +11,6 @@
 #include "path.h"
 #include "pathspec.h"
 #include "object.h"
-#include "oid-array.h"
 #include "repository.h"
 #include "statinfo.h"
 #include "mem-pool.h"
diff --git a/commit-graph.c b/commit-graph.c
index 1bf673b1345..fe9a8b2342f 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -12,6 +12,7 @@
 #include "hash-lookup.h"
 #include "commit-graph.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "alloc.h"
 #include "hashmap.h"
 #include "replace-object.h"
diff --git a/diff.c b/diff.c
index 47c1973a504..89cd0b17da5 100644
--- a/diff.c
+++ b/diff.c
@@ -29,6 +29,7 @@
 #include "string-list.h"
 #include "strvec.h"
 #include "graph.h"
+#include "oid-array.h"
 #include "packfile.h"
 #include "parse-options.h"
 #include "help.h"
diff --git a/merge-ort.c b/merge-ort.c
index ad7367179d9..9b0b184b130 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -32,6 +32,7 @@
 #include "entry.h"
 #include "ll-merge.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "promisor-remote.h"
 #include "revision.h"
 #include "strmap.h"
diff --git a/read-cache.c b/read-cache.c
index a744eb89e4e..1b585ce8424 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -15,6 +15,7 @@
 #include "refs.h"
 #include "dir.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "tree.h"
 #include "commit.h"
 #include "blob.h"
diff --git a/ref-filter.c b/ref-filter.c
index df84bb71643..1c6174c8aed 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -7,6 +7,7 @@
 #include "refs.h"
 #include "wildmatch.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "repository.h"
 #include "commit.h"
 #include "remote.h"
diff --git a/upload-pack.c b/upload-pack.c
index 71440c63806..e17545a834a 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -8,6 +8,7 @@
 #include "sideband.h"
 #include "repository.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "tag.h"
 #include "object.h"
 #include "commit.h"
-- 
gitgitgadget


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

* [PATCH v2 06/24] treewide: be explicit about dependence on mem-pool.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (4 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 05/24] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 07/24] treewide: remove unnecessary cache.h inclusion Elijah Newren via GitGitGadget
                     ` (19 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/checkout.c        | 1 +
 cache.h                   | 1 -
 merge-ort.c               | 1 +
 read-cache.c              | 1 +
 split-index.c             | 1 +
 t/helper/test-mergesort.c | 1 +
 6 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 422ea768404..65988fd8a3b 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -15,6 +15,7 @@
 #include "hook.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "mem-pool.h"
 #include "merge-recursive.h"
 #include "object-store.h"
 #include "parse-options.h"
diff --git a/cache.h b/cache.h
index 6eac3134a22..66705dd469e 100644
--- a/cache.h
+++ b/cache.h
@@ -13,7 +13,6 @@
 #include "object.h"
 #include "repository.h"
 #include "statinfo.h"
-#include "mem-pool.h"
 
 typedef struct git_zstream {
 	z_stream z;
diff --git a/merge-ort.c b/merge-ort.c
index 9b0b184b130..1008684fbbc 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -31,6 +31,7 @@
 #include "hex.h"
 #include "entry.h"
 #include "ll-merge.h"
+#include "mem-pool.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "promisor-remote.h"
diff --git a/read-cache.c b/read-cache.c
index 1b585ce8424..4ada6d62b90 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -21,6 +21,7 @@
 #include "blob.h"
 #include "environment.h"
 #include "gettext.h"
+#include "mem-pool.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/split-index.c b/split-index.c
index c98807c655b..5602b74994b 100644
--- a/split-index.c
+++ b/split-index.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "mem-pool.h"
 #include "split-index.h"
 #include "ewah/ewok.h"
 
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
index 335e5bb3a90..737e0c52358 100644
--- a/t/helper/test-mergesort.c
+++ b/t/helper/test-mergesort.c
@@ -1,5 +1,6 @@
 #include "test-tool.h"
 #include "cache.h"
+#include "mem-pool.h"
 #include "mergesort.h"
 
 static uint32_t minstd_rand(uint32_t *state)
-- 
gitgitgadget


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

* [PATCH v2 07/24] treewide: remove unnecessary cache.h inclusion
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (5 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 06/24] treewide: be explicit about dependence on mem-pool.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 08/24] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren via GitGitGadget
                     ` (18 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Several files were including cache.h solely to get other headers, such
as trace.h and trace2.h.  Since the last few commits have modified
files to make these dependencies more explicit, the inclusion of cache.h
is no longer needed in several cases.  Remove it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 compat/simple-ipc/ipc-unix-socket.c | 2 +-
 connect.c                           | 1 -
 fetch-pack.c                        | 2 +-
 pack-write.c                        | 2 +-
 promisor-remote.c                   | 2 +-
 protocol.c                          | 2 +-
 scalar.c                            | 2 +-
 t/helper/test-date.c                | 1 -
 trace.c                             | 2 +-
 upload-pack.c                       | 2 +-
 10 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/compat/simple-ipc/ipc-unix-socket.c b/compat/simple-ipc/ipc-unix-socket.c
index 7064475b39f..b2f4f22ce44 100644
--- a/compat/simple-ipc/ipc-unix-socket.c
+++ b/compat/simple-ipc/ipc-unix-socket.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "strbuf.h"
diff --git a/connect.c b/connect.c
index 929f72ec5d7..5d8036197d5 100644
--- a/connect.c
+++ b/connect.c
@@ -1,5 +1,4 @@
 #include "git-compat-util.h"
-#include "cache.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/fetch-pack.c b/fetch-pack.c
index 7d4f190fb1d..677102465a1 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "repository.h"
 #include "config.h"
diff --git a/pack-write.c b/pack-write.c
index 152c14aa7aa..d9b460fab4c 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/promisor-remote.c b/promisor-remote.c
index 9d83d2f4b9c..1adcd6fb0a5 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/protocol.c b/protocol.c
index 4d8eb887e82..079ba75acf4 100644
--- a/protocol.c
+++ b/protocol.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "protocol.h"
diff --git a/scalar.c b/scalar.c
index f7680463e1b..af64f75ca66 100644
--- a/scalar.c
+++ b/scalar.c
@@ -2,7 +2,7 @@
  * The Scalar command-line interface.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "gettext.h"
 #include "parse-options.h"
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index a01eec99f35..7adadd41e0b 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "date.h"
 #include "trace.h"
 
diff --git a/trace.c b/trace.c
index d8eaa0a786a..592c141d785 100644
--- a/trace.c
+++ b/trace.c
@@ -21,7 +21,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
 #include "quote.h"
diff --git a/upload-pack.c b/upload-pack.c
index e17545a834a..0305fb2fbdc 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-- 
gitgitgadget


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

* [PATCH v2 08/24] object-name.h: move declarations for object-name.c functions from cache.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (6 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 07/24] treewide: remove unnecessary cache.h inclusion Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 09/24] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren via GitGitGadget
                     ` (17 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 add-patch.c                      |   1 +
 apply.c                          |   1 +
 archive.h                        |   1 +
 bisect.c                         |   1 +
 branch.c                         |   1 +
 builtin/am.c                     |   1 +
 builtin/bisect.c                 |   1 +
 builtin/blame.c                  |   1 +
 builtin/branch.c                 |   1 +
 builtin/cat-file.c               |   1 +
 builtin/check-attr.c             |   1 +
 builtin/checkout.c               |   1 +
 builtin/commit-tree.c            |   1 +
 builtin/commit.c                 |   1 +
 builtin/describe.c               |   1 +
 builtin/fast-import.c            |   1 +
 builtin/fetch.c                  |   1 +
 builtin/fsck.c                   |   1 +
 builtin/grep.c                   |   1 +
 builtin/log.c                    |   1 +
 builtin/ls-files.c               |   1 +
 builtin/ls-tree.c                |   1 +
 builtin/merge-base.c             |   1 +
 builtin/merge-recursive.c        |   1 +
 builtin/merge-tree.c             |   1 +
 builtin/merge.c                  |   1 +
 builtin/name-rev.c               |   1 +
 builtin/notes.c                  |   1 +
 builtin/prune.c                  |   1 +
 builtin/pull.c                   |   1 +
 builtin/range-diff.c             |   1 +
 builtin/read-tree.c              |   1 +
 builtin/rebase.c                 |   1 +
 builtin/receive-pack.c           |   1 +
 builtin/replace.c                |   1 +
 builtin/reset.c                  |   1 +
 builtin/rev-list.c               |   1 +
 builtin/rev-parse.c              |   1 +
 builtin/rm.c                     |   1 +
 builtin/show-branch.c            |   1 +
 builtin/show-ref.c               |   1 +
 builtin/sparse-checkout.c        |   1 +
 builtin/stash.c                  |   1 +
 builtin/submodule--helper.c      |   1 +
 builtin/tag.c                    |   1 +
 builtin/unpack-file.c            |   1 +
 builtin/update-ref.c             |   1 +
 builtin/verify-commit.c          |   1 +
 builtin/verify-tag.c             |   1 +
 builtin/worktree.c               |   1 +
 cache.h                          | 110 ----------------------------
 checkout.c                       |   1 +
 combine-diff.c                   |   1 +
 commit.c                         |   1 +
 config.c                         |   1 +
 diff-lib.c                       |   1 +
 diff.c                           |   1 +
 fmt-merge-msg.c                  |   1 +
 list-objects-filter.c            |   1 +
 log-tree.c                       |   1 +
 mailmap.c                        |   1 +
 merge-ort.c                      |   1 +
 merge-recursive.c                |   1 +
 notes-merge.c                    |   1 +
 notes.c                          |   1 +
 object-name.c                    |   1 +
 object-name.h                    | 121 +++++++++++++++++++++++++++++++
 parse-options-cb.c               |   1 +
 range-diff.c                     |   1 +
 read-cache.c                     |   1 +
 rebase-interactive.c             |   1 +
 ref-filter.c                     |   1 +
 refs.c                           |   1 +
 remote.c                         |   1 +
 reset.c                          |   1 +
 revision.c                       |   1 +
 sequencer.c                      |   1 +
 setup.c                          |   1 +
 strbuf.c                         |   1 +
 submodule-config.c               |   1 +
 submodule.c                      |   1 +
 t/helper/test-fast-rebase.c      |   1 +
 t/helper/test-match-trees.c      |   1 +
 t/helper/test-oidmap.c           |   1 +
 t/helper/test-reach.c            |   1 +
 t/helper/test-submodule-config.c |   1 +
 tag.c                            |   1 +
 transport-helper.c               |   1 +
 transport.c                      |   1 +
 tree.c                           |   1 +
 wt-status.c                      |   1 +
 91 files changed, 210 insertions(+), 110 deletions(-)
 create mode 100644 object-name.h

diff --git a/add-patch.c b/add-patch.c
index b381f14a7de..b01ba8fa81d 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -4,6 +4,7 @@
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "run-command.h"
 #include "strvec.h"
diff --git a/apply.c b/apply.c
index 9b7288bc927..7e40f53ec4c 100644
--- a/apply.c
+++ b/apply.c
@@ -22,6 +22,7 @@
 #include "xdiff-interface.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "rerere.h"
diff --git a/archive.h b/archive.h
index 7178e2a9a2d..f96839ef383 100644
--- a/archive.h
+++ b/archive.h
@@ -2,6 +2,7 @@
 #define ARCHIVE_H
 
 #include "cache.h"
+#include "object-name.h"
 #include "pathspec.h"
 
 struct repository;
diff --git a/bisect.c b/bisect.c
index 0a5f2ed3546..e708e8b6aa1 100644
--- a/bisect.c
+++ b/bisect.c
@@ -17,6 +17,7 @@
 #include "strvec.h"
 #include "commit-slab.h"
 #include "commit-reach.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "dir.h"
 
diff --git a/branch.c b/branch.c
index 3a087b8b4c1..f29743b1619 100644
--- a/branch.c
+++ b/branch.c
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "refspec.h"
 #include "remote.h"
diff --git a/builtin/am.c b/builtin/am.c
index 8d876f31546..0d7ee28bddc 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -27,6 +27,7 @@
 #include "diffcore.h"
 #include "unpack-trees.h"
 #include "branch.h"
+#include "object-name.h"
 #include "sequencer.h"
 #include "revision.h"
 #include "merge-recursive.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 7dc175c6570..4b2143d4557 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "bisect.h"
 #include "refs.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index a8d2114adc9..a628388c2ce 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -28,6 +28,7 @@
 #include "line-log.h"
 #include "dir.h"
 #include "progress.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blame.h"
 #include "refs.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index 5706eb00974..7c1c872708f 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -13,6 +13,7 @@
 #include "commit.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "remote.h"
 #include "parse-options.h"
 #include "branch.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 1e4b4798f40..60b7a55dfc1 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -20,6 +20,7 @@
 #include "tree-walk.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 1dbe9d6ca88..037bf1aaa2a 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -5,6 +5,7 @@
 #include "attr.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "quote.h"
 #include "setup.h"
 #include "parse-options.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 65988fd8a3b..6f5d82ed3d3 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -17,6 +17,7 @@
 #include "lockfile.h"
 #include "mem-pool.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "refs.h"
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 15be167f87a..d1d251c3ded 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index b09017e04f9..682f47c8d5a 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -27,6 +27,7 @@
 #include "log-tree.h"
 #include "strbuf.h"
 #include "utf8.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "rerere.h"
diff --git a/builtin/describe.c b/builtin/describe.c
index 0125d4ddbac..d360b1d12af 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "revision.h"
 #include "diff.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 68b1a539870..31b8732128d 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "mem-pool.h"
 #include "commit-reach.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index e0936629213..8a8ab6799e8 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -10,6 +10,7 @@
 #include "repository.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oidset.h"
 #include "oid-array.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 095b39d3980..04bc71d148c 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -19,6 +19,7 @@
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "resolve-undo.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index a1b68d90bdb..f66e14389e1 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
 #include "write-or-die.h"
diff --git a/builtin/log.c b/builtin/log.c
index 094897df236..5cdc2276cc4 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -12,6 +12,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "color.h"
 #include "commit.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 7f228353feb..ce083cb8efd 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -13,6 +13,7 @@
 #include "dir.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "tree.h"
 #include "cache-tree.h"
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index f32e6be2198..077977a4610 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 3f22273b400..854019a32dc 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -7,6 +7,7 @@
 #include "refs.h"
 #include "diff.h"
 #include "revision.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "repository.h"
 #include "commit-reach.h"
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 25f42f2be7e..fa1035405c3 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "tag.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "xdiff-interface.h"
 
 static const char builtin_merge_recursive_usage[] =
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 803e380856e..6b9f006ec19 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -8,6 +8,7 @@
 #include "commit.h"
 #include "commit-reach.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "repository.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 225b7064066..693f185d4d3 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -15,6 +15,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "builtin.h"
 #include "lockfile.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 831d360a78a..41fd56b9ba9 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -8,6 +8,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "refs.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "hash-lookup.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 4ff44f1e3d0..896140b9055 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -13,6 +13,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "blob.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index 5c0952f5c64..09891832fb3 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "prune-packed.h"
 #include "replace-object.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "shallow.h"
 
diff --git a/builtin/pull.c b/builtin/pull.c
index 636ce12c94d..967368ebc65 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -12,6 +12,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "exec-cmd.h"
 #include "run-command.h"
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index b72af527f08..04339a92ea5 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "range-diff.h"
 #include "config.h"
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 600d4f748fc..d61cbad96de 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -11,6 +11,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "object.h"
+#include "object-name.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "cache-tree.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index fb859f93a30..ff5dd77608d 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -21,6 +21,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index aa5b6fe861f..7d921170f1c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -29,6 +29,7 @@
 #include "tmp-objdir.h"
 #include "oidset.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index d2adc8ab613..134f738a450 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -17,6 +17,7 @@
 #include "refs.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "repository.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index d8c52cc6edf..f99f32d5802 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -24,6 +24,7 @@
 #include "diffcore.h"
 #include "tree.h"
 #include "branch.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "unpack-trees.h"
 #include "cache-tree.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index a3dbbb6338e..c17f0282ae8 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -10,6 +10,7 @@
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
 #include "object.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-bitmap.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 1af2089f9bd..852e49e3403 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -15,6 +15,7 @@
 #include "refs.h"
 #include "quote.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "diff.h"
 #include "revision.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index 6be92817429..d36072252e7 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -13,6 +13,7 @@
 #include "cache-tree.h"
 #include "gettext.h"
 #include "tree-walk.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "setup.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 463a8d11c31..20030b75e39 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -8,6 +8,7 @@
 #include "builtin.h"
 #include "color.h"
 #include "strvec.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "dir.h"
 #include "commit-slab.h"
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 138d30a005e..a2243b42195 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -4,6 +4,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 090bf33510a..34b9d92fb13 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "pathspec.h"
 #include "repository.h"
diff --git a/builtin/stash.c b/builtin/stash.c
index 14194b13bd1..6442b5e20a6 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -5,6 +5,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "refs.h"
 #include "lockfile.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 83377037155..1f087d7bed2 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -24,6 +24,7 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "advice.h"
 #include "branch.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 3e801f54a07..88a25902309 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -14,6 +14,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "run-command.h"
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 314761b0b4d..21082ceb601 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "config.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "wrapper.h"
 
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 3ffd75b3e78..6ca85420c3b 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "refs.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "strvec.h"
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 4d10aa98b10..5d99b82a64f 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 28d0da68454..c6019a0ad8c 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "tag.h"
 #include "run-command.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "gpg-interface.h"
 #include "ref-filter.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 944dd40f94d..69132bba319 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "strvec.h"
 #include "branch.h"
diff --git a/cache.h b/cache.h
index 66705dd469e..21db5da39a5 100644
--- a/cache.h
+++ b/cache.h
@@ -687,24 +687,6 @@ extern int quote_path_fully;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-/*
- * Return an abbreviated sha1 unique within this repository's object database.
- * The result will be at least `len` characters long, and will be NUL
- * terminated.
- *
- * The non-`_r` version returns a static buffer which remains valid until 4
- * more calls to repo_find_unique_abbrev are made.
- *
- * The `_r` variant writes to a buffer supplied by the caller, which must be at
- * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
- * written (excluding the NUL terminator).
- *
- * Note that while this version avoids the static buffer, it is not fully
- * reentrant, as it calls into other non-reentrant git code.
- */
-const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
-int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
-
 /*
  * Create the directory containing the named path, using care to be
  * somewhat safe against races. Return one of the scld_error values to
@@ -806,94 +788,6 @@ int finalize_object_file(const char *tmpfile, const char *filename);
 /* Helper to check and "touch" a file */
 int check_and_freshen_file(const char *fn, int freshen);
 
-/* Convert to/from hex/sha1 representation */
-#define MINIMUM_ABBREV minimum_abbrev
-#define DEFAULT_ABBREV default_abbrev
-
-/* used when the code does not know or care what the default abbrev is */
-#define FALLBACK_DEFAULT_ABBREV 7
-
-struct object_context {
-	unsigned short mode;
-	/*
-	 * symlink_path is only used by get_tree_entry_follow_symlinks,
-	 * and only for symlinks that point outside the repository.
-	 */
-	struct strbuf symlink_path;
-	/*
-	 * If GET_OID_RECORD_PATH is set, this will record path (if any)
-	 * found when resolving the name. The caller is responsible for
-	 * releasing the memory.
-	 */
-	char *path;
-};
-
-int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
-__attribute__((format (printf, 2, 3)))
-int get_oidf(struct object_id *oid, const char *fmt, ...);
-int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
-void maybe_die_on_misspelt_object_name(struct repository *repo,
-				       const char *name,
-				       const char *prefix);
-enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
-					 unsigned flags, struct object_id *oid,
-					 struct object_context *oc);
-
-typedef int each_abbrev_fn(const struct object_id *oid, void *);
-int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
-
-int set_disambiguate_hint_config(const char *var, const char *value);
-
-/*
- * This reads short-hand syntax that not only evaluates to a commit
- * object name, but also can act as if the end user spelled the name
- * of the branch from the command line.
- *
- * - "@{-N}" finds the name of the Nth previous branch we were on, and
- *   places the name of the branch in the given buf and returns the
- *   number of characters parsed if successful.
- *
- * - "<branch>@{upstream}" finds the name of the other ref that
- *   <branch> is configured to merge with (missing <branch> defaults
- *   to the current branch), and places the name of the branch in the
- *   given buf and returns the number of characters parsed if
- *   successful.
- *
- * If the input is not of the accepted format, it returns a negative
- * number to signal an error.
- *
- * If the input was ok but there are not N branch switches in the
- * reflog, it returns 0.
- */
-#define INTERPRET_BRANCH_LOCAL (1<<0)
-#define INTERPRET_BRANCH_REMOTE (1<<1)
-#define INTERPRET_BRANCH_HEAD (1<<2)
-struct interpret_branch_name_options {
-	/*
-	 * If "allowed" is non-zero, it is a treated as a bitfield of allowable
-	 * expansions: local branches ("refs/heads/"), remote branches
-	 * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
-	 * allowed, even ones to refs outside of those namespaces.
-	 */
-	unsigned allowed;
-
-	/*
-	 * If ^{upstream} or ^{push} (or equivalent) is requested, and the
-	 * branch in question does not have such a reference, return -1 instead
-	 * of die()-ing.
-	 */
-	unsigned nonfatal_dangling_mark : 1;
-};
-int repo_interpret_branch_name(struct repository *r,
-			       const char *str, int len,
-			       struct strbuf *buf,
-			       const struct interpret_branch_name_options *options);
-
 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,
@@ -907,10 +801,6 @@ void *read_object_with_reference(struct repository *r,
 				 unsigned long *size,
 				 struct object_id *oid_ret);
 
-struct object *repo_peel_to_type(struct repository *r,
-				 const char *name, int namelen,
-				 struct object *o, enum object_type);
-
 const char *git_editor(void);
 const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
diff --git a/checkout.c b/checkout.c
index 1247b882248..9235073fc0d 100644
--- a/checkout.c
+++ b/checkout.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
 #include "checkout.h"
diff --git a/combine-diff.c b/combine-diff.c
index 6586e4508d6..cd5f39f22f4 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -7,6 +7,7 @@
 #include "diffcore.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "quote.h"
 #include "xdiff-interface.h"
 #include "xdiff/xmacros.h"
diff --git a/commit.c b/commit.c
index 6d844da9a6b..bad31c423a4 100644
--- a/commit.c
+++ b/commit.c
@@ -6,6 +6,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "repository.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "pkt-line.h"
 #include "utf8.h"
diff --git a/config.c b/config.c
index 9e74b5aec7f..aac439530e9 100644
--- a/config.c
+++ b/config.c
@@ -23,6 +23,7 @@
 #include "quote.h"
 #include "hashmap.h"
 #include "string-list.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "utf8.h"
 #include "dir.h"
diff --git a/diff-lib.c b/diff-lib.c
index 8b5cca96ace..d292405a262 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -8,6 +8,7 @@
 #include "diffcore.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
diff --git a/diff.c b/diff.c
index 89cd0b17da5..9e6ad94bc66 100644
--- a/diff.c
+++ b/diff.c
@@ -35,6 +35,7 @@
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
+#include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
 #include "wrapper.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 1886c92ddb9..21019c932b3 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -3,6 +3,7 @@
 #include "config.h"
 #include "environment.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "diff.h"
 #include "diff-merges.h"
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 298ca08711e..8b2a45e507d 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -15,6 +15,7 @@
 #include "list-objects-filter-options.h"
 #include "oidmap.h"
 #include "oidset.h"
+#include "object-name.h"
 #include "object-store.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/log-tree.c b/log-tree.c
index 627c711f707..f0e885635e0 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -4,6 +4,7 @@
 #include "diff.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "tmp-objdir.h"
diff --git a/mailmap.c b/mailmap.c
index 14f2c0f62ae..d62d7bf0e7f 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -2,6 +2,7 @@
 #include "environment.h"
 #include "string-list.h"
 #include "mailmap.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "setup.h"
 
diff --git a/merge-ort.c b/merge-ort.c
index 1008684fbbc..2c6a9ed9a41 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -32,6 +32,7 @@
 #include "entry.h"
 #include "ll-merge.h"
 #include "mem-pool.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "promisor-remote.h"
diff --git a/merge-recursive.c b/merge-recursive.c
index ed5534eb57d..748a6799a30 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -22,6 +22,7 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "revision.h"
diff --git a/notes-merge.c b/notes-merge.c
index 0258f87d21f..b496b77d9db 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -3,6 +3,7 @@
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "diff.h"
diff --git a/notes.c b/notes.c
index 45fb7f22d1d..c07bcbe3486 100644
--- a/notes.c
+++ b/notes.c
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/object-name.c b/object-name.c
index ff647d6c7b5..3cd5b327293 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-name.h"
 #include "advice.h"
 #include "config.h"
 #include "environment.h"
diff --git a/object-name.h b/object-name.h
new file mode 100644
index 00000000000..1d63698f42b
--- /dev/null
+++ b/object-name.h
@@ -0,0 +1,121 @@
+#ifndef OBJECT_NAME_H
+#define OBJECT_NAME_H
+
+#include "object.h"
+#include "strbuf.h"
+
+struct object_id;
+struct repository;
+
+struct object_context {
+	unsigned short mode;
+	/*
+	 * symlink_path is only used by get_tree_entry_follow_symlinks,
+	 * and only for symlinks that point outside the repository.
+	 */
+	struct strbuf symlink_path;
+	/*
+	 * If GET_OID_RECORD_PATH is set, this will record path (if any)
+	 * found when resolving the name. The caller is responsible for
+	 * releasing the memory.
+	 */
+	char *path;
+};
+
+/*
+ * Return an abbreviated sha1 unique within this repository's object database.
+ * The result will be at least `len` characters long, and will be NUL
+ * terminated.
+ *
+ * The non-`_r` version returns a static buffer which remains valid until 4
+ * more calls to repo_find_unique_abbrev are made.
+ *
+ * The `_r` variant writes to a buffer supplied by the caller, which must be at
+ * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
+ * written (excluding the NUL terminator).
+ *
+ * Note that while this version avoids the static buffer, it is not fully
+ * reentrant, as it calls into other non-reentrant git code.
+ */
+const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
+int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
+
+int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
+__attribute__((format (printf, 2, 3)))
+int get_oidf(struct object_id *oid, const char *fmt, ...);
+int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
+void maybe_die_on_misspelt_object_name(struct repository *repo,
+				       const char *name,
+				       const char *prefix);
+enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
+					 unsigned flags, struct object_id *oid,
+					 struct object_context *oc);
+
+
+typedef int each_abbrev_fn(const struct object_id *oid, void *);
+int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
+
+int set_disambiguate_hint_config(const char *var, const char *value);
+
+/*
+ * This reads short-hand syntax that not only evaluates to a commit
+ * object name, but also can act as if the end user spelled the name
+ * of the branch from the command line.
+ *
+ * - "@{-N}" finds the name of the Nth previous branch we were on, and
+ *   places the name of the branch in the given buf and returns the
+ *   number of characters parsed if successful.
+ *
+ * - "<branch>@{upstream}" finds the name of the other ref that
+ *   <branch> is configured to merge with (missing <branch> defaults
+ *   to the current branch), and places the name of the branch in the
+ *   given buf and returns the number of characters parsed if
+ *   successful.
+ *
+ * If the input is not of the accepted format, it returns a negative
+ * number to signal an error.
+ *
+ * If the input was ok but there are not N branch switches in the
+ * reflog, it returns 0.
+ */
+#define INTERPRET_BRANCH_LOCAL (1<<0)
+#define INTERPRET_BRANCH_REMOTE (1<<1)
+#define INTERPRET_BRANCH_HEAD (1<<2)
+struct interpret_branch_name_options {
+	/*
+	 * If "allowed" is non-zero, it is a treated as a bitfield of allowable
+	 * expansions: local branches ("refs/heads/"), remote branches
+	 * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
+	 * allowed, even ones to refs outside of those namespaces.
+	 */
+	unsigned allowed;
+
+	/*
+	 * If ^{upstream} or ^{push} (or equivalent) is requested, and the
+	 * branch in question does not have such a reference, return -1 instead
+	 * of die()-ing.
+	 */
+	unsigned nonfatal_dangling_mark : 1;
+};
+int repo_interpret_branch_name(struct repository *r,
+			       const char *str, int len,
+			       struct strbuf *buf,
+			       const struct interpret_branch_name_options *options);
+
+struct object *repo_peel_to_type(struct repository *r,
+				 const char *name, int namelen,
+				 struct object *o, enum object_type);
+
+/* Convert to/from hex/sha1 representation */
+#define MINIMUM_ABBREV minimum_abbrev
+#define DEFAULT_ABBREV default_abbrev
+
+/* used when the code does not know or care what the default abbrev is */
+#define FALLBACK_DEFAULT_ABBREV 7
+
+#endif /* OBJECT_NAME_H */
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 666c2129797..b4df4bcebed 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -6,6 +6,7 @@
 #include "color.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "oid-array.h"
diff --git a/range-diff.c b/range-diff.c
index d1ed3b8ee56..a2994331a14 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -2,6 +2,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "range-diff.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "run-command.h"
 #include "strvec.h"
diff --git a/read-cache.c b/read-cache.c
index 4ada6d62b90..cbbfc030da7 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -22,6 +22,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "mem-pool.h"
+#include "object-name.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 79ed61b9fa4..48467a7bc4a 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -8,6 +8,7 @@
 #include "commit-slab.h"
 #include "config.h"
 #include "dir.h"
+#include "object-name.h"
 #include "wrapper.h"
 
 static const char edit_todo_list_advice[] =
diff --git a/ref-filter.c b/ref-filter.c
index 1c6174c8aed..57a5884aec7 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -6,6 +6,7 @@
 #include "parse-options.h"
 #include "refs.h"
 #include "wildmatch.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "repository.h"
diff --git a/refs.c b/refs.c
index cfced6f174a..979ed3fbedc 100644
--- a/refs.c
+++ b/refs.c
@@ -16,6 +16,7 @@
 #include "refs/refs-internal.h"
 #include "run-command.h"
 #include "hook.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
diff --git a/remote.c b/remote.c
index 6599d52de20..3afedce593e 100644
--- a/remote.c
+++ b/remote.c
@@ -9,6 +9,7 @@
 #include "urlmatch.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/reset.c b/reset.c
index ab300923e04..48da0adf851 100644
--- a/reset.c
+++ b/reset.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "refs.h"
 #include "reset.h"
 #include "run-command.h"
diff --git a/revision.c b/revision.c
index 7c34c93885e..7438b50e267 100644
--- a/revision.c
+++ b/revision.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "blob.h"
diff --git a/sequencer.c b/sequencer.c
index eaba379e3ad..22b287be984 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "commit.h"
diff --git a/setup.c b/setup.c
index 3bb7a9fff62..8a297b3cb5c 100644
--- a/setup.c
+++ b/setup.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "repository.h"
 #include "config.h"
 #include "dir.h"
diff --git a/strbuf.c b/strbuf.c
index 70a83e7980e..1b93d9d3c47 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "string-list.h"
 #include "utf8.h"
diff --git a/submodule-config.c b/submodule-config.c
index ecf0fcf0074..252b90aa439 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -9,6 +9,7 @@
 #include "submodule-config.h"
 #include "submodule.h"
 #include "strbuf.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "tree-walk.h"
diff --git a/submodule.c b/submodule.c
index 58c9d5e5673..4f403b9eeff 100644
--- a/submodule.c
+++ b/submodule.c
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit-reach.h"
 #include "setup.h"
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index fd48e0ee2c8..d1d63feaa9e 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -20,6 +20,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "refs.h"
 #include "revision.h"
 #include "sequencer.h"
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 7066f3c71d2..3808e1ac38b 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 "object-name.h"
 #include "setup.h"
 #include "tree.h"
 
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index e2eb25ecdea..bf4fcfe6efb 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "hex.h"
+#include "object-name.h"
 #include "oidmap.h"
 #include "setup.h"
 #include "strbuf.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index b0deaa106a2..d4fa33ae751 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -6,6 +6,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "ref-filter.h"
 #include "setup.h"
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 66063b58ded..4758c8654e0 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "config.h"
+#include "object-name.h"
 #include "setup.h"
 #include "submodule-config.h"
 #include "submodule.h"
diff --git a/tag.c b/tag.c
index 01ed67d6fa6..b9fc2fc9929 100644
--- a/tag.c
+++ b/tag.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "environment.h"
 #include "tag.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "tree.h"
diff --git a/transport-helper.c b/transport-helper.c
index 76d146ee88b..ca8bec04bb3 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "remote.h"
 #include "string-list.h"
diff --git a/transport.c b/transport.c
index 82bf2496ba7..7374cfd1fa9 100644
--- a/transport.c
+++ b/transport.c
@@ -26,6 +26,7 @@
 #include "trace2.h"
 #include "transport-internal.h"
 #include "protocol.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "color.h"
 #include "bundle-uri.h"
diff --git a/tree.c b/tree.c
index 2b78708766b..e9d51ce2e00 100644
--- a/tree.c
+++ b/tree.c
@@ -2,6 +2,7 @@
 #include "cache-tree.h"
 #include "hex.h"
 #include "tree.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "commit.h"
diff --git a/wt-status.c b/wt-status.c
index 47f223c0f8d..97b9c1c0359 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -8,6 +8,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "diffcore.h"
 #include "quote.h"
-- 
gitgitgadget


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

* [PATCH v2 09/24] treewide: remove cache.h inclusion due to object-name.h changes
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (7 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 08/24] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 10/24] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren via GitGitGadget
                     ` (16 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 branch.c                         | 1 -
 checkout.c                       | 3 ++-
 fmt-merge-msg.c                  | 2 +-
 mailmap.c                        | 2 +-
 notes.c                          | 2 +-
 refs.c                           | 2 +-
 remote.c                         | 2 +-
 setup.c                          | 2 +-
 strbuf.c                         | 2 +-
 t/helper/test-oidmap.c           | 1 -
 t/helper/test-reach.c            | 1 -
 t/helper/test-submodule-config.c | 1 -
 transport-helper.c               | 2 +-
 13 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/branch.c b/branch.c
index f29743b1619..7df982693af 100644
--- a/branch.c
+++ b/branch.c
@@ -1,5 +1,4 @@
 #include "git-compat-util.h"
-#include "cache.h"
 #include "advice.h"
 #include "config.h"
 #include "branch.h"
diff --git a/checkout.c b/checkout.c
index 9235073fc0d..04238b27133 100644
--- a/checkout.c
+++ b/checkout.c
@@ -1,9 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
 #include "checkout.h"
 #include "config.h"
+#include "strbuf.h"
 
 struct tracking_name_data {
 	/* const */ char *src_ref;
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 21019c932b3..5af0d4715ba 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/mailmap.c b/mailmap.c
index d62d7bf0e7f..28d389c1f94 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "string-list.h"
 #include "mailmap.h"
diff --git a/notes.c b/notes.c
index c07bcbe3486..02f1aa39ae1 100644
--- a/notes.c
+++ b/notes.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "hex.h"
diff --git a/refs.c b/refs.c
index 979ed3fbedc..d2a98e1c21f 100644
--- a/refs.c
+++ b/refs.c
@@ -2,7 +2,7 @@
  * The backend-independent part of the reference module.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/remote.c b/remote.c
index 3afedce593e..2947743d60a 100644
--- a/remote.c
+++ b/remote.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/setup.c b/setup.c
index 8a297b3cb5c..a546da755f1 100644
--- a/setup.c
+++ b/setup.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/strbuf.c b/strbuf.c
index 1b93d9d3c47..b2e3735ba8a 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "environment.h"
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index bf4fcfe6efb..de6ab77fdaa 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "object-name.h"
 #include "oidmap.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index d4fa33ae751..5b6f2174418 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "alloc.h"
 #include "commit.h"
 #include "commit-reach.h"
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 4758c8654e0..c7c7fdbea98 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "config.h"
 #include "object-name.h"
 #include "setup.h"
diff --git a/transport-helper.c b/transport-helper.c
index ca8bec04bb3..6b816940dc6 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "transport.h"
 #include "quote.h"
 #include "run-command.h"
-- 
gitgitgadget


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

* [PATCH v2 10/24] git-zlib: move declarations for git-zlib functions from cache.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (8 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 09/24] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 11/24] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren via GitGitGadget
                     ` (15 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Move functions from cache.h for zlib.c into a new header file.  Since
adding a "zlib.h" would cause issues with the real zlib, rename zlib.c
to git-zlib.c while we are at it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 Makefile                 |  2 +-
 archive-tar.c            |  1 +
 archive-zip.c            |  1 +
 builtin/unpack-objects.c |  1 +
 cache.h                  | 25 +------------------------
 zlib.c => git-zlib.c     |  3 ++-
 git-zlib.h               | 28 ++++++++++++++++++++++++++++
 http-backend.c           |  1 +
 http.h                   |  3 +++
 9 files changed, 39 insertions(+), 26 deletions(-)
 rename zlib.c => git-zlib.c (99%)
 create mode 100644 git-zlib.h

diff --git a/Makefile b/Makefile
index 50ee51fde32..0c367881bff 100644
--- a/Makefile
+++ b/Makefile
@@ -1036,6 +1036,7 @@ LIB_OBJS += fsmonitor.o
 LIB_OBJS += fsmonitor-ipc.o
 LIB_OBJS += fsmonitor-settings.o
 LIB_OBJS += gettext.o
+LIB_OBJS += git-zlib.o
 LIB_OBJS += gpg-interface.o
 LIB_OBJS += graph.o
 LIB_OBJS += grep.o
@@ -1196,7 +1197,6 @@ LIB_OBJS += write-or-die.o
 LIB_OBJS += ws.o
 LIB_OBJS += wt-status.o
 LIB_OBJS += xdiff-interface.o
-LIB_OBJS += zlib.o
 
 BUILTIN_OBJS += builtin/add.o
 BUILTIN_OBJS += builtin/am.o
diff --git a/archive-tar.c b/archive-tar.c
index 497dad0b3af..4cd81d8161e 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -5,6 +5,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "tar.h"
 #include "archive.h"
diff --git a/archive-zip.c b/archive-zip.c
index e6f5c10a14f..ef538a90df4 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -5,6 +5,7 @@
 #include "config.h"
 #include "archive.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "streaming.h"
 #include "utf8.h"
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index f2c1323e661..ddbdb3dd226 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -4,6 +4,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "object-store.h"
 #include "object.h"
diff --git a/cache.h b/cache.h
index 21db5da39a5..c06778b69cd 100644
--- a/cache.h
+++ b/cache.h
@@ -3,6 +3,7 @@
 
 #include "git-compat-util.h"
 #include "strbuf.h"
+#include "git-zlib.h"
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
@@ -14,30 +15,6 @@
 #include "repository.h"
 #include "statinfo.h"
 
-typedef struct git_zstream {
-	z_stream z;
-	unsigned long avail_in;
-	unsigned long avail_out;
-	unsigned long total_in;
-	unsigned long total_out;
-	unsigned char *next_in;
-	unsigned char *next_out;
-} git_zstream;
-
-void git_inflate_init(git_zstream *);
-void git_inflate_init_gzip_only(git_zstream *);
-void git_inflate_end(git_zstream *);
-int git_inflate(git_zstream *, int flush);
-
-void git_deflate_init(git_zstream *, int level);
-void git_deflate_init_gzip(git_zstream *, int level);
-void git_deflate_init_raw(git_zstream *, int level);
-void git_deflate_end(git_zstream *);
-int git_deflate_abort(git_zstream *);
-int git_deflate_end_gently(git_zstream *);
-int git_deflate(git_zstream *, int flush);
-unsigned long git_deflate_bound(git_zstream *, unsigned long);
-
 #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
 #define DTYPE(de)	((de)->d_type)
 #else
diff --git a/zlib.c b/git-zlib.c
similarity index 99%
rename from zlib.c
rename to git-zlib.c
index d594cba3fc9..d43bbeb6daa 100644
--- a/zlib.c
+++ b/git-zlib.c
@@ -2,7 +2,8 @@
  * zlib wrappers to make sure we don't silently miss errors
  * at init time.
  */
-#include "cache.h"
+#include "git-compat-util.h"
+#include "git-zlib.h"
 
 static const char *zerr_to_string(int status)
 {
diff --git a/git-zlib.h b/git-zlib.h
new file mode 100644
index 00000000000..d8a670aff9f
--- /dev/null
+++ b/git-zlib.h
@@ -0,0 +1,28 @@
+#ifndef GIT_ZLIB_H
+#define GIT_ZLIB_H
+
+typedef struct git_zstream {
+	z_stream z;
+	unsigned long avail_in;
+	unsigned long avail_out;
+	unsigned long total_in;
+	unsigned long total_out;
+	unsigned char *next_in;
+	unsigned char *next_out;
+} git_zstream;
+
+void git_inflate_init(git_zstream *);
+void git_inflate_init_gzip_only(git_zstream *);
+void git_inflate_end(git_zstream *);
+int git_inflate(git_zstream *, int flush);
+
+void git_deflate_init(git_zstream *, int level);
+void git_deflate_init_gzip(git_zstream *, int level);
+void git_deflate_init_raw(git_zstream *, int level);
+void git_deflate_end(git_zstream *);
+int git_deflate_abort(git_zstream *);
+int git_deflate_end_gently(git_zstream *);
+int git_deflate(git_zstream *, int flush);
+unsigned long git_deflate_bound(git_zstream *, unsigned long);
+
+#endif /* GIT_ZLIB_H */
diff --git a/http-backend.c b/http-backend.c
index 89aad1b42c7..d41b3b9e1e7 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "repository.h"
 #include "refs.h"
diff --git a/http.h b/http.h
index 77c042706c6..783b2b09b8b 100644
--- a/http.h
+++ b/http.h
@@ -1,7 +1,10 @@
 #ifndef HTTP_H
 #define HTTP_H
 
+struct packed_git;
+
 #include "cache.h"
+#include "git-zlib.h"
 
 #include <curl/curl.h>
 #include <curl/easy.h>
-- 
gitgitgadget


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

* [PATCH v2 11/24] treewide: remove cache.h inclusion due to git-zlib changes
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (9 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 10/24] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 12/24] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren via GitGitGadget
                     ` (14 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

This actually only affects http-backend.c, but the git-zlib changes
are going to be instrumental in pulling out an object-file.h which
will help with several more files.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 http-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/http-backend.c b/http-backend.c
index d41b3b9e1e7..ac146d85c54 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
-- 
gitgitgadget


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

* [PATCH v2 12/24] object-file.h: move declarations for object-file.c functions from cache.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (10 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 11/24] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 13/24] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren via GitGitGadget
                     ` (13 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 apply.c                            |   1 +
 builtin/bugreport.c                |   1 +
 builtin/cat-file.c                 |   1 +
 builtin/clone.c                    |   1 +
 builtin/credential-cache--daemon.c |   1 +
 builtin/diagnose.c                 |   1 +
 builtin/difftool.c                 |   1 +
 builtin/fast-export.c              |   1 +
 builtin/fast-import.c              |   1 +
 builtin/fetch-pack.c               |   1 +
 builtin/fsck.c                     |   1 +
 builtin/gc.c                       |   1 +
 builtin/grep.c                     |   1 +
 builtin/hash-object.c              |   1 +
 builtin/index-pack.c               |   1 +
 builtin/init-db.c                  |   1 +
 builtin/log.c                      |   1 +
 builtin/mktag.c                    |   1 +
 builtin/mv.c                       |   1 +
 builtin/pack-objects.c             |   1 +
 builtin/prune.c                    |   1 +
 builtin/rebase.c                   |   1 +
 builtin/replace.c                  |   1 +
 builtin/rev-list.c                 |   1 +
 builtin/sparse-checkout.c          |   1 +
 builtin/submodule--helper.c        |   1 +
 builtin/update-index.c             |   1 +
 builtin/worktree.c                 |   1 +
 bulk-checkin.c                     |   1 +
 cache-tree.c                       |   1 +
 cache.h                            | 123 ---------------------------
 commit-graph.c                     |   1 +
 diff.c                             |   1 +
 dir.c                              |   1 +
 environment.c                      |   1 +
 http.c                             |   1 +
 merge-recursive.c                  |   1 +
 midx.c                             |   1 +
 notes-merge.c                      |   1 +
 object-file.c                      |   1 +
 object-file.h                      | 129 +++++++++++++++++++++++++++++
 object.c                           |   1 +
 pack-bitmap.c                      |   1 +
 pack-check.c                       |   1 +
 pack-mtimes.c                      |   1 +
 pack-revindex.c                    |   1 +
 packfile.c                         |   1 +
 read-cache.c                       |   1 +
 refs/files-backend.c               |   1 +
 rerere.c                           |   1 +
 revision.c                         |   1 +
 sequencer.c                        |   1 +
 server-info.c                      |   1 +
 streaming.c                        |   1 +
 submodule.c                        |   1 +
 tmp-objdir.c                       |   1 +
 tree-walk.c                        |   1 +
 57 files changed, 184 insertions(+), 123 deletions(-)
 create mode 100644 object-file.h

diff --git a/apply.c b/apply.c
index 7e40f53ec4c..2868cef5ddd 100644
--- a/apply.c
+++ b/apply.c
@@ -23,6 +23,7 @@
 #include "ll-merge.h"
 #include "lockfile.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "rerere.h"
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index 52955e1d389..03fb0536911 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -8,6 +8,7 @@
 #include "hook.h"
 #include "hook-list.h"
 #include "diagnose.h"
+#include "object-file.h"
 #include "setup.h"
 #include "wrapper.h"
 
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 60b7a55dfc1..0bafc14e6c0 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -20,6 +20,7 @@
 #include "tree-walk.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index f1e8aa3f27e..c7fdffb484c 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -21,6 +21,7 @@
 #include "fetch-pack.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "tree.h"
 #include "tree-walk.h"
diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index 62c09a271d6..4e571d9951b 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 
 #ifndef NO_UNIX_SOCKETS
diff --git a/builtin/diagnose.c b/builtin/diagnose.c
index 0f8b64994c4..4f22eb2b55d 100644
--- a/builtin/diagnose.c
+++ b/builtin/diagnose.c
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "diagnose.h"
 
diff --git a/builtin/difftool.c b/builtin/difftool.c
index e010a21bfbc..3ffb0524be7 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -25,6 +25,7 @@
 #include "strvec.h"
 #include "strbuf.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "dir.h"
 #include "entry.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 0bb779deb69..c7835ea0791 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -10,6 +10,7 @@
 #include "hex.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "commit.h"
 #include "object.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 31b8732128d..9f90f5b9e41 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "mem-pool.h"
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 60e5a10ffc5..664ac1ec0e8 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "pkt-line.h"
 #include "fetch-pack.h"
 #include "remote.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 04bc71d148c..35a6de3cdb5 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -19,6 +19,7 @@
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index 000a2ef5e11..b95154fba16 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -25,6 +25,7 @@
 #include "commit.h"
 #include "commit-graph.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-objects.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index f66e14389e1..fb11be6075a 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index a15fe4fd3f4..a3801211666 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "quote.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 5adfb2521cd..0f59cf8aa08 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -18,6 +18,7 @@
 #include "thread-utils.h"
 #include "packfile.h"
 #include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "replace-object.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index ba6e0b20fa5..6183f3fb3ff 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "setup.h"
 #include "worktree.h"
diff --git a/builtin/log.c b/builtin/log.c
index 5cdc2276cc4..b6246c7042c 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -12,6 +12,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "color.h"
diff --git a/builtin/mktag.c b/builtin/mktag.c
index f9d9a38452b..f33d267fcb6 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -4,6 +4,7 @@
 #include "parse-options.h"
 #include "tag.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "fsck.h"
 #include "config.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index 8f7770aa32b..32935af48e6 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -11,6 +11,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "pathspec.h"
 #include "lockfile.h"
 #include "dir.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 69c65428614..68c914a8e1a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -33,6 +33,7 @@
 #include "strvec.h"
 #include "list.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "dir.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index 09891832fb3..5dc9b207200 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "prune-packed.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "shallow.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index ff5dd77608d..34fea4d8220 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -21,6 +21,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "commit.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index 134f738a450..f4b3a8efb23 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -17,6 +17,7 @@
 #include "refs.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index c17f0282ae8..6dc8be492a2 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -11,6 +11,7 @@
 #include "list-objects-filter-options.h"
 #include "object.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-bitmap.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 34b9d92fb13..4de37d07fd9 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "pathspec.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1f087d7bed2..5d999f814e0 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -24,6 +24,7 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "advice.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 03cda5e60d2..33b00cef151 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -15,6 +15,7 @@
 #include "cache-tree.h"
 #include "tree-walk.h"
 #include "builtin.h"
+#include "object-file.h"
 #include "refs.h"
 #include "resolve-undo.h"
 #include "parse-options.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 69132bba319..0621f6f708e 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "strvec.h"
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 6362b6aabc7..af15f8a9af4 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -15,6 +15,7 @@
 #include "string-list.h"
 #include "tmp-objdir.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 static int odb_transaction_nesting;
diff --git a/cache-tree.c b/cache-tree.c
index 39f0c744727..ebfe649b330 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -7,6 +7,7 @@
 #include "tree-walk.h"
 #include "cache-tree.h"
 #include "bulk-checkin.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/cache.h b/cache.h
index c06778b69cd..89987cca22a 100644
--- a/cache.h
+++ b/cache.h
@@ -3,7 +3,6 @@
 
 #include "git-compat-util.h"
 #include "strbuf.h"
-#include "git-zlib.h"
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
@@ -596,13 +595,6 @@ int has_racy_timestamp(struct index_state *istate);
 int ie_match_stat(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 int ie_modified(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 
-#define HASH_WRITE_OBJECT 1
-#define HASH_FORMAT_CHECK 2
-#define HASH_RENORMALIZE  4
-#define HASH_SILENT 8
-int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
-int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
-
 /*
  * Record to sd the data from st that we use to check whether a file
  * might have changed.
@@ -664,107 +656,6 @@ extern int quote_path_fully;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-/*
- * Create the directory containing the named path, using care to be
- * somewhat safe against races. Return one of the scld_error values to
- * indicate success/failure. On error, set errno to describe the
- * problem.
- *
- * SCLD_VANISHED indicates that one of the ancestor directories of the
- * path existed at one point during the function call and then
- * suddenly vanished, probably because another process pruned the
- * directory while we were working.  To be robust against this kind of
- * race, callers might want to try invoking the function again when it
- * returns SCLD_VANISHED.
- *
- * safe_create_leading_directories() temporarily changes path while it
- * is working but restores it before returning.
- * safe_create_leading_directories_const() doesn't modify path, even
- * temporarily. Both these variants adjust the permissions of the
- * created directories to honor core.sharedRepository, so they are best
- * suited for files inside the git dir. For working tree files, use
- * safe_create_leading_directories_no_share() instead, as it ignores
- * the core.sharedRepository setting.
- */
-enum scld_error {
-	SCLD_OK = 0,
-	SCLD_FAILED = -1,
-	SCLD_PERMS = -2,
-	SCLD_EXISTS = -3,
-	SCLD_VANISHED = -4
-};
-enum scld_error safe_create_leading_directories(char *path);
-enum scld_error safe_create_leading_directories_const(const char *path);
-enum scld_error safe_create_leading_directories_no_share(char *path);
-
-int mkdir_in_gitdir(const char *path);
-
-int git_open_cloexec(const char *name, int flags);
-#define git_open(name) git_open_cloexec(name, O_RDONLY)
-
-/**
- * unpack_loose_header() initializes the data stream needed to unpack
- * a loose object header.
- *
- * Returns:
- *
- * - ULHR_OK on success
- * - ULHR_BAD on error
- * - ULHR_TOO_LONG if the header was too long
- *
- * It will only parse up to MAX_HEADER_LEN bytes unless an optional
- * "hdrbuf" argument is non-NULL. This is intended for use with
- * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
- * reporting. The full header will be extracted to "hdrbuf" for use
- * with parse_loose_header(), ULHR_TOO_LONG will still be returned
- * from this function to indicate that the header was too long.
- */
-enum unpack_loose_header_result {
-	ULHR_OK,
-	ULHR_BAD,
-	ULHR_TOO_LONG,
-};
-enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
-						    unsigned char *map,
-						    unsigned long mapsize,
-						    void *buffer,
-						    unsigned long bufsiz,
-						    struct strbuf *hdrbuf);
-
-/**
- * parse_loose_header() parses the starting "<type> <len>\0" of an
- * object. If it doesn't follow that format -1 is returned. To check
- * the validity of the <type> populate the "typep" in the "struct
- * object_info". It will be OBJ_BAD if the object type is unknown. The
- * parsed <len> can be retrieved via "oi->sizep", and from there
- * passed to unpack_loose_rest().
- */
-struct object_info;
-int parse_loose_header(const char *hdr, struct object_info *oi);
-
-/**
- * With in-core object data in "buf", rehash it to make sure the
- * object name actually matches "oid" to detect object corruption.
- *
- * A negative value indicates an error, usually that the OID is not
- * what we expected, but it might also indicate another error.
- */
-int check_object_signature(struct repository *r, const struct object_id *oid,
-			   void *map, unsigned long size,
-			   enum object_type type);
-
-/**
- * A streaming version of check_object_signature().
- * Try reading the object named with "oid" using
- * the streaming interface and rehash it to do the same.
- */
-int stream_object_signature(struct repository *r, const struct object_id *oid);
-
-int finalize_object_file(const char *tmpfile, const char *filename);
-
-/* Helper to check and "touch" a file */
-int check_and_freshen_file(const char *fn, int freshen);
-
 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,
@@ -772,12 +663,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);
 
-void *read_object_with_reference(struct repository *r,
-				 const struct object_id *oid,
-				 enum object_type required_type,
-				 unsigned long *size,
-				 struct object_id *oid_ret);
-
 const char *git_editor(void);
 const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
@@ -819,14 +704,6 @@ struct pack_entry {
 	struct packed_git *p;
 };
 
-/*
- * Set this to 0 to prevent oid_object_info_extended() from fetching missing
- * blobs. This has a difference only if extensions.partialClone is set.
- *
- * Its default value is 1.
- */
-extern int fetch_if_missing;
-
 /* Dumb servers support */
 int update_server_info(int);
 
diff --git a/commit-graph.c b/commit-graph.c
index fe9a8b2342f..c20e73ceebf 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -11,6 +11,7 @@
 #include "revision.h"
 #include "hash-lookup.h"
 #include "commit-graph.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "alloc.h"
diff --git a/diff.c b/diff.c
index 9e6ad94bc66..f8e0d3b5c59 100644
--- a/diff.c
+++ b/diff.c
@@ -35,6 +35,7 @@
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
diff --git a/dir.c b/dir.c
index d1f1b1ef768..aa840995c40 100644
--- a/dir.c
+++ b/dir.c
@@ -13,6 +13,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "attr.h"
 #include "refs.h"
diff --git a/environment.c b/environment.c
index e57292eccc9..39efa49fe31 100644
--- a/environment.c
+++ b/environment.c
@@ -19,6 +19,7 @@
 #include "fmt-merge-msg.h"
 #include "commit.h"
 #include "strvec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "tmp-objdir.h"
diff --git a/http.c b/http.c
index 0212c0ad3b2..c3916ceb4d8 100644
--- a/http.c
+++ b/http.c
@@ -17,6 +17,7 @@
 #include "packfile.h"
 #include "protocol.h"
 #include "string-list.h"
+#include "object-file.h"
 #include "object-store.h"
 
 static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
diff --git a/merge-recursive.c b/merge-recursive.c
index 748a6799a30..9875bdb11cb 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -22,6 +22,7 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
diff --git a/midx.c b/midx.c
index 9af3e5de889..2d0da573281 100644
--- a/midx.c
+++ b/midx.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "midx.h"
diff --git a/notes-merge.c b/notes-merge.c
index b496b77d9db..cc9538ac5c0 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -3,6 +3,7 @@
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
diff --git a/object-file.c b/object-file.c
index a4331e0da61..8163ddbaddd 100644
--- a/object-file.c
+++ b/object-file.c
@@ -36,6 +36,7 @@
 #include "mergesort.h"
 #include "quote.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "promisor-remote.h"
 #include "setup.h"
diff --git a/object-file.h b/object-file.h
new file mode 100644
index 00000000000..e0cfc3a5db8
--- /dev/null
+++ b/object-file.h
@@ -0,0 +1,129 @@
+#ifndef OBJECT_FILE_H
+#define OBJECT_FILE_H
+
+#include "git-zlib.h"
+#include "object.h"
+
+/*
+ * Set this to 0 to prevent oid_object_info_extended() from fetching missing
+ * blobs. This has a difference only if extensions.partialClone is set.
+ *
+ * Its default value is 1.
+ */
+extern int fetch_if_missing;
+
+#define HASH_WRITE_OBJECT 1
+#define HASH_FORMAT_CHECK 2
+#define HASH_RENORMALIZE  4
+#define HASH_SILENT 8
+int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
+int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
+
+/*
+ * Create the directory containing the named path, using care to be
+ * somewhat safe against races. Return one of the scld_error values to
+ * indicate success/failure. On error, set errno to describe the
+ * problem.
+ *
+ * SCLD_VANISHED indicates that one of the ancestor directories of the
+ * path existed at one point during the function call and then
+ * suddenly vanished, probably because another process pruned the
+ * directory while we were working.  To be robust against this kind of
+ * race, callers might want to try invoking the function again when it
+ * returns SCLD_VANISHED.
+ *
+ * safe_create_leading_directories() temporarily changes path while it
+ * is working but restores it before returning.
+ * safe_create_leading_directories_const() doesn't modify path, even
+ * temporarily. Both these variants adjust the permissions of the
+ * created directories to honor core.sharedRepository, so they are best
+ * suited for files inside the git dir. For working tree files, use
+ * safe_create_leading_directories_no_share() instead, as it ignores
+ * the core.sharedRepository setting.
+ */
+enum scld_error {
+	SCLD_OK = 0,
+	SCLD_FAILED = -1,
+	SCLD_PERMS = -2,
+	SCLD_EXISTS = -3,
+	SCLD_VANISHED = -4
+};
+enum scld_error safe_create_leading_directories(char *path);
+enum scld_error safe_create_leading_directories_const(const char *path);
+enum scld_error safe_create_leading_directories_no_share(char *path);
+
+int mkdir_in_gitdir(const char *path);
+
+int git_open_cloexec(const char *name, int flags);
+#define git_open(name) git_open_cloexec(name, O_RDONLY)
+
+/**
+ * unpack_loose_header() initializes the data stream needed to unpack
+ * a loose object header.
+ *
+ * Returns:
+ *
+ * - ULHR_OK on success
+ * - ULHR_BAD on error
+ * - ULHR_TOO_LONG if the header was too long
+ *
+ * It will only parse up to MAX_HEADER_LEN bytes unless an optional
+ * "hdrbuf" argument is non-NULL. This is intended for use with
+ * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
+ * reporting. The full header will be extracted to "hdrbuf" for use
+ * with parse_loose_header(), ULHR_TOO_LONG will still be returned
+ * from this function to indicate that the header was too long.
+ */
+enum unpack_loose_header_result {
+	ULHR_OK,
+	ULHR_BAD,
+	ULHR_TOO_LONG,
+};
+enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
+						    unsigned char *map,
+						    unsigned long mapsize,
+						    void *buffer,
+						    unsigned long bufsiz,
+						    struct strbuf *hdrbuf);
+
+/**
+ * parse_loose_header() parses the starting "<type> <len>\0" of an
+ * object. If it doesn't follow that format -1 is returned. To check
+ * the validity of the <type> populate the "typep" in the "struct
+ * object_info". It will be OBJ_BAD if the object type is unknown. The
+ * parsed <len> can be retrieved via "oi->sizep", and from there
+ * passed to unpack_loose_rest().
+ */
+struct object_info;
+int parse_loose_header(const char *hdr, struct object_info *oi);
+
+/**
+ * With in-core object data in "buf", rehash it to make sure the
+ * object name actually matches "oid" to detect object corruption.
+ *
+ * A negative value indicates an error, usually that the OID is not
+ * what we expected, but it might also indicate another error.
+ */
+int check_object_signature(struct repository *r, const struct object_id *oid,
+			   void *map, unsigned long size,
+			   enum object_type type);
+
+/**
+ * A streaming version of check_object_signature().
+ * Try reading the object named with "oid" using
+ * the streaming interface and rehash it to do the same.
+ */
+int stream_object_signature(struct repository *r, const struct object_id *oid);
+
+int finalize_object_file(const char *tmpfile, const char *filename);
+
+/* Helper to check and "touch" a file */
+int check_and_freshen_file(const char *fn, int freshen);
+
+void *read_object_with_reference(struct repository *r,
+				 const struct object_id *oid,
+				 enum object_type required_type,
+				 unsigned long *size,
+				 struct object_id *oid_ret);
+
+#endif /* OBJECT_FILE_H */
diff --git a/object.c b/object.c
index 45c9721b8c8..6d4ef1524de 100644
--- a/object.c
+++ b/object.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "object.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index eba838d24ee..1371f17d22f 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -16,6 +16,7 @@
 #include "packfile.h"
 #include "repository.h"
 #include "trace2.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "list-objects-filter-options.h"
 #include "midx.h"
diff --git a/pack-check.c b/pack-check.c
index 6974e40a958..40d88bc5ebe 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -6,6 +6,7 @@
 #include "pack-revindex.h"
 #include "progress.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 struct idx_entry {
diff --git a/pack-mtimes.c b/pack-mtimes.c
index afed6321906..0096ace080b 100644
--- a/pack-mtimes.c
+++ b/pack-mtimes.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "gettext.h"
 #include "pack-mtimes.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
 
diff --git a/pack-revindex.c b/pack-revindex.c
index 9f9927d9471..22a1958a1fc 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "gettext.h"
 #include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
 #include "trace2.h"
diff --git a/packfile.c b/packfile.c
index 02afbe77137..9ae2278c22e 100644
--- a/packfile.c
+++ b/packfile.c
@@ -18,6 +18,7 @@
 #include "trace.h"
 #include "tree-walk.h"
 #include "tree.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "midx.h"
 #include "commit-graph.h"
diff --git a/read-cache.c b/read-cache.c
index cbbfc030da7..f225bf44cd0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -14,6 +14,7 @@
 #include "cache-tree.h"
 #include "refs.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "tree.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index e6a6971381e..d0581ee41ac 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -12,6 +12,7 @@
 #include "../dir-iterator.h"
 #include "../lockfile.h"
 #include "../object.h"
+#include "../object-file.h"
 #include "../dir.h"
 #include "../chdir-notify.h"
 #include "../setup.h"
diff --git a/rerere.c b/rerere.c
index 5516e336d01..093c0f6f993 100644
--- a/rerere.c
+++ b/rerere.c
@@ -13,6 +13,7 @@
 #include "ll-merge.h"
 #include "attr.h"
 #include "pathspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "strmap.h"
diff --git a/revision.c b/revision.c
index 7438b50e267..3d86e07abb8 100644
--- a/revision.c
+++ b/revision.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "tag.h"
 #include "blob.h"
diff --git a/sequencer.c b/sequencer.c
index 22b287be984..be10249fd0a 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "object.h"
diff --git a/server-info.c b/server-info.c
index 355b6e01a52..68098ddd1ad 100644
--- a/server-info.c
+++ b/server-info.c
@@ -9,6 +9,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "strbuf.h"
 #include "wrapper.h"
diff --git a/streaming.c b/streaming.c
index 27e014d8b23..b3415724ee4 100644
--- a/streaming.c
+++ b/streaming.c
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "streaming.h"
 #include "repository.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "packfile.h"
diff --git a/submodule.c b/submodule.c
index 4f403b9eeff..d09bc22d4b6 100644
--- a/submodule.c
+++ b/submodule.c
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "commit-reach.h"
diff --git a/tmp-objdir.c b/tmp-objdir.c
index 5adad1925d1..fff7ff42db7 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -4,6 +4,7 @@
 #include "chdir-notify.h"
 #include "dir.h"
 #include "environment.h"
+#include "object-file.h"
 #include "sigchain.h"
 #include "string-list.h"
 #include "strbuf.h"
diff --git a/tree-walk.c b/tree-walk.c
index 59add24c8e9..2993c48c2f3 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "trace2.h"
 #include "tree.h"
-- 
gitgitgadget


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

* [PATCH v2 13/24] treewide: remove cache.h inclusion due to object-file.h changes
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (11 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 12/24] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 14/24] object.h: move some inline functions and defines from cache.h Elijah Newren via GitGitGadget
                     ` (12 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 bulk-checkin.c  | 2 +-
 commit-graph.c  | 2 +-
 http-fetch.c    | 2 +-
 http-walker.c   | 2 +-
 http.h          | 1 -
 notes-merge.c   | 2 +-
 pack-bitmap.c   | 2 +-
 pack-check.c    | 2 +-
 pack-mtimes.c   | 2 +-
 pack-revindex.c | 2 +-
 streaming.c     | 2 +-
 tmp-objdir.c    | 2 +-
 12 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/bulk-checkin.c b/bulk-checkin.c
index af15f8a9af4..9192298db6a 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "bulk-checkin.h"
 #include "environment.h"
diff --git a/commit-graph.c b/commit-graph.c
index c20e73ceebf..0c4f2266445 100644
--- a/commit-graph.c
+++ b/commit-graph.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/http-fetch.c b/http-fetch.c
index c874d3402dd..fffda592670 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "exec-cmd.h"
 #include "gettext.h"
diff --git a/http-walker.c b/http-walker.c
index 4588e6a340a..3b41f5654b3 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "repository.h"
 #include "commit.h"
 #include "hex.h"
diff --git a/http.h b/http.h
index 783b2b09b8b..3a409bccd4e 100644
--- a/http.h
+++ b/http.h
@@ -3,7 +3,6 @@
 
 struct packed_git;
 
-#include "cache.h"
 #include "git-zlib.h"
 
 #include <curl/curl.h>
diff --git a/notes-merge.c b/notes-merge.c
index cc9538ac5c0..233e49e3195 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "advice.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 1371f17d22f..48fc2ec76de 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/pack-check.c b/pack-check.c
index 40d88bc5ebe..049f2f0bfc0 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/pack-mtimes.c b/pack-mtimes.c
index 0096ace080b..020a37f8fe3 100644
--- a/pack-mtimes.c
+++ b/pack-mtimes.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-mtimes.h"
 #include "object-file.h"
diff --git a/pack-revindex.c b/pack-revindex.c
index 22a1958a1fc..4d9bb41b4db 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-revindex.h"
 #include "object-file.h"
diff --git a/streaming.c b/streaming.c
index b3415724ee4..21e39585e89 100644
--- a/streaming.c
+++ b/streaming.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "convert.h"
 #include "environment.h"
 #include "streaming.h"
diff --git a/tmp-objdir.c b/tmp-objdir.c
index fff7ff42db7..c33a554f921 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tmp-objdir.h"
 #include "abspath.h"
 #include "chdir-notify.h"
-- 
gitgitgadget


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

* [PATCH v2 14/24] object.h: move some inline functions and defines from cache.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (12 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 13/24] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 15/24] treewide: remove cache.h inclusion due to object.h changes Elijah Newren via GitGitGadget
                     ` (11 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

The object_type() inline function is very tied to the enum object_type
declaration within object.h, and just seemed to make more sense to live
there.  That makes S_ISGITLINK and some other defines make sense to go
with it, as well as the create_ce_mode() and canon_mode() inline
functions.  Move all these inline functions and defines from cache.h to
object.h.

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

diff --git a/cache.h b/cache.h
index 89987cca22a..394e8d01254 100644
--- a/cache.h
+++ b/cache.h
@@ -28,18 +28,6 @@
 #define DTYPE(de)	DT_UNKNOWN
 #endif
 
-/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
-#define S_IFINVALID     0030000
-
-/*
- * A "directory link" is a link to another git directory.
- *
- * The value 0160000 is not normally a valid mode, and
- * also just happens to be S_IFDIR + S_IFLNK
- */
-#define S_IFGITLINK	0160000
-#define S_ISGITLINK(m)	(((m) & S_IFMT) == S_IFGITLINK)
-
 /*
  * Some mode bits are also used internally for computations.
  *
@@ -155,8 +143,6 @@ struct cache_entry {
 #error "CE_EXTENDED_FLAGS out of range"
 #endif
 
-#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
-
 /* Forward structure decls */
 struct pathspec;
 struct child_process;
@@ -197,17 +183,6 @@ static inline unsigned create_ce_flags(unsigned stage)
 #define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
 #define ce_intent_to_add(ce) ((ce)->ce_flags & CE_INTENT_TO_ADD)
 
-#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
-static inline unsigned int create_ce_mode(unsigned int mode)
-{
-	if (S_ISLNK(mode))
-		return S_IFLNK;
-	if (S_ISSPARSEDIR(mode))
-		return S_IFDIR;
-	if (S_ISDIR(mode) || S_ISGITLINK(mode))
-		return S_IFGITLINK;
-	return S_IFREG | ce_permissions(mode);
-}
 static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,
 					     unsigned int mode)
 {
@@ -234,16 +209,6 @@ static inline int ce_to_dtype(const struct cache_entry *ce)
 	else
 		return DT_UNKNOWN;
 }
-static inline unsigned int canon_mode(unsigned int mode)
-{
-	if (S_ISREG(mode))
-		return S_IFREG | ce_permissions(mode);
-	if (S_ISLNK(mode))
-		return S_IFLNK;
-	if (S_ISDIR(mode))
-		return S_IFDIR;
-	return S_IFGITLINK;
-}
 
 static inline int ce_path_match(struct index_state *istate,
 				const struct cache_entry *ce,
@@ -414,13 +379,6 @@ void prefetch_cache_entries(const struct index_state *istate,
 extern struct index_state the_index;
 #endif
 
-static inline enum object_type object_type(unsigned int mode)
-{
-	return S_ISDIR(mode) ? OBJ_TREE :
-		S_ISGITLINK(mode) ? OBJ_COMMIT :
-		OBJ_BLOB;
-}
-
 #define INIT_DB_QUIET 0x0001
 #define INIT_DB_EXIST_OK 0x0002
 
diff --git a/object.h b/object.h
index fc45b158da0..96e52e24fb1 100644
--- a/object.h
+++ b/object.h
@@ -101,6 +101,50 @@ enum object_type {
 	OBJ_MAX
 };
 
+/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
+#define S_IFINVALID     0030000
+
+/*
+ * A "directory link" is a link to another git directory.
+ *
+ * The value 0160000 is not normally a valid mode, and
+ * also just happens to be S_IFDIR + S_IFLNK
+ */
+#define S_IFGITLINK	0160000
+#define S_ISGITLINK(m)	(((m) & S_IFMT) == S_IFGITLINK)
+
+#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
+
+static inline enum object_type object_type(unsigned int mode)
+{
+	return S_ISDIR(mode) ? OBJ_TREE :
+		S_ISGITLINK(mode) ? OBJ_COMMIT :
+		OBJ_BLOB;
+}
+
+#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
+static inline unsigned int create_ce_mode(unsigned int mode)
+{
+	if (S_ISLNK(mode))
+		return S_IFLNK;
+	if (S_ISSPARSEDIR(mode))
+		return S_IFDIR;
+	if (S_ISDIR(mode) || S_ISGITLINK(mode))
+		return S_IFGITLINK;
+	return S_IFREG | ce_permissions(mode);
+}
+
+static inline unsigned int canon_mode(unsigned int mode)
+{
+	if (S_ISREG(mode))
+		return S_IFREG | ce_permissions(mode);
+	if (S_ISLNK(mode))
+		return S_IFLNK;
+	if (S_ISDIR(mode))
+		return S_IFDIR;
+	return S_IFGITLINK;
+}
+
 /*
  * The object type is stored in 3 bits.
  */
-- 
gitgitgadget


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

* [PATCH v2 15/24] treewide: remove cache.h inclusion due to object.h changes
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (13 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 14/24] object.h: move some inline functions and defines from cache.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 16/24] editor: move editor-related functions and declarations into common file Elijah Newren via GitGitGadget
                     ` (10 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 bisect.c              | 2 +-
 bundle.c              | 2 +-
 commit.c              | 2 +-
 delta-islands.c       | 2 +-
 diff-no-index.c       | 2 +-
 fsck.c                | 2 +-
 http-push.c           | 2 +-
 list-objects-filter.c | 2 +-
 list-objects.c        | 2 +-
 log-tree.c            | 2 +-
 pack-bitmap-write.c   | 2 +-
 parse-options-cb.c    | 1 -
 rebase-interactive.c  | 2 +-
 submodule-config.c    | 2 +-
 tag.c                 | 2 +-
 transport.c           | 2 +-
 walker.c              | 2 +-
 17 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/bisect.c b/bisect.c
index e708e8b6aa1..8d5f8e58851 100644
--- a/bisect.c
+++ b/bisect.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/bundle.c b/bundle.c
index 6471489975a..a5505368de5 100644
--- a/bundle.c
+++ b/bundle.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "lockfile.h"
 #include "bundle.h"
 #include "environment.h"
diff --git a/commit.c b/commit.c
index bad31c423a4..878b4473e4c 100644
--- a/commit.c
+++ b/commit.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
 #include "commit-graph.h"
diff --git a/delta-islands.c b/delta-islands.c
index 40f2ccfb550..c824a5f6a42 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "attr.h"
 #include "object.h"
diff --git a/diff-no-index.c b/diff-no-index.c
index 934a24bee58..4296940f907 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2008 by Junio C Hamano
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "color.h"
 #include "commit.h"
diff --git a/fsck.c b/fsck.c
index 8ef1b022346..adbe8bf59e7 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/http-push.c b/http-push.c
index a8af6c0f690..637a4e91f7a 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 8b2a45e507d..5d270ce5987 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "gettext.h"
diff --git a/list-objects.c b/list-objects.c
index df18d103063..eecca721ac0 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/log-tree.c b/log-tree.c
index f0e885635e0..b5cf3d8439c 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "commit-reach.h"
 #include "config.h"
 #include "diff.h"
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 7f5f489beb0..faf67c94d37 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.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/parse-options-cb.c b/parse-options-cb.c
index b4df4bcebed..26a4c7d08a9 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -1,7 +1,6 @@
 #include "git-compat-util.h"
 #include "parse-options.h"
 #include "branch.h"
-#include "cache.h"
 #include "commit.h"
 #include "color.h"
 #include "environment.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 48467a7bc4a..6ff12d7be2d 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "commit.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/submodule-config.c b/submodule-config.c
index 252b90aa439..7fc0812b644 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/tag.c b/tag.c
index b9fc2fc9929..96dbd5b2d55 100644
--- a/tag.c
+++ b/tag.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "tag.h"
 #include "object-name.h"
diff --git a/transport.c b/transport.c
index 7374cfd1fa9..8d3ad8022a4 100644
--- a/transport.c
+++ b/transport.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/walker.c b/walker.c
index cfbd257fdba..24ff7dfdc28 100644
--- a/walker.c
+++ b/walker.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "walker.h"
-- 
gitgitgadget


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

* [PATCH v2 16/24] editor: move editor-related functions and declarations into common file
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (14 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 15/24] treewide: remove cache.h inclusion due to object.h changes Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 17/24] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren via GitGitGadget
                     ` (9 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

cache.h and strbuf.[ch] had editor-related functions.  Move these into
editor.[ch].

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 add-patch.c          |  1 +
 builtin/add.c        |  1 +
 builtin/am.c         |  1 +
 builtin/branch.c     |  1 +
 builtin/bugreport.c  |  1 +
 builtin/commit.c     |  1 +
 builtin/config.c     |  1 +
 builtin/merge.c      |  1 +
 builtin/notes.c      |  1 +
 builtin/replace.c    |  1 +
 builtin/tag.c        |  1 +
 builtin/var.c        |  1 +
 cache.h              |  3 ---
 color.c              |  1 +
 editor.c             | 30 ++++++++++++++++++++++++++++++
 editor.h             | 34 ++++++++++++++++++++++++++++++++++
 pager.c              |  1 +
 rebase-interactive.c |  1 +
 sideband.c           |  1 +
 strbuf.c             | 28 ----------------------------
 strbuf.h             | 24 ------------------------
 21 files changed, 80 insertions(+), 55 deletions(-)
 create mode 100644 editor.h

diff --git a/add-patch.c b/add-patch.c
index b01ba8fa81d..8d770d203ff 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -2,6 +2,7 @@
 #include "add-interactive.h"
 #include "advice.h"
 #include "alloc.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "object-name.h"
diff --git a/builtin/add.c b/builtin/add.c
index d3c51e28142..76cc026a68a 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "builtin.h"
 #include "lockfile.h"
+#include "editor.h"
 #include "dir.h"
 #include "gettext.h"
 #include "pathspec.h"
diff --git a/builtin/am.c b/builtin/am.c
index 0d7ee28bddc..f7a065e5290 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -9,6 +9,7 @@
 #include "advice.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index 7c1c872708f..1fb11d55e65 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -8,6 +8,7 @@
 #include "cache.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "environment.h"
 #include "refs.h"
 #include "commit.h"
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index 03fb0536911..daf6c236577 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "abspath.h"
+#include "editor.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "strbuf.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 682f47c8d5a..e67c4be2211 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -13,6 +13,7 @@
 #include "cache-tree.h"
 #include "color.h"
 #include "dir.h"
+#include "editor.h"
 #include "environment.h"
 #include "builtin.h"
 #include "diff.h"
diff --git a/builtin/config.c b/builtin/config.c
index fe79fb60c43..9401f1e5e3b 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -3,6 +3,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "ident.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 693f185d4d3..8da3e46abb0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -12,6 +12,7 @@
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 896140b9055..d5788352b6e 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index f4b3a8efb23..981f1894436 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -11,6 +11,7 @@
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 88a25902309..7d189a4a5d4 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -10,6 +10,7 @@
 #include "advice.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/var.c b/builtin/var.c
index d9943be9afd..90616cf65a2 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -5,6 +5,7 @@
  */
 #include "builtin.h"
 #include "config.h"
+#include "editor.h"
 #include "ident.h"
 #include "refs.h"
 
diff --git a/cache.h b/cache.h
index 394e8d01254..97ddf4094a3 100644
--- a/cache.h
+++ b/cache.h
@@ -621,10 +621,7 @@ 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);
 
-const char *git_editor(void);
-const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
-int is_terminal_dumb(void);
 
 struct cache_def {
 	struct strbuf path;
diff --git a/color.c b/color.c
index 672dcbb73a6..a8e8d5202ab 100644
--- a/color.c
+++ b/color.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "gettext.h"
 #include "hex.h"
 
diff --git a/editor.c b/editor.c
index 3bea3ef72f7..12025dfec37 100644
--- a/editor.c
+++ b/editor.c
@@ -2,12 +2,14 @@
 #include "abspath.h"
 #include "advice.h"
 #include "config.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "run-command.h"
 #include "sigchain.h"
+#include "wrapper.h"
 
 #ifndef DEFAULT_EDITOR
 #define DEFAULT_EDITOR "vi"
@@ -130,3 +132,31 @@ int launch_sequence_editor(const char *path, struct strbuf *buffer,
 {
 	return launch_specified_editor(git_sequence_editor(), path, buffer, env);
 }
+
+int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
+			      const char *const *env)
+{
+	char *path2 = NULL;
+	int fd, res = 0;
+
+	if (!is_absolute_path(path))
+		path = path2 = xstrdup(git_path("%s", path));
+
+	fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+	if (fd < 0)
+		res = error_errno(_("could not open '%s' for writing"), path);
+	else if (write_in_full(fd, buffer->buf, buffer->len) < 0) {
+		res = error_errno(_("could not write to '%s'"), path);
+		close(fd);
+	} else if (close(fd) < 0)
+		res = error_errno(_("could not close '%s'"), path);
+	else {
+		strbuf_reset(buffer);
+		if (launch_editor(path, buffer, env) < 0)
+			res = error_errno(_("could not edit '%s'"), path);
+		unlink(path);
+	}
+
+	free(path2);
+	return res;
+}
diff --git a/editor.h b/editor.h
new file mode 100644
index 00000000000..8016bb5e00b
--- /dev/null
+++ b/editor.h
@@ -0,0 +1,34 @@
+#ifndef EDITOR_H
+#define EDITOR_H
+
+struct strbuf;
+
+const char *git_editor(void);
+const char *git_sequence_editor(void);
+int is_terminal_dumb(void);
+
+/**
+ * Launch the user preferred editor to edit a file and fill the buffer
+ * with the file's contents upon the user completing their editing. The
+ * third argument can be used to set the environment which the editor is
+ * run in. If the buffer is NULL the editor is launched as usual but the
+ * file's contents are not read into the buffer upon completion.
+ */
+int launch_editor(const char *path, struct strbuf *buffer,
+		  const char *const *env);
+
+int launch_sequence_editor(const char *path, struct strbuf *buffer,
+			   const char *const *env);
+
+/*
+ * In contrast to `launch_editor()`, this function writes out the contents
+ * of the specified file first, then clears the `buffer`, then launches
+ * the editor and reads back in the file contents into the `buffer`.
+ * Finally, it deletes the temporary file.
+ *
+ * If `path` is relative, it refers to a file in the `.git` directory.
+ */
+int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
+			      const char *const *env);
+
+#endif
diff --git a/pager.c b/pager.c
index b66bbff2785..6367e8ef867 100644
--- a/pager.c
+++ b/pager.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "config.h"
+#include "editor.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "alias.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 6ff12d7be2d..789f4073617 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "commit.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "sequencer.h"
diff --git a/sideband.c b/sideband.c
index 0af582858bf..25e2a185716 100644
--- a/sideband.c
+++ b/sideband.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "color.h"
 #include "config.h"
+#include "editor.h"
 #include "gettext.h"
 #include "sideband.h"
 #include "help.h"
diff --git a/strbuf.c b/strbuf.c
index b2e3735ba8a..729378ec824 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1180,34 +1180,6 @@ int strbuf_normalize_path(struct strbuf *src)
 	return 0;
 }
 
-int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
-			      const char *const *env)
-{
-	char *path2 = NULL;
-	int fd, res = 0;
-
-	if (!is_absolute_path(path))
-		path = path2 = xstrdup(git_path("%s", path));
-
-	fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
-	if (fd < 0)
-		res = error_errno(_("could not open '%s' for writing"), path);
-	else if (write_in_full(fd, buffer->buf, buffer->len) < 0) {
-		res = error_errno(_("could not write to '%s'"), path);
-		close(fd);
-	} else if (close(fd) < 0)
-		res = error_errno(_("could not close '%s'"), path);
-	else {
-		strbuf_reset(buffer);
-		if (launch_editor(path, buffer, env) < 0)
-			res = error_errno(_("could not edit '%s'"), path);
-		unlink(path);
-	}
-
-	free(path2);
-	return res;
-}
-
 void strbuf_strip_file_from_path(struct strbuf *sb)
 {
 	char *path_sep = find_last_dir_sep(sb->buf);
diff --git a/strbuf.h b/strbuf.h
index b980f9edc6d..3dfeadb44c2 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -640,30 +640,6 @@ void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
 void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
 			      int abbrev_len);
 
-/**
- * Launch the user preferred editor to edit a file and fill the buffer
- * with the file's contents upon the user completing their editing. The
- * third argument can be used to set the environment which the editor is
- * run in. If the buffer is NULL the editor is launched as usual but the
- * file's contents are not read into the buffer upon completion.
- */
-int launch_editor(const char *path, struct strbuf *buffer,
-		  const char *const *env);
-
-int launch_sequence_editor(const char *path, struct strbuf *buffer,
-			   const char *const *env);
-
-/*
- * In contrast to `launch_editor()`, this function writes out the contents
- * of the specified file first, then clears the `buffer`, then launches
- * the editor and reads back in the file contents into the `buffer`.
- * Finally, it deletes the temporary file.
- *
- * If `path` is relative, it refers to a file in the `.git` directory.
- */
-int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
-			      const char *const *env);
-
 /*
  * Remove the filename from the provided path string. If the path
  * contains a trailing separator, then the path is considered a directory
-- 
gitgitgadget


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

* [PATCH v2 17/24] treewide: remove cache.h inclusion due to editor.h changes
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (15 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 16/24] editor: move editor-related functions and declarations into common file Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 18/24] pager.h: move declarations for pager.c functions from cache.h Elijah Newren via GitGitGadget
                     ` (8 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

This actually only affects sideband.c, but helps towards removing
cache.h inclusion in conjunction with some of the upcoming patches
that will be applied.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 sideband.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sideband.c b/sideband.c
index 25e2a185716..6cbfd391c47 100644
--- a/sideband.c
+++ b/sideband.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "color.h"
 #include "config.h"
 #include "editor.h"
-- 
gitgitgadget


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

* [PATCH v2 18/24] pager.h: move declarations for pager.c functions from cache.h
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (16 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 17/24] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 19/24] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren via GitGitGadget
                     ` (7 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/am.c       |  1 +
 builtin/blame.c    |  1 +
 builtin/fetch.c    |  1 +
 builtin/grep.c     |  1 +
 builtin/help.c     |  1 +
 builtin/log.c      |  1 +
 builtin/name-rev.c |  1 +
 builtin/var.c      |  1 +
 cache.h            | 13 -------------
 color.c            |  1 +
 column.c           |  1 +
 config.c           |  1 +
 date.c             |  1 +
 diff.c             |  1 +
 editor.c           |  1 +
 environment.c      |  1 -
 git.c              |  1 +
 pager.c            |  3 +++
 pager.h            | 17 +++++++++++++++++
 pretty.c           |  1 +
 progress.c         |  1 +
 range-diff.c       |  1 +
 sequencer.c        |  1 +
 23 files changed, 39 insertions(+), 14 deletions(-)
 create mode 100644 pager.h

diff --git a/builtin/am.c b/builtin/am.c
index f7a065e5290..5c83f2e003f 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -40,6 +40,7 @@
 #include "apply.h"
 #include "string-list.h"
 #include "packfile.h"
+#include "pager.h"
 #include "repository.h"
 #include "pretty.h"
 #include "wrapper.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index a628388c2ce..2df6039a6e0 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -30,6 +30,7 @@
 #include "progress.h"
 #include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "blame.h"
 #include "refs.h"
 #include "setup.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 8a8ab6799e8..61e8ac113b1 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -28,6 +28,7 @@
 #include "strvec.h"
 #include "utf8.h"
 #include "packfile.h"
+#include "pager.h"
 #include "list-objects-filter-options.h"
 #include "commit-reach.h"
 #include "branch.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index fb11be6075a..b86c754defb 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -30,6 +30,7 @@
 #include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
+#include "pager.h"
 #include "write-or-die.h"
 
 static const char *grep_prefix;
diff --git a/builtin/help.c b/builtin/help.c
index 87333a02ec4..128aa83099a 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -6,6 +6,7 @@
 #include "builtin.h"
 #include "exec-cmd.h"
 #include "gettext.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "run-command.h"
 #include "config-list.h"
diff --git a/builtin/log.c b/builtin/log.c
index b6246c7042c..95de51921f8 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -15,6 +15,7 @@
 #include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "color.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 41fd56b9ba9..593f0506a10 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -9,6 +9,7 @@
 #include "tag.h"
 #include "refs.h"
 #include "object-name.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "hash-lookup.h"
diff --git a/builtin/var.c b/builtin/var.c
index 90616cf65a2..aa8150fa92e 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "editor.h"
 #include "ident.h"
+#include "pager.h"
 #include "refs.h"
 
 static const char var_usage[] = "git var (-l | <variable>)";
diff --git a/cache.h b/cache.h
index 97ddf4094a3..21fd520b045 100644
--- a/cache.h
+++ b/cache.h
@@ -145,7 +145,6 @@ struct cache_entry {
 
 /* Forward structure decls */
 struct pathspec;
-struct child_process;
 struct tree;
 
 /*
@@ -621,8 +620,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);
 
-const char *git_pager(int stdout_is_tty);
-
 struct cache_def {
 	struct strbuf path;
 	int flags;
@@ -671,16 +668,6 @@ 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);
 
-/* pager.c */
-void setup_pager(void);
-int pager_in_use(void);
-extern int pager_use_color;
-int term_columns(void);
-void term_clear_line(void);
-int decimal_width(uintmax_t);
-int check_pager_config(const char *cmd);
-void prepare_pager_args(struct child_process *, const char *pager);
-
 /* 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/color.c b/color.c
index a8e8d5202ab..6031998d3ea 100644
--- a/color.c
+++ b/color.c
@@ -4,6 +4,7 @@
 #include "editor.h"
 #include "gettext.h"
 #include "hex.h"
+#include "pager.h"
 
 static int git_use_color_default = GIT_COLOR_AUTO;
 int color_stdout_is_tty = -1;
diff --git a/column.c b/column.c
index fbf88639aae..c89c90328a6 100644
--- a/column.c
+++ b/column.c
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "column.h"
 #include "string-list.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "run-command.h"
 #include "utf8.h"
diff --git a/config.c b/config.c
index aac439530e9..11e3295419b 100644
--- a/config.c
+++ b/config.c
@@ -25,6 +25,7 @@
 #include "string-list.h"
 #include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "utf8.h"
 #include "dir.h"
 #include "color.h"
diff --git a/date.c b/date.c
index 1fb2cd1b538..e944c8905af 100644
--- a/date.c
+++ b/date.c
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "date.h"
 #include "gettext.h"
+#include "pager.h"
 
 /*
  * This is like mktime, but without normalization of tm_wday and tm_yday.
diff --git a/diff.c b/diff.c
index f8e0d3b5c59..fa86d023196 100644
--- a/diff.c
+++ b/diff.c
@@ -31,6 +31,7 @@
 #include "graph.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "help.h"
 #include "promisor-remote.h"
diff --git a/editor.c b/editor.c
index 12025dfec37..7c796385493 100644
--- a/editor.c
+++ b/editor.c
@@ -5,6 +5,7 @@
 #include "editor.h"
 #include "environment.h"
 #include "gettext.h"
+#include "pager.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "run-command.h"
diff --git a/environment.c b/environment.c
index 39efa49fe31..8a96997539a 100644
--- a/environment.c
+++ b/environment.c
@@ -59,7 +59,6 @@ size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 size_t delta_base_cache_limit = 96 * 1024 * 1024;
 unsigned long big_file_threshold = 512 * 1024 * 1024;
-int pager_use_color = 1;
 const char *editor_program;
 const char *askpass_program;
 const char *excludes_file;
diff --git a/git.c b/git.c
index d2bb86e0d32..0241d2cf913 100644
--- a/git.c
+++ b/git.c
@@ -4,6 +4,7 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "help.h"
+#include "pager.h"
 #include "run-command.h"
 #include "alias.h"
 #include "replace-object.h"
diff --git a/pager.c b/pager.c
index 6367e8ef867..be78c706644 100644
--- a/pager.c
+++ b/pager.c
@@ -1,10 +1,13 @@
 #include "cache.h"
 #include "config.h"
 #include "editor.h"
+#include "pager.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "alias.h"
 
+int pager_use_color = 1;
+
 #ifndef DEFAULT_PAGER
 #define DEFAULT_PAGER "less"
 #endif
diff --git a/pager.h b/pager.h
new file mode 100644
index 00000000000..b77433026dc
--- /dev/null
+++ b/pager.h
@@ -0,0 +1,17 @@
+#ifndef PAGER_H
+#define PAGER_H
+
+struct child_process;
+
+const char *git_pager(int stdout_is_tty);
+void setup_pager(void);
+int pager_in_use(void);
+int term_columns(void);
+void term_clear_line(void);
+int decimal_width(uintmax_t);
+int check_pager_config(const char *cmd);
+void prepare_pager_args(struct child_process *, const char *pager);
+
+extern int pager_use_color;
+
+#endif /* PAGER_H */
diff --git a/pretty.c b/pretty.c
index 76fc4f61e40..c4671603b56 100644
--- a/pretty.c
+++ b/pretty.c
@@ -7,6 +7,7 @@
 #include "hex.h"
 #include "utf8.h"
 #include "diff.h"
+#include "pager.h"
 #include "revision.h"
 #include "string-list.h"
 #include "mailmap.h"
diff --git a/progress.c b/progress.c
index c5c8514737a..96a8e36a52f 100644
--- a/progress.c
+++ b/progress.c
@@ -10,6 +10,7 @@
 
 #define GIT_TEST_PROGRESS_ONLY
 #include "cache.h"
+#include "pager.h"
 #include "progress.h"
 #include "strbuf.h"
 #include "trace.h"
diff --git a/range-diff.c b/range-diff.c
index a2994331a14..a1e0cffb9f6 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -11,6 +11,7 @@
 #include "linear-assignment.h"
 #include "diffcore.h"
 #include "commit.h"
+#include "pager.h"
 #include "pretty.h"
 #include "userdiff.h"
 #include "apply.h"
diff --git a/sequencer.c b/sequencer.c
index be10249fd0a..fcca3b81447 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -12,6 +12,7 @@
 #include "object-name.h"
 #include "object-store.h"
 #include "object.h"
+#include "pager.h"
 #include "commit.h"
 #include "sequencer.h"
 #include "tag.h"
-- 
gitgitgadget


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

* [PATCH v2 19/24] treewide: remove cache.h inclusion due to pager.h changes
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (17 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 18/24] pager.h: move declarations for pager.c functions from cache.h Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 20/24] cache.h: remove unnecessary includes Elijah Newren via GitGitGadget
                     ` (6 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 column.c   | 2 +-
 editor.c   | 2 +-
 pager.c    | 2 +-
 pretty.c   | 2 +-
 progress.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/column.c b/column.c
index c89c90328a6..ff2f0abf399 100644
--- a/column.c
+++ b/column.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "column.h"
 #include "string-list.h"
diff --git a/editor.c b/editor.c
index 7c796385493..b34e10606d2 100644
--- a/editor.c
+++ b/editor.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
 #include "config.h"
diff --git a/pager.c b/pager.c
index be78c706644..63055d0873f 100644
--- a/pager.c
+++ b/pager.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "editor.h"
 #include "pager.h"
diff --git a/pretty.c b/pretty.c
index c4671603b56..0bb938021ba 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "commit.h"
diff --git a/progress.c b/progress.c
index 96a8e36a52f..72d5e0c73c1 100644
--- a/progress.c
+++ b/progress.c
@@ -9,7 +9,7 @@
  */
 
 #define GIT_TEST_PROGRESS_ONLY
-#include "cache.h"
+#include "git-compat-util.h"
 #include "pager.h"
 #include "progress.h"
 #include "strbuf.h"
-- 
gitgitgadget


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

* [PATCH v2 20/24] cache.h: remove unnecessary includes
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (18 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 19/24] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 21/24] strbuf: move forward declarations to beginning of file Elijah Newren via GitGitGadget
                     ` (5 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

cache.h did not need any of these headers, and nothing that depended
upon cache.h needed them either.  Simply expunge these includes.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/cache.h b/cache.h
index 21fd520b045..16b5fc9fa31 100644
--- a/cache.h
+++ b/cache.h
@@ -4,14 +4,10 @@
 #include "git-compat-util.h"
 #include "strbuf.h"
 #include "hashmap.h"
-#include "list.h"
 #include "gettext.h"
 #include "string-list.h"
-#include "hash.h"
-#include "path.h"
 #include "pathspec.h"
 #include "object.h"
-#include "repository.h"
 #include "statinfo.h"
 
 #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
-- 
gitgitgadget


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

* [PATCH v2 21/24] strbuf: move forward declarations to beginning of file
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (19 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 20/24] cache.h: remove unnecessary includes Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-05 17:28     ` Calvin Wan
  2023-04-04  1:22   ` [PATCH v2 22/24] treewide: remove double forward declaration of read_in_full Elijah Newren via GitGitGadget
                     ` (4 subsequent siblings)
  25 siblings, 1 reply; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 strbuf.h | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/strbuf.h b/strbuf.h
index 3dfeadb44c2..547696fb233 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -1,6 +1,8 @@
 #ifndef STRBUF_H
 #define STRBUF_H
 
+struct object_id;
+struct repository;
 struct string_list;
 
 /**
@@ -72,12 +74,6 @@ struct strbuf {
 extern char strbuf_slopbuf[];
 #define STRBUF_INIT  { .buf = strbuf_slopbuf }
 
-/*
- * Predeclare this here, since cache.h includes this file before it defines the
- * struct.
- */
-struct object_id;
-
 /**
  * Life Cycle Functions
  * --------------------
@@ -634,7 +630,6 @@ void strbuf_list_free(struct strbuf **list);
  * Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
  * the strbuf `sb`.
  */
-struct repository;
 void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
 				   const struct object_id *oid, int abbrev_len);
 void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
-- 
gitgitgadget


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

* [PATCH v2 22/24] treewide: remove double forward declaration of read_in_full
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (20 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 21/24] strbuf: move forward declarations to beginning of file Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 23/24] treewide: reduce includes of cache.h in other headers Elijah Newren via GitGitGadget
                     ` (3 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

cache.h's nature of a dumping ground of includes prevented it from
being included in some compat/ files, forcing us into a workaround
of having a double forward declaration of the read_in_full() function
(see commit 14086b0a13 ("compat/pread.c: Add a forward declaration to
fix a warning", 2007-11-17)).  Now that we have moved functions like
read_in_full() from cache.h to wrapper.h, and wrapper.h isn't littered
with unrelated and scary #defines, get rid of the extra forward
declaration and just have compat/pread.c include wrapper.h.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 builtin/clone.c       | 1 +
 bulk-checkin.c        | 1 +
 combine-diff.c        | 1 +
 compat/pread.c        | 1 +
 git-compat-util.h     | 6 ------
 grep.c                | 1 +
 pack-write.c          | 1 +
 path.c                | 1 +
 refs/packed-backend.c | 1 +
 send-pack.c           | 1 +
 setup.c               | 1 +
 upload-pack.c         | 1 +
 12 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index c7fdffb484c..4ed0a1d5aad 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -42,6 +42,7 @@
 #include "hook.h"
 #include "bundle.h"
 #include "bundle-uri.h"
+#include "wrapper.h"
 
 /*
  * Overall FIXMEs:
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 9192298db6a..d843279715c 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -17,6 +17,7 @@
 #include "packfile.h"
 #include "object-file.h"
 #include "object-store.h"
+#include "wrapper.h"
 
 static int odb_transaction_nesting;
 
diff --git a/combine-diff.c b/combine-diff.c
index cd5f39f22f4..f7e9fb57473 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -16,6 +16,7 @@
 #include "userdiff.h"
 #include "oid-array.h"
 #include "revision.h"
+#include "wrapper.h"
 
 static int compare_paths(const struct combine_diff_path *one,
 			  const struct diff_filespec *two)
diff --git a/compat/pread.c b/compat/pread.c
index 978cac4ec91..484e6d4c716 100644
--- a/compat/pread.c
+++ b/compat/pread.c
@@ -1,4 +1,5 @@
 #include "../git-compat-util.h"
+#include "../wrapper.h"
 
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
 {
diff --git a/git-compat-util.h b/git-compat-util.h
index 1e6592624d0..4fb771f42a5 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -859,12 +859,6 @@ int git_lstat(const char *, struct stat *);
 #define pread git_pread
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
 #endif
-/*
- * Forward decl that will remind us if its twin in cache.h changes.
- * This function is used in compat/pread.c.  But we can't include
- * cache.h there.
- */
-ssize_t read_in_full(int fd, void *buf, size_t count);
 
 #ifdef NO_SETENV
 #define setenv gitsetenv
diff --git a/grep.c b/grep.c
index bb8796a829f..d144b374894 100644
--- a/grep.c
+++ b/grep.c
@@ -11,6 +11,7 @@
 #include "commit.h"
 #include "quote.h"
 #include "help.h"
+#include "wrapper.h"
 
 static int grep_source_load(struct grep_source *gs);
 static int grep_source_is_binary(struct grep_source *gs,
diff --git a/pack-write.c b/pack-write.c
index d9b460fab4c..9c37121be31 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -10,6 +10,7 @@
 #include "oidmap.h"
 #include "pack-objects.h"
 #include "pack-revindex.h"
+#include "wrapper.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
 {
diff --git a/path.c b/path.c
index dff215ac693..7c1cd8182a8 100644
--- a/path.c
+++ b/path.c
@@ -18,6 +18,7 @@
 #include "object-store.h"
 #include "lockfile.h"
 #include "exec-cmd.h"
+#include "wrapper.h"
 
 static int get_st_mode_bits(const char *path, int *mode)
 {
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 1eba1015dd5..2333ed5a1f7 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 "../wrapper.h"
 #include "../write-or-die.h"
 
 enum mmap_strategy {
diff --git a/send-pack.c b/send-pack.c
index 72ebb7b61ae..351037b07bc 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -14,6 +14,7 @@
 #include "quote.h"
 #include "transport.h"
 #include "version.h"
+#include "wrapper.h"
 #include "oid-array.h"
 #include "gpg-interface.h"
 #include "shallow.h"
diff --git a/setup.c b/setup.c
index a546da755f1..59abc16ba6d 100644
--- a/setup.c
+++ b/setup.c
@@ -12,6 +12,7 @@
 #include "promisor-remote.h"
 #include "quote.h"
 #include "trace2.h"
+#include "wrapper.h"
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
diff --git a/upload-pack.c b/upload-pack.c
index 0305fb2fbdc..e16dee783dd 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -32,6 +32,7 @@
 #include "commit-graph.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "wrapper.h"
 #include "write-or-die.h"
 
 /* Remember to update object flag allocation in object.h */
-- 
gitgitgadget


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

* [PATCH v2 23/24] treewide: reduce includes of cache.h in other headers
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (21 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 22/24] treewide: remove double forward declaration of read_in_full Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-04  1:22   ` [PATCH v2 24/24] mailmap, quote: move declarations of global vars to correct unit Elijah Newren via GitGitGadget
                     ` (2 subsequent siblings)
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

We had a handful of headers including cache.h that didn't need to
anymore.  Drop those includes and replace them with includes of
smaller files, or forward declarations.  However, note that two .c
files now need to directly include cache.h, though they should have
been including it all along given they are directly using structs
defined in it.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 archive.h        | 2 +-
 chdir-notify.c   | 3 ++-
 quote.c          | 3 ++-
 refs/ref-cache.h | 2 +-
 rerere.c         | 2 +-
 resolve-undo.h   | 7 ++++++-
 revision.c       | 2 +-
 split-index.h    | 2 +-
 8 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/archive.h b/archive.h
index f96839ef383..3a4bdfbd078 100644
--- a/archive.h
+++ b/archive.h
@@ -1,9 +1,9 @@
 #ifndef ARCHIVE_H
 #define ARCHIVE_H
 
-#include "cache.h"
 #include "object-name.h"
 #include "pathspec.h"
+#include "string-list.h"
 
 struct repository;
 struct pretty_print_context;
diff --git a/chdir-notify.c b/chdir-notify.c
index 8e38cd6f3ae..0d7bc046074 100644
--- a/chdir-notify.c
+++ b/chdir-notify.c
@@ -1,7 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "chdir-notify.h"
 #include "list.h"
+#include "path.h"
 #include "strbuf.h"
 #include "trace.h"
 
diff --git a/quote.c b/quote.c
index 7ccb5a06cd1..43c739671ed 100644
--- a/quote.c
+++ b/quote.c
@@ -1,5 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
+#include "path.h"
 #include "quote.h"
 #include "strbuf.h"
 #include "strvec.h"
diff --git a/refs/ref-cache.h b/refs/ref-cache.h
index 850d9d3744e..cf4ad9070b9 100644
--- a/refs/ref-cache.h
+++ b/refs/ref-cache.h
@@ -1,7 +1,7 @@
 #ifndef REFS_REF_CACHE_H
 #define REFS_REF_CACHE_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct ref_dir;
 struct ref_store;
diff --git a/rerere.c b/rerere.c
index 093c0f6f993..7abc94bf444 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/resolve-undo.h b/resolve-undo.h
index 2b3f0f901e6..d1ea9727712 100644
--- a/resolve-undo.h
+++ b/resolve-undo.h
@@ -1,7 +1,12 @@
 #ifndef RESOLVE_UNDO_H
 #define RESOLVE_UNDO_H
 
-#include "cache.h"
+struct cache_entry;
+struct index_state;
+struct pathspec;
+struct string_list;
+
+#include "hash.h"
 
 struct resolve_undo_info {
 	unsigned int mode[3];
diff --git a/revision.c b/revision.c
index 3d86e07abb8..43f88eaf56c 100644
--- a/revision.c
+++ b/revision.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/split-index.h b/split-index.h
index 7a435ca2c97..1a153f47ba3 100644
--- a/split-index.h
+++ b/split-index.h
@@ -1,7 +1,7 @@
 #ifndef SPLIT_INDEX_H
 #define SPLIT_INDEX_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct index_state;
 struct strbuf;
-- 
gitgitgadget


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

* [PATCH v2 24/24] mailmap, quote: move declarations of global vars to correct unit
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (22 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 23/24] treewide: reduce includes of cache.h in other headers Elijah Newren via GitGitGadget
@ 2023-04-04  1:22   ` Elijah Newren via GitGitGadget
  2023-04-05 17:30   ` [PATCH v2 00/24] Header cleanups (splitting up cache.h) Calvin Wan
  2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
  25 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-04  1:22 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Since earlier commits removed the inclusion of cache.h from mailmap.c
and quote.c, it feels odd to have the extern declarations of
global variables in cache.h rather than the actual header included
by the source file.  Move these global variable extern declarations
from cache.h to mailmap.c and quote.c.

Signed-off-by: Elijah Newren <newren@gmail.com>
---
 cache.h   | 5 -----
 config.c  | 1 +
 mailmap.h | 3 +++
 quote.h   | 2 ++
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/cache.h b/cache.h
index 16b5fc9fa31..2f21704da9e 100644
--- a/cache.h
+++ b/cache.h
@@ -599,8 +599,6 @@ void set_alternate_index_output(const char *);
 extern int verify_index_checksum;
 extern int verify_ce_order;
 
-extern int quote_path_fully;
-
 #define MTIME_CHANGED	0x0001
 #define CTIME_CHANGED	0x0002
 #define OWNER_CHANGED	0x0004
@@ -655,9 +653,6 @@ struct pack_entry {
 /* Dumb servers support */
 int update_server_info(int);
 
-extern const char *git_mailmap_file;
-extern const char *git_mailmap_blob;
-
 #define COPY_READ_ERROR (-2)
 #define COPY_WRITE_ERROR (-3)
 int copy_fd(int ifd, int ofd);
diff --git a/config.c b/config.c
index 11e3295419b..9beba19b41c 100644
--- a/config.c
+++ b/config.c
@@ -18,6 +18,7 @@
 #include "ident.h"
 #include "repository.h"
 #include "lockfile.h"
+#include "mailmap.h"
 #include "exec-cmd.h"
 #include "strbuf.h"
 #include "quote.h"
diff --git a/mailmap.h b/mailmap.h
index 7e99fccb46c..0f8fd2c586f 100644
--- a/mailmap.h
+++ b/mailmap.h
@@ -3,6 +3,9 @@
 
 struct string_list;
 
+extern const char *git_mailmap_file;
+extern const char *git_mailmap_blob;
+
 int read_mailmap(struct string_list *map);
 void clear_mailmap(struct string_list *map);
 
diff --git a/quote.h b/quote.h
index 87ff458b06d..0300c291041 100644
--- a/quote.h
+++ b/quote.h
@@ -3,6 +3,8 @@
 
 struct strbuf;
 
+extern int quote_path_fully;
+
 /* Help to copy the thing properly quoted for the shell safety.
  * any single quote is replaced with '\'', any exclamation point
  * is replaced with '\!', and the whole thing is enclosed in a
-- 
gitgitgadget

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

* Re: [PATCH v2 21/24] strbuf: move forward declarations to beginning of file
  2023-04-04  1:22   ` [PATCH v2 21/24] strbuf: move forward declarations to beginning of file Elijah Newren via GitGitGadget
@ 2023-04-05 17:28     ` Calvin Wan
  2023-04-07  6:07       ` Elijah Newren
  0 siblings, 1 reply; 101+ messages in thread
From: Calvin Wan @ 2023-04-05 17:28 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget; +Cc: Calvin Wan, git, Elijah Newren

 Instead of moving these declarations, can we move
 strbuf_repo_add_unique_abbrev() and strbuf_add_unique_abbrev() to
 object-name.[ch]? These functions are related to both strbuf and
 object-name, but object-name should be a higher level API than strbuf
 so it seems more natural to belong in there.

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Elijah Newren <newren@gmail.com>
> 
> Signed-off-by: Elijah Newren <newren@gmail.com>
> ---
>  strbuf.h | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/strbuf.h b/strbuf.h
> index 3dfeadb44c2..547696fb233 100644
> --- a/strbuf.h
> +++ b/strbuf.h
> @@ -1,6 +1,8 @@
>  #ifndef STRBUF_H
>  #define STRBUF_H
>  
> +struct object_id;
> +struct repository;
>  struct string_list;
>  
>  /**
> @@ -72,12 +74,6 @@ struct strbuf {
>  extern char strbuf_slopbuf[];
>  #define STRBUF_INIT  { .buf = strbuf_slopbuf }
>  
> -/*
> - * Predeclare this here, since cache.h includes this file before it defines the
> - * struct.
> - */
> -struct object_id;
> -
>  /**
>   * Life Cycle Functions
>   * --------------------
> @@ -634,7 +630,6 @@ void strbuf_list_free(struct strbuf **list);
>   * Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
>   * the strbuf `sb`.
>   */
> -struct repository;
>  void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
>  				   const struct object_id *oid, int abbrev_len);
>  void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
> -- 
> gitgitgadget
> 
> 
> 

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

* Re: [PATCH v2 00/24] Header cleanups (splitting up cache.h)
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (23 preceding siblings ...)
  2023-04-04  1:22   ` [PATCH v2 24/24] mailmap, quote: move declarations of global vars to correct unit Elijah Newren via GitGitGadget
@ 2023-04-05 17:30   ` Calvin Wan
  2023-04-07  7:08     ` Elijah Newren
  2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
  25 siblings, 1 reply; 101+ messages in thread
From: Calvin Wan @ 2023-04-05 17:30 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget; +Cc: Calvin Wan, git, Elijah Newren

"Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> Maintainer notes: (1) This series is based on a merge of
> en/header-split-cleanup and ab/remove-implicit-use-of-the-repository (both
> in next). (2) Although I've tweaked the series to minimize conflicts (and
> this series merges syntactically cleanly with next and seen), there is a
> semantic conflict with each of ja/worktree-orphan and
> ab/tag-object-type-errors in seen; to correct, simply add an include of
> advice.h in builtin/worktree.c and an include of gettext.h in tag.c,
> respectively.
> 
> This series builds on en/header-cleanup
> (https://lore.kernel.org/git/pull.1485.v2.git.1677197376.gitgitgadget@gmail.com/)
> and en/header-split-cleanup
> (https://lore.kernel.org/git/pull.1493.v2.git.1679379968.gitgitgadget@gmail.com/),
> and continues to focus on splitting declarations from cache.h to separate
> headers. This series continues dropping the number of cache.h includes; in
> this series we go from 254 such includes to 190.
> 
> The series may appear to be long at first glance, but is repetitive and
> simple. It should be relatively easy to review, and falls into roughly 3
> categories. An overview:
> 
>  * Patches 1-6, 7: Being more explicit about dependencies. This was
>    motivated by the fact that trying to find unnecessary dependencies on
>    cache.h were being made harder by implicit dependencies on trace.h,
>    trace2.h, and advice.h that were included via cache.h. (Similar to
>    gettext.h handling in the previous series.) So I simply try to make
>    dependencies more explicit, for both these headers and a few others. To
>    make review easy, I split it into half a dozen patches, one header per
>    patch (well, except that I handle trace.h and trace2.h together). Patch 7
>    then removes several includes of cache.h that are no longer needed due to
>    patches 1-6.
>  * Patches 8-19: For several choices of FOO, move declarations of functions
>    for FOO.c from cache.h to FOO.h. To simplify reviewing, each case is
>    split into two patches, with the second patch cleaning up unnecessary
>    includes of cache.h in other source files.
>  * Patches 20-24: Other small manual cleanups noticed while doing above work
> 
> Since patches 1-15 & 17-19 are just more of the same types of patches
> already reviewed in the last two series, it probably makes more sense for
> reviewers to focus on the other patches: 16 + 20-24 (which also happen to be
> smaller). I would particularly most like review of patches 16, 22, & 24
> since they are the least like any previously reviewed patches.

Patches 1-15 a& 17-19 LGTM! Very welcome changes to see the size of
cache.h shrink after this and your previous series. 

I had the same change in patch 16 on a local branch, specifically moving
editor related functions from strbuf. The eventual dream for lower level
libraries such as strbuf is to separate out the functions that touch
higher level objects, allowing for the eventual libification of parts of
Git.

Patch 20: removal of unnecessary headers are always welcome since it
allows readers to easily understand what dependencies a file has.

Patch 21: I do have a suggestion that I will leave on the patch

Patch 22: with what's currently in wrapper.h, it feels like it's
becoming the new dumping ground for functions that don't quite have a
home elsewhere. While I think this change makes sense right now, I do
hope in the future wrapper.h can be broken up with more reasonable
boundaries rather than "this function is a git-specific stdlib or
whatever lib function". 

Patch 23: same reasoning as with patch 20, swapping to more precise
headers clarifies file dependencies

Patch 24: moving more items from the "dumping ground" to where they're
supposed to be :)

Besides patch 21, the rest of the series LGTM, thanks!

> 
> Changes since v1:
> 
>  * Moved a few more things from cache.h to object.h, object-file.h, and
>    object-name.h
>  * Split the object.h changes into two patches to be more like all the other
>    patches in 8-19
>  * Squashed patches 22 & 23, since both were just manual replacements of
>    cache.h inclusion with some other header
>  * Removed a couple cases of duplicate inclusions of git-compat-util.h
> 
> There are more changes I plan to make after this series graduates (still
> focused around splitting up cache.h), but this series was long enough.
> 
> 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 (24):
>   treewide: be explicit about dependence on trace.h & trace2.h
>   treewide: be explicit about dependence on advice.h
>   treewide: be explicit about dependence on convert.h
>   treewide: be explicit about dependence on pack-revindex.h
>   treewide: be explicit about dependence on oid-array.h
>   treewide: be explicit about dependence on mem-pool.h
>   treewide: remove unnecessary cache.h inclusion
>   object-name.h: move declarations for object-name.c functions from
>     cache.h
>   treewide: remove cache.h inclusion due to object-name.h changes
>   git-zlib: move declarations for git-zlib functions from cache.h
>   treewide: remove cache.h inclusion due to git-zlib changes
>   object-file.h: move declarations for object-file.c functions from
>     cache.h
>   treewide: remove cache.h inclusion due to object-file.h changes
>   object.h: move some inline functions and defines from cache.h
>   treewide: remove cache.h inclusion due to object.h changes
>   editor: move editor-related functions and declarations into common
>     file
>   treewide: remove cache.h inclusion due to editor.h changes
>   pager.h: move declarations for pager.c functions from cache.h
>   treewide: remove cache.h inclusion due to pager.h changes
>   cache.h: remove unnecessary includes
>   strbuf: move forward declarations to beginning of file
>   treewide: remove double forward declaration of read_in_full
>   treewide: reduce includes of cache.h in other headers
>   mailmap, quote: move declarations of global vars to correct unit
> 
>  Makefile                                 |   2 +-
>  add-patch.c                              |   3 +
>  apply.c                                  |   2 +
>  archive-tar.c                            |   1 +
>  archive-zip.c                            |   1 +
>  archive.c                                |   1 +
>  archive.h                                |   3 +-
>  bisect.c                                 |   3 +-
>  blame.c                                  |   2 +
>  branch.c                                 |   3 +-
>  builtin/add.c                            |   2 +
>  builtin/am.c                             |   4 +
>  builtin/bisect.c                         |   2 +
>  builtin/blame.c                          |   2 +
>  builtin/branch.c                         |   2 +
>  builtin/bugreport.c                      |   2 +
>  builtin/cat-file.c                       |   3 +
>  builtin/check-attr.c                     |   1 +
>  builtin/checkout.c                       |   3 +
>  builtin/clone.c                          |   3 +
>  builtin/commit-graph.c                   |   1 +
>  builtin/commit-tree.c                    |   1 +
>  builtin/commit.c                         |   3 +
>  builtin/config.c                         |   1 +
>  builtin/credential-cache--daemon.c       |   1 +
>  builtin/describe.c                       |   1 +
>  builtin/diagnose.c                       |   1 +
>  builtin/difftool.c                       |   1 +
>  builtin/fast-export.c                    |   1 +
>  builtin/fast-import.c                    |   2 +
>  builtin/fetch-pack.c                     |   1 +
>  builtin/fetch.c                          |   6 +
>  builtin/fsck.c                           |   2 +
>  builtin/fsmonitor--daemon.c              |   1 +
>  builtin/gc.c                             |   2 +
>  builtin/grep.c                           |   3 +
>  builtin/hash-object.c                    |   1 +
>  builtin/help.c                           |   1 +
>  builtin/index-pack.c                     |   3 +
>  builtin/init-db.c                        |   1 +
>  builtin/log.c                            |   4 +
>  builtin/ls-files.c                       |   2 +
>  builtin/ls-tree.c                        |   1 +
>  builtin/merge-base.c                     |   1 +
>  builtin/merge-recursive.c                |   2 +
>  builtin/merge-tree.c                     |   1 +
>  builtin/merge.c                          |   3 +
>  builtin/mktag.c                          |   1 +
>  builtin/mv.c                             |   2 +
>  builtin/name-rev.c                       |   2 +
>  builtin/notes.c                          |   2 +
>  builtin/pack-objects.c                   |   1 +
>  builtin/prune.c                          |   2 +
>  builtin/pull.c                           |   2 +
>  builtin/push.c                           |   2 +
>  builtin/range-diff.c                     |   1 +
>  builtin/read-tree.c                      |   1 +
>  builtin/rebase.c                         |   3 +
>  builtin/receive-pack.c                   |   3 +
>  builtin/replace.c                        |   3 +
>  builtin/reset.c                          |   4 +
>  builtin/rev-list.c                       |   2 +
>  builtin/rev-parse.c                      |   1 +
>  builtin/rm.c                             |   1 +
>  builtin/show-branch.c                    |   1 +
>  builtin/show-ref.c                       |   1 +
>  builtin/sparse-checkout.c                |   2 +
>  builtin/stash.c                          |   1 +
>  builtin/submodule--helper.c              |   2 +
>  builtin/tag.c                            |   3 +
>  builtin/unpack-file.c                    |   1 +
>  builtin/unpack-objects.c                 |   1 +
>  builtin/update-index.c                   |   1 +
>  builtin/update-ref.c                     |   1 +
>  builtin/var.c                            |   2 +
>  builtin/verify-commit.c                  |   1 +
>  builtin/verify-tag.c                     |   1 +
>  builtin/worktree.c                       |   2 +
>  bulk-checkin.c                           |   4 +-
>  bundle.c                                 |   2 +-
>  cache-tree.c                             |   3 +
>  cache.h                                  | 330 -----------------------
>  chdir-notify.c                           |   4 +-
>  checkout.c                               |   4 +-
>  color.c                                  |   2 +
>  column.c                                 |   3 +-
>  combine-diff.c                           |   3 +
>  commit-graph.c                           |   4 +-
>  commit.c                                 |   3 +-
>  common-main.c                            |   1 +
>  compat/fsmonitor/fsm-listen-win32.c      |   1 +
>  compat/mingw.c                           |   1 +
>  compat/pread.c                           |   1 +
>  compat/simple-ipc/ipc-unix-socket.c      |   3 +-
>  compat/simple-ipc/ipc-win32.c            |   2 +
>  compat/win32/trace2_win32_process_info.c |   1 +
>  config.c                                 |   6 +
>  connect.c                                |   2 +-
>  convert.c                                |   3 +
>  date.c                                   |   1 +
>  delta-islands.c                          |   2 +-
>  diff-lib.c                               |   2 +
>  diff-no-index.c                          |   2 +-
>  diff.c                                   |   5 +
>  dir.c                                    |   3 +
>  editor.c                                 |  34 ++-
>  editor.h                                 |  34 +++
>  environment.c                            |   4 +-
>  exec-cmd.c                               |   2 +
>  fetch-pack.c                             |   3 +-
>  fmt-merge-msg.c                          |   3 +-
>  fsck.c                                   |   2 +-
>  fsmonitor.c                              |   1 +
>  fsmonitor.h                              |   1 +
>  git-compat-util.h                        |   6 -
>  zlib.c => git-zlib.c                     |   3 +-
>  git-zlib.h                               |  28 ++
>  git.c                                    |   3 +
>  grep.c                                   |   1 +
>  http-backend.c                           |   3 +-
>  http-fetch.c                             |   2 +-
>  http-push.c                              |   2 +-
>  http-walker.c                            |   2 +-
>  http.c                                   |   2 +
>  http.h                                   |   4 +-
>  list-objects-filter.c                    |   3 +-
>  list-objects.c                           |   2 +-
>  ll-merge.c                               |   1 +
>  log-tree.c                               |   3 +-
>  mailmap.c                                |   3 +-
>  mailmap.h                                |   3 +
>  merge-ort.c                              |   4 +
>  merge-recursive.c                        |   2 +
>  midx.c                                   |   1 +
>  name-hash.c                              |   1 +
>  notes-merge.c                            |   6 +-
>  notes.c                                  |   3 +-
>  object-file.c                            |   2 +
>  object-file.h                            | 129 +++++++++
>  object-name.c                            |   2 +
>  object-name.h                            | 121 +++++++++
>  object.c                                 |   1 +
>  object.h                                 |  44 +++
>  pack-bitmap-write.c                      |   2 +-
>  pack-bitmap.c                            |   4 +-
>  pack-check.c                             |   3 +-
>  pack-mtimes.c                            |   3 +-
>  pack-revindex.c                          |   4 +-
>  pack-write.c                             |   4 +-
>  packfile.c                               |   3 +
>  pager.c                                  |   6 +-
>  pager.h                                  |  17 ++
>  parse-options-cb.c                       |   2 +-
>  path.c                                   |   1 +
>  pkt-line.c                               |   1 +
>  preload-index.c                          |   1 +
>  pretty.c                                 |   3 +-
>  progress.c                               |   4 +-
>  promisor-remote.c                        |   3 +-
>  protocol.c                               |   3 +-
>  quote.c                                  |   3 +-
>  quote.h                                  |   2 +
>  range-diff.c                             |   2 +
>  read-cache.c                             |   5 +
>  rebase-interactive.c                     |   4 +-
>  ref-filter.c                             |   2 +
>  refs.c                                   |   4 +-
>  refs/files-backend.c                     |   1 +
>  refs/packed-backend.c                    |   1 +
>  refs/ref-cache.h                         |   2 +-
>  remote-curl.c                            |   1 +
>  remote.c                                 |   3 +-
>  repository.c                             |   1 +
>  rerere.c                                 |   3 +-
>  reset.c                                  |   1 +
>  resolve-undo.h                           |   7 +-
>  revision.c                               |   5 +-
>  run-command.c                            |   2 +
>  scalar.c                                 |   3 +-
>  send-pack.c                              |   1 +
>  sequencer.c                              |   4 +
>  server-info.c                            |   1 +
>  setup.c                                  |   5 +-
>  shallow.c                                |   1 +
>  sideband.c                               |   3 +-
>  split-index.c                            |   1 +
>  split-index.h                            |   2 +-
>  strbuf.c                                 |  31 +--
>  strbuf.h                                 |  33 +--
>  streaming.c                              |   4 +-
>  submodule-config.c                       |   3 +-
>  submodule.c                              |   3 +
>  t/helper/test-date.c                     |   2 +-
>  t/helper/test-fast-rebase.c              |   1 +
>  t/helper/test-lazy-init-name-hash.c      |   1 +
>  t/helper/test-match-trees.c              |   1 +
>  t/helper/test-mergesort.c                |   1 +
>  t/helper/test-oidmap.c                   |   2 +-
>  t/helper/test-path-utils.c               |   1 +
>  t/helper/test-reach.c                    |   2 +-
>  t/helper/test-submodule-config.c         |   2 +-
>  tag.c                                    |   3 +-
>  tmp-objdir.c                             |   3 +-
>  trace.c                                  |   3 +-
>  trace2.c                                 |   1 +
>  transport-helper.c                       |   3 +-
>  transport.c                              |   5 +-
>  tree-walk.c                              |   2 +
>  tree.c                                   |   1 +
>  unpack-trees.c                           |   2 +
>  unpack-trees.h                           |   1 +
>  upload-pack.c                            |   5 +-
>  walker.c                                 |   2 +-
>  wrapper.c                                |   1 +
>  wt-status.c                              |   4 +
>  215 files changed, 807 insertions(+), 465 deletions(-)
>  create mode 100644 editor.h
>  rename zlib.c => git-zlib.c (99%)
>  create mode 100644 git-zlib.h
>  create mode 100644 object-file.h
>  create mode 100644 object-name.h
>  create mode 100644 pager.h
> 
> 
> base-commit: dc1c48a4a2bce29542f330137106c01daa728f9e
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1509%2Fnewren%2Fheader-cleanup-3-v2
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1509/newren/header-cleanup-3-v2
> Pull-Request: https://github.com/gitgitgadget/git/pull/1509
> 
> Range-diff vs v1:
> 
>   1:  6acf4eb2c77 =  1:  6acf4eb2c77 treewide: be explicit about dependence on trace.h & trace2.h
>   2:  e163bed61ff =  2:  e163bed61ff treewide: be explicit about dependence on advice.h
>   3:  4ef4ee9daf3 =  3:  4ef4ee9daf3 treewide: be explicit about dependence on convert.h
>   4:  86b47be1776 =  4:  86b47be1776 treewide: be explicit about dependence on pack-revindex.h
>   5:  81a9378be43 =  5:  81a9378be43 treewide: be explicit about dependence on oid-array.h
>   6:  c6a561cf433 =  6:  c6a561cf433 treewide: be explicit about dependence on mem-pool.h
>   7:  22709819107 !  7:  3c12d5ba6c3 treewide: remove unnecessary cache.h inclusion
>      @@ connect.c
>       @@
>        #include "git-compat-util.h"
>       -#include "cache.h"
>      -+#include "git-compat-util.h"
>        #include "config.h"
>        #include "environment.h"
>        #include "gettext.h"
>   8:  b513a6711ff !  8:  1e2e60bffc7 object-name.h: move declarations for object-name.c functions from cache.h
>      @@ archive.h
>        
>        struct repository;
>       
>      + ## bisect.c ##
>      +@@
>      + #include "strvec.h"
>      + #include "commit-slab.h"
>      + #include "commit-reach.h"
>      ++#include "object-name.h"
>      + #include "object-store.h"
>      + #include "dir.h"
>      + 
>      +
>        ## branch.c ##
>       @@
>        #include "environment.h"
>      @@ cache.h: extern int quote_path_fully;
>        /*
>         * Create the directory containing the named path, using care to be
>         * somewhat safe against races. Return one of the scld_error values to
>      -@@ cache.h: struct object_context {
>      - 	char *path;
>      - };
>      +@@ cache.h: int finalize_object_file(const char *tmpfile, const char *filename);
>      + /* Helper to check and "touch" a file */
>      + int check_and_freshen_file(const char *fn, int freshen);
>        
>      +-/* Convert to/from hex/sha1 representation */
>      +-#define MINIMUM_ABBREV minimum_abbrev
>      +-#define DEFAULT_ABBREV default_abbrev
>      +-
>      +-/* used when the code does not know or care what the default abbrev is */
>      +-#define FALLBACK_DEFAULT_ABBREV 7
>      +-
>      +-struct object_context {
>      +-	unsigned short mode;
>      +-	/*
>      +-	 * symlink_path is only used by get_tree_entry_follow_symlinks,
>      +-	 * and only for symlinks that point outside the repository.
>      +-	 */
>      +-	struct strbuf symlink_path;
>      +-	/*
>      +-	 * If GET_OID_RECORD_PATH is set, this will record path (if any)
>      +-	 * found when resolving the name. The caller is responsible for
>      +-	 * releasing the memory.
>      +-	 */
>      +-	char *path;
>      +-};
>      +-
>       -int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
>       -__attribute__((format (printf, 2, 3)))
>       -int get_oidf(struct object_id *oid, const char *fmt, ...);
>      @@ merge-ort.c
>        #include "oid-array.h"
>        #include "promisor-remote.h"
>       
>      + ## merge-recursive.c ##
>      +@@
>      + #include "hex.h"
>      + #include "ll-merge.h"
>      + #include "lockfile.h"
>      ++#include "object-name.h"
>      + #include "object-store.h"
>      + #include "repository.h"
>      + #include "revision.h"
>      +
>        ## notes-merge.c ##
>       @@
>        #include "commit.h"
>      @@ object-name.h (new)
>       +#define OBJECT_NAME_H
>       +
>       +#include "object.h"
>      ++#include "strbuf.h"
>       +
>      -+struct object_context;
>       +struct object_id;
>       +struct repository;
>      -+struct strbuf;
>      ++
>      ++struct object_context {
>      ++	unsigned short mode;
>      ++	/*
>      ++	 * symlink_path is only used by get_tree_entry_follow_symlinks,
>      ++	 * and only for symlinks that point outside the repository.
>      ++	 */
>      ++	struct strbuf symlink_path;
>      ++	/*
>      ++	 * If GET_OID_RECORD_PATH is set, this will record path (if any)
>      ++	 * found when resolving the name. The caller is responsible for
>      ++	 * releasing the memory.
>      ++	 */
>      ++	char *path;
>      ++};
>       +
>       +/*
>       + * Return an abbreviated sha1 unique within this repository's object database.
>      @@ object-name.h (new)
>       +struct object *repo_peel_to_type(struct repository *r,
>       +				 const char *name, int namelen,
>       +				 struct object *o, enum object_type);
>      ++
>      ++/* Convert to/from hex/sha1 representation */
>      ++#define MINIMUM_ABBREV minimum_abbrev
>      ++#define DEFAULT_ABBREV default_abbrev
>      ++
>      ++/* used when the code does not know or care what the default abbrev is */
>      ++#define FALLBACK_DEFAULT_ABBREV 7
>      ++
>       +#endif /* OBJECT_NAME_H */
>       
>        ## parse-options-cb.c ##
>   9:  e3ec14f90a5 !  9:  62f61514e2f treewide: remove cache.h inclusion due to object-name.h changes
>      @@ branch.c
>       @@
>        #include "git-compat-util.h"
>       -#include "cache.h"
>      -+#include "git-compat-util.h"
>        #include "advice.h"
>        #include "config.h"
>        #include "branch.h"
>  10:  2f240f07551 = 10:  54545bbb02c git-zlib: move declarations for git-zlib functions from cache.h
>  11:  7c969dc801d = 11:  dbfe03129e3 treewide: remove cache.h inclusion due to git-zlib changes
>  12:  7cd3acfdb86 ! 12:  5efd49df148 object-file.h: move declarations for object-file.c functions from cache.h
>      @@ builtin/fast-import.c
>        #include "object-store.h"
>        #include "mem-pool.h"
>       
>      + ## builtin/fetch-pack.c ##
>      +@@
>      + #include "alloc.h"
>      + #include "gettext.h"
>      + #include "hex.h"
>      ++#include "object-file.h"
>      + #include "pkt-line.h"
>      + #include "fetch-pack.h"
>      + #include "remote.h"
>      +
>        ## builtin/fsck.c ##
>       @@
>        #include "streaming.h"
>      @@ builtin/pack-objects.c
>        #include "replace-object.h"
>        #include "dir.h"
>       
>      + ## builtin/prune.c ##
>      +@@
>      + #include "progress.h"
>      + #include "prune-packed.h"
>      + #include "replace-object.h"
>      ++#include "object-file.h"
>      + #include "object-name.h"
>      + #include "object-store.h"
>      + #include "shallow.h"
>      +
>        ## builtin/rebase.c ##
>       @@
>        #include "cache-tree.h"
>      @@ builtin/replace.c
>        #include "object-store.h"
>        #include "replace-object.h"
>       
>      + ## builtin/rev-list.c ##
>      +@@
>      + #include "list-objects-filter-options.h"
>      + #include "object.h"
>      + #include "object-name.h"
>      ++#include "object-file.h"
>      + #include "object-store.h"
>      + #include "pack.h"
>      + #include "pack-bitmap.h"
>      +
>        ## builtin/sparse-checkout.c ##
>       @@
>        #include "dir.h"
>      @@ cache-tree.c
>        #include "promisor-remote.h"
>       
>        ## cache.h ##
>      +@@
>      + 
>      + #include "git-compat-util.h"
>      + #include "strbuf.h"
>      +-#include "git-zlib.h"
>      + #include "hashmap.h"
>      + #include "list.h"
>      + #include "gettext.h"
>       @@ cache.h: int has_racy_timestamp(struct index_state *istate);
>        int ie_match_stat(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
>        int ie_modified(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
>      @@ cache.h: extern int quote_path_fully;
>       -/* Helper to check and "touch" a file */
>       -int check_and_freshen_file(const char *fn, int freshen);
>       -
>      - /* Convert to/from hex/sha1 representation */
>      - #define MINIMUM_ABBREV minimum_abbrev
>      - #define DEFAULT_ABBREV default_abbrev
>      + 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,
>       @@ cache.h: 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);
>      @@ cache.h: int df_name_compare(const char *name1, size_t len1, int mode1,
>        const char *git_editor(void);
>        const char *git_sequence_editor(void);
>        const char *git_pager(int stdout_is_tty);
>      +@@ cache.h: struct pack_entry {
>      + 	struct packed_git *p;
>      + };
>      + 
>      +-/*
>      +- * Set this to 0 to prevent oid_object_info_extended() from fetching missing
>      +- * blobs. This has a difference only if extensions.partialClone is set.
>      +- *
>      +- * Its default value is 1.
>      +- */
>      +-extern int fetch_if_missing;
>      +-
>      + /* Dumb servers support */
>      + int update_server_info(int);
>      + 
>       
>        ## commit-graph.c ##
>       @@
>      @@ merge-recursive.c
>        #include "ll-merge.h"
>        #include "lockfile.h"
>       +#include "object-file.h"
>      + #include "object-name.h"
>        #include "object-store.h"
>        #include "repository.h"
>      - #include "revision.h"
>       
>        ## midx.c ##
>       @@
>      @@ object-file.h (new)
>       +#include "git-zlib.h"
>       +#include "object.h"
>       +
>      ++/*
>      ++ * Set this to 0 to prevent oid_object_info_extended() from fetching missing
>      ++ * blobs. This has a difference only if extensions.partialClone is set.
>      ++ *
>      ++ * Its default value is 1.
>      ++ */
>      ++extern int fetch_if_missing;
>      ++
>       +#define HASH_WRITE_OBJECT 1
>       +#define HASH_FORMAT_CHECK 2
>       +#define HASH_RENORMALIZE  4
>      @@ rerere.c
>        #include "hash-lookup.h"
>        #include "strmap.h"
>       
>      + ## revision.c ##
>      +@@
>      + #include "gettext.h"
>      + #include "hex.h"
>      + #include "object-name.h"
>      ++#include "object-file.h"
>      + #include "object-store.h"
>      + #include "tag.h"
>      + #include "blob.h"
>      +
>        ## sequencer.c ##
>       @@
>        #include "hex.h"
>  13:  c103d486b2a = 13:  1827ecb4d1d treewide: remove cache.h inclusion due to object-file.h changes
>  14:  fa58cf82c66 ! 14:  8937f6d5ac5 object.h: move an inline function and some defines from cache.h
>      @@ Metadata
>       Author: Elijah Newren <newren@gmail.com>
>       
>        ## Commit message ##
>      -    object.h: move an inline function and some defines from cache.h
>      +    object.h: move some inline functions and defines from cache.h
>       
>           The object_type() inline function is very tied to the enum object_type
>           declaration within object.h, and just seemed to make more sense to live
>      -    there.  Move it, and as a side-effect, remove a bunch of dependencies
>      -    on cache.h that are no longer needed.
>      +    there.  That makes S_ISGITLINK and some other defines make sense to go
>      +    with it, as well as the create_ce_mode() and canon_mode() inline
>      +    functions.  Move all these inline functions and defines from cache.h to
>      +    object.h.
>       
>           Signed-off-by: Elijah Newren <newren@gmail.com>
>       
>      - ## bundle.c ##
>      -@@
>      --#include "cache.h"
>      -+#include "git-compat-util.h"
>      - #include "lockfile.h"
>      - #include "bundle.h"
>      - #include "environment.h"
>      -
>        ## cache.h ##
>       @@
>        #define DTYPE(de)	DT_UNKNOWN
>      @@ cache.h: struct cache_entry {
>        /* Forward structure decls */
>        struct pathspec;
>        struct child_process;
>      +@@ cache.h: static inline unsigned create_ce_flags(unsigned stage)
>      + #define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
>      + #define ce_intent_to_add(ce) ((ce)->ce_flags & CE_INTENT_TO_ADD)
>      + 
>      +-#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
>      +-static inline unsigned int create_ce_mode(unsigned int mode)
>      +-{
>      +-	if (S_ISLNK(mode))
>      +-		return S_IFLNK;
>      +-	if (S_ISSPARSEDIR(mode))
>      +-		return S_IFDIR;
>      +-	if (S_ISDIR(mode) || S_ISGITLINK(mode))
>      +-		return S_IFGITLINK;
>      +-	return S_IFREG | ce_permissions(mode);
>      +-}
>      + static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,
>      + 					     unsigned int mode)
>      + {
>      +@@ cache.h: static inline int ce_to_dtype(const struct cache_entry *ce)
>      + 	else
>      + 		return DT_UNKNOWN;
>      + }
>      +-static inline unsigned int canon_mode(unsigned int mode)
>      +-{
>      +-	if (S_ISREG(mode))
>      +-		return S_IFREG | ce_permissions(mode);
>      +-	if (S_ISLNK(mode))
>      +-		return S_IFLNK;
>      +-	if (S_ISDIR(mode))
>      +-		return S_IFDIR;
>      +-	return S_IFGITLINK;
>      +-}
>      + 
>      + static inline int ce_path_match(struct index_state *istate,
>      + 				const struct cache_entry *ce,
>       @@ cache.h: void prefetch_cache_entries(const struct index_state *istate,
>        extern struct index_state the_index;
>        #endif
>      @@ cache.h: void prefetch_cache_entries(const struct index_state *istate,
>        #define INIT_DB_EXIST_OK 0x0002
>        
>       
>      - ## delta-islands.c ##
>      -@@
>      --#include "cache.h"
>      -+#include "git-compat-util.h"
>      - #include "alloc.h"
>      - #include "attr.h"
>      - #include "object.h"
>      -
>      - ## fsck.c ##
>      -@@
>      --#include "cache.h"
>      -+#include "git-compat-util.h"
>      - #include "alloc.h"
>      - #include "hex.h"
>      - #include "object-store.h"
>      -
>      - ## http-push.c ##
>      -@@
>      --#include "cache.h"
>      -+#include "git-compat-util.h"
>      - #include "environment.h"
>      - #include "hex.h"
>      - #include "repository.h"
>      -
>      - ## list-objects.c ##
>      -@@
>      --#include "cache.h"
>      -+#include "git-compat-util.h"
>      - #include "tag.h"
>      - #include "commit.h"
>      - #include "gettext.h"
>      -
>        ## object.h ##
>       @@ object.h: enum object_type {
>        	OBJ_MAX
>      @@ object.h: enum object_type {
>       +		S_ISGITLINK(mode) ? OBJ_COMMIT :
>       +		OBJ_BLOB;
>       +}
>      ++
>      ++#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
>      ++static inline unsigned int create_ce_mode(unsigned int mode)
>      ++{
>      ++	if (S_ISLNK(mode))
>      ++		return S_IFLNK;
>      ++	if (S_ISSPARSEDIR(mode))
>      ++		return S_IFDIR;
>      ++	if (S_ISDIR(mode) || S_ISGITLINK(mode))
>      ++		return S_IFGITLINK;
>      ++	return S_IFREG | ce_permissions(mode);
>      ++}
>      ++
>      ++static inline unsigned int canon_mode(unsigned int mode)
>      ++{
>      ++	if (S_ISREG(mode))
>      ++		return S_IFREG | ce_permissions(mode);
>      ++	if (S_ISLNK(mode))
>      ++		return S_IFLNK;
>      ++	if (S_ISDIR(mode))
>      ++		return S_IFDIR;
>      ++	return S_IFGITLINK;
>      ++}
>       +
>        /*
>         * The object type is stored in 3 bits.
>         */
>      -
>      - ## pack-bitmap-write.c ##
>      -@@
>      --#include "cache.h"
>      -+#include "git-compat-util.h"
>      - #include "alloc.h"
>      - #include "environment.h"
>      - #include "gettext.h"
>      -
>      - ## submodule-config.c ##
>      -@@
>      --#include "cache.h"
>      -+#include "git-compat-util.h"
>      - #include "alloc.h"
>      - #include "dir.h"
>      - #include "environment.h"
>      -
>      - ## walker.c ##
>      -@@
>      --#include "cache.h"
>      -+#include "git-compat-util.h"
>      - #include "gettext.h"
>      - #include "hex.h"
>      - #include "walker.h"
>   -:  ----------- > 15:  c85f9baed8c treewide: remove cache.h inclusion due to object.h changes
>  15:  1e0a9441e73 ! 16:  0ac095731a7 editor: move editor-related functions and declarations into common file
>      @@ pager.c
>       
>        ## rebase-interactive.c ##
>       @@
>      - #include "cache.h"
>      + #include "git-compat-util.h"
>        #include "commit.h"
>       +#include "editor.h"
>        #include "environment.h"
>  16:  4b41942a24e = 17:  9550d976141 treewide: remove cache.h inclusion due to editor.h changes
>  17:  be8c5229baa ! 18:  d658ee210d9 pager.h: move declarations for pager.c functions from cache.h
>      @@ builtin/var.c
>        static const char var_usage[] = "git var (-l | <variable>)";
>       
>        ## cache.h ##
>      +@@ cache.h: struct cache_entry {
>      + 
>      + /* Forward structure decls */
>      + struct pathspec;
>      +-struct child_process;
>      + struct tree;
>      + 
>      + /*
>       @@ cache.h: 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);
>  18:  ec79da0235e = 19:  07d1a65a0ec treewide: remove cache.h inclusion due to pager.h changes
>  19:  c8f7559553f ! 20:  23e0a81e788 cache.h: remove unnecessary includes
>      @@ Commit message
>       
>        ## cache.h ##
>       @@
>      + #include "git-compat-util.h"
>        #include "strbuf.h"
>      - #include "git-zlib.h"
>        #include "hashmap.h"
>       -#include "list.h"
>        #include "gettext.h"
>  20:  7c3235c7943 = 21:  47afc6a6c87 strbuf: move forward declarations to beginning of file
>  21:  3a0d78e2f93 = 22:  6079c470cd1 treewide: remove double forward declaration of read_in_full
>  22:  c4808cf9578 ! 23:  538d95833a2 treewide: reduce includes of cache.h in other headers
>      @@ archive.h
>        struct repository;
>        struct pretty_print_context;
>       
>      + ## chdir-notify.c ##
>      +@@
>      +-#include "cache.h"
>      ++#include "git-compat-util.h"
>      + #include "abspath.h"
>      + #include "chdir-notify.h"
>      + #include "list.h"
>      ++#include "path.h"
>      + #include "strbuf.h"
>      + #include "trace.h"
>      + 
>      +
>      + ## quote.c ##
>      +@@
>      +-#include "cache.h"
>      ++#include "git-compat-util.h"
>      + #include "alloc.h"
>      ++#include "path.h"
>      + #include "quote.h"
>      + #include "strbuf.h"
>      + #include "strvec.h"
>      +
>        ## refs/ref-cache.h ##
>       @@
>        #ifndef REFS_REF_CACHE_H
>  23:  50cbcacaad1 <  -:  ----------- chdir-notify, quote: replace cache.h include with path.h
>  24:  2421bb380b1 ! 24:  30e37a37c12 mailmap, quote: move declarations of global vars to correct unit
>      @@ cache.h: void set_alternate_index_output(const char *);
>        #define MTIME_CHANGED	0x0001
>        #define CTIME_CHANGED	0x0002
>        #define OWNER_CHANGED	0x0004
>      -@@ cache.h: extern int fetch_if_missing;
>      +@@ cache.h: struct pack_entry {
>        /* Dumb servers support */
>        int update_server_info(int);
>        
> 
> -- 
> gitgitgadget
> 
> 

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

* Re: [PATCH v2 21/24] strbuf: move forward declarations to beginning of file
  2023-04-05 17:28     ` Calvin Wan
@ 2023-04-07  6:07       ` Elijah Newren
  2023-04-10 15:52         ` Calvin Wan
  0 siblings, 1 reply; 101+ messages in thread
From: Elijah Newren @ 2023-04-07  6:07 UTC (permalink / raw)
  To: Calvin Wan; +Cc: Elijah Newren via GitGitGadget, git

On Wed, Apr 5, 2023 at 10:28 AM Calvin Wan <calvinwan@google.com> wrote:
>
>  Instead of moving these declarations, can we move
>  strbuf_repo_add_unique_abbrev() and strbuf_add_unique_abbrev() to
>  object-name.[ch]? These functions are related to both strbuf and
>  object-name, but object-name should be a higher level API than strbuf
>  so it seems more natural to belong in there.

I like that suggestion; that would be better overall.  However, should
it be in this (already lengthy) series?  I'm guessing you likely
already have such a change in the series you're including, and if I
were to add it to mine (and risk doing it slightly differently), that
might increase the conflicts you need to deal with.  Would it perhaps
be easier to keep this small change for this series, or even drop this
particular patch, and then let you address this improved direction
with your strbuf work?

> "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> > From: Elijah Newren <newren@gmail.com>
> >
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > ---
> >  strbuf.h | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/strbuf.h b/strbuf.h
> > index 3dfeadb44c2..547696fb233 100644
> > --- a/strbuf.h
> > +++ b/strbuf.h
> > @@ -1,6 +1,8 @@
> >  #ifndef STRBUF_H
> >  #define STRBUF_H
> >
> > +struct object_id;
> > +struct repository;
> >  struct string_list;
> >
> >  /**
> > @@ -72,12 +74,6 @@ struct strbuf {
> >  extern char strbuf_slopbuf[];
> >  #define STRBUF_INIT  { .buf = strbuf_slopbuf }
> >
> > -/*
> > - * Predeclare this here, since cache.h includes this file before it defines the
> > - * struct.
> > - */
> > -struct object_id;
> > -
> >  /**
> >   * Life Cycle Functions
> >   * --------------------
> > @@ -634,7 +630,6 @@ void strbuf_list_free(struct strbuf **list);
> >   * Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
> >   * the strbuf `sb`.
> >   */
> > -struct repository;
> >  void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
> >                                  const struct object_id *oid, int abbrev_len);
> >  void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
> > --
> > gitgitgadget

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

* Re: [PATCH v2 00/24] Header cleanups (splitting up cache.h)
  2023-04-05 17:30   ` [PATCH v2 00/24] Header cleanups (splitting up cache.h) Calvin Wan
@ 2023-04-07  7:08     ` Elijah Newren
  2023-04-10 15:54       ` Calvin Wan
  0 siblings, 1 reply; 101+ messages in thread
From: Elijah Newren @ 2023-04-07  7:08 UTC (permalink / raw)
  To: Calvin Wan; +Cc: Elijah Newren via GitGitGadget, git

On Wed, Apr 5, 2023 at 10:30 AM Calvin Wan <calvinwan@google.com> wrote:
>
> "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> > This series builds on en/header-cleanup
> > (https://lore.kernel.org/git/pull.1485.v2.git.1677197376.gitgitgadget@gmail.com/)
> > and en/header-split-cleanup
> > (https://lore.kernel.org/git/pull.1493.v2.git.1679379968.gitgitgadget@gmail.com/),
> > and continues to focus on splitting declarations from cache.h to separate
> > headers. This series continues dropping the number of cache.h includes; in
> > this series we go from 254 such includes to 190.
> >
> > The series may appear to be long at first glance, but is repetitive and
> > simple. It should be relatively easy to review, and falls into roughly 3
> > categories. An overview:
> >
> >  * Patches 1-6, 7: Being more explicit about dependencies. This was
> >    motivated by the fact that trying to find unnecessary dependencies on
> >    cache.h were being made harder by implicit dependencies on trace.h,
> >    trace2.h, and advice.h that were included via cache.h. (Similar to
> >    gettext.h handling in the previous series.) So I simply try to make
> >    dependencies more explicit, for both these headers and a few others. To
> >    make review easy, I split it into half a dozen patches, one header per
> >    patch (well, except that I handle trace.h and trace2.h together). Patch 7
> >    then removes several includes of cache.h that are no longer needed due to
> >    patches 1-6.
> >  * Patches 8-19: For several choices of FOO, move declarations of functions
> >    for FOO.c from cache.h to FOO.h. To simplify reviewing, each case is
> >    split into two patches, with the second patch cleaning up unnecessary
> >    includes of cache.h in other source files.
> >  * Patches 20-24: Other small manual cleanups noticed while doing above work
> >
> > Since patches 1-15 & 17-19 are just more of the same types of patches
> > already reviewed in the last two series, it probably makes more sense for
> > reviewers to focus on the other patches: 16 + 20-24 (which also happen to be
> > smaller). I would particularly most like review of patches 16, 22, & 24
> > since they are the least like any previously reviewed patches.
>
> Patches 1-15 a& 17-19 LGTM! Very welcome changes to see the size of
> cache.h shrink after this and your previous series.
>
> I had the same change in patch 16 on a local branch, specifically moving
> editor related functions from strbuf. The eventual dream for lower level
> libraries such as strbuf is to separate out the functions that touch
> higher level objects, allowing for the eventual libification of parts of
> Git.
>
> Patch 20: removal of unnecessary headers are always welcome since it
> allows readers to easily understand what dependencies a file has.
>
> Patch 21: I do have a suggestion that I will leave on the patch
>
> Patch 22: with what's currently in wrapper.h, it feels like it's
> becoming the new dumping ground for functions that don't quite have a
> home elsewhere. While I think this change makes sense right now, I do
> hope in the future wrapper.h can be broken up with more reasonable
> boundaries rather than "this function is a git-specific stdlib or
> whatever lib function".

Yeah, I wouldn't be surprised that we have multiple places needing
cleanup.  I haven't looked much at wrapper.[ch] from this angle, but
you got me curious and I took a brief glance.  Do you really mean
wrapper.h, or wrapper.c?  wrapper.h is actually pretty small, only
declaring 8 functions.  The other 32 non-static functions in wrapper.c
are declared in git-compat-util.h.

> Patch 23: same reasoning as with patch 20, swapping to more precise
> headers clarifies file dependencies
>
> Patch 24: moving more items from the "dumping ground" to where they're
> supposed to be :)
>
> Besides patch 21, the rest of the series LGTM, thanks!

Thanks for taking a look!

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

* Re: [PATCH v2 21/24] strbuf: move forward declarations to beginning of file
  2023-04-07  6:07       ` Elijah Newren
@ 2023-04-10 15:52         ` Calvin Wan
  2023-04-10 16:47           ` Elijah Newren
  0 siblings, 1 reply; 101+ messages in thread
From: Calvin Wan @ 2023-04-10 15:52 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Elijah Newren via GitGitGadget, git

I do have this change in one of my series already, and since I'm
planning on removing the declarations anyways, dropping this patch for
now would be my recommendation.

On Thu, Apr 6, 2023 at 11:08 PM Elijah Newren <newren@gmail.com> wrote:
>
> On Wed, Apr 5, 2023 at 10:28 AM Calvin Wan <calvinwan@google.com> wrote:
> >
> >  Instead of moving these declarations, can we move
> >  strbuf_repo_add_unique_abbrev() and strbuf_add_unique_abbrev() to
> >  object-name.[ch]? These functions are related to both strbuf and
> >  object-name, but object-name should be a higher level API than strbuf
> >  so it seems more natural to belong in there.
>
> I like that suggestion; that would be better overall.  However, should
> it be in this (already lengthy) series?  I'm guessing you likely
> already have such a change in the series you're including, and if I
> were to add it to mine (and risk doing it slightly differently), that
> might increase the conflicts you need to deal with.  Would it perhaps
> be easier to keep this small change for this series, or even drop this
> particular patch, and then let you address this improved direction
> with your strbuf work?
>
> > "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> > > From: Elijah Newren <newren@gmail.com>
> > >
> > > Signed-off-by: Elijah Newren <newren@gmail.com>
> > > ---
> > >  strbuf.h | 9 ++-------
> > >  1 file changed, 2 insertions(+), 7 deletions(-)
> > >
> > > diff --git a/strbuf.h b/strbuf.h
> > > index 3dfeadb44c2..547696fb233 100644
> > > --- a/strbuf.h
> > > +++ b/strbuf.h
> > > @@ -1,6 +1,8 @@
> > >  #ifndef STRBUF_H
> > >  #define STRBUF_H
> > >
> > > +struct object_id;
> > > +struct repository;
> > >  struct string_list;
> > >
> > >  /**
> > > @@ -72,12 +74,6 @@ struct strbuf {
> > >  extern char strbuf_slopbuf[];
> > >  #define STRBUF_INIT  { .buf = strbuf_slopbuf }
> > >
> > > -/*
> > > - * Predeclare this here, since cache.h includes this file before it defines the
> > > - * struct.
> > > - */
> > > -struct object_id;
> > > -
> > >  /**
> > >   * Life Cycle Functions
> > >   * --------------------
> > > @@ -634,7 +630,6 @@ void strbuf_list_free(struct strbuf **list);
> > >   * Add the abbreviation, as generated by repo_find_unique_abbrev(), of `sha1` to
> > >   * the strbuf `sb`.
> > >   */
> > > -struct repository;
> > >  void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
> > >                                  const struct object_id *oid, int abbrev_len);
> > >  void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
> > > --
> > > gitgitgadget

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

* Re: [PATCH v2 00/24] Header cleanups (splitting up cache.h)
  2023-04-07  7:08     ` Elijah Newren
@ 2023-04-10 15:54       ` Calvin Wan
  0 siblings, 0 replies; 101+ messages in thread
From: Calvin Wan @ 2023-04-10 15:54 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Elijah Newren via GitGitGadget, git

I meant wrapper.c haha -- I'm also currently interested in doing the
same header cleanup you did in cache.h with git-compat-util.h

On Fri, Apr 7, 2023 at 12:08 AM Elijah Newren <newren@gmail.com> wrote:
>
> On Wed, Apr 5, 2023 at 10:30 AM Calvin Wan <calvinwan@google.com> wrote:
> >
> > "Elijah Newren via GitGitGadget" <gitgitgadget@gmail.com> writes:
> > > This series builds on en/header-cleanup
> > > (https://lore.kernel.org/git/pull.1485.v2.git.1677197376.gitgitgadget@gmail.com/)
> > > and en/header-split-cleanup
> > > (https://lore.kernel.org/git/pull.1493.v2.git.1679379968.gitgitgadget@gmail.com/),
> > > and continues to focus on splitting declarations from cache.h to separate
> > > headers. This series continues dropping the number of cache.h includes; in
> > > this series we go from 254 such includes to 190.
> > >
> > > The series may appear to be long at first glance, but is repetitive and
> > > simple. It should be relatively easy to review, and falls into roughly 3
> > > categories. An overview:
> > >
> > >  * Patches 1-6, 7: Being more explicit about dependencies. This was
> > >    motivated by the fact that trying to find unnecessary dependencies on
> > >    cache.h were being made harder by implicit dependencies on trace.h,
> > >    trace2.h, and advice.h that were included via cache.h. (Similar to
> > >    gettext.h handling in the previous series.) So I simply try to make
> > >    dependencies more explicit, for both these headers and a few others. To
> > >    make review easy, I split it into half a dozen patches, one header per
> > >    patch (well, except that I handle trace.h and trace2.h together). Patch 7
> > >    then removes several includes of cache.h that are no longer needed due to
> > >    patches 1-6.
> > >  * Patches 8-19: For several choices of FOO, move declarations of functions
> > >    for FOO.c from cache.h to FOO.h. To simplify reviewing, each case is
> > >    split into two patches, with the second patch cleaning up unnecessary
> > >    includes of cache.h in other source files.
> > >  * Patches 20-24: Other small manual cleanups noticed while doing above work
> > >
> > > Since patches 1-15 & 17-19 are just more of the same types of patches
> > > already reviewed in the last two series, it probably makes more sense for
> > > reviewers to focus on the other patches: 16 + 20-24 (which also happen to be
> > > smaller). I would particularly most like review of patches 16, 22, & 24
> > > since they are the least like any previously reviewed patches.
> >
> > Patches 1-15 a& 17-19 LGTM! Very welcome changes to see the size of
> > cache.h shrink after this and your previous series.
> >
> > I had the same change in patch 16 on a local branch, specifically moving
> > editor related functions from strbuf. The eventual dream for lower level
> > libraries such as strbuf is to separate out the functions that touch
> > higher level objects, allowing for the eventual libification of parts of
> > Git.
> >
> > Patch 20: removal of unnecessary headers are always welcome since it
> > allows readers to easily understand what dependencies a file has.
> >
> > Patch 21: I do have a suggestion that I will leave on the patch
> >
> > Patch 22: with what's currently in wrapper.h, it feels like it's
> > becoming the new dumping ground for functions that don't quite have a
> > home elsewhere. While I think this change makes sense right now, I do
> > hope in the future wrapper.h can be broken up with more reasonable
> > boundaries rather than "this function is a git-specific stdlib or
> > whatever lib function".
>
> Yeah, I wouldn't be surprised that we have multiple places needing
> cleanup.  I haven't looked much at wrapper.[ch] from this angle, but
> you got me curious and I took a brief glance.  Do you really mean
> wrapper.h, or wrapper.c?  wrapper.h is actually pretty small, only
> declaring 8 functions.  The other 32 non-static functions in wrapper.c
> are declared in git-compat-util.h.
>
> > Patch 23: same reasoning as with patch 20, swapping to more precise
> > headers clarifies file dependencies
> >
> > Patch 24: moving more items from the "dumping ground" to where they're
> > supposed to be :)
> >
> > Besides patch 21, the rest of the series LGTM, thanks!
>
> Thanks for taking a look!

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

* Re: [PATCH v2 21/24] strbuf: move forward declarations to beginning of file
  2023-04-10 15:52         ` Calvin Wan
@ 2023-04-10 16:47           ` Elijah Newren
  0 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-10 16:47 UTC (permalink / raw)
  To: Calvin Wan; +Cc: Elijah Newren via GitGitGadget, git

On Mon, Apr 10, 2023 at 8:52 AM Calvin Wan <calvinwan@google.com> wrote:
>
> I do have this change in one of my series already, and since I'm
> planning on removing the declarations anyways, dropping this patch for
> now would be my recommendation.

Cool, I'll submit a reroll tonight with this patch dropped.

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

* [PATCH v3 00/23] Header cleanups (splitting up cache.h)
  2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
                     ` (24 preceding siblings ...)
  2023-04-05 17:30   ` [PATCH v2 00/24] Header cleanups (splitting up cache.h) Calvin Wan
@ 2023-04-11  3:00   ` Elijah Newren via GitGitGadget
  2023-04-11  3:00     ` [PATCH v3 01/23] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
                       ` (6 more replies)
  25 siblings, 7 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-11  3:00 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren

Changes since v2:

 * Dropped patch 21 (Calvin is making more thorough changes to strbuf.[ch]
   in his series which will obsolete this patch and dropping it makes it
   easier to deconflict.)
 * Added Calvin's Acked-by to all the other patches.

Changes since v1:

 * Moved a few more things from cache.h to object.h, object-file.h, and
   object-name.h
 * Split the object.h changes into two patches to be more like all the other
   patches in 8-19
 * Squashed patches 22 & 23, since both were just manual replacements of
   cache.h inclusion with some other header
 * Removed a couple cases of duplicate inclusions of git-compat-util.h

Maintainer notes: (1) This series is based on a merge of
en/header-split-cleanup and ab/remove-implicit-use-of-the-repository (both
in next). (2) Although I've tweaked the series to minimize conflicts (and
this series merges syntactically cleanly with next and seen), there is a
semantic conflict with each of ja/worktree-orphan and
ab/tag-object-type-errors in seen; to correct, simply add an include of
advice.h in builtin/worktree.c and an include of gettext.h in tag.c,
respectively.

This series builds on en/header-cleanup
(https://lore.kernel.org/git/pull.1485.v2.git.1677197376.gitgitgadget@gmail.com/)
and en/header-split-cleanup
(https://lore.kernel.org/git/pull.1493.v2.git.1679379968.gitgitgadget@gmail.com/),
and continues to focus on splitting declarations from cache.h to separate
headers. This series continues dropping the number of cache.h includes; in
this series we go from 254 such includes to 190.

The series may appear to be long at first glance, but is repetitive and
simple. It should be relatively easy to review, and falls into roughly 3
categories. An overview:

 * Patches 1-6, 7: Being more explicit about dependencies. This was
   motivated by the fact that trying to find unnecessary dependencies on
   cache.h were being made harder by implicit dependencies on trace.h,
   trace2.h, and advice.h that were included via cache.h. (Similar to
   gettext.h handling in the previous series.) So I simply try to make
   dependencies more explicit, for both these headers and a few others. To
   make review easy, I split it into half a dozen patches, one header per
   patch (well, except that I handle trace.h and trace2.h together). Patch 7
   then removes several includes of cache.h that are no longer needed due to
   patches 1-6.
 * Patches 8-19: For several choices of FOO, move declarations of functions
   for FOO.c from cache.h to FOO.h. To simplify reviewing, each case is
   split into two patches, with the second patch cleaning up unnecessary
   includes of cache.h in other source files.
 * Patches 20-24: Other small manual cleanups noticed while doing above work

Since patches 1-15 & 17-19 are just more of the same types of patches
already reviewed in the last two series, it probably makes more sense for
reviewers to focus on the other patches: 16 + 20-24 (which also happen to be
smaller). I would particularly most like review of patches 16, 22, & 24
since they are the least like any previously reviewed patches.

There are more changes I plan to make after this series graduates (still
focused around splitting up cache.h), but this series was long enough.

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 trace.h & trace2.h
  treewide: be explicit about dependence on advice.h
  treewide: be explicit about dependence on convert.h
  treewide: be explicit about dependence on pack-revindex.h
  treewide: be explicit about dependence on oid-array.h
  treewide: be explicit about dependence on mem-pool.h
  treewide: remove unnecessary cache.h inclusion
  object-name.h: move declarations for object-name.c functions from
    cache.h
  treewide: remove cache.h inclusion due to object-name.h changes
  git-zlib: move declarations for git-zlib functions from cache.h
  treewide: remove cache.h inclusion due to git-zlib changes
  object-file.h: move declarations for object-file.c functions from
    cache.h
  treewide: remove cache.h inclusion due to object-file.h changes
  object.h: move some inline functions and defines from cache.h
  treewide: remove cache.h inclusion due to object.h changes
  editor: move editor-related functions and declarations into common
    file
  treewide: remove cache.h inclusion due to editor.h changes
  pager.h: move declarations for pager.c functions from cache.h
  treewide: remove cache.h inclusion due to pager.h changes
  cache.h: remove unnecessary includes
  treewide: remove double forward declaration of read_in_full
  treewide: reduce includes of cache.h in other headers
  mailmap, quote: move declarations of global vars to correct unit

 Makefile                                 |   2 +-
 add-patch.c                              |   3 +
 apply.c                                  |   2 +
 archive-tar.c                            |   1 +
 archive-zip.c                            |   1 +
 archive.c                                |   1 +
 archive.h                                |   3 +-
 bisect.c                                 |   3 +-
 blame.c                                  |   2 +
 branch.c                                 |   3 +-
 builtin/add.c                            |   2 +
 builtin/am.c                             |   4 +
 builtin/bisect.c                         |   2 +
 builtin/blame.c                          |   2 +
 builtin/branch.c                         |   2 +
 builtin/bugreport.c                      |   2 +
 builtin/cat-file.c                       |   3 +
 builtin/check-attr.c                     |   1 +
 builtin/checkout.c                       |   3 +
 builtin/clone.c                          |   3 +
 builtin/commit-graph.c                   |   1 +
 builtin/commit-tree.c                    |   1 +
 builtin/commit.c                         |   3 +
 builtin/config.c                         |   1 +
 builtin/credential-cache--daemon.c       |   1 +
 builtin/describe.c                       |   1 +
 builtin/diagnose.c                       |   1 +
 builtin/difftool.c                       |   1 +
 builtin/fast-export.c                    |   1 +
 builtin/fast-import.c                    |   2 +
 builtin/fetch-pack.c                     |   1 +
 builtin/fetch.c                          |   6 +
 builtin/fsck.c                           |   2 +
 builtin/fsmonitor--daemon.c              |   1 +
 builtin/gc.c                             |   2 +
 builtin/grep.c                           |   3 +
 builtin/hash-object.c                    |   1 +
 builtin/help.c                           |   1 +
 builtin/index-pack.c                     |   3 +
 builtin/init-db.c                        |   1 +
 builtin/log.c                            |   4 +
 builtin/ls-files.c                       |   2 +
 builtin/ls-tree.c                        |   1 +
 builtin/merge-base.c                     |   1 +
 builtin/merge-recursive.c                |   2 +
 builtin/merge-tree.c                     |   1 +
 builtin/merge.c                          |   3 +
 builtin/mktag.c                          |   1 +
 builtin/mv.c                             |   2 +
 builtin/name-rev.c                       |   2 +
 builtin/notes.c                          |   2 +
 builtin/pack-objects.c                   |   1 +
 builtin/prune.c                          |   2 +
 builtin/pull.c                           |   2 +
 builtin/push.c                           |   2 +
 builtin/range-diff.c                     |   1 +
 builtin/read-tree.c                      |   1 +
 builtin/rebase.c                         |   3 +
 builtin/receive-pack.c                   |   3 +
 builtin/replace.c                        |   3 +
 builtin/reset.c                          |   4 +
 builtin/rev-list.c                       |   2 +
 builtin/rev-parse.c                      |   1 +
 builtin/rm.c                             |   1 +
 builtin/show-branch.c                    |   1 +
 builtin/show-ref.c                       |   1 +
 builtin/sparse-checkout.c                |   2 +
 builtin/stash.c                          |   1 +
 builtin/submodule--helper.c              |   2 +
 builtin/tag.c                            |   3 +
 builtin/unpack-file.c                    |   1 +
 builtin/unpack-objects.c                 |   1 +
 builtin/update-index.c                   |   1 +
 builtin/update-ref.c                     |   1 +
 builtin/var.c                            |   2 +
 builtin/verify-commit.c                  |   1 +
 builtin/verify-tag.c                     |   1 +
 builtin/worktree.c                       |   2 +
 bulk-checkin.c                           |   4 +-
 bundle.c                                 |   2 +-
 cache-tree.c                             |   3 +
 cache.h                                  | 330 -----------------------
 chdir-notify.c                           |   4 +-
 checkout.c                               |   4 +-
 color.c                                  |   2 +
 column.c                                 |   3 +-
 combine-diff.c                           |   3 +
 commit-graph.c                           |   4 +-
 commit.c                                 |   3 +-
 common-main.c                            |   1 +
 compat/fsmonitor/fsm-listen-win32.c      |   1 +
 compat/mingw.c                           |   1 +
 compat/pread.c                           |   1 +
 compat/simple-ipc/ipc-unix-socket.c      |   3 +-
 compat/simple-ipc/ipc-win32.c            |   2 +
 compat/win32/trace2_win32_process_info.c |   1 +
 config.c                                 |   6 +
 connect.c                                |   2 +-
 convert.c                                |   3 +
 date.c                                   |   1 +
 delta-islands.c                          |   2 +-
 diff-lib.c                               |   2 +
 diff-no-index.c                          |   2 +-
 diff.c                                   |   5 +
 dir.c                                    |   3 +
 editor.c                                 |  34 ++-
 editor.h                                 |  34 +++
 environment.c                            |   4 +-
 exec-cmd.c                               |   2 +
 fetch-pack.c                             |   3 +-
 fmt-merge-msg.c                          |   3 +-
 fsck.c                                   |   2 +-
 fsmonitor.c                              |   1 +
 fsmonitor.h                              |   1 +
 git-compat-util.h                        |   6 -
 zlib.c => git-zlib.c                     |   3 +-
 git-zlib.h                               |  28 ++
 git.c                                    |   3 +
 grep.c                                   |   1 +
 http-backend.c                           |   3 +-
 http-fetch.c                             |   2 +-
 http-push.c                              |   2 +-
 http-walker.c                            |   2 +-
 http.c                                   |   2 +
 http.h                                   |   4 +-
 list-objects-filter.c                    |   3 +-
 list-objects.c                           |   2 +-
 ll-merge.c                               |   1 +
 log-tree.c                               |   3 +-
 mailmap.c                                |   3 +-
 mailmap.h                                |   3 +
 merge-ort.c                              |   4 +
 merge-recursive.c                        |   2 +
 midx.c                                   |   1 +
 name-hash.c                              |   1 +
 notes-merge.c                            |   6 +-
 notes.c                                  |   3 +-
 object-file.c                            |   2 +
 object-file.h                            | 129 +++++++++
 object-name.c                            |   2 +
 object-name.h                            | 121 +++++++++
 object.c                                 |   1 +
 object.h                                 |  44 +++
 pack-bitmap-write.c                      |   2 +-
 pack-bitmap.c                            |   4 +-
 pack-check.c                             |   3 +-
 pack-mtimes.c                            |   3 +-
 pack-revindex.c                          |   4 +-
 pack-write.c                             |   4 +-
 packfile.c                               |   3 +
 pager.c                                  |   6 +-
 pager.h                                  |  17 ++
 parse-options-cb.c                       |   2 +-
 path.c                                   |   1 +
 pkt-line.c                               |   1 +
 preload-index.c                          |   1 +
 pretty.c                                 |   3 +-
 progress.c                               |   4 +-
 promisor-remote.c                        |   3 +-
 protocol.c                               |   3 +-
 quote.c                                  |   3 +-
 quote.h                                  |   2 +
 range-diff.c                             |   2 +
 read-cache.c                             |   5 +
 rebase-interactive.c                     |   4 +-
 ref-filter.c                             |   2 +
 refs.c                                   |   4 +-
 refs/files-backend.c                     |   1 +
 refs/packed-backend.c                    |   1 +
 refs/ref-cache.h                         |   2 +-
 remote-curl.c                            |   1 +
 remote.c                                 |   3 +-
 repository.c                             |   1 +
 rerere.c                                 |   3 +-
 reset.c                                  |   1 +
 resolve-undo.h                           |   7 +-
 revision.c                               |   5 +-
 run-command.c                            |   2 +
 scalar.c                                 |   3 +-
 send-pack.c                              |   1 +
 sequencer.c                              |   4 +
 server-info.c                            |   1 +
 setup.c                                  |   5 +-
 shallow.c                                |   1 +
 sideband.c                               |   3 +-
 split-index.c                            |   1 +
 split-index.h                            |   2 +-
 strbuf.c                                 |  31 +--
 strbuf.h                                 |  24 --
 streaming.c                              |   4 +-
 submodule-config.c                       |   3 +-
 submodule.c                              |   3 +
 t/helper/test-date.c                     |   2 +-
 t/helper/test-fast-rebase.c              |   1 +
 t/helper/test-lazy-init-name-hash.c      |   1 +
 t/helper/test-match-trees.c              |   1 +
 t/helper/test-mergesort.c                |   1 +
 t/helper/test-oidmap.c                   |   2 +-
 t/helper/test-path-utils.c               |   1 +
 t/helper/test-reach.c                    |   2 +-
 t/helper/test-submodule-config.c         |   2 +-
 tag.c                                    |   3 +-
 tmp-objdir.c                             |   3 +-
 trace.c                                  |   3 +-
 trace2.c                                 |   1 +
 transport-helper.c                       |   3 +-
 transport.c                              |   5 +-
 tree-walk.c                              |   2 +
 tree.c                                   |   1 +
 unpack-trees.c                           |   2 +
 unpack-trees.h                           |   1 +
 upload-pack.c                            |   5 +-
 walker.c                                 |   2 +-
 wrapper.c                                |   1 +
 wt-status.c                              |   4 +
 215 files changed, 805 insertions(+), 458 deletions(-)
 create mode 100644 editor.h
 rename zlib.c => git-zlib.c (99%)
 create mode 100644 git-zlib.h
 create mode 100644 object-file.h
 create mode 100644 object-name.h
 create mode 100644 pager.h


base-commit: dc1c48a4a2bce29542f330137106c01daa728f9e
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1509%2Fnewren%2Fheader-cleanup-3-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1509/newren/header-cleanup-3-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1509

Range-diff vs v2:

  1:  6acf4eb2c77 !  1:  eb90e25c53e treewide: be explicit about dependence on trace.h & trace2.h
     @@ Commit message
          explicitly include trace.h or trace2.h if they are using them.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## blame.c ##
      @@
  2:  e163bed61ff !  2:  af2c81883f2 treewide: be explicit about dependence on advice.h
     @@ Commit message
          advice.h if they are using it.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## add-patch.c ##
      @@
  3:  4ef4ee9daf3 !  3:  146aaef8e6a treewide: be explicit about dependence on convert.h
     @@ Commit message
          treewide: be explicit about dependence on convert.h
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## archive.c ##
      @@
  4:  86b47be1776 !  4:  bcc35c33728 treewide: be explicit about dependence on pack-revindex.h
     @@ Commit message
          treewide: be explicit about dependence on pack-revindex.h
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## builtin/index-pack.c ##
      @@
  5:  81a9378be43 !  5:  f3c5ad2a2be treewide: be explicit about dependence on oid-array.h
     @@ Commit message
          treewide: be explicit about dependence on oid-array.h
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## builtin/bisect.c ##
      @@
  6:  c6a561cf433 !  6:  063298fec2d treewide: be explicit about dependence on mem-pool.h
     @@ Commit message
          treewide: be explicit about dependence on mem-pool.h
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## builtin/checkout.c ##
      @@
  7:  3c12d5ba6c3 !  7:  c80b25eed80 treewide: remove unnecessary cache.h inclusion
     @@ Commit message
          is no longer needed in several cases.  Remove it.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## compat/simple-ipc/ipc-unix-socket.c ##
      @@
  8:  1e2e60bffc7 !  8:  3559fbd7b7e object-name.h: move declarations for object-name.c functions from cache.h
     @@ Commit message
          object-name.h: move declarations for object-name.c functions from cache.h
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## add-patch.c ##
      @@
  9:  62f61514e2f !  9:  c930f9b2cad treewide: remove cache.h inclusion due to object-name.h changes
     @@ Commit message
          treewide: remove cache.h inclusion due to object-name.h changes
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## branch.c ##
      @@
 10:  54545bbb02c ! 10:  5e6f971d43f git-zlib: move declarations for git-zlib functions from cache.h
     @@ Commit message
          to git-zlib.c while we are at it.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## Makefile ##
      @@ Makefile: LIB_OBJS += fsmonitor.o
 11:  dbfe03129e3 ! 11:  74848b59f84 treewide: remove cache.h inclusion due to git-zlib changes
     @@ Commit message
          will help with several more files.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## http-backend.c ##
      @@
 12:  5efd49df148 ! 12:  78fd01017ee object-file.h: move declarations for object-file.c functions from cache.h
     @@ Commit message
          object-file.h: move declarations for object-file.c functions from cache.h
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## apply.c ##
      @@
 13:  1827ecb4d1d ! 13:  81313a5c304 treewide: remove cache.h inclusion due to object-file.h changes
     @@ Commit message
          treewide: remove cache.h inclusion due to object-file.h changes
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## bulk-checkin.c ##
      @@
 14:  8937f6d5ac5 ! 14:  2a43afb7951 object.h: move some inline functions and defines from cache.h
     @@ Commit message
          object.h.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## cache.h ##
      @@
 15:  c85f9baed8c ! 15:  29cf21b52d3 treewide: remove cache.h inclusion due to object.h changes
     @@ Commit message
          treewide: remove cache.h inclusion due to object.h changes
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## bisect.c ##
      @@
 16:  0ac095731a7 ! 16:  3b25f2880e5 editor: move editor-related functions and declarations into common file
     @@ Commit message
          editor.[ch].
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## add-patch.c ##
      @@
 17:  9550d976141 ! 17:  515eed36f3d treewide: remove cache.h inclusion due to editor.h changes
     @@ Commit message
          that will be applied.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## sideband.c ##
      @@
 18:  d658ee210d9 ! 18:  775332fdf12 pager.h: move declarations for pager.c functions from cache.h
     @@ Commit message
          pager.h: move declarations for pager.c functions from cache.h
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## builtin/am.c ##
      @@
 19:  07d1a65a0ec ! 19:  7fd8079a2ea treewide: remove cache.h inclusion due to pager.h changes
     @@ Commit message
          treewide: remove cache.h inclusion due to pager.h changes
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## column.c ##
      @@
 20:  23e0a81e788 ! 20:  8be1673ba37 cache.h: remove unnecessary includes
     @@ Commit message
          upon cache.h needed them either.  Simply expunge these includes.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## cache.h ##
      @@
 21:  47afc6a6c87 <  -:  ----------- strbuf: move forward declarations to beginning of file
 22:  6079c470cd1 ! 21:  6a853d51522 treewide: remove double forward declaration of read_in_full
     @@ Commit message
          declaration and just have compat/pread.c include wrapper.h.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## builtin/clone.c ##
      @@
 23:  538d95833a2 ! 22:  8c9260bc7b8 treewide: reduce includes of cache.h in other headers
     @@ Commit message
          defined in it.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## archive.h ##
      @@
 24:  30e37a37c12 ! 23:  4b09ea7d413 mailmap, quote: move declarations of global vars to correct unit
     @@ Commit message
          from cache.h to mailmap.c and quote.c.
      
          Signed-off-by: Elijah Newren <newren@gmail.com>
     +    Acked-by: Calvin Wan <calvinwan@google.com>
      
       ## cache.h ##
      @@ cache.h: void set_alternate_index_output(const char *);

-- 
gitgitgadget

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

* [PATCH v3 01/23] treewide: be explicit about dependence on trace.h & trace2.h
  2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
@ 2023-04-11  3:00     ` Elijah Newren via GitGitGadget
  2023-04-11  3:00     ` [PATCH v3 02/23] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
                       ` (5 subsequent siblings)
  6 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-11  3:00 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Dozens of files made use of trace and trace2 functions, without
explicitly including trace.h or trace2.h.  This made it more difficult
to find which files could remove a dependence on cache.h.  Make C files
explicitly include trace.h or trace2.h if they are using them.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 blame.c                                  | 1 +
 builtin/checkout.c                       | 1 +
 builtin/commit-graph.c                   | 1 +
 builtin/fetch.c                          | 2 ++
 builtin/fsmonitor--daemon.c              | 1 +
 builtin/gc.c                             | 1 +
 builtin/push.c                           | 1 +
 builtin/rebase.c                         | 1 +
 builtin/receive-pack.c                   | 2 ++
 builtin/reset.c                          | 2 ++
 cache-tree.c                             | 2 ++
 cache.h                                  | 2 --
 chdir-notify.c                           | 1 +
 common-main.c                            | 1 +
 compat/fsmonitor/fsm-listen-win32.c      | 1 +
 compat/mingw.c                           | 1 +
 compat/simple-ipc/ipc-unix-socket.c      | 1 +
 compat/simple-ipc/ipc-win32.c            | 2 ++
 compat/win32/trace2_win32_process_info.c | 1 +
 config.c                                 | 1 +
 connect.c                                | 1 +
 convert.c                                | 1 +
 diff-lib.c                               | 1 +
 dir.c                                    | 1 +
 environment.c                            | 1 +
 exec-cmd.c                               | 2 ++
 fetch-pack.c                             | 1 +
 fsmonitor.c                              | 1 +
 fsmonitor.h                              | 1 +
 git.c                                    | 2 ++
 http.c                                   | 1 +
 merge-ort.c                              | 1 +
 name-hash.c                              | 1 +
 notes-merge.c                            | 1 +
 pack-bitmap.c                            | 1 +
 pack-revindex.c                          | 1 +
 packfile.c                               | 1 +
 pkt-line.c                               | 1 +
 preload-index.c                          | 1 +
 progress.c                               | 1 +
 promisor-remote.c                        | 1 +
 protocol.c                               | 1 +
 read-cache.c                             | 1 +
 remote-curl.c                            | 1 +
 repository.c                             | 1 +
 revision.c                               | 1 +
 run-command.c                            | 2 ++
 scalar.c                                 | 1 +
 setup.c                                  | 1 +
 shallow.c                                | 1 +
 submodule.c                              | 1 +
 t/helper/test-date.c                     | 1 +
 t/helper/test-lazy-init-name-hash.c      | 1 +
 t/helper/test-path-utils.c               | 1 +
 trace.c                                  | 1 +
 trace2.c                                 | 1 +
 transport.c                              | 1 +
 tree-walk.c                              | 1 +
 unpack-trees.c                           | 1 +
 upload-pack.c                            | 1 +
 wrapper.c                                | 1 +
 wt-status.c                              | 2 ++
 62 files changed, 70 insertions(+), 2 deletions(-)

diff --git a/blame.c b/blame.c
index 62db9807640..3455f6a5ea3 100644
--- a/blame.c
+++ b/blame.c
@@ -9,6 +9,7 @@
 #include "hex.h"
 #include "setup.h"
 #include "tag.h"
+#include "trace2.h"
 #include "blame.h"
 #include "alloc.h"
 #include "commit-slab.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 38a8cd6a965..422ea768404 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "unpack-trees.h"
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 90114269761..a3d00fa232b 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -12,6 +12,7 @@
 #include "progress.h"
 #include "replace-object.h"
 #include "tag.h"
+#include "trace2.h"
 
 #define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \
 	N_("git commit-graph verify [--object-dir <dir>] [--shallow] [--[no-]progress]")
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 6a6a58d49c9..ffe0e214592 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -31,6 +31,8 @@
 #include "promisor-remote.h"
 #include "commit-graph.h"
 #include "shallow.h"
+#include "trace.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "bundle-uri.h"
 
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index a280d8bb14f..df876b41d65 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -14,6 +14,7 @@
 #include "simple-ipc.h"
 #include "khash.h"
 #include "pkt-line.h"
+#include "trace2.h"
 
 static const char * const builtin_fsmonitor__daemon_usage[] = {
 	N_("git fsmonitor--daemon start [<options>]"),
diff --git a/builtin/gc.c b/builtin/gc.c
index b291e23b13d..000a2ef5e11 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -37,6 +37,7 @@
 #include "gettext.h"
 #include "hook.h"
 #include "setup.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 #define FAILED_RUN "failed to run %s"
diff --git a/builtin/push.c b/builtin/push.c
index fa550b8f80a..a99ba38a368 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -16,6 +16,7 @@
 #include "submodule.h"
 #include "submodule-config.h"
 #include "send-pack.h"
+#include "trace2.h"
 #include "color.h"
 
 static const char * const push_usage[] = {
diff --git a/builtin/rebase.c b/builtin/rebase.c
index dbc8f90ef04..fb859f93a30 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -32,6 +32,7 @@
 #include "sequencer.h"
 #include "rebase-interactive.h"
 #include "reset.h"
+#include "trace2.h"
 #include "hook.h"
 #include "wrapper.h"
 
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index 2ba5a74ba7b..aa5b6fe861f 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -32,6 +32,8 @@
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
+#include "trace.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "shallow.h"
 #include "wrapper.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 0ed329236c8..4d639ec6b37 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -29,6 +29,8 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace.h"
+#include "trace2.h"
 #include "dir.h"
 #include "add-interactive.h"
 
diff --git a/cache-tree.c b/cache-tree.c
index ff14b527da3..39f0c744727 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -11,6 +11,8 @@
 #include "replace-object.h"
 #include "promisor-remote.h"
 #include "sparse-index.h"
+#include "trace.h"
+#include "trace2.h"
 
 #ifndef DEBUG_CACHE_TREE
 #define DEBUG_CACHE_TREE 0
diff --git a/cache.h b/cache.h
index 82d7b112b4e..c8ae80fded3 100644
--- a/cache.h
+++ b/cache.h
@@ -8,8 +8,6 @@
 #include "advice.h"
 #include "gettext.h"
 #include "convert.h"
-#include "trace.h"
-#include "trace2.h"
 #include "string-list.h"
 #include "pack-revindex.h"
 #include "hash.h"
diff --git a/chdir-notify.c b/chdir-notify.c
index 929ec01b3a2..8e38cd6f3ae 100644
--- a/chdir-notify.c
+++ b/chdir-notify.c
@@ -3,6 +3,7 @@
 #include "chdir-notify.h"
 #include "list.h"
 #include "strbuf.h"
+#include "trace.h"
 
 struct chdir_notify_entry {
 	const char *name;
diff --git a/common-main.c b/common-main.c
index b83cb5cf066..f3193173535 100644
--- a/common-main.c
+++ b/common-main.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "attr.h"
 #include "setup.h"
+#include "trace2.h"
 
 /*
  * Many parts of Git have subprograms communicate via pipe, expect the
diff --git a/compat/fsmonitor/fsm-listen-win32.c b/compat/fsmonitor/fsm-listen-win32.c
index 7b07b74ba5b..677b1bbdeca 100644
--- a/compat/fsmonitor/fsm-listen-win32.c
+++ b/compat/fsmonitor/fsm-listen-win32.c
@@ -4,6 +4,7 @@
 #include "fsm-listen.h"
 #include "fsmonitor--daemon.h"
 #include "gettext.h"
+#include "trace2.h"
 
 /*
  * The documentation of ReadDirectoryChangesW() states that the maximum
diff --git a/compat/mingw.c b/compat/mingw.c
index 94c5a1daa40..abbc3faf32f 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -12,6 +12,7 @@
 #include "win32/lazyload.h"
 #include "../config.h"
 #include "../environment.h"
+#include "../trace2.h"
 #include "../wrapper.h"
 #include "dir.h"
 #include "gettext.h"
diff --git a/compat/simple-ipc/ipc-unix-socket.c b/compat/simple-ipc/ipc-unix-socket.c
index 152db60a311..7064475b39f 100644
--- a/compat/simple-ipc/ipc-unix-socket.c
+++ b/compat/simple-ipc/ipc-unix-socket.c
@@ -4,6 +4,7 @@
 #include "strbuf.h"
 #include "pkt-line.h"
 #include "thread-utils.h"
+#include "trace2.h"
 #include "unix-socket.h"
 #include "unix-stream-server.h"
 
diff --git a/compat/simple-ipc/ipc-win32.c b/compat/simple-ipc/ipc-win32.c
index 997f6144344..6adce3c650e 100644
--- a/compat/simple-ipc/ipc-win32.c
+++ b/compat/simple-ipc/ipc-win32.c
@@ -5,6 +5,8 @@
 #include "strbuf.h"
 #include "pkt-line.h"
 #include "thread-utils.h"
+#include "trace.h"
+#include "trace2.h"
 #include "accctrl.h"
 #include "aclapi.h"
 
diff --git a/compat/win32/trace2_win32_process_info.c b/compat/win32/trace2_win32_process_info.c
index a53fd924340..e3e895c78a2 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 "../../trace2.h"
 #include "lazyload.h"
 #include <Psapi.h>
 #include <tlHelp32.h>
diff --git a/config.c b/config.c
index 5ad9ae91436..e5c2e477319 100644
--- a/config.c
+++ b/config.c
@@ -28,6 +28,7 @@
 #include "replace-object.h"
 #include "refs.h"
 #include "setup.h"
+#include "trace2.h"
 #include "worktree.h"
 #include "wrapper.h"
 #include "write-or-die.h"
diff --git a/connect.c b/connect.c
index 737dd906f72..929f72ec5d7 100644
--- a/connect.c
+++ b/connect.c
@@ -14,6 +14,7 @@
 #include "string-list.h"
 #include "oid-array.h"
 #include "transport.h"
+#include "trace2.h"
 #include "strbuf.h"
 #include "version.h"
 #include "protocol.h"
diff --git a/convert.c b/convert.c
index da06e2f51cb..126036ec330 100644
--- a/convert.c
+++ b/convert.c
@@ -9,6 +9,7 @@
 #include "sigchain.h"
 #include "pkt-line.h"
 #include "sub-process.h"
+#include "trace.h"
 #include "utf8.h"
 #include "ll-merge.h"
 #include "wrapper.h"
diff --git a/diff-lib.c b/diff-lib.c
index 4169dd8cb13..8b5cca96ace 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -13,6 +13,7 @@
 #include "unpack-trees.h"
 #include "refs.h"
 #include "submodule.h"
+#include "trace.h"
 #include "dir.h"
 #include "fsmonitor.h"
 #include "commit-reach.h"
diff --git a/dir.c b/dir.c
index 18fd14c46b2..10f6c38b930 100644
--- a/dir.c
+++ b/dir.c
@@ -23,6 +23,7 @@
 #include "fsmonitor.h"
 #include "setup.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 /*
diff --git a/environment.c b/environment.c
index 63c697e7e97..2254595e4a8 100644
--- a/environment.c
+++ b/environment.c
@@ -24,6 +24,7 @@
 #include "chdir-notify.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/exec-cmd.c b/exec-cmd.c
index fae0d4b244a..6f618463896 100644
--- a/exec-cmd.c
+++ b/exec-cmd.c
@@ -5,6 +5,8 @@
 #include "gettext.h"
 #include "quote.h"
 #include "strvec.h"
+#include "trace.h"
+#include "trace2.h"
 
 #if defined(RUNTIME_PREFIX)
 
diff --git a/fetch-pack.c b/fetch-pack.c
index 368f2ed25a1..7d4f190fb1d 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -17,6 +17,7 @@
 #include "remote.h"
 #include "run-command.h"
 #include "connect.h"
+#include "trace2.h"
 #include "transport.h"
 #include "version.h"
 #include "oid-array.h"
diff --git a/fsmonitor.c b/fsmonitor.c
index c956a347a27..28c083d4d84 100644
--- a/fsmonitor.c
+++ b/fsmonitor.c
@@ -7,6 +7,7 @@
 #include "fsmonitor-ipc.h"
 #include "run-command.h"
 #include "strbuf.h"
+#include "trace2.h"
 
 #define INDEX_EXTENSION_VERSION1	(1)
 #define INDEX_EXTENSION_VERSION2	(2)
diff --git a/fsmonitor.h b/fsmonitor.h
index edf7ce5203b..67faf592e12 100644
--- a/fsmonitor.h
+++ b/fsmonitor.h
@@ -4,6 +4,7 @@
 #include "cache.h"
 #include "dir.h"
 #include "fsmonitor-settings.h"
+#include "trace.h"
 
 extern struct trace_key trace_fsmonitor;
 
diff --git a/git.c b/git.c
index 77f920a6f6f..d2bb86e0d32 100644
--- a/git.c
+++ b/git.c
@@ -9,6 +9,8 @@
 #include "replace-object.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace.h"
+#include "trace2.h"
 
 #define RUN_SETUP		(1<<0)
 #define RUN_SETUP_GENTLY	(1<<1)
diff --git a/http.c b/http.c
index dbe4d29ef7a..0212c0ad3b2 100644
--- a/http.c
+++ b/http.c
@@ -12,6 +12,7 @@
 #include "version.h"
 #include "pkt-line.h"
 #include "gettext.h"
+#include "trace.h"
 #include "transport.h"
 #include "packfile.h"
 #include "protocol.h"
diff --git a/merge-ort.c b/merge-ort.c
index 5bf64354d16..ad7367179d9 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -37,6 +37,7 @@
 #include "strmap.h"
 #include "submodule-config.h"
 #include "submodule.h"
+#include "trace2.h"
 #include "tree.h"
 #include "unpack-trees.h"
 #include "xdiff-interface.h"
diff --git a/name-hash.c b/name-hash.c
index 2c2861efd1c..fb13716e430 100644
--- a/name-hash.c
+++ b/name-hash.c
@@ -9,6 +9,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "thread-utils.h"
+#include "trace.h"
 #include "trace2.h"
 #include "sparse-index.h"
 
diff --git a/notes-merge.c b/notes-merge.c
index c40107c3aa0..19405ec71ac 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -13,6 +13,7 @@
 #include "notes.h"
 #include "notes-merge.h"
 #include "strbuf.h"
+#include "trace.h"
 #include "notes-utils.h"
 #include "commit-reach.h"
 #include "wrapper.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 23d87e71bd9..eba838d24ee 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -15,6 +15,7 @@
 #include "pack-objects.h"
 #include "packfile.h"
 #include "repository.h"
+#include "trace2.h"
 #include "object-store.h"
 #include "list-objects-filter-options.h"
 #include "midx.h"
diff --git a/pack-revindex.c b/pack-revindex.c
index 03c7e81f9da..9f9927d9471 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -3,6 +3,7 @@
 #include "pack-revindex.h"
 #include "object-store.h"
 #include "packfile.h"
+#include "trace2.h"
 #include "config.h"
 #include "midx.h"
 
diff --git a/packfile.c b/packfile.c
index b120405ccc8..2d3dabb1aee 100644
--- a/packfile.c
+++ b/packfile.c
@@ -15,6 +15,7 @@
 #include "commit.h"
 #include "object.h"
 #include "tag.h"
+#include "trace.h"
 #include "tree-walk.h"
 #include "tree.h"
 #include "object-store.h"
diff --git a/pkt-line.c b/pkt-line.c
index 36ae0fea4a3..3561d853584 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "run-command.h"
+#include "trace.h"
 #include "wrapper.h"
 #include "write-or-die.h"
 
diff --git a/preload-index.c b/preload-index.c
index 52544d004e7..4abf9c983b2 100644
--- a/preload-index.c
+++ b/preload-index.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "thread-utils.h"
 #include "repository.h"
+#include "trace2.h"
 
 /*
  * Mostly randomly chosen maximum thread counts: we
diff --git a/progress.c b/progress.c
index 44c784d75f1..c5c8514737a 100644
--- a/progress.c
+++ b/progress.c
@@ -13,6 +13,7 @@
 #include "progress.h"
 #include "strbuf.h"
 #include "trace.h"
+#include "trace2.h"
 #include "utf8.h"
 #include "config.h"
 
diff --git a/promisor-remote.c b/promisor-remote.c
index a8dbb788e8f..9d83d2f4b9c 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -4,6 +4,7 @@
 #include "object-store.h"
 #include "promisor-remote.h"
 #include "config.h"
+#include "trace2.h"
 #include "transport.h"
 #include "strvec.h"
 #include "packfile.h"
diff --git a/protocol.c b/protocol.c
index bdb32e1eeb6..4d8eb887e82 100644
--- a/protocol.c
+++ b/protocol.c
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "environment.h"
 #include "protocol.h"
+#include "trace2.h"
 
 static enum protocol_version parse_protocol_version(const char *value)
 {
diff --git a/read-cache.c b/read-cache.c
index e5e72169047..a744eb89e4e 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -23,6 +23,7 @@
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
+#include "trace2.h"
 #include "varint.h"
 #include "split-index.h"
 #include "utf8.h"
diff --git a/remote-curl.c b/remote-curl.c
index 0f2410da8e7..0ada1dd8026 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -21,6 +21,7 @@
 #include "setup.h"
 #include "protocol.h"
 #include "quote.h"
+#include "trace2.h"
 #include "transport.h"
 #include "write-or-die.h"
 
diff --git a/repository.c b/repository.c
index f6d9f5db08e..c53e480e326 100644
--- a/repository.c
+++ b/repository.c
@@ -14,6 +14,7 @@
 #include "setup.h"
 #include "submodule-config.h"
 #include "sparse-index.h"
+#include "trace2.h"
 #include "promisor-remote.h"
 
 /* The main repository */
diff --git a/revision.c b/revision.c
index cd3e841433a..7c34c93885e 100644
--- a/revision.c
+++ b/revision.c
@@ -31,6 +31,7 @@
 #include "worktree.h"
 #include "setup.h"
 #include "strvec.h"
+#include "trace2.h"
 #include "commit-reach.h"
 #include "commit-graph.h"
 #include "prio-queue.h"
diff --git a/run-command.c b/run-command.c
index 614d48fa9a2..e64bb08a5bf 100644
--- a/run-command.c
+++ b/run-command.c
@@ -8,6 +8,8 @@
 #include "thread-utils.h"
 #include "strbuf.h"
 #include "string-list.h"
+#include "trace.h"
+#include "trace2.h"
 #include "quote.h"
 #include "config.h"
 #include "packfile.h"
diff --git a/scalar.c b/scalar.c
index 27635658c01..f7680463e1b 100644
--- a/scalar.c
+++ b/scalar.c
@@ -16,6 +16,7 @@
 #include "packfile.h"
 #include "help.h"
 #include "setup.h"
+#include "trace2.h"
 
 static void setup_enlistment_directory(int argc, const char **argv,
 				       const char * const *usagestr,
diff --git a/setup.c b/setup.c
index 6c5b85e96c1..3bb7a9fff62 100644
--- a/setup.c
+++ b/setup.c
@@ -10,6 +10,7 @@
 #include "chdir-notify.h"
 #include "promisor-remote.h"
 #include "quote.h"
+#include "trace2.h"
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
diff --git a/shallow.c b/shallow.c
index b4d726bd595..128f56179ed 100644
--- a/shallow.c
+++ b/shallow.c
@@ -17,6 +17,7 @@
 #include "list-objects.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "trace.h"
 #include "wrapper.h"
 
 void set_alternate_shallow_file(struct repository *r, const char *path, int override)
diff --git a/submodule.c b/submodule.c
index d7d0a8a0834..58c9d5e5673 100644
--- a/submodule.c
+++ b/submodule.c
@@ -28,6 +28,7 @@
 #include "commit-reach.h"
 #include "setup.h"
 #include "shallow.h"
+#include "trace2.h"
 
 static int config_update_recurse_submodules = RECURSE_SUBMODULES_OFF;
 static int initialized_fetch_ref_tips;
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index 45951b1df87..a01eec99f35 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "date.h"
+#include "trace.h"
 
 static const char *usage_msg = "\n"
 "  test-tool date relative [time_t]...\n"
diff --git a/t/helper/test-lazy-init-name-hash.c b/t/helper/test-lazy-init-name-hash.c
index 06ce3a47ccf..f23d983c118 100644
--- a/t/helper/test-lazy-init-name-hash.c
+++ b/t/helper/test-lazy-init-name-hash.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "parse-options.h"
 #include "setup.h"
+#include "trace.h"
 
 static int single;
 static int multi;
diff --git a/t/helper/test-path-utils.c b/t/helper/test-path-utils.c
index 4f5ac2fadce..6355c9e4b6d 100644
--- a/t/helper/test-path-utils.c
+++ b/t/helper/test-path-utils.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "setup.h"
 #include "string-list.h"
+#include "trace.h"
 #include "utf8.h"
 
 /*
diff --git a/trace.c b/trace.c
index 81318a2455d..d8eaa0a786a 100644
--- a/trace.c
+++ b/trace.c
@@ -26,6 +26,7 @@
 #include "environment.h"
 #include "quote.h"
 #include "setup.h"
+#include "trace.h"
 #include "wrapper.h"
 
 struct trace_key trace_default_key = { "GIT_TRACE", 0, 0, 0 };
diff --git a/trace2.c b/trace2.c
index e8ba62c0c3d..21264df71b7 100644
--- a/trace2.c
+++ b/trace2.c
@@ -7,6 +7,7 @@
 #include "thread-utils.h"
 #include "version.h"
 #include "trace.h"
+#include "trace2.h"
 #include "trace2/tr2_cfg.h"
 #include "trace2/tr2_cmd_name.h"
 #include "trace2/tr2_ctr.h"
diff --git a/transport.c b/transport.c
index d2a1af43b5c..11b38d16dcf 100644
--- a/transport.c
+++ b/transport.c
@@ -22,6 +22,7 @@
 #include "string-list.h"
 #include "oid-array.h"
 #include "sigchain.h"
+#include "trace2.h"
 #include "transport-internal.h"
 #include "protocol.h"
 #include "object-store.h"
diff --git a/tree-walk.c b/tree-walk.c
index 38b6556478d..59add24c8e9 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
+#include "trace2.h"
 #include "tree.h"
 #include "pathspec.h"
 #include "json-writer.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index 4a5522bdb26..d41489b4adb 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -17,6 +17,7 @@
 #include "sparse-index.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "trace2.h"
 #include "fsmonitor.h"
 #include "object-store.h"
 #include "promisor-remote.h"
diff --git a/upload-pack.c b/upload-pack.c
index e23f16dfdd2..71440c63806 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -22,6 +22,7 @@
 #include "version.h"
 #include "string-list.h"
 #include "strvec.h"
+#include "trace2.h"
 #include "prio-queue.h"
 #include "protocol.h"
 #include "quote.h"
diff --git a/wrapper.c b/wrapper.c
index ee837575902..c130d7518bf 100644
--- a/wrapper.c
+++ b/wrapper.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "config.h"
 #include "gettext.h"
+#include "trace2.h"
 #include "wrapper.h"
 
 static intmax_t count_fsync_writeout_only;
diff --git a/wt-status.c b/wt-status.c
index 4bef09de1ca..ccbfd9cc6de 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -18,6 +18,8 @@
 #include "column.h"
 #include "setup.h"
 #include "strbuf.h"
+#include "trace.h"
+#include "trace2.h"
 #include "utf8.h"
 #include "worktree.h"
 #include "lockfile.h"
-- 
gitgitgadget


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

* [PATCH v3 02/23] treewide: be explicit about dependence on advice.h
  2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
  2023-04-11  3:00     ` [PATCH v3 01/23] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
@ 2023-04-11  3:00     ` Elijah Newren via GitGitGadget
  2023-04-11  3:00     ` [PATCH v3 03/23] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
                       ` (4 subsequent siblings)
  6 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-11  3:00 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Dozens of files made use of advice functions, without explicitly
including advice.h.  This made it more difficult to find which files
could remove a dependence on cache.h.  Make C files explicitly include
advice.h if they are using it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 add-patch.c               | 1 +
 branch.c                  | 1 +
 builtin/add.c             | 1 +
 builtin/am.c              | 1 +
 builtin/clone.c           | 1 +
 builtin/commit.c          | 1 +
 builtin/fetch.c           | 1 +
 builtin/merge-recursive.c | 1 +
 builtin/merge.c           | 1 +
 builtin/mv.c              | 1 +
 builtin/pull.c            | 1 +
 builtin/push.c            | 1 +
 builtin/reset.c           | 1 +
 builtin/tag.c             | 1 +
 cache.h                   | 1 -
 config.c                  | 1 +
 convert.c                 | 1 +
 editor.c                  | 1 +
 notes-merge.c             | 1 +
 object-name.c             | 1 +
 refs.c                    | 1 +
 sequencer.c               | 1 +
 transport.c               | 1 +
 unpack-trees.c            | 1 +
 wt-status.c               | 1 +
 25 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/add-patch.c b/add-patch.c
index 1e1ee2df596..b381f14a7de 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "add-interactive.h"
+#include "advice.h"
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/branch.c b/branch.c
index 99a0e7889e4..3a087b8b4c1 100644
--- a/branch.c
+++ b/branch.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "branch.h"
 #include "environment.h"
diff --git a/builtin/add.c b/builtin/add.c
index f12054d9be1..d3c51e28142 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -5,6 +5,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "lockfile.h"
diff --git a/builtin/am.c b/builtin/am.c
index cd1e20f24e5..8d876f31546 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -6,6 +6,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "environment.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index c171def1f3e..f1e8aa3f27e 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -11,6 +11,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 9d8e1ea91a3..b09017e04f9 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -7,6 +7,7 @@
 
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "lockfile.h"
 #include "cache-tree.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index ffe0e214592..f2b80987751 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -2,6 +2,7 @@
  * "git fetch"
  */
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "gettext.h"
 #include "environment.h"
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 8ea9dc78aa1..25f42f2be7e 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "builtin.h"
+#include "advice.h"
 #include "commit.h"
 #include "gettext.h"
 #include "tag.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index a99be9610e9..225b7064066 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -9,6 +9,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index b7c5ffbd8c7..8f7770aa32b 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -6,6 +6,7 @@
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/builtin/pull.c b/builtin/pull.c
index 5405d09f22f..636ce12c94d 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -7,6 +7,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "gettext.h"
diff --git a/builtin/push.c b/builtin/push.c
index a99ba38a368..6001e4ae0a4 100644
--- a/builtin/push.c
+++ b/builtin/push.c
@@ -2,6 +2,7 @@
  * "git push"
  */
 #include "cache.h"
+#include "advice.h"
 #include "branch.h"
 #include "config.h"
 #include "environment.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 4d639ec6b37..d8c52cc6edf 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -9,6 +9,7 @@
  */
 #define USE_THE_INDEX_VARIABLE
 #include "builtin.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index bfd51389571..3e801f54a07 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -7,6 +7,7 @@
  */
 
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "builtin.h"
 #include "environment.h"
diff --git a/cache.h b/cache.h
index c8ae80fded3..d9ca2688d8c 100644
--- a/cache.h
+++ b/cache.h
@@ -5,7 +5,6 @@
 #include "strbuf.h"
 #include "hashmap.h"
 #include "list.h"
-#include "advice.h"
 #include "gettext.h"
 #include "convert.h"
 #include "string-list.h"
diff --git a/config.c b/config.c
index e5c2e477319..3cee6538f3f 100644
--- a/config.c
+++ b/config.c
@@ -7,6 +7,7 @@
  */
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "date.h"
 #include "branch.h"
diff --git a/convert.c b/convert.c
index 126036ec330..59127706448 100644
--- a/convert.c
+++ b/convert.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/editor.c b/editor.c
index d632d790660..3bea3ef72f7 100644
--- a/editor.c
+++ b/editor.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/notes-merge.c b/notes-merge.c
index 19405ec71ac..0258f87d21f 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
diff --git a/object-name.c b/object-name.c
index 53f9d359ee8..ff647d6c7b5 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/refs.c b/refs.c
index 0f369dbde7a..cfced6f174a 100644
--- a/refs.c
+++ b/refs.c
@@ -3,6 +3,7 @@
  */
 
 #include "cache.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/sequencer.c b/sequencer.c
index 1a315ac13c9..eaba379e3ad 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "abspath.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/transport.c b/transport.c
index 11b38d16dcf..82bf2496ba7 100644
--- a/transport.c
+++ b/transport.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index d41489b4adb..c6de2ca5a7e 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "strvec.h"
 #include "repository.h"
 #include "config.h"
diff --git a/wt-status.c b/wt-status.c
index ccbfd9cc6de..47f223c0f8d 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "advice.h"
 #include "wt-status.h"
 #include "object.h"
 #include "dir.h"
-- 
gitgitgadget


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

* [PATCH v3 03/23] treewide: be explicit about dependence on convert.h
  2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
  2023-04-11  3:00     ` [PATCH v3 01/23] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
  2023-04-11  3:00     ` [PATCH v3 02/23] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
@ 2023-04-11  3:00     ` Elijah Newren via GitGitGadget
  2023-04-11  3:00     ` [PATCH v3 04/23] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
                       ` (3 subsequent siblings)
  6 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-11  3:00 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 archive.c          | 1 +
 blame.c            | 1 +
 builtin/cat-file.c | 1 +
 builtin/ls-files.c | 1 +
 cache.h            | 1 -
 combine-diff.c     | 1 +
 config.c           | 1 +
 convert.c          | 1 +
 diff.c             | 1 +
 dir.c              | 1 +
 environment.c      | 1 +
 ll-merge.c         | 1 +
 object-file.c      | 1 +
 streaming.c        | 1 +
 unpack-trees.h     | 1 +
 15 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/archive.c b/archive.c
index f1b8e9ce486..ab8966d73a5 100644
--- a/archive.c
+++ b/archive.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/blame.c b/blame.c
index 3455f6a5ea3..ff2a6c49125 100644
--- a/blame.c
+++ b/blame.c
@@ -3,6 +3,7 @@
 #include "object-store.h"
 #include "cache-tree.h"
 #include "mergesort.h"
+#include "convert.h"
 #include "diff.h"
 #include "diffcore.h"
 #include "gettext.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 04d4bb6c777..1e4b4798f40 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "builtin.h"
 #include "diff.h"
 #include "environment.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 68532f3e51a..7f228353feb 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -8,6 +8,7 @@
 #include "cache.h"
 #include "repository.h"
 #include "config.h"
+#include "convert.h"
 #include "quote.h"
 #include "dir.h"
 #include "builtin.h"
diff --git a/cache.h b/cache.h
index d9ca2688d8c..415f0f85670 100644
--- a/cache.h
+++ b/cache.h
@@ -6,7 +6,6 @@
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
-#include "convert.h"
 #include "string-list.h"
 #include "pack-revindex.h"
 #include "hash.h"
diff --git a/combine-diff.c b/combine-diff.c
index 44ef6a1a812..6586e4508d6 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "object-store.h"
 #include "commit.h"
+#include "convert.h"
 #include "blob.h"
 #include "diff.h"
 #include "diffcore.h"
diff --git a/config.c b/config.c
index 3cee6538f3f..9e74b5aec7f 100644
--- a/config.c
+++ b/config.c
@@ -12,6 +12,7 @@
 #include "date.h"
 #include "branch.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "ident.h"
diff --git a/convert.c b/convert.c
index 59127706448..5a2ea5308d6 100644
--- a/convert.c
+++ b/convert.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "advice.h"
 #include "config.h"
+#include "convert.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/diff.c b/diff.c
index e55a015cfd0..47c1973a504 100644
--- a/diff.c
+++ b/diff.c
@@ -5,6 +5,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "tempfile.h"
diff --git a/dir.c b/dir.c
index 10f6c38b930..d1f1b1ef768 100644
--- a/dir.c
+++ b/dir.c
@@ -9,6 +9,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/environment.c b/environment.c
index 2254595e4a8..e57292eccc9 100644
--- a/environment.c
+++ b/environment.c
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "abspath.h"
 #include "branch.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "repository.h"
diff --git a/ll-merge.c b/ll-merge.c
index 8be38d3bd41..28bc94c45d6 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -6,6 +6,7 @@
 
 #include "cache.h"
 #include "config.h"
+#include "convert.h"
 #include "attr.h"
 #include "xdiff-interface.h"
 #include "run-command.h"
diff --git a/object-file.c b/object-file.c
index 76b22ca75cd..a4331e0da61 100644
--- a/object-file.c
+++ b/object-file.c
@@ -10,6 +10,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
+#include "convert.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/streaming.c b/streaming.c
index 024fd796b7d..27e014d8b23 100644
--- a/streaming.c
+++ b/streaming.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2011, Google Inc.
  */
 #include "cache.h"
+#include "convert.h"
 #include "environment.h"
 #include "streaming.h"
 #include "repository.h"
diff --git a/unpack-trees.h b/unpack-trees.h
index 61c06eb7c50..30622aeebff 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -2,6 +2,7 @@
 #define UNPACK_TREES_H
 
 #include "cache.h"
+#include "convert.h"
 #include "strvec.h"
 #include "string-list.h"
 #include "tree-walk.h"
-- 
gitgitgadget


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

* [PATCH v3 04/23] treewide: be explicit about dependence on pack-revindex.h
  2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
                       ` (2 preceding siblings ...)
  2023-04-11  3:00     ` [PATCH v3 03/23] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
@ 2023-04-11  3:00     ` Elijah Newren via GitGitGadget
  2023-04-11  3:00     ` [PATCH v3 05/23] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
                       ` (2 subsequent siblings)
  6 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-11  3:00 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 builtin/index-pack.c | 1 +
 cache.h              | 1 -
 pack-write.c         | 1 +
 packfile.c           | 1 +
 4 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index b17e79cd40f..ceb0f120ede 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -17,6 +17,7 @@
 #include "streaming.h"
 #include "thread-utils.h"
 #include "packfile.h"
+#include "pack-revindex.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/cache.h b/cache.h
index 415f0f85670..5f1279454a8 100644
--- a/cache.h
+++ b/cache.h
@@ -7,7 +7,6 @@
 #include "list.h"
 #include "gettext.h"
 #include "string-list.h"
-#include "pack-revindex.h"
 #include "hash.h"
 #include "path.h"
 #include "pathspec.h"
diff --git a/pack-write.c b/pack-write.c
index f1714054951..152c14aa7aa 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -9,6 +9,7 @@
 #include "pack-mtimes.h"
 #include "oidmap.h"
 #include "pack-objects.h"
+#include "pack-revindex.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
 {
diff --git a/packfile.c b/packfile.c
index 2d3dabb1aee..02afbe77137 100644
--- a/packfile.c
+++ b/packfile.c
@@ -21,6 +21,7 @@
 #include "object-store.h"
 #include "midx.h"
 #include "commit-graph.h"
+#include "pack-revindex.h"
 #include "promisor-remote.h"
 #include "wrapper.h"
 
-- 
gitgitgadget


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

* [PATCH v3 05/23] treewide: be explicit about dependence on oid-array.h
  2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
                       ` (3 preceding siblings ...)
  2023-04-11  3:00     ` [PATCH v3 04/23] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
@ 2023-04-11  3:00     ` Elijah Newren via GitGitGadget
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
  2023-04-11  7:47     ` [PATCH v3 00/23] Header cleanups (splitting up cache.h) Elijah Newren
  6 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren via GitGitGadget @ 2023-04-11  3:00 UTC (permalink / raw)
  To: git; +Cc: Calvin Wan, Elijah Newren, Elijah Newren, Elijah Newren

From: Elijah Newren <newren@gmail.com>

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 builtin/bisect.c     | 1 +
 builtin/fetch.c      | 1 +
 builtin/index-pack.c | 1 +
 builtin/log.c        | 1 +
 cache.h              | 1 -
 commit-graph.c       | 1 +
 diff.c               | 1 +
 merge-ort.c          | 1 +
 read-cache.c         | 1 +
 ref-filter.c         | 1 +
 upload-pack.c        | 1 +
 11 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/builtin/bisect.c b/builtin/bisect.c
index 26f07357a03..7dc175c6570 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -9,6 +9,7 @@
 #include "dir.h"
 #include "strvec.h"
 #include "run-command.h"
+#include "oid-array.h"
 #include "prompt.h"
 #include "quote.h"
 #include "revision.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index f2b80987751..e0936629213 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -12,6 +12,7 @@
 #include "refspec.h"
 #include "object-store.h"
 #include "oidset.h"
+#include "oid-array.h"
 #include "commit.h"
 #include "builtin.h"
 #include "string-list.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index ceb0f120ede..5adfb2521cd 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -19,6 +19,7 @@
 #include "packfile.h"
 #include "pack-revindex.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
 #include "setup.h"
diff --git a/builtin/log.c b/builtin/log.c
index 2ce645eee97..094897df236 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -20,6 +20,7 @@
 #include "revision.h"
 #include "log-tree.h"
 #include "builtin.h"
+#include "oid-array.h"
 #include "tag.h"
 #include "reflog-walk.h"
 #include "patch-ids.h"
diff --git a/cache.h b/cache.h
index 5f1279454a8..6eac3134a22 100644
--- a/cache.h
+++ b/cache.h
@@ -11,7 +11,6 @@
 #include "path.h"
 #include "pathspec.h"
 #include "object.h"
-#include "oid-array.h"
 #include "repository.h"
 #include "statinfo.h"
 #include "mem-pool.h"
diff --git a/commit-graph.c b/commit-graph.c
index 1bf673b1345..fe9a8b2342f 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -12,6 +12,7 @@
 #include "hash-lookup.h"
 #include "commit-graph.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "alloc.h"
 #include "hashmap.h"
 #include "replace-object.h"
diff --git a/diff.c b/diff.c
index 47c1973a504..89cd0b17da5 100644
--- a/diff.c
+++ b/diff.c
@@ -29,6 +29,7 @@
 #include "string-list.h"
 #include "strvec.h"
 #include "graph.h"
+#include "oid-array.h"
 #include "packfile.h"
 #include "parse-options.h"
 #include "help.h"
diff --git a/merge-ort.c b/merge-ort.c
index ad7367179d9..9b0b184b130 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -32,6 +32,7 @@
 #include "entry.h"
 #include "ll-merge.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "promisor-remote.h"
 #include "revision.h"
 #include "strmap.h"
diff --git a/read-cache.c b/read-cache.c
index a744eb89e4e..1b585ce8424 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -15,6 +15,7 @@
 #include "refs.h"
 #include "dir.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "tree.h"
 #include "commit.h"
 #include "blob.h"
diff --git a/ref-filter.c b/ref-filter.c
index df84bb71643..1c6174c8aed 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -7,6 +7,7 @@
 #include "refs.h"
 #include "wildmatch.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "repository.h"
 #include "commit.h"
 #include "remote.h"
diff --git a/upload-pack.c b/upload-pack.c
index 71440c63806..e17545a834a 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -8,6 +8,7 @@
 #include "sideband.h"
 #include "repository.h"
 #include "object-store.h"
+#include "oid-array.h"
 #include "tag.h"
 #include "object.h"
 #include "commit.h"
-- 
gitgitgadget


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

* [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h
  2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
                       ` (4 preceding siblings ...)
  2023-04-11  3:00     ` [PATCH v3 05/23] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
@ 2023-04-11  7:41     ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 07/23] treewide: remove unnecessary cache.h inclusion Elijah Newren
                         ` (16 more replies)
  2023-04-11  7:47     ` [PATCH v3 00/23] Header cleanups (splitting up cache.h) Elijah Newren
  6 siblings, 17 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 builtin/checkout.c        | 1 +
 cache.h                   | 1 -
 merge-ort.c               | 1 +
 read-cache.c              | 1 +
 split-index.c             | 1 +
 t/helper/test-mergesort.c | 1 +
 6 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/builtin/checkout.c b/builtin/checkout.c
index 422ea768404..65988fd8a3b 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -15,6 +15,7 @@
 #include "hook.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "mem-pool.h"
 #include "merge-recursive.h"
 #include "object-store.h"
 #include "parse-options.h"
diff --git a/cache.h b/cache.h
index 6eac3134a22..66705dd469e 100644
--- a/cache.h
+++ b/cache.h
@@ -13,7 +13,6 @@
 #include "object.h"
 #include "repository.h"
 #include "statinfo.h"
-#include "mem-pool.h"
 
 typedef struct git_zstream {
 	z_stream z;
diff --git a/merge-ort.c b/merge-ort.c
index 9b0b184b130..1008684fbbc 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -31,6 +31,7 @@
 #include "hex.h"
 #include "entry.h"
 #include "ll-merge.h"
+#include "mem-pool.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "promisor-remote.h"
diff --git a/read-cache.c b/read-cache.c
index 1b585ce8424..4ada6d62b90 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -21,6 +21,7 @@
 #include "blob.h"
 #include "environment.h"
 #include "gettext.h"
+#include "mem-pool.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/split-index.c b/split-index.c
index c98807c655b..5602b74994b 100644
--- a/split-index.c
+++ b/split-index.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "mem-pool.h"
 #include "split-index.h"
 #include "ewah/ewok.h"
 
diff --git a/t/helper/test-mergesort.c b/t/helper/test-mergesort.c
index 335e5bb3a90..737e0c52358 100644
--- a/t/helper/test-mergesort.c
+++ b/t/helper/test-mergesort.c
@@ -1,5 +1,6 @@
 #include "test-tool.h"
 #include "cache.h"
+#include "mem-pool.h"
 #include "mergesort.h"
 
 static uint32_t minstd_rand(uint32_t *state)
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 07/23] treewide: remove unnecessary cache.h inclusion
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-15 11:06         ` [PATCH/RFD] fix connection via git protocol Michael J Gruber
  2023-04-11  7:41       ` [PATCH v3 08/23] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren
                         ` (15 subsequent siblings)
  16 siblings, 1 reply; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Several files were including cache.h solely to get other headers, such
as trace.h and trace2.h.  Since the last few commits have modified
files to make these dependencies more explicit, the inclusion of cache.h
is no longer needed in several cases.  Remove it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 compat/simple-ipc/ipc-unix-socket.c | 2 +-
 connect.c                           | 1 -
 fetch-pack.c                        | 2 +-
 pack-write.c                        | 2 +-
 promisor-remote.c                   | 2 +-
 protocol.c                          | 2 +-
 scalar.c                            | 2 +-
 t/helper/test-date.c                | 1 -
 trace.c                             | 2 +-
 upload-pack.c                       | 2 +-
 10 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/compat/simple-ipc/ipc-unix-socket.c b/compat/simple-ipc/ipc-unix-socket.c
index 7064475b39f..b2f4f22ce44 100644
--- a/compat/simple-ipc/ipc-unix-socket.c
+++ b/compat/simple-ipc/ipc-unix-socket.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "simple-ipc.h"
 #include "strbuf.h"
diff --git a/connect.c b/connect.c
index 929f72ec5d7..5d8036197d5 100644
--- a/connect.c
+++ b/connect.c
@@ -1,5 +1,4 @@
 #include "git-compat-util.h"
-#include "cache.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/fetch-pack.c b/fetch-pack.c
index 7d4f190fb1d..677102465a1 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "repository.h"
 #include "config.h"
diff --git a/pack-write.c b/pack-write.c
index 152c14aa7aa..d9b460fab4c 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/promisor-remote.c b/promisor-remote.c
index 9d83d2f4b9c..1adcd6fb0a5 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/protocol.c b/protocol.c
index 4d8eb887e82..079ba75acf4 100644
--- a/protocol.c
+++ b/protocol.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "protocol.h"
diff --git a/scalar.c b/scalar.c
index f7680463e1b..af64f75ca66 100644
--- a/scalar.c
+++ b/scalar.c
@@ -2,7 +2,7 @@
  * The Scalar command-line interface.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "gettext.h"
 #include "parse-options.h"
diff --git a/t/helper/test-date.c b/t/helper/test-date.c
index a01eec99f35..7adadd41e0b 100644
--- a/t/helper/test-date.c
+++ b/t/helper/test-date.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "date.h"
 #include "trace.h"
 
diff --git a/trace.c b/trace.c
index d8eaa0a786a..592c141d785 100644
--- a/trace.c
+++ b/trace.c
@@ -21,7 +21,7 @@
  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
 #include "quote.h"
diff --git a/upload-pack.c b/upload-pack.c
index e17545a834a..0305fb2fbdc 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 08/23] object-name.h: move declarations for object-name.c functions from cache.h
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 07/23] treewide: remove unnecessary cache.h inclusion Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 09/23] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren
                         ` (14 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 add-patch.c                      |   1 +
 apply.c                          |   1 +
 archive.h                        |   1 +
 bisect.c                         |   1 +
 branch.c                         |   1 +
 builtin/am.c                     |   1 +
 builtin/bisect.c                 |   1 +
 builtin/blame.c                  |   1 +
 builtin/branch.c                 |   1 +
 builtin/cat-file.c               |   1 +
 builtin/check-attr.c             |   1 +
 builtin/checkout.c               |   1 +
 builtin/commit-tree.c            |   1 +
 builtin/commit.c                 |   1 +
 builtin/describe.c               |   1 +
 builtin/fast-import.c            |   1 +
 builtin/fetch.c                  |   1 +
 builtin/fsck.c                   |   1 +
 builtin/grep.c                   |   1 +
 builtin/log.c                    |   1 +
 builtin/ls-files.c               |   1 +
 builtin/ls-tree.c                |   1 +
 builtin/merge-base.c             |   1 +
 builtin/merge-recursive.c        |   1 +
 builtin/merge-tree.c             |   1 +
 builtin/merge.c                  |   1 +
 builtin/name-rev.c               |   1 +
 builtin/notes.c                  |   1 +
 builtin/prune.c                  |   1 +
 builtin/pull.c                   |   1 +
 builtin/range-diff.c             |   1 +
 builtin/read-tree.c              |   1 +
 builtin/rebase.c                 |   1 +
 builtin/receive-pack.c           |   1 +
 builtin/replace.c                |   1 +
 builtin/reset.c                  |   1 +
 builtin/rev-list.c               |   1 +
 builtin/rev-parse.c              |   1 +
 builtin/rm.c                     |   1 +
 builtin/show-branch.c            |   1 +
 builtin/show-ref.c               |   1 +
 builtin/sparse-checkout.c        |   1 +
 builtin/stash.c                  |   1 +
 builtin/submodule--helper.c      |   1 +
 builtin/tag.c                    |   1 +
 builtin/unpack-file.c            |   1 +
 builtin/update-ref.c             |   1 +
 builtin/verify-commit.c          |   1 +
 builtin/verify-tag.c             |   1 +
 builtin/worktree.c               |   1 +
 cache.h                          | 110 ----------------------------
 checkout.c                       |   1 +
 combine-diff.c                   |   1 +
 commit.c                         |   1 +
 config.c                         |   1 +
 diff-lib.c                       |   1 +
 diff.c                           |   1 +
 fmt-merge-msg.c                  |   1 +
 list-objects-filter.c            |   1 +
 log-tree.c                       |   1 +
 mailmap.c                        |   1 +
 merge-ort.c                      |   1 +
 merge-recursive.c                |   1 +
 notes-merge.c                    |   1 +
 notes.c                          |   1 +
 object-name.c                    |   1 +
 object-name.h                    | 121 +++++++++++++++++++++++++++++++
 parse-options-cb.c               |   1 +
 range-diff.c                     |   1 +
 read-cache.c                     |   1 +
 rebase-interactive.c             |   1 +
 ref-filter.c                     |   1 +
 refs.c                           |   1 +
 remote.c                         |   1 +
 reset.c                          |   1 +
 revision.c                       |   1 +
 sequencer.c                      |   1 +
 setup.c                          |   1 +
 strbuf.c                         |   1 +
 submodule-config.c               |   1 +
 submodule.c                      |   1 +
 t/helper/test-fast-rebase.c      |   1 +
 t/helper/test-match-trees.c      |   1 +
 t/helper/test-oidmap.c           |   1 +
 t/helper/test-reach.c            |   1 +
 t/helper/test-submodule-config.c |   1 +
 tag.c                            |   1 +
 transport-helper.c               |   1 +
 transport.c                      |   1 +
 tree.c                           |   1 +
 wt-status.c                      |   1 +
 91 files changed, 210 insertions(+), 110 deletions(-)
 create mode 100644 object-name.h

diff --git a/add-patch.c b/add-patch.c
index b381f14a7de..b01ba8fa81d 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -4,6 +4,7 @@
 #include "alloc.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "run-command.h"
 #include "strvec.h"
diff --git a/apply.c b/apply.c
index 9b7288bc927..7e40f53ec4c 100644
--- a/apply.c
+++ b/apply.c
@@ -22,6 +22,7 @@
 #include "xdiff-interface.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "rerere.h"
diff --git a/archive.h b/archive.h
index 7178e2a9a2d..f96839ef383 100644
--- a/archive.h
+++ b/archive.h
@@ -2,6 +2,7 @@
 #define ARCHIVE_H
 
 #include "cache.h"
+#include "object-name.h"
 #include "pathspec.h"
 
 struct repository;
diff --git a/bisect.c b/bisect.c
index 0a5f2ed3546..e708e8b6aa1 100644
--- a/bisect.c
+++ b/bisect.c
@@ -17,6 +17,7 @@
 #include "strvec.h"
 #include "commit-slab.h"
 #include "commit-reach.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "dir.h"
 
diff --git a/branch.c b/branch.c
index 3a087b8b4c1..f29743b1619 100644
--- a/branch.c
+++ b/branch.c
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "refspec.h"
 #include "remote.h"
diff --git a/builtin/am.c b/builtin/am.c
index 8d876f31546..0d7ee28bddc 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -27,6 +27,7 @@
 #include "diffcore.h"
 #include "unpack-trees.h"
 #include "branch.h"
+#include "object-name.h"
 #include "sequencer.h"
 #include "revision.h"
 #include "merge-recursive.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 7dc175c6570..4b2143d4557 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "bisect.h"
 #include "refs.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index a8d2114adc9..a628388c2ce 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -28,6 +28,7 @@
 #include "line-log.h"
 #include "dir.h"
 #include "progress.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blame.h"
 #include "refs.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index 5706eb00974..7c1c872708f 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -13,6 +13,7 @@
 #include "commit.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "remote.h"
 #include "parse-options.h"
 #include "branch.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 1e4b4798f40..60b7a55dfc1 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -20,6 +20,7 @@
 #include "tree-walk.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 1dbe9d6ca88..037bf1aaa2a 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -5,6 +5,7 @@
 #include "attr.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "quote.h"
 #include "setup.h"
 #include "parse-options.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 65988fd8a3b..6f5d82ed3d3 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -17,6 +17,7 @@
 #include "lockfile.h"
 #include "mem-pool.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "refs.h"
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index 15be167f87a..d1d251c3ded 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index b09017e04f9..682f47c8d5a 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -27,6 +27,7 @@
 #include "log-tree.h"
 #include "strbuf.h"
 #include "utf8.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "rerere.h"
diff --git a/builtin/describe.c b/builtin/describe.c
index 0125d4ddbac..d360b1d12af 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "revision.h"
 #include "diff.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 68b1a539870..31b8732128d 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "mem-pool.h"
 #include "commit-reach.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index e0936629213..8a8ab6799e8 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -10,6 +10,7 @@
 #include "repository.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oidset.h"
 #include "oid-array.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 095b39d3980..04bc71d148c 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -19,6 +19,7 @@
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "resolve-undo.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index a1b68d90bdb..f66e14389e1 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
 #include "write-or-die.h"
diff --git a/builtin/log.c b/builtin/log.c
index 094897df236..5cdc2276cc4 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -12,6 +12,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "color.h"
 #include "commit.h"
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index 7f228353feb..ce083cb8efd 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -13,6 +13,7 @@
 #include "dir.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "strbuf.h"
 #include "tree.h"
 #include "cache-tree.h"
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index f32e6be2198..077977a4610 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 3f22273b400..854019a32dc 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -7,6 +7,7 @@
 #include "refs.h"
 #include "diff.h"
 #include "revision.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "repository.h"
 #include "commit-reach.h"
diff --git a/builtin/merge-recursive.c b/builtin/merge-recursive.c
index 25f42f2be7e..fa1035405c3 100644
--- a/builtin/merge-recursive.c
+++ b/builtin/merge-recursive.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "tag.h"
 #include "merge-recursive.h"
+#include "object-name.h"
 #include "xdiff-interface.h"
 
 static const char builtin_merge_recursive_usage[] =
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 803e380856e..6b9f006ec19 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -8,6 +8,7 @@
 #include "commit.h"
 #include "commit-reach.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "repository.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 225b7064066..693f185d4d3 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -15,6 +15,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "builtin.h"
 #include "lockfile.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 831d360a78a..41fd56b9ba9 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -8,6 +8,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "refs.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "hash-lookup.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 4ff44f1e3d0..896140b9055 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -13,6 +13,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "blob.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index 5c0952f5c64..09891832fb3 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "prune-packed.h"
 #include "replace-object.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "shallow.h"
 
diff --git a/builtin/pull.c b/builtin/pull.c
index 636ce12c94d..967368ebc65 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -12,6 +12,7 @@
 #include "builtin.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "exec-cmd.h"
 #include "run-command.h"
diff --git a/builtin/range-diff.c b/builtin/range-diff.c
index b72af527f08..04339a92ea5 100644
--- a/builtin/range-diff.c
+++ b/builtin/range-diff.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "range-diff.h"
 #include "config.h"
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 600d4f748fc..d61cbad96de 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -11,6 +11,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "object.h"
+#include "object-name.h"
 #include "tree.h"
 #include "tree-walk.h"
 #include "cache-tree.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index fb859f93a30..ff5dd77608d 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -21,6 +21,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index aa5b6fe861f..7d921170f1c 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -29,6 +29,7 @@
 #include "tmp-objdir.h"
 #include "oidset.h"
 #include "packfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "protocol.h"
 #include "commit-reach.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index d2adc8ab613..134f738a450 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -17,6 +17,7 @@
 #include "refs.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "repository.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index d8c52cc6edf..f99f32d5802 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -24,6 +24,7 @@
 #include "diffcore.h"
 #include "tree.h"
 #include "branch.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "unpack-trees.h"
 #include "cache-tree.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index a3dbbb6338e..c17f0282ae8 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -10,6 +10,7 @@
 #include "list-objects-filter.h"
 #include "list-objects-filter-options.h"
 #include "object.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-bitmap.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index 1af2089f9bd..852e49e3403 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -15,6 +15,7 @@
 #include "refs.h"
 #include "quote.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "diff.h"
 #include "revision.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index 6be92817429..d36072252e7 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -13,6 +13,7 @@
 #include "cache-tree.h"
 #include "gettext.h"
 #include "tree-walk.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "string-list.h"
 #include "setup.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 463a8d11c31..20030b75e39 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -8,6 +8,7 @@
 #include "builtin.h"
 #include "color.h"
 #include "strvec.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "dir.h"
 #include "commit-slab.h"
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 138d30a005e..a2243b42195 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -4,6 +4,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 090bf33510a..34b9d92fb13 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "pathspec.h"
 #include "repository.h"
diff --git a/builtin/stash.c b/builtin/stash.c
index 14194b13bd1..6442b5e20a6 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -5,6 +5,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "refs.h"
 #include "lockfile.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 83377037155..1f087d7bed2 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -24,6 +24,7 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "advice.h"
 #include "branch.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 3e801f54a07..88a25902309 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -14,6 +14,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "run-command.h"
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 314761b0b4d..21082ceb601 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "config.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "wrapper.h"
 
diff --git a/builtin/update-ref.c b/builtin/update-ref.c
index 3ffd75b3e78..6ca85420c3b 100644
--- a/builtin/update-ref.c
+++ b/builtin/update-ref.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "refs.h"
 #include "builtin.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "strvec.h"
diff --git a/builtin/verify-commit.c b/builtin/verify-commit.c
index 4d10aa98b10..5d99b82a64f 100644
--- a/builtin/verify-commit.c
+++ b/builtin/verify-commit.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "builtin.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "commit.h"
diff --git a/builtin/verify-tag.c b/builtin/verify-tag.c
index 28d0da68454..c6019a0ad8c 100644
--- a/builtin/verify-tag.c
+++ b/builtin/verify-tag.c
@@ -11,6 +11,7 @@
 #include "gettext.h"
 #include "tag.h"
 #include "run-command.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "gpg-interface.h"
 #include "ref-filter.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 944dd40f94d..69132bba319 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "strvec.h"
 #include "branch.h"
diff --git a/cache.h b/cache.h
index 66705dd469e..21db5da39a5 100644
--- a/cache.h
+++ b/cache.h
@@ -687,24 +687,6 @@ extern int quote_path_fully;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-/*
- * Return an abbreviated sha1 unique within this repository's object database.
- * The result will be at least `len` characters long, and will be NUL
- * terminated.
- *
- * The non-`_r` version returns a static buffer which remains valid until 4
- * more calls to repo_find_unique_abbrev are made.
- *
- * The `_r` variant writes to a buffer supplied by the caller, which must be at
- * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
- * written (excluding the NUL terminator).
- *
- * Note that while this version avoids the static buffer, it is not fully
- * reentrant, as it calls into other non-reentrant git code.
- */
-const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
-int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
-
 /*
  * Create the directory containing the named path, using care to be
  * somewhat safe against races. Return one of the scld_error values to
@@ -806,94 +788,6 @@ int finalize_object_file(const char *tmpfile, const char *filename);
 /* Helper to check and "touch" a file */
 int check_and_freshen_file(const char *fn, int freshen);
 
-/* Convert to/from hex/sha1 representation */
-#define MINIMUM_ABBREV minimum_abbrev
-#define DEFAULT_ABBREV default_abbrev
-
-/* used when the code does not know or care what the default abbrev is */
-#define FALLBACK_DEFAULT_ABBREV 7
-
-struct object_context {
-	unsigned short mode;
-	/*
-	 * symlink_path is only used by get_tree_entry_follow_symlinks,
-	 * and only for symlinks that point outside the repository.
-	 */
-	struct strbuf symlink_path;
-	/*
-	 * If GET_OID_RECORD_PATH is set, this will record path (if any)
-	 * found when resolving the name. The caller is responsible for
-	 * releasing the memory.
-	 */
-	char *path;
-};
-
-int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
-__attribute__((format (printf, 2, 3)))
-int get_oidf(struct object_id *oid, const char *fmt, ...);
-int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
-int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
-void maybe_die_on_misspelt_object_name(struct repository *repo,
-				       const char *name,
-				       const char *prefix);
-enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
-					 unsigned flags, struct object_id *oid,
-					 struct object_context *oc);
-
-typedef int each_abbrev_fn(const struct object_id *oid, void *);
-int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
-
-int set_disambiguate_hint_config(const char *var, const char *value);
-
-/*
- * This reads short-hand syntax that not only evaluates to a commit
- * object name, but also can act as if the end user spelled the name
- * of the branch from the command line.
- *
- * - "@{-N}" finds the name of the Nth previous branch we were on, and
- *   places the name of the branch in the given buf and returns the
- *   number of characters parsed if successful.
- *
- * - "<branch>@{upstream}" finds the name of the other ref that
- *   <branch> is configured to merge with (missing <branch> defaults
- *   to the current branch), and places the name of the branch in the
- *   given buf and returns the number of characters parsed if
- *   successful.
- *
- * If the input is not of the accepted format, it returns a negative
- * number to signal an error.
- *
- * If the input was ok but there are not N branch switches in the
- * reflog, it returns 0.
- */
-#define INTERPRET_BRANCH_LOCAL (1<<0)
-#define INTERPRET_BRANCH_REMOTE (1<<1)
-#define INTERPRET_BRANCH_HEAD (1<<2)
-struct interpret_branch_name_options {
-	/*
-	 * If "allowed" is non-zero, it is a treated as a bitfield of allowable
-	 * expansions: local branches ("refs/heads/"), remote branches
-	 * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
-	 * allowed, even ones to refs outside of those namespaces.
-	 */
-	unsigned allowed;
-
-	/*
-	 * If ^{upstream} or ^{push} (or equivalent) is requested, and the
-	 * branch in question does not have such a reference, return -1 instead
-	 * of die()-ing.
-	 */
-	unsigned nonfatal_dangling_mark : 1;
-};
-int repo_interpret_branch_name(struct repository *r,
-			       const char *str, int len,
-			       struct strbuf *buf,
-			       const struct interpret_branch_name_options *options);
-
 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,
@@ -907,10 +801,6 @@ void *read_object_with_reference(struct repository *r,
 				 unsigned long *size,
 				 struct object_id *oid_ret);
 
-struct object *repo_peel_to_type(struct repository *r,
-				 const char *name, int namelen,
-				 struct object *o, enum object_type);
-
 const char *git_editor(void);
 const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
diff --git a/checkout.c b/checkout.c
index 1247b882248..9235073fc0d 100644
--- a/checkout.c
+++ b/checkout.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
 #include "checkout.h"
diff --git a/combine-diff.c b/combine-diff.c
index 6586e4508d6..cd5f39f22f4 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -7,6 +7,7 @@
 #include "diffcore.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "quote.h"
 #include "xdiff-interface.h"
 #include "xdiff/xmacros.h"
diff --git a/commit.c b/commit.c
index 6d844da9a6b..bad31c423a4 100644
--- a/commit.c
+++ b/commit.c
@@ -6,6 +6,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "repository.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "pkt-line.h"
 #include "utf8.h"
diff --git a/config.c b/config.c
index 9e74b5aec7f..aac439530e9 100644
--- a/config.c
+++ b/config.c
@@ -23,6 +23,7 @@
 #include "quote.h"
 #include "hashmap.h"
 #include "string-list.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "utf8.h"
 #include "dir.h"
diff --git a/diff-lib.c b/diff-lib.c
index 8b5cca96ace..d292405a262 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -8,6 +8,7 @@
 #include "diffcore.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "cache-tree.h"
 #include "unpack-trees.h"
diff --git a/diff.c b/diff.c
index 89cd0b17da5..9e6ad94bc66 100644
--- a/diff.c
+++ b/diff.c
@@ -35,6 +35,7 @@
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
+#include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
 #include "wrapper.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 1886c92ddb9..21019c932b3 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -3,6 +3,7 @@
 #include "config.h"
 #include "environment.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "diff.h"
 #include "diff-merges.h"
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 298ca08711e..8b2a45e507d 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -15,6 +15,7 @@
 #include "list-objects-filter-options.h"
 #include "oidmap.h"
 #include "oidset.h"
+#include "object-name.h"
 #include "object-store.h"
 
 /* Remember to update object flag allocation in object.h */
diff --git a/log-tree.c b/log-tree.c
index 627c711f707..f0e885635e0 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -4,6 +4,7 @@
 #include "diff.h"
 #include "environment.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "tmp-objdir.h"
diff --git a/mailmap.c b/mailmap.c
index 14f2c0f62ae..d62d7bf0e7f 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -2,6 +2,7 @@
 #include "environment.h"
 #include "string-list.h"
 #include "mailmap.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "setup.h"
 
diff --git a/merge-ort.c b/merge-ort.c
index 1008684fbbc..2c6a9ed9a41 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -32,6 +32,7 @@
 #include "entry.h"
 #include "ll-merge.h"
 #include "mem-pool.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "promisor-remote.h"
diff --git a/merge-recursive.c b/merge-recursive.c
index ed5534eb57d..748a6799a30 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -22,6 +22,7 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "revision.h"
diff --git a/notes-merge.c b/notes-merge.c
index 0258f87d21f..b496b77d9db 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -3,6 +3,7 @@
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
 #include "diff.h"
diff --git a/notes.c b/notes.c
index 45fb7f22d1d..c07bcbe3486 100644
--- a/notes.c
+++ b/notes.c
@@ -3,6 +3,7 @@
 #include "environment.h"
 #include "hex.h"
 #include "notes.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/object-name.c b/object-name.c
index ff647d6c7b5..3cd5b327293 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "object-name.h"
 #include "advice.h"
 #include "config.h"
 #include "environment.h"
diff --git a/object-name.h b/object-name.h
new file mode 100644
index 00000000000..1d63698f42b
--- /dev/null
+++ b/object-name.h
@@ -0,0 +1,121 @@
+#ifndef OBJECT_NAME_H
+#define OBJECT_NAME_H
+
+#include "object.h"
+#include "strbuf.h"
+
+struct object_id;
+struct repository;
+
+struct object_context {
+	unsigned short mode;
+	/*
+	 * symlink_path is only used by get_tree_entry_follow_symlinks,
+	 * and only for symlinks that point outside the repository.
+	 */
+	struct strbuf symlink_path;
+	/*
+	 * If GET_OID_RECORD_PATH is set, this will record path (if any)
+	 * found when resolving the name. The caller is responsible for
+	 * releasing the memory.
+	 */
+	char *path;
+};
+
+/*
+ * Return an abbreviated sha1 unique within this repository's object database.
+ * The result will be at least `len` characters long, and will be NUL
+ * terminated.
+ *
+ * The non-`_r` version returns a static buffer which remains valid until 4
+ * more calls to repo_find_unique_abbrev are made.
+ *
+ * The `_r` variant writes to a buffer supplied by the caller, which must be at
+ * least `GIT_MAX_HEXSZ + 1` bytes. The return value is the number of bytes
+ * written (excluding the NUL terminator).
+ *
+ * Note that while this version avoids the static buffer, it is not fully
+ * reentrant, as it calls into other non-reentrant git code.
+ */
+const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len);
+int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len);
+
+int repo_get_oid(struct repository *r, const char *str, struct object_id *oid);
+__attribute__((format (printf, 2, 3)))
+int get_oidf(struct object_id *oid, const char *fmt, ...);
+int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid);
+int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid);
+void maybe_die_on_misspelt_object_name(struct repository *repo,
+				       const char *name,
+				       const char *prefix);
+enum get_oid_result get_oid_with_context(struct repository *repo, const char *str,
+					 unsigned flags, struct object_id *oid,
+					 struct object_context *oc);
+
+
+typedef int each_abbrev_fn(const struct object_id *oid, void *);
+int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *);
+
+int set_disambiguate_hint_config(const char *var, const char *value);
+
+/*
+ * This reads short-hand syntax that not only evaluates to a commit
+ * object name, but also can act as if the end user spelled the name
+ * of the branch from the command line.
+ *
+ * - "@{-N}" finds the name of the Nth previous branch we were on, and
+ *   places the name of the branch in the given buf and returns the
+ *   number of characters parsed if successful.
+ *
+ * - "<branch>@{upstream}" finds the name of the other ref that
+ *   <branch> is configured to merge with (missing <branch> defaults
+ *   to the current branch), and places the name of the branch in the
+ *   given buf and returns the number of characters parsed if
+ *   successful.
+ *
+ * If the input is not of the accepted format, it returns a negative
+ * number to signal an error.
+ *
+ * If the input was ok but there are not N branch switches in the
+ * reflog, it returns 0.
+ */
+#define INTERPRET_BRANCH_LOCAL (1<<0)
+#define INTERPRET_BRANCH_REMOTE (1<<1)
+#define INTERPRET_BRANCH_HEAD (1<<2)
+struct interpret_branch_name_options {
+	/*
+	 * If "allowed" is non-zero, it is a treated as a bitfield of allowable
+	 * expansions: local branches ("refs/heads/"), remote branches
+	 * ("refs/remotes/"), or "HEAD". If no "allowed" bits are set, any expansion is
+	 * allowed, even ones to refs outside of those namespaces.
+	 */
+	unsigned allowed;
+
+	/*
+	 * If ^{upstream} or ^{push} (or equivalent) is requested, and the
+	 * branch in question does not have such a reference, return -1 instead
+	 * of die()-ing.
+	 */
+	unsigned nonfatal_dangling_mark : 1;
+};
+int repo_interpret_branch_name(struct repository *r,
+			       const char *str, int len,
+			       struct strbuf *buf,
+			       const struct interpret_branch_name_options *options);
+
+struct object *repo_peel_to_type(struct repository *r,
+				 const char *name, int namelen,
+				 struct object *o, enum object_type);
+
+/* Convert to/from hex/sha1 representation */
+#define MINIMUM_ABBREV minimum_abbrev
+#define DEFAULT_ABBREV default_abbrev
+
+/* used when the code does not know or care what the default abbrev is */
+#define FALLBACK_DEFAULT_ABBREV 7
+
+#endif /* OBJECT_NAME_H */
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 666c2129797..b4df4bcebed 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -6,6 +6,7 @@
 #include "color.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "strvec.h"
 #include "oid-array.h"
diff --git a/range-diff.c b/range-diff.c
index d1ed3b8ee56..a2994331a14 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -2,6 +2,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "range-diff.h"
+#include "object-name.h"
 #include "string-list.h"
 #include "run-command.h"
 #include "strvec.h"
diff --git a/read-cache.c b/read-cache.c
index 4ada6d62b90..cbbfc030da7 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -22,6 +22,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "mem-pool.h"
+#include "object-name.h"
 #include "resolve-undo.h"
 #include "run-command.h"
 #include "strbuf.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 79ed61b9fa4..48467a7bc4a 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -8,6 +8,7 @@
 #include "commit-slab.h"
 #include "config.h"
 #include "dir.h"
+#include "object-name.h"
 #include "wrapper.h"
 
 static const char edit_todo_list_advice[] =
diff --git a/ref-filter.c b/ref-filter.c
index 1c6174c8aed..57a5884aec7 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -6,6 +6,7 @@
 #include "parse-options.h"
 #include "refs.h"
 #include "wildmatch.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "repository.h"
diff --git a/refs.c b/refs.c
index cfced6f174a..979ed3fbedc 100644
--- a/refs.c
+++ b/refs.c
@@ -16,6 +16,7 @@
 #include "refs/refs-internal.h"
 #include "run-command.h"
 #include "hook.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "tag.h"
diff --git a/remote.c b/remote.c
index 6599d52de20..3afedce593e 100644
--- a/remote.c
+++ b/remote.c
@@ -9,6 +9,7 @@
 #include "urlmatch.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/reset.c b/reset.c
index ab300923e04..48da0adf851 100644
--- a/reset.c
+++ b/reset.c
@@ -3,6 +3,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "lockfile.h"
+#include "object-name.h"
 #include "refs.h"
 #include "reset.h"
 #include "run-command.h"
diff --git a/revision.c b/revision.c
index 7c34c93885e..7438b50e267 100644
--- a/revision.c
+++ b/revision.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "tag.h"
 #include "blob.h"
diff --git a/sequencer.c b/sequencer.c
index eaba379e3ad..22b287be984 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "object.h"
 #include "commit.h"
diff --git a/setup.c b/setup.c
index 3bb7a9fff62..8a297b3cb5c 100644
--- a/setup.c
+++ b/setup.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-name.h"
 #include "repository.h"
 #include "config.h"
 #include "dir.h"
diff --git a/strbuf.c b/strbuf.c
index 70a83e7980e..1b93d9d3c47 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -4,6 +4,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "refs.h"
 #include "string-list.h"
 #include "utf8.h"
diff --git a/submodule-config.c b/submodule-config.c
index ecf0fcf0074..252b90aa439 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -9,6 +9,7 @@
 #include "submodule-config.h"
 #include "submodule.h"
 #include "strbuf.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "parse-options.h"
 #include "tree-walk.h"
diff --git a/submodule.c b/submodule.c
index 58c9d5e5673..4f403b9eeff 100644
--- a/submodule.c
+++ b/submodule.c
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit-reach.h"
 #include "setup.h"
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index fd48e0ee2c8..d1d63feaa9e 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -20,6 +20,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "merge-ort.h"
+#include "object-name.h"
 #include "refs.h"
 #include "revision.h"
 #include "sequencer.h"
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 7066f3c71d2..3808e1ac38b 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 "object-name.h"
 #include "setup.h"
 #include "tree.h"
 
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index e2eb25ecdea..bf4fcfe6efb 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "hex.h"
+#include "object-name.h"
 #include "oidmap.h"
 #include "setup.h"
 #include "strbuf.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index b0deaa106a2..d4fa33ae751 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -6,6 +6,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "parse-options.h"
 #include "ref-filter.h"
 #include "setup.h"
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 66063b58ded..4758c8654e0 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,6 +1,7 @@
 #include "test-tool.h"
 #include "cache.h"
 #include "config.h"
+#include "object-name.h"
 #include "setup.h"
 #include "submodule-config.h"
 #include "submodule.h"
diff --git a/tag.c b/tag.c
index 01ed67d6fa6..b9fc2fc9929 100644
--- a/tag.c
+++ b/tag.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "environment.h"
 #include "tag.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "commit.h"
 #include "tree.h"
diff --git a/transport-helper.c b/transport-helper.c
index 76d146ee88b..ca8bec04bb3 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "remote.h"
 #include "string-list.h"
diff --git a/transport.c b/transport.c
index 82bf2496ba7..7374cfd1fa9 100644
--- a/transport.c
+++ b/transport.c
@@ -26,6 +26,7 @@
 #include "trace2.h"
 #include "transport-internal.h"
 #include "protocol.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "color.h"
 #include "bundle-uri.h"
diff --git a/tree.c b/tree.c
index 2b78708766b..e9d51ce2e00 100644
--- a/tree.c
+++ b/tree.c
@@ -2,6 +2,7 @@
 #include "cache-tree.h"
 #include "hex.h"
 #include "tree.h"
+#include "object-name.h"
 #include "object-store.h"
 #include "blob.h"
 #include "commit.h"
diff --git a/wt-status.c b/wt-status.c
index 47f223c0f8d..97b9c1c0359 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -8,6 +8,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-name.h"
 #include "revision.h"
 #include "diffcore.h"
 #include "quote.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 09/23] treewide: remove cache.h inclusion due to object-name.h changes
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 07/23] treewide: remove unnecessary cache.h inclusion Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 08/23] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 10/23] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren
                         ` (13 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 branch.c                         | 1 -
 checkout.c                       | 3 ++-
 fmt-merge-msg.c                  | 2 +-
 mailmap.c                        | 2 +-
 notes.c                          | 2 +-
 refs.c                           | 2 +-
 remote.c                         | 2 +-
 setup.c                          | 2 +-
 strbuf.c                         | 2 +-
 t/helper/test-oidmap.c           | 1 -
 t/helper/test-reach.c            | 1 -
 t/helper/test-submodule-config.c | 1 -
 transport-helper.c               | 2 +-
 13 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/branch.c b/branch.c
index f29743b1619..7df982693af 100644
--- a/branch.c
+++ b/branch.c
@@ -1,5 +1,4 @@
 #include "git-compat-util.h"
-#include "cache.h"
 #include "advice.h"
 #include "config.h"
 #include "branch.h"
diff --git a/checkout.c b/checkout.c
index 9235073fc0d..04238b27133 100644
--- a/checkout.c
+++ b/checkout.c
@@ -1,9 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "object-name.h"
 #include "remote.h"
 #include "refspec.h"
 #include "checkout.h"
 #include "config.h"
+#include "strbuf.h"
 
 struct tracking_name_data {
 	/* const */ char *src_ref;
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index 21019c932b3..5af0d4715ba 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/mailmap.c b/mailmap.c
index d62d7bf0e7f..28d389c1f94 100644
--- a/mailmap.c
+++ b/mailmap.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "string-list.h"
 #include "mailmap.h"
diff --git a/notes.c b/notes.c
index c07bcbe3486..02f1aa39ae1 100644
--- a/notes.c
+++ b/notes.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "environment.h"
 #include "hex.h"
diff --git a/refs.c b/refs.c
index 979ed3fbedc..d2a98e1c21f 100644
--- a/refs.c
+++ b/refs.c
@@ -2,7 +2,7 @@
  * The backend-independent part of the reference module.
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/remote.c b/remote.c
index 3afedce593e..2947743d60a 100644
--- a/remote.c
+++ b/remote.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/setup.c b/setup.c
index 8a297b3cb5c..a546da755f1 100644
--- a/setup.c
+++ b/setup.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/strbuf.c b/strbuf.c
index 1b93d9d3c47..b2e3735ba8a 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "environment.h"
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index bf4fcfe6efb..de6ab77fdaa 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "hex.h"
 #include "object-name.h"
 #include "oidmap.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index d4fa33ae751..5b6f2174418 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "alloc.h"
 #include "commit.h"
 #include "commit-reach.h"
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index 4758c8654e0..c7c7fdbea98 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,5 +1,4 @@
 #include "test-tool.h"
-#include "cache.h"
 #include "config.h"
 #include "object-name.h"
 #include "setup.h"
diff --git a/transport-helper.c b/transport-helper.c
index ca8bec04bb3..6b816940dc6 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "transport.h"
 #include "quote.h"
 #include "run-command.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 10/23] git-zlib: move declarations for git-zlib functions from cache.h
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (2 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 09/23] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 11/23] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren
                         ` (12 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Move functions from cache.h for zlib.c into a new header file.  Since
adding a "zlib.h" would cause issues with the real zlib, rename zlib.c
to git-zlib.c while we are at it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 Makefile                 |  2 +-
 archive-tar.c            |  1 +
 archive-zip.c            |  1 +
 builtin/unpack-objects.c |  1 +
 cache.h                  | 25 +------------------------
 zlib.c => git-zlib.c     |  3 ++-
 git-zlib.h               | 28 ++++++++++++++++++++++++++++
 http-backend.c           |  1 +
 http.h                   |  3 +++
 9 files changed, 39 insertions(+), 26 deletions(-)
 rename zlib.c => git-zlib.c (99%)
 create mode 100644 git-zlib.h

diff --git a/Makefile b/Makefile
index 50ee51fde32..0c367881bff 100644
--- a/Makefile
+++ b/Makefile
@@ -1036,6 +1036,7 @@ LIB_OBJS += fsmonitor.o
 LIB_OBJS += fsmonitor-ipc.o
 LIB_OBJS += fsmonitor-settings.o
 LIB_OBJS += gettext.o
+LIB_OBJS += git-zlib.o
 LIB_OBJS += gpg-interface.o
 LIB_OBJS += graph.o
 LIB_OBJS += grep.o
@@ -1196,7 +1197,6 @@ LIB_OBJS += write-or-die.o
 LIB_OBJS += ws.o
 LIB_OBJS += wt-status.o
 LIB_OBJS += xdiff-interface.o
-LIB_OBJS += zlib.o
 
 BUILTIN_OBJS += builtin/add.o
 BUILTIN_OBJS += builtin/am.o
diff --git a/archive-tar.c b/archive-tar.c
index 497dad0b3af..4cd81d8161e 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -5,6 +5,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "tar.h"
 #include "archive.h"
diff --git a/archive-zip.c b/archive-zip.c
index e6f5c10a14f..ef538a90df4 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -5,6 +5,7 @@
 #include "config.h"
 #include "archive.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "streaming.h"
 #include "utf8.h"
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index f2c1323e661..ddbdb3dd226 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -4,6 +4,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "object-store.h"
 #include "object.h"
diff --git a/cache.h b/cache.h
index 21db5da39a5..c06778b69cd 100644
--- a/cache.h
+++ b/cache.h
@@ -3,6 +3,7 @@
 
 #include "git-compat-util.h"
 #include "strbuf.h"
+#include "git-zlib.h"
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
@@ -14,30 +15,6 @@
 #include "repository.h"
 #include "statinfo.h"
 
-typedef struct git_zstream {
-	z_stream z;
-	unsigned long avail_in;
-	unsigned long avail_out;
-	unsigned long total_in;
-	unsigned long total_out;
-	unsigned char *next_in;
-	unsigned char *next_out;
-} git_zstream;
-
-void git_inflate_init(git_zstream *);
-void git_inflate_init_gzip_only(git_zstream *);
-void git_inflate_end(git_zstream *);
-int git_inflate(git_zstream *, int flush);
-
-void git_deflate_init(git_zstream *, int level);
-void git_deflate_init_gzip(git_zstream *, int level);
-void git_deflate_init_raw(git_zstream *, int level);
-void git_deflate_end(git_zstream *);
-int git_deflate_abort(git_zstream *);
-int git_deflate_end_gently(git_zstream *);
-int git_deflate(git_zstream *, int flush);
-unsigned long git_deflate_bound(git_zstream *, unsigned long);
-
 #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
 #define DTYPE(de)	((de)->d_type)
 #else
diff --git a/zlib.c b/git-zlib.c
similarity index 99%
rename from zlib.c
rename to git-zlib.c
index d594cba3fc9..d43bbeb6daa 100644
--- a/zlib.c
+++ b/git-zlib.c
@@ -2,7 +2,8 @@
  * zlib wrappers to make sure we don't silently miss errors
  * at init time.
  */
-#include "cache.h"
+#include "git-compat-util.h"
+#include "git-zlib.h"
 
 static const char *zerr_to_string(int status)
 {
diff --git a/git-zlib.h b/git-zlib.h
new file mode 100644
index 00000000000..d8a670aff9f
--- /dev/null
+++ b/git-zlib.h
@@ -0,0 +1,28 @@
+#ifndef GIT_ZLIB_H
+#define GIT_ZLIB_H
+
+typedef struct git_zstream {
+	z_stream z;
+	unsigned long avail_in;
+	unsigned long avail_out;
+	unsigned long total_in;
+	unsigned long total_out;
+	unsigned char *next_in;
+	unsigned char *next_out;
+} git_zstream;
+
+void git_inflate_init(git_zstream *);
+void git_inflate_init_gzip_only(git_zstream *);
+void git_inflate_end(git_zstream *);
+int git_inflate(git_zstream *, int flush);
+
+void git_deflate_init(git_zstream *, int level);
+void git_deflate_init_gzip(git_zstream *, int level);
+void git_deflate_init_raw(git_zstream *, int level);
+void git_deflate_end(git_zstream *);
+int git_deflate_abort(git_zstream *);
+int git_deflate_end_gently(git_zstream *);
+int git_deflate(git_zstream *, int flush);
+unsigned long git_deflate_bound(git_zstream *, unsigned long);
+
+#endif /* GIT_ZLIB_H */
diff --git a/http-backend.c b/http-backend.c
index 89aad1b42c7..d41b3b9e1e7 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
+#include "git-zlib.h"
 #include "hex.h"
 #include "repository.h"
 #include "refs.h"
diff --git a/http.h b/http.h
index 77c042706c6..783b2b09b8b 100644
--- a/http.h
+++ b/http.h
@@ -1,7 +1,10 @@
 #ifndef HTTP_H
 #define HTTP_H
 
+struct packed_git;
+
 #include "cache.h"
+#include "git-zlib.h"
 
 #include <curl/curl.h>
 #include <curl/easy.h>
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 11/23] treewide: remove cache.h inclusion due to git-zlib changes
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (3 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 10/23] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 12/23] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren
                         ` (11 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

This actually only affects http-backend.c, but the git-zlib changes
are going to be instrumental in pulling out an object-file.h which
will help with several more files.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 http-backend.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/http-backend.c b/http-backend.c
index d41b3b9e1e7..ac146d85c54 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 12/23] object-file.h: move declarations for object-file.c functions from cache.h
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (4 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 11/23] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 13/23] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren
                         ` (10 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 apply.c                            |   1 +
 builtin/bugreport.c                |   1 +
 builtin/cat-file.c                 |   1 +
 builtin/clone.c                    |   1 +
 builtin/credential-cache--daemon.c |   1 +
 builtin/diagnose.c                 |   1 +
 builtin/difftool.c                 |   1 +
 builtin/fast-export.c              |   1 +
 builtin/fast-import.c              |   1 +
 builtin/fetch-pack.c               |   1 +
 builtin/fsck.c                     |   1 +
 builtin/gc.c                       |   1 +
 builtin/grep.c                     |   1 +
 builtin/hash-object.c              |   1 +
 builtin/index-pack.c               |   1 +
 builtin/init-db.c                  |   1 +
 builtin/log.c                      |   1 +
 builtin/mktag.c                    |   1 +
 builtin/mv.c                       |   1 +
 builtin/pack-objects.c             |   1 +
 builtin/prune.c                    |   1 +
 builtin/rebase.c                   |   1 +
 builtin/replace.c                  |   1 +
 builtin/rev-list.c                 |   1 +
 builtin/sparse-checkout.c          |   1 +
 builtin/submodule--helper.c        |   1 +
 builtin/update-index.c             |   1 +
 builtin/worktree.c                 |   1 +
 bulk-checkin.c                     |   1 +
 cache-tree.c                       |   1 +
 cache.h                            | 123 ---------------------------
 commit-graph.c                     |   1 +
 diff.c                             |   1 +
 dir.c                              |   1 +
 environment.c                      |   1 +
 http.c                             |   1 +
 merge-recursive.c                  |   1 +
 midx.c                             |   1 +
 notes-merge.c                      |   1 +
 object-file.c                      |   1 +
 object-file.h                      | 129 +++++++++++++++++++++++++++++
 object.c                           |   1 +
 pack-bitmap.c                      |   1 +
 pack-check.c                       |   1 +
 pack-mtimes.c                      |   1 +
 pack-revindex.c                    |   1 +
 packfile.c                         |   1 +
 read-cache.c                       |   1 +
 refs/files-backend.c               |   1 +
 rerere.c                           |   1 +
 revision.c                         |   1 +
 sequencer.c                        |   1 +
 server-info.c                      |   1 +
 streaming.c                        |   1 +
 submodule.c                        |   1 +
 tmp-objdir.c                       |   1 +
 tree-walk.c                        |   1 +
 57 files changed, 184 insertions(+), 123 deletions(-)
 create mode 100644 object-file.h

diff --git a/apply.c b/apply.c
index 7e40f53ec4c..2868cef5ddd 100644
--- a/apply.c
+++ b/apply.c
@@ -23,6 +23,7 @@
 #include "ll-merge.h"
 #include "lockfile.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "quote.h"
 #include "rerere.h"
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index 52955e1d389..03fb0536911 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -8,6 +8,7 @@
 #include "hook.h"
 #include "hook-list.h"
 #include "diagnose.h"
+#include "object-file.h"
 #include "setup.h"
 #include "wrapper.h"
 
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 60b7a55dfc1..0bafc14e6c0 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -20,6 +20,7 @@
 #include "tree-walk.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index f1e8aa3f27e..c7fdffb484c 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -21,6 +21,7 @@
 #include "fetch-pack.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "tree.h"
 #include "tree-walk.h"
diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index 62c09a271d6..4e571d9951b 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -2,6 +2,7 @@
 #include "abspath.h"
 #include "alloc.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 
 #ifndef NO_UNIX_SOCKETS
diff --git a/builtin/diagnose.c b/builtin/diagnose.c
index 0f8b64994c4..4f22eb2b55d 100644
--- a/builtin/diagnose.c
+++ b/builtin/diagnose.c
@@ -1,6 +1,7 @@
 #include "builtin.h"
 #include "abspath.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "diagnose.h"
 
diff --git a/builtin/difftool.c b/builtin/difftool.c
index e010a21bfbc..3ffb0524be7 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -25,6 +25,7 @@
 #include "strvec.h"
 #include "strbuf.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "dir.h"
 #include "entry.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 0bb779deb69..c7835ea0791 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -10,6 +10,7 @@
 #include "hex.h"
 #include "refs.h"
 #include "refspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "commit.h"
 #include "object.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 31b8732128d..9f90f5b9e41 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -19,6 +19,7 @@
 #include "dir.h"
 #include "run-command.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "mem-pool.h"
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 60e5a10ffc5..664ac1ec0e8 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -2,6 +2,7 @@
 #include "alloc.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "pkt-line.h"
 #include "fetch-pack.h"
 #include "remote.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 04bc71d148c..35a6de3cdb5 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -19,6 +19,7 @@
 #include "streaming.h"
 #include "decorate.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index 000a2ef5e11..b95154fba16 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -25,6 +25,7 @@
 #include "commit.h"
 #include "commit-graph.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-objects.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index f66e14389e1..fb11be6075a 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -26,6 +26,7 @@
 #include "setup.h"
 #include "submodule.h"
 #include "submodule-config.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index a15fe4fd3f4..a3801211666 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "quote.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 5adfb2521cd..0f59cf8aa08 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -18,6 +18,7 @@
 #include "thread-utils.h"
 #include "packfile.h"
 #include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "replace-object.h"
diff --git a/builtin/init-db.c b/builtin/init-db.c
index ba6e0b20fa5..6183f3fb3ff 100644
--- a/builtin/init-db.c
+++ b/builtin/init-db.c
@@ -11,6 +11,7 @@
 #include "refs.h"
 #include "builtin.h"
 #include "exec-cmd.h"
+#include "object-file.h"
 #include "parse-options.h"
 #include "setup.h"
 #include "worktree.h"
diff --git a/builtin/log.c b/builtin/log.c
index 5cdc2276cc4..b6246c7042c 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -12,6 +12,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "refs.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "color.h"
diff --git a/builtin/mktag.c b/builtin/mktag.c
index f9d9a38452b..f33d267fcb6 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -4,6 +4,7 @@
 #include "parse-options.h"
 #include "tag.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "fsck.h"
 #include "config.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index 8f7770aa32b..32935af48e6 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -11,6 +11,7 @@
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "pathspec.h"
 #include "lockfile.h"
 #include "dir.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 69c65428614..68c914a8e1a 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -33,6 +33,7 @@
 #include "strvec.h"
 #include "list.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "dir.h"
diff --git a/builtin/prune.c b/builtin/prune.c
index 09891832fb3..5dc9b207200 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -11,6 +11,7 @@
 #include "progress.h"
 #include "prune-packed.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "shallow.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index ff5dd77608d..34fea4d8220 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -21,6 +21,7 @@
 #include "cache-tree.h"
 #include "unpack-trees.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "commit.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index 134f738a450..f4b3a8efb23 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -17,6 +17,7 @@
 #include "refs.h"
 #include "parse-options.h"
 #include "run-command.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "replace-object.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index c17f0282ae8..6dc8be492a2 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -11,6 +11,7 @@
 #include "list-objects-filter-options.h"
 #include "object.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "pack.h"
 #include "pack-bitmap.h"
diff --git a/builtin/sparse-checkout.c b/builtin/sparse-checkout.c
index 34b9d92fb13..4de37d07fd9 100644
--- a/builtin/sparse-checkout.c
+++ b/builtin/sparse-checkout.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "pathspec.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 1f087d7bed2..5d999f814e0 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -24,6 +24,7 @@
 #include "revision.h"
 #include "diffcore.h"
 #include "diff.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "advice.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index 03cda5e60d2..33b00cef151 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -15,6 +15,7 @@
 #include "cache-tree.h"
 #include "tree-walk.h"
 #include "builtin.h"
+#include "object-file.h"
 #include "refs.h"
 #include "resolve-undo.h"
 #include "parse-options.h"
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 69132bba319..0621f6f708e 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -7,6 +7,7 @@
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "parse-options.h"
 #include "strvec.h"
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 6362b6aabc7..af15f8a9af4 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -15,6 +15,7 @@
 #include "string-list.h"
 #include "tmp-objdir.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 static int odb_transaction_nesting;
diff --git a/cache-tree.c b/cache-tree.c
index 39f0c744727..ebfe649b330 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -7,6 +7,7 @@
 #include "tree-walk.h"
 #include "cache-tree.h"
 #include "bulk-checkin.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "promisor-remote.h"
diff --git a/cache.h b/cache.h
index c06778b69cd..89987cca22a 100644
--- a/cache.h
+++ b/cache.h
@@ -3,7 +3,6 @@
 
 #include "git-compat-util.h"
 #include "strbuf.h"
-#include "git-zlib.h"
 #include "hashmap.h"
 #include "list.h"
 #include "gettext.h"
@@ -596,13 +595,6 @@ int has_racy_timestamp(struct index_state *istate);
 int ie_match_stat(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 int ie_modified(struct index_state *, const struct cache_entry *, struct stat *, unsigned int);
 
-#define HASH_WRITE_OBJECT 1
-#define HASH_FORMAT_CHECK 2
-#define HASH_RENORMALIZE  4
-#define HASH_SILENT 8
-int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
-int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
-
 /*
  * Record to sd the data from st that we use to check whether a file
  * might have changed.
@@ -664,107 +656,6 @@ extern int quote_path_fully;
 #define DATA_CHANGED    0x0020
 #define TYPE_CHANGED    0x0040
 
-/*
- * Create the directory containing the named path, using care to be
- * somewhat safe against races. Return one of the scld_error values to
- * indicate success/failure. On error, set errno to describe the
- * problem.
- *
- * SCLD_VANISHED indicates that one of the ancestor directories of the
- * path existed at one point during the function call and then
- * suddenly vanished, probably because another process pruned the
- * directory while we were working.  To be robust against this kind of
- * race, callers might want to try invoking the function again when it
- * returns SCLD_VANISHED.
- *
- * safe_create_leading_directories() temporarily changes path while it
- * is working but restores it before returning.
- * safe_create_leading_directories_const() doesn't modify path, even
- * temporarily. Both these variants adjust the permissions of the
- * created directories to honor core.sharedRepository, so they are best
- * suited for files inside the git dir. For working tree files, use
- * safe_create_leading_directories_no_share() instead, as it ignores
- * the core.sharedRepository setting.
- */
-enum scld_error {
-	SCLD_OK = 0,
-	SCLD_FAILED = -1,
-	SCLD_PERMS = -2,
-	SCLD_EXISTS = -3,
-	SCLD_VANISHED = -4
-};
-enum scld_error safe_create_leading_directories(char *path);
-enum scld_error safe_create_leading_directories_const(const char *path);
-enum scld_error safe_create_leading_directories_no_share(char *path);
-
-int mkdir_in_gitdir(const char *path);
-
-int git_open_cloexec(const char *name, int flags);
-#define git_open(name) git_open_cloexec(name, O_RDONLY)
-
-/**
- * unpack_loose_header() initializes the data stream needed to unpack
- * a loose object header.
- *
- * Returns:
- *
- * - ULHR_OK on success
- * - ULHR_BAD on error
- * - ULHR_TOO_LONG if the header was too long
- *
- * It will only parse up to MAX_HEADER_LEN bytes unless an optional
- * "hdrbuf" argument is non-NULL. This is intended for use with
- * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
- * reporting. The full header will be extracted to "hdrbuf" for use
- * with parse_loose_header(), ULHR_TOO_LONG will still be returned
- * from this function to indicate that the header was too long.
- */
-enum unpack_loose_header_result {
-	ULHR_OK,
-	ULHR_BAD,
-	ULHR_TOO_LONG,
-};
-enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
-						    unsigned char *map,
-						    unsigned long mapsize,
-						    void *buffer,
-						    unsigned long bufsiz,
-						    struct strbuf *hdrbuf);
-
-/**
- * parse_loose_header() parses the starting "<type> <len>\0" of an
- * object. If it doesn't follow that format -1 is returned. To check
- * the validity of the <type> populate the "typep" in the "struct
- * object_info". It will be OBJ_BAD if the object type is unknown. The
- * parsed <len> can be retrieved via "oi->sizep", and from there
- * passed to unpack_loose_rest().
- */
-struct object_info;
-int parse_loose_header(const char *hdr, struct object_info *oi);
-
-/**
- * With in-core object data in "buf", rehash it to make sure the
- * object name actually matches "oid" to detect object corruption.
- *
- * A negative value indicates an error, usually that the OID is not
- * what we expected, but it might also indicate another error.
- */
-int check_object_signature(struct repository *r, const struct object_id *oid,
-			   void *map, unsigned long size,
-			   enum object_type type);
-
-/**
- * A streaming version of check_object_signature().
- * Try reading the object named with "oid" using
- * the streaming interface and rehash it to do the same.
- */
-int stream_object_signature(struct repository *r, const struct object_id *oid);
-
-int finalize_object_file(const char *tmpfile, const char *filename);
-
-/* Helper to check and "touch" a file */
-int check_and_freshen_file(const char *fn, int freshen);
-
 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,
@@ -772,12 +663,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);
 
-void *read_object_with_reference(struct repository *r,
-				 const struct object_id *oid,
-				 enum object_type required_type,
-				 unsigned long *size,
-				 struct object_id *oid_ret);
-
 const char *git_editor(void);
 const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
@@ -819,14 +704,6 @@ struct pack_entry {
 	struct packed_git *p;
 };
 
-/*
- * Set this to 0 to prevent oid_object_info_extended() from fetching missing
- * blobs. This has a difference only if extensions.partialClone is set.
- *
- * Its default value is 1.
- */
-extern int fetch_if_missing;
-
 /* Dumb servers support */
 int update_server_info(int);
 
diff --git a/commit-graph.c b/commit-graph.c
index fe9a8b2342f..c20e73ceebf 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -11,6 +11,7 @@
 #include "revision.h"
 #include "hash-lookup.h"
 #include "commit-graph.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "alloc.h"
diff --git a/diff.c b/diff.c
index 9e6ad94bc66..f8e0d3b5c59 100644
--- a/diff.c
+++ b/diff.c
@@ -35,6 +35,7 @@
 #include "help.h"
 #include "promisor-remote.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "setup.h"
 #include "strmap.h"
diff --git a/dir.c b/dir.c
index d1f1b1ef768..aa840995c40 100644
--- a/dir.c
+++ b/dir.c
@@ -13,6 +13,7 @@
 #include "dir.h"
 #include "environment.h"
 #include "gettext.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "attr.h"
 #include "refs.h"
diff --git a/environment.c b/environment.c
index e57292eccc9..39efa49fe31 100644
--- a/environment.c
+++ b/environment.c
@@ -19,6 +19,7 @@
 #include "fmt-merge-msg.h"
 #include "commit.h"
 #include "strvec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "tmp-objdir.h"
diff --git a/http.c b/http.c
index 0212c0ad3b2..c3916ceb4d8 100644
--- a/http.c
+++ b/http.c
@@ -17,6 +17,7 @@
 #include "packfile.h"
 #include "protocol.h"
 #include "string-list.h"
+#include "object-file.h"
 #include "object-store.h"
 
 static struct trace_key trace_curl = TRACE_KEY_INIT(CURL);
diff --git a/merge-recursive.c b/merge-recursive.c
index 748a6799a30..9875bdb11cb 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -22,6 +22,7 @@
 #include "hex.h"
 #include "ll-merge.h"
 #include "lockfile.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
diff --git a/midx.c b/midx.c
index 9af3e5de889..2d0da573281 100644
--- a/midx.c
+++ b/midx.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "midx.h"
diff --git a/notes-merge.c b/notes-merge.c
index b496b77d9db..cc9538ac5c0 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -3,6 +3,7 @@
 #include "commit.h"
 #include "gettext.h"
 #include "refs.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "repository.h"
diff --git a/object-file.c b/object-file.c
index a4331e0da61..8163ddbaddd 100644
--- a/object-file.c
+++ b/object-file.c
@@ -36,6 +36,7 @@
 #include "mergesort.h"
 #include "quote.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "promisor-remote.h"
 #include "setup.h"
diff --git a/object-file.h b/object-file.h
new file mode 100644
index 00000000000..e0cfc3a5db8
--- /dev/null
+++ b/object-file.h
@@ -0,0 +1,129 @@
+#ifndef OBJECT_FILE_H
+#define OBJECT_FILE_H
+
+#include "git-zlib.h"
+#include "object.h"
+
+/*
+ * Set this to 0 to prevent oid_object_info_extended() from fetching missing
+ * blobs. This has a difference only if extensions.partialClone is set.
+ *
+ * Its default value is 1.
+ */
+extern int fetch_if_missing;
+
+#define HASH_WRITE_OBJECT 1
+#define HASH_FORMAT_CHECK 2
+#define HASH_RENORMALIZE  4
+#define HASH_SILENT 8
+int index_fd(struct index_state *istate, struct object_id *oid, int fd, struct stat *st, enum object_type type, const char *path, unsigned flags);
+int index_path(struct index_state *istate, struct object_id *oid, const char *path, struct stat *st, unsigned flags);
+
+/*
+ * Create the directory containing the named path, using care to be
+ * somewhat safe against races. Return one of the scld_error values to
+ * indicate success/failure. On error, set errno to describe the
+ * problem.
+ *
+ * SCLD_VANISHED indicates that one of the ancestor directories of the
+ * path existed at one point during the function call and then
+ * suddenly vanished, probably because another process pruned the
+ * directory while we were working.  To be robust against this kind of
+ * race, callers might want to try invoking the function again when it
+ * returns SCLD_VANISHED.
+ *
+ * safe_create_leading_directories() temporarily changes path while it
+ * is working but restores it before returning.
+ * safe_create_leading_directories_const() doesn't modify path, even
+ * temporarily. Both these variants adjust the permissions of the
+ * created directories to honor core.sharedRepository, so they are best
+ * suited for files inside the git dir. For working tree files, use
+ * safe_create_leading_directories_no_share() instead, as it ignores
+ * the core.sharedRepository setting.
+ */
+enum scld_error {
+	SCLD_OK = 0,
+	SCLD_FAILED = -1,
+	SCLD_PERMS = -2,
+	SCLD_EXISTS = -3,
+	SCLD_VANISHED = -4
+};
+enum scld_error safe_create_leading_directories(char *path);
+enum scld_error safe_create_leading_directories_const(const char *path);
+enum scld_error safe_create_leading_directories_no_share(char *path);
+
+int mkdir_in_gitdir(const char *path);
+
+int git_open_cloexec(const char *name, int flags);
+#define git_open(name) git_open_cloexec(name, O_RDONLY)
+
+/**
+ * unpack_loose_header() initializes the data stream needed to unpack
+ * a loose object header.
+ *
+ * Returns:
+ *
+ * - ULHR_OK on success
+ * - ULHR_BAD on error
+ * - ULHR_TOO_LONG if the header was too long
+ *
+ * It will only parse up to MAX_HEADER_LEN bytes unless an optional
+ * "hdrbuf" argument is non-NULL. This is intended for use with
+ * OBJECT_INFO_ALLOW_UNKNOWN_TYPE to extract the bad type for (error)
+ * reporting. The full header will be extracted to "hdrbuf" for use
+ * with parse_loose_header(), ULHR_TOO_LONG will still be returned
+ * from this function to indicate that the header was too long.
+ */
+enum unpack_loose_header_result {
+	ULHR_OK,
+	ULHR_BAD,
+	ULHR_TOO_LONG,
+};
+enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
+						    unsigned char *map,
+						    unsigned long mapsize,
+						    void *buffer,
+						    unsigned long bufsiz,
+						    struct strbuf *hdrbuf);
+
+/**
+ * parse_loose_header() parses the starting "<type> <len>\0" of an
+ * object. If it doesn't follow that format -1 is returned. To check
+ * the validity of the <type> populate the "typep" in the "struct
+ * object_info". It will be OBJ_BAD if the object type is unknown. The
+ * parsed <len> can be retrieved via "oi->sizep", and from there
+ * passed to unpack_loose_rest().
+ */
+struct object_info;
+int parse_loose_header(const char *hdr, struct object_info *oi);
+
+/**
+ * With in-core object data in "buf", rehash it to make sure the
+ * object name actually matches "oid" to detect object corruption.
+ *
+ * A negative value indicates an error, usually that the OID is not
+ * what we expected, but it might also indicate another error.
+ */
+int check_object_signature(struct repository *r, const struct object_id *oid,
+			   void *map, unsigned long size,
+			   enum object_type type);
+
+/**
+ * A streaming version of check_object_signature().
+ * Try reading the object named with "oid" using
+ * the streaming interface and rehash it to do the same.
+ */
+int stream_object_signature(struct repository *r, const struct object_id *oid);
+
+int finalize_object_file(const char *tmpfile, const char *filename);
+
+/* Helper to check and "touch" a file */
+int check_and_freshen_file(const char *fn, int freshen);
+
+void *read_object_with_reference(struct repository *r,
+				 const struct object_id *oid,
+				 enum object_type required_type,
+				 unsigned long *size,
+				 struct object_id *oid_ret);
+
+#endif /* OBJECT_FILE_H */
diff --git a/object.c b/object.c
index 45c9721b8c8..6d4ef1524de 100644
--- a/object.c
+++ b/object.c
@@ -3,6 +3,7 @@
 #include "hex.h"
 #include "object.h"
 #include "replace-object.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "blob.h"
 #include "tree.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index eba838d24ee..1371f17d22f 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -16,6 +16,7 @@
 #include "packfile.h"
 #include "repository.h"
 #include "trace2.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "list-objects-filter-options.h"
 #include "midx.h"
diff --git a/pack-check.c b/pack-check.c
index 6974e40a958..40d88bc5ebe 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -6,6 +6,7 @@
 #include "pack-revindex.h"
 #include "progress.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 
 struct idx_entry {
diff --git a/pack-mtimes.c b/pack-mtimes.c
index afed6321906..0096ace080b 100644
--- a/pack-mtimes.c
+++ b/pack-mtimes.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "gettext.h"
 #include "pack-mtimes.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
 
diff --git a/pack-revindex.c b/pack-revindex.c
index 9f9927d9471..22a1958a1fc 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "gettext.h"
 #include "pack-revindex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "packfile.h"
 #include "trace2.h"
diff --git a/packfile.c b/packfile.c
index 02afbe77137..9ae2278c22e 100644
--- a/packfile.c
+++ b/packfile.c
@@ -18,6 +18,7 @@
 #include "trace.h"
 #include "tree-walk.h"
 #include "tree.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "midx.h"
 #include "commit-graph.h"
diff --git a/read-cache.c b/read-cache.c
index cbbfc030da7..f225bf44cd0 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -14,6 +14,7 @@
 #include "cache-tree.h"
 #include "refs.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "oid-array.h"
 #include "tree.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index e6a6971381e..d0581ee41ac 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -12,6 +12,7 @@
 #include "../dir-iterator.h"
 #include "../lockfile.h"
 #include "../object.h"
+#include "../object-file.h"
 #include "../dir.h"
 #include "../chdir-notify.h"
 #include "../setup.h"
diff --git a/rerere.c b/rerere.c
index 5516e336d01..093c0f6f993 100644
--- a/rerere.c
+++ b/rerere.c
@@ -13,6 +13,7 @@
 #include "ll-merge.h"
 #include "attr.h"
 #include "pathspec.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "hash-lookup.h"
 #include "strmap.h"
diff --git a/revision.c b/revision.c
index 7438b50e267..3d86e07abb8 100644
--- a/revision.c
+++ b/revision.c
@@ -5,6 +5,7 @@
 #include "gettext.h"
 #include "hex.h"
 #include "object-name.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "tag.h"
 #include "blob.h"
diff --git a/sequencer.c b/sequencer.c
index 22b287be984..be10249fd0a 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -8,6 +8,7 @@
 #include "hex.h"
 #include "lockfile.h"
 #include "dir.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "object.h"
diff --git a/server-info.c b/server-info.c
index 355b6e01a52..68098ddd1ad 100644
--- a/server-info.c
+++ b/server-info.c
@@ -9,6 +9,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "packfile.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "strbuf.h"
 #include "wrapper.h"
diff --git a/streaming.c b/streaming.c
index 27e014d8b23..b3415724ee4 100644
--- a/streaming.c
+++ b/streaming.c
@@ -6,6 +6,7 @@
 #include "environment.h"
 #include "streaming.h"
 #include "repository.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "replace-object.h"
 #include "packfile.h"
diff --git a/submodule.c b/submodule.c
index 4f403b9eeff..d09bc22d4b6 100644
--- a/submodule.c
+++ b/submodule.c
@@ -24,6 +24,7 @@
 #include "remote.h"
 #include "worktree.h"
 #include "parse-options.h"
+#include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
 #include "commit-reach.h"
diff --git a/tmp-objdir.c b/tmp-objdir.c
index 5adad1925d1..fff7ff42db7 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -4,6 +4,7 @@
 #include "chdir-notify.h"
 #include "dir.h"
 #include "environment.h"
+#include "object-file.h"
 #include "sigchain.h"
 #include "string-list.h"
 #include "strbuf.h"
diff --git a/tree-walk.c b/tree-walk.c
index 59add24c8e9..2993c48c2f3 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -4,6 +4,7 @@
 #include "dir.h"
 #include "gettext.h"
 #include "hex.h"
+#include "object-file.h"
 #include "object-store.h"
 #include "trace2.h"
 #include "tree.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 13/23] treewide: remove cache.h inclusion due to object-file.h changes
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (5 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 12/23] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 14/23] object.h: move some inline functions and defines from cache.h Elijah Newren
                         ` (9 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 bulk-checkin.c  | 2 +-
 commit-graph.c  | 2 +-
 http-fetch.c    | 2 +-
 http-walker.c   | 2 +-
 http.h          | 1 -
 notes-merge.c   | 2 +-
 pack-bitmap.c   | 2 +-
 pack-check.c    | 2 +-
 pack-mtimes.c   | 2 +-
 pack-revindex.c | 2 +-
 streaming.c     | 2 +-
 tmp-objdir.c    | 2 +-
 12 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/bulk-checkin.c b/bulk-checkin.c
index af15f8a9af4..9192298db6a 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "bulk-checkin.h"
 #include "environment.h"
diff --git a/commit-graph.c b/commit-graph.c
index c20e73ceebf..0c4f2266445 100644
--- a/commit-graph.c
+++ b/commit-graph.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/http-fetch.c b/http-fetch.c
index c874d3402dd..fffda592670 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "exec-cmd.h"
 #include "gettext.h"
diff --git a/http-walker.c b/http-walker.c
index 4588e6a340a..3b41f5654b3 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "repository.h"
 #include "commit.h"
 #include "hex.h"
diff --git a/http.h b/http.h
index 783b2b09b8b..3a409bccd4e 100644
--- a/http.h
+++ b/http.h
@@ -3,7 +3,6 @@
 
 struct packed_git;
 
-#include "cache.h"
 #include "git-zlib.h"
 
 #include <curl/curl.h>
diff --git a/notes-merge.c b/notes-merge.c
index cc9538ac5c0..233e49e3195 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "advice.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index 1371f17d22f..48fc2ec76de 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/pack-check.c b/pack-check.c
index 40d88bc5ebe..049f2f0bfc0 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/pack-mtimes.c b/pack-mtimes.c
index 0096ace080b..020a37f8fe3 100644
--- a/pack-mtimes.c
+++ b/pack-mtimes.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-mtimes.h"
 #include "object-file.h"
diff --git a/pack-revindex.c b/pack-revindex.c
index 22a1958a1fc..4d9bb41b4db 100644
--- a/pack-revindex.c
+++ b/pack-revindex.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "pack-revindex.h"
 #include "object-file.h"
diff --git a/streaming.c b/streaming.c
index b3415724ee4..21e39585e89 100644
--- a/streaming.c
+++ b/streaming.c
@@ -1,7 +1,7 @@
 /*
  * Copyright (c) 2011, Google Inc.
  */
-#include "cache.h"
+#include "git-compat-util.h"
 #include "convert.h"
 #include "environment.h"
 #include "streaming.h"
diff --git a/tmp-objdir.c b/tmp-objdir.c
index fff7ff42db7..c33a554f921 100644
--- a/tmp-objdir.c
+++ b/tmp-objdir.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tmp-objdir.h"
 #include "abspath.h"
 #include "chdir-notify.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 14/23] object.h: move some inline functions and defines from cache.h
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (6 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 13/23] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 15/23] treewide: remove cache.h inclusion due to object.h changes Elijah Newren
                         ` (8 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

The object_type() inline function is very tied to the enum object_type
declaration within object.h, and just seemed to make more sense to live
there.  That makes S_ISGITLINK and some other defines make sense to go
with it, as well as the create_ce_mode() and canon_mode() inline
functions.  Move all these inline functions and defines from cache.h to
object.h.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 cache.h  | 42 ------------------------------------------
 object.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 42 deletions(-)

diff --git a/cache.h b/cache.h
index 89987cca22a..394e8d01254 100644
--- a/cache.h
+++ b/cache.h
@@ -28,18 +28,6 @@
 #define DTYPE(de)	DT_UNKNOWN
 #endif
 
-/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
-#define S_IFINVALID     0030000
-
-/*
- * A "directory link" is a link to another git directory.
- *
- * The value 0160000 is not normally a valid mode, and
- * also just happens to be S_IFDIR + S_IFLNK
- */
-#define S_IFGITLINK	0160000
-#define S_ISGITLINK(m)	(((m) & S_IFMT) == S_IFGITLINK)
-
 /*
  * Some mode bits are also used internally for computations.
  *
@@ -155,8 +143,6 @@ struct cache_entry {
 #error "CE_EXTENDED_FLAGS out of range"
 #endif
 
-#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
-
 /* Forward structure decls */
 struct pathspec;
 struct child_process;
@@ -197,17 +183,6 @@ static inline unsigned create_ce_flags(unsigned stage)
 #define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
 #define ce_intent_to_add(ce) ((ce)->ce_flags & CE_INTENT_TO_ADD)
 
-#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
-static inline unsigned int create_ce_mode(unsigned int mode)
-{
-	if (S_ISLNK(mode))
-		return S_IFLNK;
-	if (S_ISSPARSEDIR(mode))
-		return S_IFDIR;
-	if (S_ISDIR(mode) || S_ISGITLINK(mode))
-		return S_IFGITLINK;
-	return S_IFREG | ce_permissions(mode);
-}
 static inline unsigned int ce_mode_from_stat(const struct cache_entry *ce,
 					     unsigned int mode)
 {
@@ -234,16 +209,6 @@ static inline int ce_to_dtype(const struct cache_entry *ce)
 	else
 		return DT_UNKNOWN;
 }
-static inline unsigned int canon_mode(unsigned int mode)
-{
-	if (S_ISREG(mode))
-		return S_IFREG | ce_permissions(mode);
-	if (S_ISLNK(mode))
-		return S_IFLNK;
-	if (S_ISDIR(mode))
-		return S_IFDIR;
-	return S_IFGITLINK;
-}
 
 static inline int ce_path_match(struct index_state *istate,
 				const struct cache_entry *ce,
@@ -414,13 +379,6 @@ void prefetch_cache_entries(const struct index_state *istate,
 extern struct index_state the_index;
 #endif
 
-static inline enum object_type object_type(unsigned int mode)
-{
-	return S_ISDIR(mode) ? OBJ_TREE :
-		S_ISGITLINK(mode) ? OBJ_COMMIT :
-		OBJ_BLOB;
-}
-
 #define INIT_DB_QUIET 0x0001
 #define INIT_DB_EXIST_OK 0x0002
 
diff --git a/object.h b/object.h
index fc45b158da0..96e52e24fb1 100644
--- a/object.h
+++ b/object.h
@@ -101,6 +101,50 @@ enum object_type {
 	OBJ_MAX
 };
 
+/* unknown mode (impossible combination S_IFIFO|S_IFCHR) */
+#define S_IFINVALID     0030000
+
+/*
+ * A "directory link" is a link to another git directory.
+ *
+ * The value 0160000 is not normally a valid mode, and
+ * also just happens to be S_IFDIR + S_IFLNK
+ */
+#define S_IFGITLINK	0160000
+#define S_ISGITLINK(m)	(((m) & S_IFMT) == S_IFGITLINK)
+
+#define S_ISSPARSEDIR(m) ((m) == S_IFDIR)
+
+static inline enum object_type object_type(unsigned int mode)
+{
+	return S_ISDIR(mode) ? OBJ_TREE :
+		S_ISGITLINK(mode) ? OBJ_COMMIT :
+		OBJ_BLOB;
+}
+
+#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
+static inline unsigned int create_ce_mode(unsigned int mode)
+{
+	if (S_ISLNK(mode))
+		return S_IFLNK;
+	if (S_ISSPARSEDIR(mode))
+		return S_IFDIR;
+	if (S_ISDIR(mode) || S_ISGITLINK(mode))
+		return S_IFGITLINK;
+	return S_IFREG | ce_permissions(mode);
+}
+
+static inline unsigned int canon_mode(unsigned int mode)
+{
+	if (S_ISREG(mode))
+		return S_IFREG | ce_permissions(mode);
+	if (S_ISLNK(mode))
+		return S_IFLNK;
+	if (S_ISDIR(mode))
+		return S_IFDIR;
+	return S_IFGITLINK;
+}
+
 /*
  * The object type is stored in 3 bits.
  */
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 15/23] treewide: remove cache.h inclusion due to object.h changes
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (7 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 14/23] object.h: move some inline functions and defines from cache.h Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 16/23] editor: move editor-related functions and declarations into common file Elijah Newren
                         ` (7 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 bisect.c              | 2 +-
 bundle.c              | 2 +-
 commit.c              | 2 +-
 delta-islands.c       | 2 +-
 diff-no-index.c       | 2 +-
 fsck.c                | 2 +-
 http-push.c           | 2 +-
 list-objects-filter.c | 2 +-
 list-objects.c        | 2 +-
 log-tree.c            | 2 +-
 pack-bitmap-write.c   | 2 +-
 parse-options-cb.c    | 1 -
 rebase-interactive.c  | 2 +-
 submodule-config.c    | 2 +-
 tag.c                 | 2 +-
 transport.c           | 2 +-
 walker.c              | 2 +-
 17 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/bisect.c b/bisect.c
index e708e8b6aa1..8d5f8e58851 100644
--- a/bisect.c
+++ b/bisect.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/bundle.c b/bundle.c
index 6471489975a..a5505368de5 100644
--- a/bundle.c
+++ b/bundle.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "lockfile.h"
 #include "bundle.h"
 #include "environment.h"
diff --git a/commit.c b/commit.c
index bad31c423a4..878b4473e4c 100644
--- a/commit.c
+++ b/commit.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
 #include "commit-graph.h"
diff --git a/delta-islands.c b/delta-islands.c
index 40f2ccfb550..c824a5f6a42 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "attr.h"
 #include "object.h"
diff --git a/diff-no-index.c b/diff-no-index.c
index 934a24bee58..4296940f907 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -4,7 +4,7 @@
  * Copyright (c) 2008 by Junio C Hamano
  */
 
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "color.h"
 #include "commit.h"
diff --git a/fsck.c b/fsck.c
index 8ef1b022346..adbe8bf59e7 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "hex.h"
 #include "object-store.h"
diff --git a/http-push.c b/http-push.c
index a8af6c0f690..637a4e91f7a 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "hex.h"
 #include "repository.h"
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 8b2a45e507d..5d270ce5987 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "gettext.h"
diff --git a/list-objects.c b/list-objects.c
index df18d103063..eecca721ac0 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "tag.h"
 #include "commit.h"
 #include "gettext.h"
diff --git a/log-tree.c b/log-tree.c
index f0e885635e0..b5cf3d8439c 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "commit-reach.h"
 #include "config.h"
 #include "diff.h"
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index 7f5f489beb0..faf67c94d37 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.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/parse-options-cb.c b/parse-options-cb.c
index b4df4bcebed..26a4c7d08a9 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -1,7 +1,6 @@
 #include "git-compat-util.h"
 #include "parse-options.h"
 #include "branch.h"
-#include "cache.h"
 #include "commit.h"
 #include "color.h"
 #include "environment.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 48467a7bc4a..6ff12d7be2d 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "commit.h"
 #include "environment.h"
 #include "gettext.h"
diff --git a/submodule-config.c b/submodule-config.c
index 252b90aa439..7fc0812b644 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "dir.h"
 #include "environment.h"
diff --git a/tag.c b/tag.c
index b9fc2fc9929..96dbd5b2d55 100644
--- a/tag.c
+++ b/tag.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "environment.h"
 #include "tag.h"
 #include "object-name.h"
diff --git a/transport.c b/transport.c
index 7374cfd1fa9..8d3ad8022a4 100644
--- a/transport.c
+++ b/transport.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/walker.c b/walker.c
index cfbd257fdba..24ff7dfdc28 100644
--- a/walker.c
+++ b/walker.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "gettext.h"
 #include "hex.h"
 #include "walker.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 16/23] editor: move editor-related functions and declarations into common file
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (8 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 15/23] treewide: remove cache.h inclusion due to object.h changes Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 17/23] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren
                         ` (6 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

cache.h and strbuf.[ch] had editor-related functions.  Move these into
editor.[ch].

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 add-patch.c          |  1 +
 builtin/add.c        |  1 +
 builtin/am.c         |  1 +
 builtin/branch.c     |  1 +
 builtin/bugreport.c  |  1 +
 builtin/commit.c     |  1 +
 builtin/config.c     |  1 +
 builtin/merge.c      |  1 +
 builtin/notes.c      |  1 +
 builtin/replace.c    |  1 +
 builtin/tag.c        |  1 +
 builtin/var.c        |  1 +
 cache.h              |  3 ---
 color.c              |  1 +
 editor.c             | 30 ++++++++++++++++++++++++++++++
 editor.h             | 34 ++++++++++++++++++++++++++++++++++
 pager.c              |  1 +
 rebase-interactive.c |  1 +
 sideband.c           |  1 +
 strbuf.c             | 28 ----------------------------
 strbuf.h             | 24 ------------------------
 21 files changed, 80 insertions(+), 55 deletions(-)
 create mode 100644 editor.h

diff --git a/add-patch.c b/add-patch.c
index b01ba8fa81d..8d770d203ff 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -2,6 +2,7 @@
 #include "add-interactive.h"
 #include "advice.h"
 #include "alloc.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "object-name.h"
diff --git a/builtin/add.c b/builtin/add.c
index d3c51e28142..76cc026a68a 100644
--- a/builtin/add.c
+++ b/builtin/add.c
@@ -9,6 +9,7 @@
 #include "config.h"
 #include "builtin.h"
 #include "lockfile.h"
+#include "editor.h"
 #include "dir.h"
 #include "gettext.h"
 #include "pathspec.h"
diff --git a/builtin/am.c b/builtin/am.c
index 0d7ee28bddc..f7a065e5290 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -9,6 +9,7 @@
 #include "advice.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "exec-cmd.h"
 #include "gettext.h"
diff --git a/builtin/branch.c b/builtin/branch.c
index 7c1c872708f..1fb11d55e65 100644
--- a/builtin/branch.c
+++ b/builtin/branch.c
@@ -8,6 +8,7 @@
 #include "cache.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "environment.h"
 #include "refs.h"
 #include "commit.h"
diff --git a/builtin/bugreport.c b/builtin/bugreport.c
index 03fb0536911..daf6c236577 100644
--- a/builtin/bugreport.c
+++ b/builtin/bugreport.c
@@ -1,5 +1,6 @@
 #include "builtin.h"
 #include "abspath.h"
+#include "editor.h"
 #include "gettext.h"
 #include "parse-options.h"
 #include "strbuf.h"
diff --git a/builtin/commit.c b/builtin/commit.c
index 682f47c8d5a..e67c4be2211 100644
--- a/builtin/commit.c
+++ b/builtin/commit.c
@@ -13,6 +13,7 @@
 #include "cache-tree.h"
 #include "color.h"
 #include "dir.h"
+#include "editor.h"
 #include "environment.h"
 #include "builtin.h"
 #include "diff.h"
diff --git a/builtin/config.c b/builtin/config.c
index fe79fb60c43..9401f1e5e3b 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -3,6 +3,7 @@
 #include "alloc.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "ident.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 693f185d4d3..8da3e46abb0 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -12,6 +12,7 @@
 #include "advice.h"
 #include "alloc.h"
 #include "config.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 896140b9055..d5788352b6e 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -10,6 +10,7 @@
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "gettext.h"
 #include "hex.h"
 #include "notes.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index f4b3a8efb23..981f1894436 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -11,6 +11,7 @@
 #include "cache.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index 88a25902309..7d189a4a5d4 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -10,6 +10,7 @@
 #include "advice.h"
 #include "config.h"
 #include "builtin.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "hex.h"
diff --git a/builtin/var.c b/builtin/var.c
index d9943be9afd..90616cf65a2 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -5,6 +5,7 @@
  */
 #include "builtin.h"
 #include "config.h"
+#include "editor.h"
 #include "ident.h"
 #include "refs.h"
 
diff --git a/cache.h b/cache.h
index 394e8d01254..97ddf4094a3 100644
--- a/cache.h
+++ b/cache.h
@@ -621,10 +621,7 @@ 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);
 
-const char *git_editor(void);
-const char *git_sequence_editor(void);
 const char *git_pager(int stdout_is_tty);
-int is_terminal_dumb(void);
 
 struct cache_def {
 	struct strbuf path;
diff --git a/color.c b/color.c
index 672dcbb73a6..a8e8d5202ab 100644
--- a/color.c
+++ b/color.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "config.h"
 #include "color.h"
+#include "editor.h"
 #include "gettext.h"
 #include "hex.h"
 
diff --git a/editor.c b/editor.c
index 3bea3ef72f7..12025dfec37 100644
--- a/editor.c
+++ b/editor.c
@@ -2,12 +2,14 @@
 #include "abspath.h"
 #include "advice.h"
 #include "config.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "run-command.h"
 #include "sigchain.h"
+#include "wrapper.h"
 
 #ifndef DEFAULT_EDITOR
 #define DEFAULT_EDITOR "vi"
@@ -130,3 +132,31 @@ int launch_sequence_editor(const char *path, struct strbuf *buffer,
 {
 	return launch_specified_editor(git_sequence_editor(), path, buffer, env);
 }
+
+int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
+			      const char *const *env)
+{
+	char *path2 = NULL;
+	int fd, res = 0;
+
+	if (!is_absolute_path(path))
+		path = path2 = xstrdup(git_path("%s", path));
+
+	fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+	if (fd < 0)
+		res = error_errno(_("could not open '%s' for writing"), path);
+	else if (write_in_full(fd, buffer->buf, buffer->len) < 0) {
+		res = error_errno(_("could not write to '%s'"), path);
+		close(fd);
+	} else if (close(fd) < 0)
+		res = error_errno(_("could not close '%s'"), path);
+	else {
+		strbuf_reset(buffer);
+		if (launch_editor(path, buffer, env) < 0)
+			res = error_errno(_("could not edit '%s'"), path);
+		unlink(path);
+	}
+
+	free(path2);
+	return res;
+}
diff --git a/editor.h b/editor.h
new file mode 100644
index 00000000000..8016bb5e00b
--- /dev/null
+++ b/editor.h
@@ -0,0 +1,34 @@
+#ifndef EDITOR_H
+#define EDITOR_H
+
+struct strbuf;
+
+const char *git_editor(void);
+const char *git_sequence_editor(void);
+int is_terminal_dumb(void);
+
+/**
+ * Launch the user preferred editor to edit a file and fill the buffer
+ * with the file's contents upon the user completing their editing. The
+ * third argument can be used to set the environment which the editor is
+ * run in. If the buffer is NULL the editor is launched as usual but the
+ * file's contents are not read into the buffer upon completion.
+ */
+int launch_editor(const char *path, struct strbuf *buffer,
+		  const char *const *env);
+
+int launch_sequence_editor(const char *path, struct strbuf *buffer,
+			   const char *const *env);
+
+/*
+ * In contrast to `launch_editor()`, this function writes out the contents
+ * of the specified file first, then clears the `buffer`, then launches
+ * the editor and reads back in the file contents into the `buffer`.
+ * Finally, it deletes the temporary file.
+ *
+ * If `path` is relative, it refers to a file in the `.git` directory.
+ */
+int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
+			      const char *const *env);
+
+#endif
diff --git a/pager.c b/pager.c
index b66bbff2785..6367e8ef867 100644
--- a/pager.c
+++ b/pager.c
@@ -1,5 +1,6 @@
 #include "cache.h"
 #include "config.h"
+#include "editor.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "alias.h"
diff --git a/rebase-interactive.c b/rebase-interactive.c
index 6ff12d7be2d..789f4073617 100644
--- a/rebase-interactive.c
+++ b/rebase-interactive.c
@@ -1,5 +1,6 @@
 #include "git-compat-util.h"
 #include "commit.h"
+#include "editor.h"
 #include "environment.h"
 #include "gettext.h"
 #include "sequencer.h"
diff --git a/sideband.c b/sideband.c
index 0af582858bf..25e2a185716 100644
--- a/sideband.c
+++ b/sideband.c
@@ -1,6 +1,7 @@
 #include "cache.h"
 #include "color.h"
 #include "config.h"
+#include "editor.h"
 #include "gettext.h"
 #include "sideband.h"
 #include "help.h"
diff --git a/strbuf.c b/strbuf.c
index b2e3735ba8a..729378ec824 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1180,34 +1180,6 @@ int strbuf_normalize_path(struct strbuf *src)
 	return 0;
 }
 
-int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
-			      const char *const *env)
-{
-	char *path2 = NULL;
-	int fd, res = 0;
-
-	if (!is_absolute_path(path))
-		path = path2 = xstrdup(git_path("%s", path));
-
-	fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, 0666);
-	if (fd < 0)
-		res = error_errno(_("could not open '%s' for writing"), path);
-	else if (write_in_full(fd, buffer->buf, buffer->len) < 0) {
-		res = error_errno(_("could not write to '%s'"), path);
-		close(fd);
-	} else if (close(fd) < 0)
-		res = error_errno(_("could not close '%s'"), path);
-	else {
-		strbuf_reset(buffer);
-		if (launch_editor(path, buffer, env) < 0)
-			res = error_errno(_("could not edit '%s'"), path);
-		unlink(path);
-	}
-
-	free(path2);
-	return res;
-}
-
 void strbuf_strip_file_from_path(struct strbuf *sb)
 {
 	char *path_sep = find_last_dir_sep(sb->buf);
diff --git a/strbuf.h b/strbuf.h
index b980f9edc6d..3dfeadb44c2 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -640,30 +640,6 @@ void strbuf_repo_add_unique_abbrev(struct strbuf *sb, struct repository *repo,
 void strbuf_add_unique_abbrev(struct strbuf *sb, const struct object_id *oid,
 			      int abbrev_len);
 
-/**
- * Launch the user preferred editor to edit a file and fill the buffer
- * with the file's contents upon the user completing their editing. The
- * third argument can be used to set the environment which the editor is
- * run in. If the buffer is NULL the editor is launched as usual but the
- * file's contents are not read into the buffer upon completion.
- */
-int launch_editor(const char *path, struct strbuf *buffer,
-		  const char *const *env);
-
-int launch_sequence_editor(const char *path, struct strbuf *buffer,
-			   const char *const *env);
-
-/*
- * In contrast to `launch_editor()`, this function writes out the contents
- * of the specified file first, then clears the `buffer`, then launches
- * the editor and reads back in the file contents into the `buffer`.
- * Finally, it deletes the temporary file.
- *
- * If `path` is relative, it refers to a file in the `.git` directory.
- */
-int strbuf_edit_interactively(struct strbuf *buffer, const char *path,
-			      const char *const *env);
-
 /*
  * Remove the filename from the provided path string. If the path
  * contains a trailing separator, then the path is considered a directory
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 17/23] treewide: remove cache.h inclusion due to editor.h changes
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (9 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 16/23] editor: move editor-related functions and declarations into common file Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:41       ` [PATCH v3 18/23] pager.h: move declarations for pager.c functions from cache.h Elijah Newren
                         ` (5 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

This actually only affects sideband.c, but helps towards removing
cache.h inclusion in conjunction with some of the upcoming patches
that will be applied.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 sideband.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sideband.c b/sideband.c
index 25e2a185716..6cbfd391c47 100644
--- a/sideband.c
+++ b/sideband.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "color.h"
 #include "config.h"
 #include "editor.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 18/23] pager.h: move declarations for pager.c functions from cache.h
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (10 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 17/23] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren
@ 2023-04-11  7:41       ` Elijah Newren
  2023-04-11  7:42       ` [PATCH v3 19/23] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren
                         ` (4 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:41 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 builtin/am.c       |  1 +
 builtin/blame.c    |  1 +
 builtin/fetch.c    |  1 +
 builtin/grep.c     |  1 +
 builtin/help.c     |  1 +
 builtin/log.c      |  1 +
 builtin/name-rev.c |  1 +
 builtin/var.c      |  1 +
 cache.h            | 13 -------------
 color.c            |  1 +
 column.c           |  1 +
 config.c           |  1 +
 date.c             |  1 +
 diff.c             |  1 +
 editor.c           |  1 +
 environment.c      |  1 -
 git.c              |  1 +
 pager.c            |  3 +++
 pager.h            | 17 +++++++++++++++++
 pretty.c           |  1 +
 progress.c         |  1 +
 range-diff.c       |  1 +
 sequencer.c        |  1 +
 23 files changed, 39 insertions(+), 14 deletions(-)
 create mode 100644 pager.h

diff --git a/builtin/am.c b/builtin/am.c
index f7a065e5290..5c83f2e003f 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -40,6 +40,7 @@
 #include "apply.h"
 #include "string-list.h"
 #include "packfile.h"
+#include "pager.h"
 #include "repository.h"
 #include "pretty.h"
 #include "wrapper.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index a628388c2ce..2df6039a6e0 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -30,6 +30,7 @@
 #include "progress.h"
 #include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "blame.h"
 #include "refs.h"
 #include "setup.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 8a8ab6799e8..61e8ac113b1 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -28,6 +28,7 @@
 #include "strvec.h"
 #include "utf8.h"
 #include "packfile.h"
+#include "pager.h"
 #include "list-objects-filter-options.h"
 #include "commit-reach.h"
 #include "branch.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index fb11be6075a..b86c754defb 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -30,6 +30,7 @@
 #include "object-name.h"
 #include "object-store.h"
 #include "packfile.h"
+#include "pager.h"
 #include "write-or-die.h"
 
 static const char *grep_prefix;
diff --git a/builtin/help.c b/builtin/help.c
index 87333a02ec4..128aa83099a 100644
--- a/builtin/help.c
+++ b/builtin/help.c
@@ -6,6 +6,7 @@
 #include "builtin.h"
 #include "exec-cmd.h"
 #include "gettext.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "run-command.h"
 #include "config-list.h"
diff --git a/builtin/log.c b/builtin/log.c
index b6246c7042c..95de51921f8 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -15,6 +15,7 @@
 #include "object-file.h"
 #include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "color.h"
 #include "commit.h"
 #include "diff.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 41fd56b9ba9..593f0506a10 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -9,6 +9,7 @@
 #include "tag.h"
 #include "refs.h"
 #include "object-name.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "prio-queue.h"
 #include "hash-lookup.h"
diff --git a/builtin/var.c b/builtin/var.c
index 90616cf65a2..aa8150fa92e 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -7,6 +7,7 @@
 #include "config.h"
 #include "editor.h"
 #include "ident.h"
+#include "pager.h"
 #include "refs.h"
 
 static const char var_usage[] = "git var (-l | <variable>)";
diff --git a/cache.h b/cache.h
index 97ddf4094a3..21fd520b045 100644
--- a/cache.h
+++ b/cache.h
@@ -145,7 +145,6 @@ struct cache_entry {
 
 /* Forward structure decls */
 struct pathspec;
-struct child_process;
 struct tree;
 
 /*
@@ -621,8 +620,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);
 
-const char *git_pager(int stdout_is_tty);
-
 struct cache_def {
 	struct strbuf path;
 	int flags;
@@ -671,16 +668,6 @@ 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);
 
-/* pager.c */
-void setup_pager(void);
-int pager_in_use(void);
-extern int pager_use_color;
-int term_columns(void);
-void term_clear_line(void);
-int decimal_width(uintmax_t);
-int check_pager_config(const char *cmd);
-void prepare_pager_args(struct child_process *, const char *pager);
-
 /* 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/color.c b/color.c
index a8e8d5202ab..6031998d3ea 100644
--- a/color.c
+++ b/color.c
@@ -4,6 +4,7 @@
 #include "editor.h"
 #include "gettext.h"
 #include "hex.h"
+#include "pager.h"
 
 static int git_use_color_default = GIT_COLOR_AUTO;
 int color_stdout_is_tty = -1;
diff --git a/column.c b/column.c
index fbf88639aae..c89c90328a6 100644
--- a/column.c
+++ b/column.c
@@ -2,6 +2,7 @@
 #include "config.h"
 #include "column.h"
 #include "string-list.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "run-command.h"
 #include "utf8.h"
diff --git a/config.c b/config.c
index aac439530e9..11e3295419b 100644
--- a/config.c
+++ b/config.c
@@ -25,6 +25,7 @@
 #include "string-list.h"
 #include "object-name.h"
 #include "object-store.h"
+#include "pager.h"
 #include "utf8.h"
 #include "dir.h"
 #include "color.h"
diff --git a/date.c b/date.c
index 1fb2cd1b538..e944c8905af 100644
--- a/date.c
+++ b/date.c
@@ -7,6 +7,7 @@
 #include "cache.h"
 #include "date.h"
 #include "gettext.h"
+#include "pager.h"
 
 /*
  * This is like mktime, but without normalization of tm_wday and tm_yday.
diff --git a/diff.c b/diff.c
index f8e0d3b5c59..fa86d023196 100644
--- a/diff.c
+++ b/diff.c
@@ -31,6 +31,7 @@
 #include "graph.h"
 #include "oid-array.h"
 #include "packfile.h"
+#include "pager.h"
 #include "parse-options.h"
 #include "help.h"
 #include "promisor-remote.h"
diff --git a/editor.c b/editor.c
index 12025dfec37..7c796385493 100644
--- a/editor.c
+++ b/editor.c
@@ -5,6 +5,7 @@
 #include "editor.h"
 #include "environment.h"
 #include "gettext.h"
+#include "pager.h"
 #include "strbuf.h"
 #include "strvec.h"
 #include "run-command.h"
diff --git a/environment.c b/environment.c
index 39efa49fe31..8a96997539a 100644
--- a/environment.c
+++ b/environment.c
@@ -59,7 +59,6 @@ size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 size_t delta_base_cache_limit = 96 * 1024 * 1024;
 unsigned long big_file_threshold = 512 * 1024 * 1024;
-int pager_use_color = 1;
 const char *editor_program;
 const char *askpass_program;
 const char *excludes_file;
diff --git a/git.c b/git.c
index d2bb86e0d32..0241d2cf913 100644
--- a/git.c
+++ b/git.c
@@ -4,6 +4,7 @@
 #include "exec-cmd.h"
 #include "gettext.h"
 #include "help.h"
+#include "pager.h"
 #include "run-command.h"
 #include "alias.h"
 #include "replace-object.h"
diff --git a/pager.c b/pager.c
index 6367e8ef867..be78c706644 100644
--- a/pager.c
+++ b/pager.c
@@ -1,10 +1,13 @@
 #include "cache.h"
 #include "config.h"
 #include "editor.h"
+#include "pager.h"
 #include "run-command.h"
 #include "sigchain.h"
 #include "alias.h"
 
+int pager_use_color = 1;
+
 #ifndef DEFAULT_PAGER
 #define DEFAULT_PAGER "less"
 #endif
diff --git a/pager.h b/pager.h
new file mode 100644
index 00000000000..b77433026dc
--- /dev/null
+++ b/pager.h
@@ -0,0 +1,17 @@
+#ifndef PAGER_H
+#define PAGER_H
+
+struct child_process;
+
+const char *git_pager(int stdout_is_tty);
+void setup_pager(void);
+int pager_in_use(void);
+int term_columns(void);
+void term_clear_line(void);
+int decimal_width(uintmax_t);
+int check_pager_config(const char *cmd);
+void prepare_pager_args(struct child_process *, const char *pager);
+
+extern int pager_use_color;
+
+#endif /* PAGER_H */
diff --git a/pretty.c b/pretty.c
index 76fc4f61e40..c4671603b56 100644
--- a/pretty.c
+++ b/pretty.c
@@ -7,6 +7,7 @@
 #include "hex.h"
 #include "utf8.h"
 #include "diff.h"
+#include "pager.h"
 #include "revision.h"
 #include "string-list.h"
 #include "mailmap.h"
diff --git a/progress.c b/progress.c
index c5c8514737a..96a8e36a52f 100644
--- a/progress.c
+++ b/progress.c
@@ -10,6 +10,7 @@
 
 #define GIT_TEST_PROGRESS_ONLY
 #include "cache.h"
+#include "pager.h"
 #include "progress.h"
 #include "strbuf.h"
 #include "trace.h"
diff --git a/range-diff.c b/range-diff.c
index a2994331a14..a1e0cffb9f6 100644
--- a/range-diff.c
+++ b/range-diff.c
@@ -11,6 +11,7 @@
 #include "linear-assignment.h"
 #include "diffcore.h"
 #include "commit.h"
+#include "pager.h"
 #include "pretty.h"
 #include "userdiff.h"
 #include "apply.h"
diff --git a/sequencer.c b/sequencer.c
index be10249fd0a..fcca3b81447 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -12,6 +12,7 @@
 #include "object-name.h"
 #include "object-store.h"
 #include "object.h"
+#include "pager.h"
 #include "commit.h"
 #include "sequencer.h"
 #include "tag.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 19/23] treewide: remove cache.h inclusion due to pager.h changes
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (11 preceding siblings ...)
  2023-04-11  7:41       ` [PATCH v3 18/23] pager.h: move declarations for pager.c functions from cache.h Elijah Newren
@ 2023-04-11  7:42       ` Elijah Newren
  2023-04-11  7:42       ` [PATCH v3 20/23] cache.h: remove unnecessary includes Elijah Newren
                         ` (3 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:42 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 column.c   | 2 +-
 editor.c   | 2 +-
 pager.c    | 2 +-
 pretty.c   | 2 +-
 progress.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/column.c b/column.c
index c89c90328a6..ff2f0abf399 100644
--- a/column.c
+++ b/column.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "column.h"
 #include "string-list.h"
diff --git a/editor.c b/editor.c
index 7c796385493..b34e10606d2 100644
--- a/editor.c
+++ b/editor.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "advice.h"
 #include "config.h"
diff --git a/pager.c b/pager.c
index be78c706644..63055d0873f 100644
--- a/pager.c
+++ b/pager.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "config.h"
 #include "editor.h"
 #include "pager.h"
diff --git a/pretty.c b/pretty.c
index c4671603b56..0bb938021ba 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
 #include "config.h"
 #include "commit.h"
diff --git a/progress.c b/progress.c
index 96a8e36a52f..72d5e0c73c1 100644
--- a/progress.c
+++ b/progress.c
@@ -9,7 +9,7 @@
  */
 
 #define GIT_TEST_PROGRESS_ONLY
-#include "cache.h"
+#include "git-compat-util.h"
 #include "pager.h"
 #include "progress.h"
 #include "strbuf.h"
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 20/23] cache.h: remove unnecessary includes
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (12 preceding siblings ...)
  2023-04-11  7:42       ` [PATCH v3 19/23] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren
@ 2023-04-11  7:42       ` Elijah Newren
  2023-04-11  7:42       ` [PATCH v3 21/23] treewide: remove double forward declaration of read_in_full Elijah Newren
                         ` (2 subsequent siblings)
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:42 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

cache.h did not need any of these headers, and nothing that depended
upon cache.h needed them either.  Simply expunge these includes.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 cache.h | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/cache.h b/cache.h
index 21fd520b045..16b5fc9fa31 100644
--- a/cache.h
+++ b/cache.h
@@ -4,14 +4,10 @@
 #include "git-compat-util.h"
 #include "strbuf.h"
 #include "hashmap.h"
-#include "list.h"
 #include "gettext.h"
 #include "string-list.h"
-#include "hash.h"
-#include "path.h"
 #include "pathspec.h"
 #include "object.h"
-#include "repository.h"
 #include "statinfo.h"
 
 #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 21/23] treewide: remove double forward declaration of read_in_full
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (13 preceding siblings ...)
  2023-04-11  7:42       ` [PATCH v3 20/23] cache.h: remove unnecessary includes Elijah Newren
@ 2023-04-11  7:42       ` Elijah Newren
  2023-04-11  7:42       ` [PATCH v3 22/23] treewide: reduce includes of cache.h in other headers Elijah Newren
  2023-04-11  7:42       ` [PATCH v3 23/23] mailmap, quote: move declarations of global vars to correct unit Elijah Newren
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:42 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

cache.h's nature of a dumping ground of includes prevented it from
being included in some compat/ files, forcing us into a workaround
of having a double forward declaration of the read_in_full() function
(see commit 14086b0a13 ("compat/pread.c: Add a forward declaration to
fix a warning", 2007-11-17)).  Now that we have moved functions like
read_in_full() from cache.h to wrapper.h, and wrapper.h isn't littered
with unrelated and scary #defines, get rid of the extra forward
declaration and just have compat/pread.c include wrapper.h.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 builtin/clone.c       | 1 +
 bulk-checkin.c        | 1 +
 combine-diff.c        | 1 +
 compat/pread.c        | 1 +
 git-compat-util.h     | 6 ------
 grep.c                | 1 +
 pack-write.c          | 1 +
 path.c                | 1 +
 refs/packed-backend.c | 1 +
 send-pack.c           | 1 +
 setup.c               | 1 +
 upload-pack.c         | 1 +
 12 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/builtin/clone.c b/builtin/clone.c
index c7fdffb484c..4ed0a1d5aad 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -42,6 +42,7 @@
 #include "hook.h"
 #include "bundle.h"
 #include "bundle-uri.h"
+#include "wrapper.h"
 
 /*
  * Overall FIXMEs:
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 9192298db6a..d843279715c 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -17,6 +17,7 @@
 #include "packfile.h"
 #include "object-file.h"
 #include "object-store.h"
+#include "wrapper.h"
 
 static int odb_transaction_nesting;
 
diff --git a/combine-diff.c b/combine-diff.c
index cd5f39f22f4..f7e9fb57473 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -16,6 +16,7 @@
 #include "userdiff.h"
 #include "oid-array.h"
 #include "revision.h"
+#include "wrapper.h"
 
 static int compare_paths(const struct combine_diff_path *one,
 			  const struct diff_filespec *two)
diff --git a/compat/pread.c b/compat/pread.c
index 978cac4ec91..484e6d4c716 100644
--- a/compat/pread.c
+++ b/compat/pread.c
@@ -1,4 +1,5 @@
 #include "../git-compat-util.h"
+#include "../wrapper.h"
 
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
 {
diff --git a/git-compat-util.h b/git-compat-util.h
index 1e6592624d0..4fb771f42a5 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -859,12 +859,6 @@ int git_lstat(const char *, struct stat *);
 #define pread git_pread
 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
 #endif
-/*
- * Forward decl that will remind us if its twin in cache.h changes.
- * This function is used in compat/pread.c.  But we can't include
- * cache.h there.
- */
-ssize_t read_in_full(int fd, void *buf, size_t count);
 
 #ifdef NO_SETENV
 #define setenv gitsetenv
diff --git a/grep.c b/grep.c
index bb8796a829f..d144b374894 100644
--- a/grep.c
+++ b/grep.c
@@ -11,6 +11,7 @@
 #include "commit.h"
 #include "quote.h"
 #include "help.h"
+#include "wrapper.h"
 
 static int grep_source_load(struct grep_source *gs);
 static int grep_source_is_binary(struct grep_source *gs,
diff --git a/pack-write.c b/pack-write.c
index d9b460fab4c..9c37121be31 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -10,6 +10,7 @@
 #include "oidmap.h"
 #include "pack-objects.h"
 #include "pack-revindex.h"
+#include "wrapper.h"
 
 void reset_pack_idx_option(struct pack_idx_option *opts)
 {
diff --git a/path.c b/path.c
index dff215ac693..7c1cd8182a8 100644
--- a/path.c
+++ b/path.c
@@ -18,6 +18,7 @@
 #include "object-store.h"
 #include "lockfile.h"
 #include "exec-cmd.h"
+#include "wrapper.h"
 
 static int get_st_mode_bits(const char *path, int *mode)
 {
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 1eba1015dd5..2333ed5a1f7 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 "../wrapper.h"
 #include "../write-or-die.h"
 
 enum mmap_strategy {
diff --git a/send-pack.c b/send-pack.c
index 72ebb7b61ae..351037b07bc 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -14,6 +14,7 @@
 #include "quote.h"
 #include "transport.h"
 #include "version.h"
+#include "wrapper.h"
 #include "oid-array.h"
 #include "gpg-interface.h"
 #include "shallow.h"
diff --git a/setup.c b/setup.c
index a546da755f1..59abc16ba6d 100644
--- a/setup.c
+++ b/setup.c
@@ -12,6 +12,7 @@
 #include "promisor-remote.h"
 #include "quote.h"
 #include "trace2.h"
+#include "wrapper.h"
 
 static int inside_git_dir = -1;
 static int inside_work_tree = -1;
diff --git a/upload-pack.c b/upload-pack.c
index 0305fb2fbdc..e16dee783dd 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -32,6 +32,7 @@
 #include "commit-graph.h"
 #include "commit-reach.h"
 #include "shallow.h"
+#include "wrapper.h"
 #include "write-or-die.h"
 
 /* Remember to update object flag allocation in object.h */
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 22/23] treewide: reduce includes of cache.h in other headers
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (14 preceding siblings ...)
  2023-04-11  7:42       ` [PATCH v3 21/23] treewide: remove double forward declaration of read_in_full Elijah Newren
@ 2023-04-11  7:42       ` Elijah Newren
  2023-04-11  7:42       ` [PATCH v3 23/23] mailmap, quote: move declarations of global vars to correct unit Elijah Newren
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:42 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

We had a handful of headers including cache.h that didn't need to
anymore.  Drop those includes and replace them with includes of
smaller files, or forward declarations.  However, note that two .c
files now need to directly include cache.h, though they should have
been including it all along given they are directly using structs
defined in it.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 archive.h        | 2 +-
 chdir-notify.c   | 3 ++-
 quote.c          | 3 ++-
 refs/ref-cache.h | 2 +-
 rerere.c         | 2 +-
 resolve-undo.h   | 7 ++++++-
 revision.c       | 2 +-
 split-index.h    | 2 +-
 8 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/archive.h b/archive.h
index f96839ef383..3a4bdfbd078 100644
--- a/archive.h
+++ b/archive.h
@@ -1,9 +1,9 @@
 #ifndef ARCHIVE_H
 #define ARCHIVE_H
 
-#include "cache.h"
 #include "object-name.h"
 #include "pathspec.h"
+#include "string-list.h"
 
 struct repository;
 struct pretty_print_context;
diff --git a/chdir-notify.c b/chdir-notify.c
index 8e38cd6f3ae..0d7bc046074 100644
--- a/chdir-notify.c
+++ b/chdir-notify.c
@@ -1,7 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "abspath.h"
 #include "chdir-notify.h"
 #include "list.h"
+#include "path.h"
 #include "strbuf.h"
 #include "trace.h"
 
diff --git a/quote.c b/quote.c
index 7ccb5a06cd1..43c739671ed 100644
--- a/quote.c
+++ b/quote.c
@@ -1,5 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
 #include "alloc.h"
+#include "path.h"
 #include "quote.h"
 #include "strbuf.h"
 #include "strvec.h"
diff --git a/refs/ref-cache.h b/refs/ref-cache.h
index 850d9d3744e..cf4ad9070b9 100644
--- a/refs/ref-cache.h
+++ b/refs/ref-cache.h
@@ -1,7 +1,7 @@
 #ifndef REFS_REF_CACHE_H
 #define REFS_REF_CACHE_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct ref_dir;
 struct ref_store;
diff --git a/rerere.c b/rerere.c
index 093c0f6f993..7abc94bf444 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "abspath.h"
 #include "alloc.h"
 #include "config.h"
diff --git a/resolve-undo.h b/resolve-undo.h
index 2b3f0f901e6..d1ea9727712 100644
--- a/resolve-undo.h
+++ b/resolve-undo.h
@@ -1,7 +1,12 @@
 #ifndef RESOLVE_UNDO_H
 #define RESOLVE_UNDO_H
 
-#include "cache.h"
+struct cache_entry;
+struct index_state;
+struct pathspec;
+struct string_list;
+
+#include "hash.h"
 
 struct resolve_undo_info {
 	unsigned int mode[3];
diff --git a/revision.c b/revision.c
index 3d86e07abb8..43f88eaf56c 100644
--- a/revision.c
+++ b/revision.c
@@ -1,4 +1,4 @@
-#include "git-compat-util.h"
+#include "cache.h"
 #include "alloc.h"
 #include "config.h"
 #include "environment.h"
diff --git a/split-index.h b/split-index.h
index 7a435ca2c97..1a153f47ba3 100644
--- a/split-index.h
+++ b/split-index.h
@@ -1,7 +1,7 @@
 #ifndef SPLIT_INDEX_H
 #define SPLIT_INDEX_H
 
-#include "cache.h"
+#include "hash.h"
 
 struct index_state;
 struct strbuf;
-- 
2.40.0.172.g72fe1174621


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

* [PATCH v3 23/23] mailmap, quote: move declarations of global vars to correct unit
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
                         ` (15 preceding siblings ...)
  2023-04-11  7:42       ` [PATCH v3 22/23] treewide: reduce includes of cache.h in other headers Elijah Newren
@ 2023-04-11  7:42       ` Elijah Newren
  16 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:42 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

Since earlier commits removed the inclusion of cache.h from mailmap.c
and quote.c, it feels odd to have the extern declarations of
global variables in cache.h rather than the actual header included
by the source file.  Move these global variable extern declarations
from cache.h to mailmap.c and quote.c.

Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
---
 cache.h   | 5 -----
 config.c  | 1 +
 mailmap.h | 3 +++
 quote.h   | 2 ++
 4 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/cache.h b/cache.h
index 16b5fc9fa31..2f21704da9e 100644
--- a/cache.h
+++ b/cache.h
@@ -599,8 +599,6 @@ void set_alternate_index_output(const char *);
 extern int verify_index_checksum;
 extern int verify_ce_order;
 
-extern int quote_path_fully;
-
 #define MTIME_CHANGED	0x0001
 #define CTIME_CHANGED	0x0002
 #define OWNER_CHANGED	0x0004
@@ -655,9 +653,6 @@ struct pack_entry {
 /* Dumb servers support */
 int update_server_info(int);
 
-extern const char *git_mailmap_file;
-extern const char *git_mailmap_blob;
-
 #define COPY_READ_ERROR (-2)
 #define COPY_WRITE_ERROR (-3)
 int copy_fd(int ifd, int ofd);
diff --git a/config.c b/config.c
index 11e3295419b..9beba19b41c 100644
--- a/config.c
+++ b/config.c
@@ -18,6 +18,7 @@
 #include "ident.h"
 #include "repository.h"
 #include "lockfile.h"
+#include "mailmap.h"
 #include "exec-cmd.h"
 #include "strbuf.h"
 #include "quote.h"
diff --git a/mailmap.h b/mailmap.h
index 7e99fccb46c..0f8fd2c586f 100644
--- a/mailmap.h
+++ b/mailmap.h
@@ -3,6 +3,9 @@
 
 struct string_list;
 
+extern const char *git_mailmap_file;
+extern const char *git_mailmap_blob;
+
 int read_mailmap(struct string_list *map);
 void clear_mailmap(struct string_list *map);
 
diff --git a/quote.h b/quote.h
index 87ff458b06d..0300c291041 100644
--- a/quote.h
+++ b/quote.h
@@ -3,6 +3,8 @@
 
 struct strbuf;
 
+extern int quote_path_fully;
+
 /* Help to copy the thing properly quoted for the shell safety.
  * any single quote is replaced with '\'', any exclamation point
  * is replaced with '\!', and the whole thing is enclosed in a
-- 
2.40.0.172.g72fe1174621


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

* Re: [PATCH v3 00/23] Header cleanups (splitting up cache.h)
  2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
                       ` (5 preceding siblings ...)
  2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
@ 2023-04-11  7:47     ` Elijah Newren
  6 siblings, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-11  7:47 UTC (permalink / raw)
  To: Elijah Newren via GitGitGadget; +Cc: git, Calvin Wan

On Mon, Apr 10, 2023 at 8:01 PM Elijah Newren via GitGitGadget
<gitgitgadget@gmail.com> wrote:
>
> Changes since v2:
>
>  * Dropped patch 21 (Calvin is making more thorough changes to strbuf.[ch]
>    in his series which will obsolete this patch and dropping it makes it
>    easier to deconflict.)
>  * Added Calvin's Acked-by to all the other patches.

Sorry for the horrible threading.  Gitgitgadget ran into some kind of
snafu and only sent the first five patches.  Attempts to force
gitgitgadget to resend were unsuccessful and Dscho is off right now,
so I decided to try re-sending with git-send-email, and it ended up
treating patches 7-23 as a response to patch 6.

:-(

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

* [PATCH/RFD] fix connection via git protocol
  2023-04-11  7:41       ` [PATCH v3 07/23] treewide: remove unnecessary cache.h inclusion Elijah Newren
@ 2023-04-15 11:06         ` Michael J Gruber
  2023-04-16  5:47           ` Elijah Newren
  0 siblings, 1 reply; 101+ messages in thread
From: Michael J Gruber @ 2023-04-15 11:06 UTC (permalink / raw)
  To: git; +Cc: Elijah Newren, Calvin Wan

5579f44d2f ("treewide: remove unnecessary cache.h inclusion", 2023-04-11)
broke connections via git protocol because it removed the inclusion of
the default port macro. While some may consider this transport to be
deprecated, it still serves some purpose.

connect.c (no more chache.h) and daemon.c (which still includes cache.h)
are the only users of the macro. Hot fix the issue by copying the
definition to connect.c.

A real fix will identify a proper common header file (I couldn't) or
create a new one.

Signed-off-by: Michael J Gruber <git@grubix.eu>
---
 connect.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/connect.c b/connect.c
index 5d8036197d..64f89e33cf 100644
--- a/connect.c
+++ b/connect.c
@@ -20,6 +20,8 @@
 #include "alias.h"
 #include "bundle-uri.h"
 
+#define DEFAULT_GIT_PORT 9418
+
 static char *server_capabilities_v1;
 static struct strvec server_capabilities_v2 = STRVEC_INIT;
 static const char *next_server_feature_value(const char *feature, int *len, int *offset);
-- 
2.40.0.403.g8e07f5f217


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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-15 11:06         ` [PATCH/RFD] fix connection via git protocol Michael J Gruber
@ 2023-04-16  5:47           ` Elijah Newren
  2023-04-16  5:51             ` Elijah Newren
                               ` (2 more replies)
  0 siblings, 3 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-16  5:47 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: git, Calvin Wan, Elijah Newren

On Sat, Apr 15, 2023 at 4:06 AM Michael J Gruber <git@grubix.eu> wrote:
>
> 5579f44d2f ("treewide: remove unnecessary cache.h inclusion", 2023-04-11)
> broke connections via git protocol because it removed the inclusion of
> the default port macro. While some may consider this transport to be
> deprecated, it still serves some purpose.

In particular the problem is that

	const char *port = STR(DEFAULT_GIT_PORT);

translates now to

	const char *port = "DEFAULT_GIT_PORT";

instead of

	const char *port = "9418";

Since both compile and nothing in the testsuite tests this, I just
missed this problem when making the other changes.

Sorry about this.

> connect.c (no more chache.h) and daemon.c (which still includes cache.h)
> are the only users of the macro. Hot fix the issue by copying the
> definition to connect.c.
>
> A real fix will identify a proper common header file (I couldn't) or
> create a new one.

I've got a patch that does precisely this that I just submitted as
part of my follow-on to the en/header-split-cache-h series.  I've included
that patch below in case Junio wants to advance it faster than the rest of
that series.

-- >8 --
Subject: [PATCH] protocol.h: move definition of DEFAULT_GIT_PORT from cache.h

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 2f21704da9e..71e2fe74c4f 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,
-- 
2.40.0.195.gf32d4fa3dbf


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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-16  5:47           ` Elijah Newren
@ 2023-04-16  5:51             ` Elijah Newren
  2023-04-16 11:21               ` Michael J Gruber
  2023-04-17  7:38             ` Jeff King
  2023-04-17 16:29             ` Junio C Hamano
  2 siblings, 1 reply; 101+ messages in thread
From: Elijah Newren @ 2023-04-16  5:51 UTC (permalink / raw)
  To: Michael J Gruber; +Cc: git, Calvin Wan

On Sat, Apr 15, 2023 at 10:47 PM Elijah Newren <newren@gmail.com> wrote:
>
> On Sat, Apr 15, 2023 at 4:06 AM Michael J Gruber <git@grubix.eu> wrote:
> >
<snip>
> > A real fix will identify a proper common header file (I couldn't) or
> > create a new one.
>
> I've got a patch that does precisely this that I just submitted as
> part of my follow-on to the en/header-split-cache-h series.  I've included
> that patch below in case Junio wants to advance it faster than the rest of
> that series.

Link to other follow-up series I took this patch from:
https://lore.kernel.org/git/003548de707f57cb9908b6dfbdf42954f668ee43.1681614206.git.gitgitgadget@gmail.com/

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-16  5:51             ` Elijah Newren
@ 2023-04-16 11:21               ` Michael J Gruber
  0 siblings, 0 replies; 101+ messages in thread
From: Michael J Gruber @ 2023-04-16 11:21 UTC (permalink / raw)
  To: Elijah Newren; +Cc: git, Calvin Wan

Elijah Newren venit, vidit, dixit 2023-04-16 07:51:03:
> On Sat, Apr 15, 2023 at 10:47 PM Elijah Newren <newren@gmail.com> wrote:
> >
> > On Sat, Apr 15, 2023 at 4:06 AM Michael J Gruber <git@grubix.eu> wrote:
> > >
> <snip>
> > > A real fix will identify a proper common header file (I couldn't) or
> > > create a new one.
> >
> > I've got a patch that does precisely this that I just submitted as
> > part of my follow-on to the en/header-split-cache-h series.  I've included
> > that patch below in case Junio wants to advance it faster than the rest of
> > that series.
> 
> Link to other follow-up series I took this patch from:
> https://lore.kernel.org/git/003548de707f57cb9908b6dfbdf42954f668ee43.1681614206.git.gitgitgadget@gmail.com/

Thanks, protocol.h looks like a good place. I wasn't sure whether
daemon.c wants to include it, but I'm fine with it.

The change which broke git protocol hit me basically at the same time at
which I upgraded my system (F37->F38) which made the first analysis
interesting ... Anyway, it's "released" on next only, and the fix is
simple, thus not urgent. git.git/next works nicely on Fedora 38 by the
way, no surprises with tool chain upgrades so far.

Apparantly, we don't test this protocol, and almost all our next users
don't use it either ;)

Cheers
Michael

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-16  5:47           ` Elijah Newren
  2023-04-16  5:51             ` Elijah Newren
@ 2023-04-17  7:38             ` Jeff King
  2023-04-17 16:33               ` Junio C Hamano
  2023-04-18  1:56               ` Elijah Newren
  2023-04-17 16:29             ` Junio C Hamano
  2 siblings, 2 replies; 101+ messages in thread
From: Jeff King @ 2023-04-17  7:38 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Michael J Gruber, git, Calvin Wan

On Sat, Apr 15, 2023 at 10:47:35PM -0700, Elijah Newren wrote:

> On Sat, Apr 15, 2023 at 4:06 AM Michael J Gruber <git@grubix.eu> wrote:
> >
> > 5579f44d2f ("treewide: remove unnecessary cache.h inclusion", 2023-04-11)
> > broke connections via git protocol because it removed the inclusion of
> > the default port macro. While some may consider this transport to be
> > deprecated, it still serves some purpose.
> 
> In particular the problem is that
> 
> 	const char *port = STR(DEFAULT_GIT_PORT);
> 
> translates now to
> 
> 	const char *port = "DEFAULT_GIT_PORT";
> 
> instead of
> 
> 	const char *port = "9418";
> 
> Since both compile and nothing in the testsuite tests this, I just
> missed this problem when making the other changes.

Your fix looks obviously correct, but the much more interesting thing to
me is how surprising it is that neither the compiler nor tests caught
it.  The tests don't catch it because we never use the default port for
our daemon tests, since we don't want two scripts running in parallel to
conflict. And your example above shows what the compiler sees, but root
issue is this funky string-ification macro:

  #define STR_(s) # s
  #define STR(s) STR_(s)

The preprocessor doesn't know that we'll be confused if "s" isn't
resolved, and by the time the compiler sees it, it's a string already.

Obviously we could add a test that catches this at run-time, but we
should be able to do better (catch it earlier, and with less code).

My first thought was: why can't we just treat the port as an "int" in
the first place? The answer is mostly that getaddrinfo() expects it as a
string. It could even be a non-numeric service like "http" in theory
(and looked up in /etc/services; Debian's even has "git" in it!), but
our get_host_and_port() refuses to allow that. But even if we didn't
want to ever support non-numeric service names, it makes the code more
awkward (we have to format the port into an extra buffer).

This would work:

diff --git a/connect.c b/connect.c
index fd3179e545..1eba71e34c 100644
--- a/connect.c
+++ b/connect.c
@@ -753,7 +753,7 @@ static char *host_end(char **hoststart, int removebrackets)
 }
 
 #define STR_(s)	# s
-#define STR(s)	STR_(s)
+#define STR(s) (STR_(s) + BUILD_ASSERT_OR_ZERO(s))
 
 static void get_host_and_port(char **host, const char **port)
 {

The error message is a bit verbose, but it starts with:

  connect.c: In function ‘git_tcp_connect_sock’:
  connect.c:801:32: error: ‘DEFAULT_GIT_PORT’ undeclared (first use in this function)
  801 |         const char *port = STR(DEFAULT_GIT_PORT);
      |                                ^~~~~~~~~~~~~~~~

which seems OK in practice.

Another alternative is to just declare this STR() thing too clever, and
put:

  #define DEFAULT_GIT_PORT_STR "9418"

next to the int declaration. It's not like its going to change. But the
BUILD_ASSERT doesn't seem too bad to me.

-Peff

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-16  5:47           ` Elijah Newren
  2023-04-16  5:51             ` Elijah Newren
  2023-04-17  7:38             ` Jeff King
@ 2023-04-17 16:29             ` Junio C Hamano
  2023-04-18  1:55               ` Elijah Newren
  2 siblings, 1 reply; 101+ messages in thread
From: Junio C Hamano @ 2023-04-17 16:29 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Michael J Gruber, git, Calvin Wan

Elijah Newren <newren@gmail.com> writes:

>> 5579f44d2f ("treewide: remove unnecessary cache.h inclusion", 2023-04-11)
>> broke connections via git protocol because it removed the inclusion of
>> the default port macro. While some may consider this transport to be
>> deprecated, it still serves some purpose.
>
> In particular the problem is that
>
> 	const char *port = STR(DEFAULT_GIT_PORT);
>
> translates now to
>
> 	const char *port = "DEFAULT_GIT_PORT";
>
> instead of
>
> 	const char *port = "9418";

Wow, that is a bad one.  If people do want "DEFAULT_GIT_PORT", they
would never write STR(DEFAULT_GIT_PORT).  I wonder if we can have a
bit more clever STR() macro that catches this kind of mistake at the
compile time.

If this is worth fixing, the fix would probably be worth protecting
with a test or two, but the networking test with fixed port is not
something we can easily do without a sealed environment, so...

Thanks Michael for catching this.

> I've got a patch that does precisely this that I just submitted as
> part of my follow-on to the en/header-split-cache-h series.  I've included
> that patch below in case Junio wants to advance it faster than the rest of
> that series.

Yeah, burying it in a 24-patch series is a bit unfortunate.


> -- >8 --
> Subject: [PATCH] protocol.h: move definition of DEFAULT_GIT_PORT from cache.h
>
> 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 2f21704da9e..71e2fe74c4f 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,

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-17  7:38             ` Jeff King
@ 2023-04-17 16:33               ` Junio C Hamano
  2023-04-17 18:31                 ` Junio C Hamano
  2023-04-18  3:39                 ` Jeff King
  2023-04-18  1:56               ` Elijah Newren
  1 sibling, 2 replies; 101+ messages in thread
From: Junio C Hamano @ 2023-04-17 16:33 UTC (permalink / raw)
  To: Jeff King; +Cc: Elijah Newren, Michael J Gruber, git, Calvin Wan

Jeff King <peff@peff.net> writes:

> The preprocessor doesn't know that we'll be confused if "s" isn't
> resolved, and by the time the compiler sees it, it's a string already.
>
> Obviously we could add a test that catches this at run-time, but we
> should be able to do better (catch it earlier, and with less code).

Ah, great minds think alike.  I am glad you have already thought it
through.

> My first thought was: why can't we just treat the port as an "int" in
> the first place? The answer is mostly that getaddrinfo() expects it as a
> string. It could even be a non-numeric service like "http" in theory
> (and looked up in /etc/services; Debian's even has "git" in it!), but
> our get_host_and_port() refuses to allow that. But even if we didn't
> want to ever support non-numeric service names, it makes the code more
> awkward (we have to format the port into an extra buffer).
>
> This would work:
>
> diff --git a/connect.c b/connect.c
> index fd3179e545..1eba71e34c 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -753,7 +753,7 @@ static char *host_end(char **hoststart, int removebrackets)
>  }
>  
>  #define STR_(s)	# s
> -#define STR(s)	STR_(s)
> +#define STR(s) (STR_(s) + BUILD_ASSERT_OR_ZERO(s))

OOoooh.  Clever.  A pointer plus N indexes into an array, but if the
offset is N then the pointer is left intact so the caller does not
see the difference.

> ... But the
> BUILD_ASSERT doesn't seem too bad to me.

Indeed.

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-17 16:33               ` Junio C Hamano
@ 2023-04-17 18:31                 ` Junio C Hamano
  2023-04-18  3:39                 ` Jeff King
  1 sibling, 0 replies; 101+ messages in thread
From: Junio C Hamano @ 2023-04-17 18:31 UTC (permalink / raw)
  To: Jeff King; +Cc: Elijah Newren, Michael J Gruber, git, Calvin Wan

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

>>  #define STR_(s)	# s
>> -#define STR(s)	STR_(s)
>> +#define STR(s) (STR_(s) + BUILD_ASSERT_OR_ZERO(s))
>
> OOoooh.  Clever.  A pointer plus N indexes into an array, but if the
> offset is N then the pointer is left intact so the caller does not

Sorry, but s/N/0/ obviously.

> see the difference.
>
>> ... But the
>> BUILD_ASSERT doesn't seem too bad to me.
>
> Indeed.

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-17 16:29             ` Junio C Hamano
@ 2023-04-18  1:55               ` Elijah Newren
  2023-04-18 21:00                 ` Junio C Hamano
  0 siblings, 1 reply; 101+ messages in thread
From: Elijah Newren @ 2023-04-18  1:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Michael J Gruber, git, Calvin Wan

On Mon, Apr 17, 2023 at 9:29 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> Elijah Newren <newren@gmail.com> writes:
>
> >> 5579f44d2f ("treewide: remove unnecessary cache.h inclusion", 2023-04-11)
> >> broke connections via git protocol because it removed the inclusion of
> >> the default port macro. While some may consider this transport to be
> >> deprecated, it still serves some purpose.
> >
> > In particular the problem is that
> >
> >       const char *port = STR(DEFAULT_GIT_PORT);
> >
> > translates now to
> >
> >       const char *port = "DEFAULT_GIT_PORT";
> >
> > instead of
> >
> >       const char *port = "9418";
>
> Wow, that is a bad one.  If people do want "DEFAULT_GIT_PORT", they
> would never write STR(DEFAULT_GIT_PORT).  I wonder if we can have a
> bit more clever STR() macro that catches this kind of mistake at the
> compile time.
>
> If this is worth fixing, the fix would probably be worth protecting
> with a test or two, but the networking test with fixed port is not
> something we can easily do without a sealed environment, so...
>
> Thanks Michael for catching this.

Yup.

> > I've got a patch that does precisely this that I just submitted as
> > part of my follow-on to the en/header-split-cache-h series.  I've included
> > that patch below in case Junio wants to advance it faster than the rest of
> > that series.
>
> Yeah, burying it in a 24-patch series is a bit unfortunate.

I didn't know it was a fix for anything when I wrote it; it was in the
24-patch series just as a further refactoring.  Then I found out after
this report and doing a little digging I found it might be considered
a good fix for the issue so I included it here too.

If you apply this patch directly on this series, I'm happy to drop it
from the other series or do whatever makes things easiest.

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-17  7:38             ` Jeff King
  2023-04-17 16:33               ` Junio C Hamano
@ 2023-04-18  1:56               ` Elijah Newren
  2023-04-18  3:40                 ` Jeff King
  1 sibling, 1 reply; 101+ messages in thread
From: Elijah Newren @ 2023-04-18  1:56 UTC (permalink / raw)
  To: Jeff King; +Cc: Michael J Gruber, git, Calvin Wan

On Mon, Apr 17, 2023 at 12:38 AM Jeff King <peff@peff.net> wrote:
>
> On Sat, Apr 15, 2023 at 10:47:35PM -0700, Elijah Newren wrote:
>
> > On Sat, Apr 15, 2023 at 4:06 AM Michael J Gruber <git@grubix.eu> wrote:
> > >
> > > 5579f44d2f ("treewide: remove unnecessary cache.h inclusion", 2023-04-11)
> > > broke connections via git protocol because it removed the inclusion of
> > > the default port macro. While some may consider this transport to be
> > > deprecated, it still serves some purpose.
> >
> > In particular the problem is that
> >
> >       const char *port = STR(DEFAULT_GIT_PORT);
> >
> > translates now to
> >
> >       const char *port = "DEFAULT_GIT_PORT";
> >
> > instead of
> >
> >       const char *port = "9418";
> >
> > Since both compile and nothing in the testsuite tests this, I just
> > missed this problem when making the other changes.
>
> Your fix looks obviously correct, but the much more interesting thing to
> me is how surprising it is that neither the compiler nor tests caught
> it.  The tests don't catch it because we never use the default port for
> our daemon tests, since we don't want two scripts running in parallel to
> conflict. And your example above shows what the compiler sees, but root
> issue is this funky string-ification macro:
>
>   #define STR_(s) # s
>   #define STR(s) STR_(s)
>
> The preprocessor doesn't know that we'll be confused if "s" isn't
> resolved, and by the time the compiler sees it, it's a string already.
>
> Obviously we could add a test that catches this at run-time, but we
> should be able to do better (catch it earlier, and with less code).
>
> My first thought was: why can't we just treat the port as an "int" in
> the first place? The answer is mostly that getaddrinfo() expects it as a
> string. It could even be a non-numeric service like "http" in theory
> (and looked up in /etc/services; Debian's even has "git" in it!), but
> our get_host_and_port() refuses to allow that. But even if we didn't
> want to ever support non-numeric service names, it makes the code more
> awkward (we have to format the port into an extra buffer).
>
> This would work:
>
> diff --git a/connect.c b/connect.c
> index fd3179e545..1eba71e34c 100644
> --- a/connect.c
> +++ b/connect.c
> @@ -753,7 +753,7 @@ static char *host_end(char **hoststart, int removebrackets)
>  }
>
>  #define STR_(s)        # s
> -#define STR(s) STR_(s)
> +#define STR(s) (STR_(s) + BUILD_ASSERT_OR_ZERO(s))
>
>  static void get_host_and_port(char **host, const char **port)
>  {
>
> The error message is a bit verbose, but it starts with:
>
>   connect.c: In function ‘git_tcp_connect_sock’:
>   connect.c:801:32: error: ‘DEFAULT_GIT_PORT’ undeclared (first use in this function)
>   801 |         const char *port = STR(DEFAULT_GIT_PORT);
>       |                                ^~~~~~~~~~~~~~~~
>
> which seems OK in practice.

Seems pretty good to me.

> Another alternative is to just declare this STR() thing too clever, and
> put:
>
>   #define DEFAULT_GIT_PORT_STR "9418"
>
> next to the int declaration. It's not like its going to change. But the
> BUILD_ASSERT doesn't seem too bad to me.

Yeah, I like the BUILD_ASSERT.

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-17 16:33               ` Junio C Hamano
  2023-04-17 18:31                 ` Junio C Hamano
@ 2023-04-18  3:39                 ` Jeff King
  2023-04-18 20:47                   ` Junio C Hamano
  1 sibling, 1 reply; 101+ messages in thread
From: Jeff King @ 2023-04-18  3:39 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Elijah Newren, Michael J Gruber, git, Calvin Wan

On Mon, Apr 17, 2023 at 09:33:57AM -0700, Junio C Hamano wrote:

> > diff --git a/connect.c b/connect.c
> > index fd3179e545..1eba71e34c 100644
> > --- a/connect.c
> > +++ b/connect.c
> > @@ -753,7 +753,7 @@ static char *host_end(char **hoststart, int removebrackets)
> >  }
> >  
> >  #define STR_(s)	# s
> > -#define STR(s)	STR_(s)
> > +#define STR(s) (STR_(s) + BUILD_ASSERT_OR_ZERO(s))
> 
> OOoooh.  Clever.  A pointer plus N indexes into an array, but if the
> offset is N then the pointer is left intact so the caller does not
> see the difference.
> 
> > ... But the
> > BUILD_ASSERT doesn't seem too bad to me.
> 
> Indeed.

So I started to write this up as a patch, but there's another subtle
thing going on.

The BUILD_ASSERT is actually checking two things: that the result
compiles (which is what we care about here), and that the expression it
evaluates is nonzero (which we don't).

So this would fail for example with:

  #define ZERO 0
  const char *x = STR(ZERO);

That is OK for our purposes here (a zero port does not make any sense).
But it feels a bit weird for a macro as generically named as STR(). At
least it's local to the one file. But maybe it should be PORT_TO_STR()
or something.

All of that makes me wonder if we wouldn't be just as happy with it as a
string in the first place. In three out of four locations that use it,
they want the string anyway (to feed to getaddrinfo). And in the final
one (git-daemon), we need to convert from the user's "--port" anyway, so
there's always some string-to-int parsing. And depending on the #ifdefs,
in most cases we turn it back into a string anyway to feed to...you
guessed it, getaddrinfo!

The exception is when NO_IPV6 is defined, in which we do want the
numeric value. But we could delay parsing until that point (and
otherwise let getaddrinfo handle, which seems more correct anyway).

Something like this (though I'd probably split it into a few patches to
reason about the motivation and implications of each):

diff --git a/cache.h b/cache.h
index 2f21704da9..2ece09a2b8 100644
--- a/cache.h
+++ b/cache.h
@@ -58,7 +58,7 @@
  *
  * See http://www.iana.org/assignments/port-numbers
  */
-#define DEFAULT_GIT_PORT 9418
+#define DEFAULT_GIT_PORT "9418"
 
 /*
  * Basic data structures for the directory cache
diff --git a/connect.c b/connect.c
index fd3179e545..189367604c 100644
--- a/connect.c
+++ b/connect.c
@@ -1,4 +1,5 @@
 #include "git-compat-util.h"
+#include "cache.h" /* or protocol.h after Elijah's patch */
 #include "config.h"
 #include "environment.h"
 #include "gettext.h"
@@ -752,9 +753,6 @@ static char *host_end(char **hoststart, int removebrackets)
 	return end;
 }
 
-#define STR_(s)	# s
-#define STR(s)	STR_(s)
-
 static void get_host_and_port(char **host, const char **port)
 {
 	char *colon, *end;
@@ -798,7 +796,7 @@ static int git_tcp_connect_sock(char *host, int flags)
 {
 	struct strbuf error_message = STRBUF_INIT;
 	int sockfd = -1;
-	const char *port = STR(DEFAULT_GIT_PORT);
+	const char *port = DEFAULT_GIT_PORT;
 	struct addrinfo hints, *ai0, *ai;
 	int gai;
 	int cnt = 0;
@@ -868,7 +866,7 @@ static int git_tcp_connect_sock(char *host, int flags)
 {
 	struct strbuf error_message = STRBUF_INIT;
 	int sockfd = -1;
-	const char *port = STR(DEFAULT_GIT_PORT);
+	const char *port = DEFAULT_GIT_PORT;
 	char *ep;
 	struct hostent *he;
 	struct sockaddr_in sa;
@@ -1020,7 +1018,7 @@ static int git_use_proxy(const char *host)
 
 static struct child_process *git_proxy_connect(int fd[2], char *host)
 {
-	const char *port = STR(DEFAULT_GIT_PORT);
+	const char *port = DEFAULT_GIT_PORT;
 	struct child_process *proxy;
 
 	get_host_and_port(&host, &port);
diff --git a/daemon.c b/daemon.c
index db8a31a6ea..ce692bad35 100644
--- a/daemon.c
+++ b/daemon.c
@@ -984,22 +984,20 @@ static const char *ip2str(int family, struct sockaddr *sin, socklen_t len)
 
 #ifndef NO_IPV6
 
-static int setup_named_sock(char *listen_addr, int listen_port, struct socketlist *socklist)
+static int setup_named_sock(char *listen_addr, const char *listen_port, struct socketlist *socklist)
 {
 	int socknum = 0;
-	char pbuf[NI_MAXSERV];
 	struct addrinfo hints, *ai0, *ai;
 	int gai;
 	long flags;
 
-	xsnprintf(pbuf, sizeof(pbuf), "%d", listen_port);
 	memset(&hints, 0, sizeof(hints));
 	hints.ai_family = AF_UNSPEC;
 	hints.ai_socktype = SOCK_STREAM;
 	hints.ai_protocol = IPPROTO_TCP;
 	hints.ai_flags = AI_PASSIVE;
 
-	gai = getaddrinfo(listen_addr, pbuf, &hints, &ai0);
+	gai = getaddrinfo(listen_addr, listen_port, &hints, &ai0);
 	if (gai) {
 		logerror("getaddrinfo() for %s failed: %s", listen_addr, gai_strerror(gai));
 		return 0;
@@ -1065,15 +1063,27 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct socketlis
 
 #else /* NO_IPV6 */
 
-static int setup_named_sock(char *listen_addr, int listen_port, struct socketlist *socklist)
+static int parse_port(const char *s)
+{
+	unsigned long ret;
+	char *end;
+
+	ret = strtoul(s, &end, 0);
+	if (!ret || ret > 65535 || *end)
+		die(_("invalid listen port: %s"), s);
+
+	return ret;
+}
+
+static int setup_named_sock(char *listen_addr, const char *listen_port, struct socketlist *socklist)
 {
 	struct sockaddr_in sin;
 	int sockfd;
 	long flags;
 
 	memset(&sin, 0, sizeof sin);
 	sin.sin_family = AF_INET;
-	sin.sin_port = htons(listen_port);
+	sin.sin_port = parse_port(listen_port);
 
 	if (listen_addr) {
 		/* Well, host better be an IP address here. */
@@ -1122,7 +1132,7 @@ static int setup_named_sock(char *listen_addr, int listen_port, struct socketlis
 
 #endif
 
-static void socksetup(struct string_list *listen_addr, int listen_port, struct socketlist *socklist)
+static void socksetup(struct string_list *listen_addr, const char *listen_port, struct socketlist *socklist)
 {
 	if (!listen_addr->nr)
 		setup_named_sock(NULL, listen_port, socklist);
@@ -1133,7 +1143,7 @@ static void socksetup(struct string_list *listen_addr, int listen_port, struct s
 						   listen_port, socklist);
 
 			if (socknum == 0)
-				logerror("unable to allocate any listen sockets for host %s on port %u",
+				logerror("unable to allocate any listen sockets for host %s on port %s",
 					 listen_addr->items[i].string, listen_port);
 		}
 	}
@@ -1246,14 +1256,14 @@ static struct credentials *prepare_credentials(const char *user_name,
 }
 #endif
 
-static int serve(struct string_list *listen_addr, int listen_port,
+static int serve(struct string_list *listen_addr, const char *listen_port,
     struct credentials *cred)
 {
 	struct socketlist socklist = { NULL, 0, 0 };
 
 	socksetup(listen_addr, listen_port, &socklist);
 	if (socklist.nr == 0)
-		die("unable to allocate any listen sockets on port %u",
+		die("unable to allocate any listen sockets on port %s",
 		    listen_port);
 
 	drop_privileges(cred);
@@ -1265,7 +1275,7 @@ static int serve(struct string_list *listen_addr, int listen_port,
 
 int cmd_main(int argc, const char **argv)
 {
-	int listen_port = 0;
+	const char *listen_port = NULL;
 	struct string_list listen_addr = STRING_LIST_INIT_NODUP;
 	int serve_mode = 0, inetd_mode = 0;
 	const char *pid_file = NULL, *user_name = NULL, *group_name = NULL;
@@ -1282,13 +1292,8 @@ int cmd_main(int argc, const char **argv)
 			continue;
 		}
 		if (skip_prefix(arg, "--port=", &v)) {
-			char *end;
-			unsigned long n;
-			n = strtoul(v, &end, 0);
-			if (*v && !*end) {
-				listen_port = n;
-				continue;
-			}
+			listen_port = v;
+			continue;
 		}
 		if (!strcmp(arg, "--serve")) {
 			serve_mode = 1;
@@ -1439,7 +1444,7 @@ int cmd_main(int argc, const char **argv)
 
 	if (inetd_mode && (listen_port || (listen_addr.nr > 0)))
 		die("--listen= and --port= are incompatible with --inetd");
-	else if (listen_port == 0)
+	else if (!listen_port)
 		listen_port = DEFAULT_GIT_PORT;
 
 	if (group_name && !user_name)

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-18  1:56               ` Elijah Newren
@ 2023-04-18  3:40                 ` Jeff King
  0 siblings, 0 replies; 101+ messages in thread
From: Jeff King @ 2023-04-18  3:40 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Michael J Gruber, git, Calvin Wan

On Mon, Apr 17, 2023 at 06:56:42PM -0700, Elijah Newren wrote:

> > The error message is a bit verbose, but it starts with:
> >
> >   connect.c: In function ‘git_tcp_connect_sock’:
> >   connect.c:801:32: error: ‘DEFAULT_GIT_PORT’ undeclared (first use in this function)
> >   801 |         const char *port = STR(DEFAULT_GIT_PORT);
> >       |                                ^~~~~~~~~~~~~~~~
> >
> > which seems OK in practice.
> 
> Seems pretty good to me.

The rest of it is less nice:
  connect.c: In function ‘git_tcp_connect_sock’:
  connect.c:801:32: error: ‘DEFAULT_GIT_PORT’ undeclared (first use in this function)
    801 |         const char *port = STR(DEFAULT_GIT_PORT);
        |                                ^~~~~~~~~~~~~~~~
  git-compat-util.h:93:31: note: in definition of macro ‘BUILD_ASSERT_OR_ZERO’
     93 |         (sizeof(char [1 - 2*!(cond)]) - 1)
        |                               ^~~~
  connect.c:801:28: note: in expansion of macro ‘STR’
    801 |         const char *port = STR(DEFAULT_GIT_PORT);
        |                            ^~~
  connect.c:801:32: note: each undeclared identifier is reported only once for each function it appears in
    801 |         const char *port = STR(DEFAULT_GIT_PORT);
        |                                ^~~~~~~~~~~~~~~~
  git-compat-util.h:93:31: note: in definition of macro ‘BUILD_ASSERT_OR_ZERO’
     93 |         (sizeof(char [1 - 2*!(cond)]) - 1)
        |                               ^~~~
  connect.c:801:28: note: in expansion of macro ‘STR’
    801 |         const char *port = STR(DEFAULT_GIT_PORT);
        |                            ^~~

but that's kind of the nature of BUILD_ASSERT (it's even worse if the
code compiles but the assertion is false, since the first thing is that
funky sizeof() line). I guess it's the best we can do. The point is that
these aren't supposed to happen very often.

-Peff

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-18  3:39                 ` Jeff King
@ 2023-04-18 20:47                   ` Junio C Hamano
  0 siblings, 0 replies; 101+ messages in thread
From: Junio C Hamano @ 2023-04-18 20:47 UTC (permalink / raw)
  To: Jeff King; +Cc: Elijah Newren, Michael J Gruber, git, Calvin Wan

Jeff King <peff@peff.net> writes:

> All of that makes me wonder if we wouldn't be just as happy with it as a
> string in the first place. In three out of four locations that use it,
> they want the string anyway (to feed to getaddrinfo). And in the final
> one (git-daemon), we need to convert from the user's "--port" anyway, so
> there's always some string-to-int parsing. And depending on the #ifdefs,
> in most cases we turn it back into a string anyway to feed to...you
> guessed it, getaddrinfo!
>
> The exception is when NO_IPV6 is defined, in which we do want the
> numeric value. But we could delay parsing until that point (and
> otherwise let getaddrinfo handle, which seems more correct anyway).
>
> Something like this (though I'd probably split it into a few patches to
> reason about the motivation and implications of each):

The updated code keeps the "port" as a string and turns it into a
short integer only when it is needed, which is nice.  In the future,
parse_port() may even want to be extended to call something like
getservbyname(), to allow something silly like

	#define DEFAULT_GIT_PORT "git"


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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-18  1:55               ` Elijah Newren
@ 2023-04-18 21:00                 ` Junio C Hamano
  2023-04-18 21:24                   ` Eric Sunshine
  2023-04-19  3:15                   ` Elijah Newren
  0 siblings, 2 replies; 101+ messages in thread
From: Junio C Hamano @ 2023-04-18 21:00 UTC (permalink / raw)
  To: Elijah Newren; +Cc: Michael J Gruber, git, Calvin Wan

Elijah Newren <newren@gmail.com> writes:

> I didn't know it was a fix for anything when I wrote it; it was in the
> 24-patch series just as a further refactoring.  Then I found out after
> this report and doing a little digging I found it might be considered
> a good fix for the issue so I included it here too.

Yup, let's queue it at the tip of (and as a part of) the base series
with a bit of explanation.  How does this look?

----- >8 --------- >8 --------- >8 --------- >8 -----
From: Elijah Newren <newren@gmail.com>
Date: Sun, 16 Apr 2023 03:03:05 +0000
Subject: [PATCH] protocol.h: move definition of DEFAULT_GIT_PORT from cache.h

Michael J Gruber noticed that connection via the git:// protocol no
longer worked after a recent header clean-up.  This was caused by
funny interaction of few gotchas.  First, a necessary definition

	#define DEFAULT_GIT_PORT 9418

was made invisible to a place where

	const char *port = STR(DEFAULT_GIT_PORT);

was expecting to turn the integer into "9418" with a clever STR()
macro, and ended up stringifying it to

	const char *port = "DEFAULT_GIT_PORT";

without giving any chance to compilers to notice such a mistake.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.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 2f21704da9..71e2fe74c4 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 db8a31a6ea..75c3c06457 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 cef1a4a01c..de66bf80f8 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,
-- 
2.40.0-352-g667fcf4e15




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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-18 21:00                 ` Junio C Hamano
@ 2023-04-18 21:24                   ` Eric Sunshine
  2023-04-19  3:16                     ` Elijah Newren
  2023-04-24 20:57                     ` Junio C Hamano
  2023-04-19  3:15                   ` Elijah Newren
  1 sibling, 2 replies; 101+ messages in thread
From: Eric Sunshine @ 2023-04-18 21:24 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Elijah Newren, Michael J Gruber, git, Calvin Wan

On Tue, Apr 18, 2023 at 5:06 PM Junio C Hamano <gitster@pobox.com> wrote:
> From: Elijah Newren <newren@gmail.com>
> Subject: [PATCH] protocol.h: move definition of DEFAULT_GIT_PORT from cache.h
>
> Michael J Gruber noticed that connection via the git:// protocol no
> longer worked after a recent header clean-up.

A link to Michael's email might be useful for future readers of this
commit message.

    Michale J Gruber noticed[1] that connection...

    [1]: https://lore.kernel.org/git/5d4e0ce10f537b4bb795a70dd51db12ecaf0206d.1681556597.git.git@grubix.eu/

> This was caused by
> funny interaction of few gotchas.  First, a necessary definition
>
>         #define DEFAULT_GIT_PORT 9418
>
> was made invisible to a place where
>
>         const char *port = STR(DEFAULT_GIT_PORT);
>
> was expecting to turn the integer into "9418" with a clever STR()
> macro, and ended up stringifying it to
>
>         const char *port = "DEFAULT_GIT_PORT";
>
> without giving any chance to compilers to notice such a mistake.
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Perhaps an additional tailer would be appropriate?

    Reported-by: Michael J Gruber <git@grubix.eu>

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-18 21:00                 ` Junio C Hamano
  2023-04-18 21:24                   ` Eric Sunshine
@ 2023-04-19  3:15                   ` Elijah Newren
  1 sibling, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-19  3:15 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Michael J Gruber, git, Calvin Wan

On Tue, Apr 18, 2023 at 2:00 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> Elijah Newren <newren@gmail.com> writes:
>
> > I didn't know it was a fix for anything when I wrote it; it was in the
> > 24-patch series just as a further refactoring.  Then I found out after
> > this report and doing a little digging I found it might be considered
> > a good fix for the issue so I included it here too.
>
> Yup, let's queue it at the tip of (and as a part of) the base series
> with a bit of explanation.  How does this look?
>
> ----- >8 --------- >8 --------- >8 --------- >8 -----
> From: Elijah Newren <newren@gmail.com>
> Date: Sun, 16 Apr 2023 03:03:05 +0000
> Subject: [PATCH] protocol.h: move definition of DEFAULT_GIT_PORT from cache.h
>
> Michael J Gruber noticed that connection via the git:// protocol no
> longer worked after a recent header clean-up.  This was caused by
> funny interaction of few gotchas.  First, a necessary definition
>
>         #define DEFAULT_GIT_PORT 9418
>
> was made invisible to a place where
>
>         const char *port = STR(DEFAULT_GIT_PORT);
>
> was expecting to turn the integer into "9418" with a clever STR()
> macro, and ended up stringifying it to
>
>         const char *port = "DEFAULT_GIT_PORT";
>
> without giving any chance to compilers to notice such a mistake.
>
> Signed-off-by: Elijah Newren <newren@gmail.com>
> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Looks great!

> ---
>  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 2f21704da9..71e2fe74c4 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 db8a31a6ea..75c3c06457 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 cef1a4a01c..de66bf80f8 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,
> --
> 2.40.0-352-g667fcf4e15
>
>
>

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-18 21:24                   ` Eric Sunshine
@ 2023-04-19  3:16                     ` Elijah Newren
  2023-04-24 20:57                     ` Junio C Hamano
  1 sibling, 0 replies; 101+ messages in thread
From: Elijah Newren @ 2023-04-19  3:16 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Junio C Hamano, Michael J Gruber, git, Calvin Wan

On Tue, Apr 18, 2023 at 2:25 PM Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Tue, Apr 18, 2023 at 5:06 PM Junio C Hamano <gitster@pobox.com> wrote:
> > From: Elijah Newren <newren@gmail.com>
> > Subject: [PATCH] protocol.h: move definition of DEFAULT_GIT_PORT from cache.h
> >
> > Michael J Gruber noticed that connection via the git:// protocol no
> > longer worked after a recent header clean-up.
>
> A link to Michael's email might be useful for future readers of this
> commit message.
>
>     Michale J Gruber noticed[1] that connection...
>
>     [1]: https://lore.kernel.org/git/5d4e0ce10f537b4bb795a70dd51db12ecaf0206d.1681556597.git.git@grubix.eu/
>
> > This was caused by
> > funny interaction of few gotchas.  First, a necessary definition
> >
> >         #define DEFAULT_GIT_PORT 9418
> >
> > was made invisible to a place where
> >
> >         const char *port = STR(DEFAULT_GIT_PORT);
> >
> > was expecting to turn the integer into "9418" with a clever STR()
> > macro, and ended up stringifying it to
> >
> >         const char *port = "DEFAULT_GIT_PORT";
> >
> > without giving any chance to compilers to notice such a mistake.
> >
> > Signed-off-by: Elijah Newren <newren@gmail.com>
> > Signed-off-by: Junio C Hamano <gitster@pobox.com>
>
> Perhaps an additional tailer would be appropriate?
>
>     Reported-by: Michael J Gruber <git@grubix.eu>

These both look like good additions too.

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

* Re: [PATCH/RFD] fix connection via git protocol
  2023-04-18 21:24                   ` Eric Sunshine
  2023-04-19  3:16                     ` Elijah Newren
@ 2023-04-24 20:57                     ` Junio C Hamano
  1 sibling, 0 replies; 101+ messages in thread
From: Junio C Hamano @ 2023-04-24 20:57 UTC (permalink / raw)
  To: Eric Sunshine; +Cc: Elijah Newren, Michael J Gruber, git, Calvin Wan

Eric Sunshine <sunshine@sunshineco.com> writes:

> A link to Michael's email might be useful for future readers of this
> commit message.
>
>     Michale J Gruber noticed[1] that connection...

I don't think so.  At least, I tried to write the proposed log
message in such a way that it is not needed.

I encourage people not to add URLs just so that they can be lazy and
omit summarizing the discussion for readers so that they do not have
to refer to external material in order to understand "git log"
output.  And I was trying to show by example.

Was there anything you couldn't read out of what I wrote that is
necessary to understand the issue the commit tried to address
without reading the original discussion?

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

end of thread, other threads:[~2023-04-24 20:58 UTC | newest]

Thread overview: 101+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-01 15:10 [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 02/24] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 03/24] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 04/24] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 05/24] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 06/24] treewide: be explicit about dependence on mem-pool.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 07/24] treewide: remove unnecessary cache.h inclusion Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 08/24] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 09/24] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 10/24] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 11/24] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 12/24] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 13/24] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 14/24] object.h: move an inline function and some defines from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 15/24] editor: move editor-related functions and declarations into common file Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 16/24] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 17/24] pager.h: move declarations for pager.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 18/24] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 19/24] cache.h: remove unnecessary includes Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 20/24] strbuf: move forward declarations to beginning of file Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 21/24] treewide: remove double forward declaration of read_in_full Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 22/24] treewide: reduce includes of cache.h in other headers Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 23/24] chdir-notify, quote: replace cache.h include with path.h Elijah Newren via GitGitGadget
2023-04-01 15:10 ` [PATCH 24/24] mailmap, quote: move declarations of global vars to correct unit Elijah Newren via GitGitGadget
2023-04-03 16:23 ` [PATCH 00/24] Header cleanups (splitting up cache.h) Elijah Newren
2023-04-04  1:22 ` [PATCH v2 " Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 01/24] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 02/24] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 03/24] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 04/24] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 05/24] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 06/24] treewide: be explicit about dependence on mem-pool.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 07/24] treewide: remove unnecessary cache.h inclusion Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 08/24] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 09/24] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 10/24] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 11/24] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 12/24] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 13/24] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 14/24] object.h: move some inline functions and defines from cache.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 15/24] treewide: remove cache.h inclusion due to object.h changes Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 16/24] editor: move editor-related functions and declarations into common file Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 17/24] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 18/24] pager.h: move declarations for pager.c functions from cache.h Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 19/24] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 20/24] cache.h: remove unnecessary includes Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 21/24] strbuf: move forward declarations to beginning of file Elijah Newren via GitGitGadget
2023-04-05 17:28     ` Calvin Wan
2023-04-07  6:07       ` Elijah Newren
2023-04-10 15:52         ` Calvin Wan
2023-04-10 16:47           ` Elijah Newren
2023-04-04  1:22   ` [PATCH v2 22/24] treewide: remove double forward declaration of read_in_full Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 23/24] treewide: reduce includes of cache.h in other headers Elijah Newren via GitGitGadget
2023-04-04  1:22   ` [PATCH v2 24/24] mailmap, quote: move declarations of global vars to correct unit Elijah Newren via GitGitGadget
2023-04-05 17:30   ` [PATCH v2 00/24] Header cleanups (splitting up cache.h) Calvin Wan
2023-04-07  7:08     ` Elijah Newren
2023-04-10 15:54       ` Calvin Wan
2023-04-11  3:00   ` [PATCH v3 00/23] " Elijah Newren via GitGitGadget
2023-04-11  3:00     ` [PATCH v3 01/23] treewide: be explicit about dependence on trace.h & trace2.h Elijah Newren via GitGitGadget
2023-04-11  3:00     ` [PATCH v3 02/23] treewide: be explicit about dependence on advice.h Elijah Newren via GitGitGadget
2023-04-11  3:00     ` [PATCH v3 03/23] treewide: be explicit about dependence on convert.h Elijah Newren via GitGitGadget
2023-04-11  3:00     ` [PATCH v3 04/23] treewide: be explicit about dependence on pack-revindex.h Elijah Newren via GitGitGadget
2023-04-11  3:00     ` [PATCH v3 05/23] treewide: be explicit about dependence on oid-array.h Elijah Newren via GitGitGadget
2023-04-11  7:41     ` [PATCH v3 06/23] treewide: be explicit about dependence on mem-pool.h Elijah Newren
2023-04-11  7:41       ` [PATCH v3 07/23] treewide: remove unnecessary cache.h inclusion Elijah Newren
2023-04-15 11:06         ` [PATCH/RFD] fix connection via git protocol Michael J Gruber
2023-04-16  5:47           ` Elijah Newren
2023-04-16  5:51             ` Elijah Newren
2023-04-16 11:21               ` Michael J Gruber
2023-04-17  7:38             ` Jeff King
2023-04-17 16:33               ` Junio C Hamano
2023-04-17 18:31                 ` Junio C Hamano
2023-04-18  3:39                 ` Jeff King
2023-04-18 20:47                   ` Junio C Hamano
2023-04-18  1:56               ` Elijah Newren
2023-04-18  3:40                 ` Jeff King
2023-04-17 16:29             ` Junio C Hamano
2023-04-18  1:55               ` Elijah Newren
2023-04-18 21:00                 ` Junio C Hamano
2023-04-18 21:24                   ` Eric Sunshine
2023-04-19  3:16                     ` Elijah Newren
2023-04-24 20:57                     ` Junio C Hamano
2023-04-19  3:15                   ` Elijah Newren
2023-04-11  7:41       ` [PATCH v3 08/23] object-name.h: move declarations for object-name.c functions from cache.h Elijah Newren
2023-04-11  7:41       ` [PATCH v3 09/23] treewide: remove cache.h inclusion due to object-name.h changes Elijah Newren
2023-04-11  7:41       ` [PATCH v3 10/23] git-zlib: move declarations for git-zlib functions from cache.h Elijah Newren
2023-04-11  7:41       ` [PATCH v3 11/23] treewide: remove cache.h inclusion due to git-zlib changes Elijah Newren
2023-04-11  7:41       ` [PATCH v3 12/23] object-file.h: move declarations for object-file.c functions from cache.h Elijah Newren
2023-04-11  7:41       ` [PATCH v3 13/23] treewide: remove cache.h inclusion due to object-file.h changes Elijah Newren
2023-04-11  7:41       ` [PATCH v3 14/23] object.h: move some inline functions and defines from cache.h Elijah Newren
2023-04-11  7:41       ` [PATCH v3 15/23] treewide: remove cache.h inclusion due to object.h changes Elijah Newren
2023-04-11  7:41       ` [PATCH v3 16/23] editor: move editor-related functions and declarations into common file Elijah Newren
2023-04-11  7:41       ` [PATCH v3 17/23] treewide: remove cache.h inclusion due to editor.h changes Elijah Newren
2023-04-11  7:41       ` [PATCH v3 18/23] pager.h: move declarations for pager.c functions from cache.h Elijah Newren
2023-04-11  7:42       ` [PATCH v3 19/23] treewide: remove cache.h inclusion due to pager.h changes Elijah Newren
2023-04-11  7:42       ` [PATCH v3 20/23] cache.h: remove unnecessary includes Elijah Newren
2023-04-11  7:42       ` [PATCH v3 21/23] treewide: remove double forward declaration of read_in_full Elijah Newren
2023-04-11  7:42       ` [PATCH v3 22/23] treewide: reduce includes of cache.h in other headers Elijah Newren
2023-04-11  7:42       ` [PATCH v3 23/23] mailmap, quote: move declarations of global vars to correct unit Elijah Newren
2023-04-11  7:47     ` [PATCH v3 00/23] Header cleanups (splitting up cache.h) Elijah Newren

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