Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/CodingGuidelines8
-rw-r--r--add-interactive.c1
-rw-r--r--add-patch.c1
-rw-r--r--advice.c4
-rw-r--r--advice.h2
-rw-r--r--alias.c4
-rw-r--r--alloc.c2
-rw-r--r--alloc.h75
-rw-r--r--apply.c2
-rw-r--r--archive-tar.c4
-rw-r--r--archive-zip.c1
-rw-r--r--archive.c4
-rw-r--r--attr.c1
-rw-r--r--bisect.c1
-rw-r--r--blame.c1
-rw-r--r--blame.h1
-rw-r--r--blob.c2
-rw-r--r--branch.c1
-rw-r--r--builtin/am.c1
-rw-r--r--builtin/bisect.c1
-rw-r--r--builtin/blame.c4
-rw-r--r--builtin/cat-file.c4
-rw-r--r--builtin/check-mailmap.c1
-rw-r--r--builtin/checkout--worker.c1
-rw-r--r--builtin/checkout.c1
-rw-r--r--builtin/clone.c1
-rw-r--r--builtin/commit-graph.c2
-rw-r--r--builtin/commit-tree.c1
-rw-r--r--builtin/config.c3
-rw-r--r--builtin/credential-cache--daemon.c1
-rw-r--r--builtin/describe.c1
-rw-r--r--builtin/diff-tree.c1
-rw-r--r--builtin/difftool.c1
-rw-r--r--builtin/fast-export.c1
-rw-r--r--builtin/fast-import.c1
-rw-r--r--builtin/fetch-pack.c2
-rw-r--r--builtin/fetch.c1
-rw-r--r--builtin/fsck.c2
-rw-r--r--builtin/fsmonitor--daemon.c1
-rw-r--r--builtin/gc.c1
-rw-r--r--builtin/grep.c2
-rw-r--r--builtin/hash-object.c1
-rw-r--r--builtin/index-pack.c3
-rw-r--r--builtin/log.c4
-rw-r--r--builtin/ls-remote.c1
-rw-r--r--builtin/ls-tree.c1
-rw-r--r--builtin/merge-base.c1
-rw-r--r--builtin/merge-index.c1
-rw-r--r--builtin/merge-tree.c1
-rw-r--r--builtin/merge.c2
-rw-r--r--builtin/mktag.c1
-rw-r--r--builtin/mktree.c2
-rw-r--r--builtin/mv.c1
-rw-r--r--builtin/name-rev.c3
-rw-r--r--builtin/notes.c1
-rw-r--r--builtin/pack-objects.c4
-rw-r--r--builtin/pack-redundant.c1
-rw-r--r--builtin/patch-id.c1
-rw-r--r--builtin/prune.c2
-rw-r--r--builtin/pull.c1
-rw-r--r--builtin/read-tree.c1
-rw-r--r--builtin/rebase.c1
-rw-r--r--builtin/receive-pack.c1
-rw-r--r--builtin/repack.c3
-rw-r--r--builtin/replace.c2
-rw-r--r--builtin/reset.c1
-rw-r--r--builtin/rev-list.c1
-rw-r--r--builtin/rev-parse.c2
-rw-r--r--builtin/revert.c3
-rw-r--r--builtin/rm.c1
-rw-r--r--builtin/send-pack.c1
-rw-r--r--builtin/show-branch.c1
-rw-r--r--builtin/show-index.c1
-rw-r--r--builtin/show-ref.c1
-rw-r--r--builtin/stash.c1
-rw-r--r--builtin/submodule--helper.c2
-rw-r--r--builtin/tag.c1
-rw-r--r--builtin/unpack-file.c1
-rw-r--r--builtin/unpack-objects.c2
-rw-r--r--builtin/update-index.c1
-rw-r--r--builtin/upload-pack.c1
-rw-r--r--builtin/var.c1
-rw-r--r--builtin/worktree.c1
-rw-r--r--builtin/write-tree.c1
-rw-r--r--bulk-checkin.c4
-rw-r--r--bundle.c1
-rw-r--r--cache-tree.c4
-rw-r--r--cache-tree.h1
-rw-r--r--cache.h305
-rw-r--r--cbtree.c1
-rw-r--r--cbtree.h2
-rw-r--r--checkout.h2
-rw-r--r--chunk-format.c3
-rw-r--r--chunk-format.h1
-rw-r--r--color.c1
-rw-r--r--combine-diff.c1
-rw-r--r--commit-graph.c1
-rw-r--r--commit-graph.h1
-rw-r--r--commit-reach.c4
-rw-r--r--commit-slab-impl.h2
-rw-r--r--commit.c1
-rw-r--r--commit.h1
-rw-r--r--compat/fsmonitor/fsm-ipc-darwin.c1
-rw-r--r--compat/fsmonitor/fsm-ipc-win32.c1
-rw-r--r--compat/fsmonitor/fsm-settings-darwin.c1
-rw-r--r--compat/mingw.c1
-rw-r--r--config.c5
-rw-r--r--connect.c1
-rw-r--r--connected.c1
-rw-r--r--convert.c1
-rw-r--r--daemon.c1
-rw-r--r--decorate.c3
-rw-r--r--delta-islands.c4
-rw-r--r--diagnose.c1
-rw-r--r--diff-lib.c1
-rw-r--r--diff-merges.c2
-rw-r--r--diff-no-index.c1
-rw-r--r--diff.c2
-rw-r--r--diff.h3
-rw-r--r--diffcore-delta.c2
-rw-r--r--diffcore-order.c3
-rw-r--r--diffcore-pickaxe.c4
-rw-r--r--diffcore-rename.c7
-rw-r--r--diffcore-rotate.c3
-rw-r--r--diffcore.h4
-rw-r--r--dir-iterator.c3
-rw-r--r--dir.c3
-rw-r--r--dir.h16
-rw-r--r--entry.c1
-rw-r--r--entry.h4
-rw-r--r--environment.c1
-rw-r--r--ewah/bitmap.c3
-rw-r--r--ewah/ewah_bitmap.c2
-rw-r--r--fetch-pack.c4
-rw-r--r--fmt-merge-msg.c3
-rw-r--r--fsck.c4
-rw-r--r--fsck.h1
-rw-r--r--fsmonitor-settings.c3
-rw-r--r--git-compat-util.h1
-rw-r--r--git.c1
-rw-r--r--gpg-interface.c1
-rw-r--r--graph.c3
-rw-r--r--grep.c1
-rw-r--r--hash.h35
-rw-r--r--hashmap.c2
-rw-r--r--help.c4
-rw-r--r--hex.c3
-rw-r--r--hex.h84
-rw-r--r--hook.c5
-rw-r--r--http-backend.c4
-rw-r--r--http-fetch.c1
-rw-r--r--http-push.c1
-rw-r--r--http-walker.c1
-rw-r--r--http.c1
-rw-r--r--ident.c5
-rw-r--r--ident.h67
-rw-r--r--imap-send.c2
-rw-r--r--json-writer.c2
-rw-r--r--khash.h1
-rw-r--r--kwset.c2
-rw-r--r--levenshtein.c2
-rw-r--r--line-log.c2
-rw-r--r--line-log.h1
-rw-r--r--linear-assignment.c2
-rw-r--r--list-objects-filter-options.c4
-rw-r--r--list-objects-filter-options.h3
-rw-r--r--list-objects-filter.c2
-rw-r--r--list-objects.c1
-rw-r--r--log-tree.c2
-rw-r--r--ls-refs.c1
-rw-r--r--mailinfo.c4
-rw-r--r--match-trees.c1
-rw-r--r--mem-pool.c2
-rw-r--r--merge-blobs.c2
-rw-r--r--merge-ort.c1
-rw-r--r--merge-recursive.c2
-rw-r--r--merge.c1
-rw-r--r--midx.c4
-rw-r--r--negotiator/noop.c2
-rw-r--r--negotiator/skipping.c1
-rw-r--r--notes-merge.c1
-rw-r--r--notes.c1
-rw-r--r--object-file.c4
-rw-r--r--object-name.c1
-rw-r--r--object-store.h128
-rw-r--r--object.c1
-rw-r--r--object.h22
-rw-r--r--oid-array.c3
-rw-r--r--oidmap.c2
-rw-r--r--oidmap.h1
-rw-r--r--oidset.c4
-rw-r--r--oidtree.c1
-rw-r--r--oss-fuzz/fuzz-commit-graph.c1
-rw-r--r--oss-fuzz/fuzz-pack-headers.c1
-rw-r--r--oss-fuzz/fuzz-pack-idx.c1
-rw-r--r--pack-bitmap-write.c4
-rw-r--r--pack-bitmap.c4
-rw-r--r--pack-check.c1
-rw-r--r--pack-mtimes.h2
-rw-r--r--pack-objects.c3
-rw-r--r--pack-write.c1
-rw-r--r--packfile.c4
-rw-r--r--parallel-checkout.c2
-rw-r--r--patch-ids.c1
-rw-r--r--path.c1
-rw-r--r--pathspec.h5
-rw-r--r--pkt-line.c1
-rw-r--r--pkt-line.h1
-rw-r--r--pretty.c2
-rw-r--r--pretty.h4
-rw-r--r--prio-queue.c3
-rw-r--r--promisor-remote.c1
-rw-r--r--protocol-caps.c2
-rw-r--r--prune-packed.c1
-rw-r--r--quote.c2
-rw-r--r--reachable.c1
-rw-r--r--read-cache.c2
-rw-r--r--rebase.c1
-rw-r--r--ref-filter.c6
-rw-r--r--reflog-walk.c3
-rw-r--r--reflog-walk.h2
-rw-r--r--refs.c4
-rw-r--r--refs/debug.c3
-rw-r--r--refs/files-backend.c2
-rw-r--r--refs/packed-backend.c4
-rw-r--r--refs/ref-cache.c3
-rw-r--r--refs/refs-internal.h1
-rw-r--r--refspec.c4
-rw-r--r--remote-curl.c4
-rw-r--r--remote.c4
-rw-r--r--remote.h1
-rw-r--r--replace-object.c1
-rw-r--r--replace-object.h8
-rw-r--r--repo-settings.c2
-rw-r--r--repository.h1
-rw-r--r--rerere.c4
-rw-r--r--reset.c1
-rw-r--r--revision.c4
-rw-r--r--revision.h1
-rw-r--r--send-pack.c3
-rw-r--r--sequencer.c2
-rw-r--r--sequencer.h2
-rw-r--r--serve.c3
-rw-r--r--server-info.c4
-rw-r--r--sha1dc_git.c4
-rw-r--r--shallow.c4
-rw-r--r--shallow.h2
-rw-r--r--shell.c2
-rw-r--r--sigchain.c3
-rw-r--r--sparse-index.c1
-rw-r--r--split-index.c1
-rw-r--r--statinfo.h24
-rw-r--r--strbuf.c4
-rw-r--r--string-list.c3
-rw-r--r--strvec.c4
-rw-r--r--sub-process.c1
-rw-r--r--sub-process.h1
-rw-r--r--submodule-config.c2
-rw-r--r--submodule-config.h1
-rw-r--r--submodule.c5
-rw-r--r--t/helper/test-bloom.c3
-rw-r--r--t/helper/test-cache-tree.c1
-rw-r--r--t/helper/test-crontab.c1
-rw-r--r--t/helper/test-ctype.c1
-rw-r--r--t/helper/test-dump-cache-tree.c1
-rw-r--r--t/helper/test-dump-split-index.c1
-rw-r--r--t/helper/test-dump-untracked-cache.c1
-rw-r--r--t/helper/test-example-decorate.c2
-rw-r--r--t/helper/test-fast-rebase.c1
-rw-r--r--t/helper/test-hash.c1
-rw-r--r--t/helper/test-json-writer.c1
-rw-r--r--t/helper/test-match-trees.c1
-rw-r--r--t/helper/test-oid-array.c1
-rw-r--r--t/helper/test-oidmap.c1
-rw-r--r--t/helper/test-oidtree.c1
-rw-r--r--t/helper/test-pack-mtimes.c1
-rw-r--r--t/helper/test-partial-clone.c1
-rw-r--r--t/helper/test-pcre2-config.c1
-rw-r--r--t/helper/test-prio-queue.c1
-rw-r--r--t/helper/test-proc-receive.c1
-rw-r--r--t/helper/test-reach.c3
-rw-r--r--t/helper/test-read-midx.c1
-rw-r--r--t/helper/test-ref-store.c1
-rw-r--r--t/helper/test-repository.c1
-rw-r--r--t/helper/test-run-command.c2
-rw-r--r--t/helper/test-sigchain.c1
-rw-r--r--t/helper/test-simple-ipc.c3
-rw-r--r--t/helper/test-submodule-nested-repo-config.c1
-rw-r--r--t/helper/test-wildmatch.c1
-rw-r--r--tag.c1
-rw-r--r--thread-utils.c2
-rw-r--r--trace.h1
-rw-r--r--trace2.c3
-rw-r--r--trace2/tr2_ctr.c2
-rw-r--r--trace2/tr2_sid.c1
-rw-r--r--trace2/tr2_sysenv.c2
-rw-r--r--trace2/tr2_tbuf.c2
-rw-r--r--trace2/tr2_tgt_event.c2
-rw-r--r--trace2/tr2_tgt_normal.c2
-rw-r--r--trace2/tr2_tgt_perf.c2
-rw-r--r--trace2/tr2_tls.c4
-rw-r--r--trace2/tr2_tmr.c3
-rw-r--r--trailer.c1
-rw-r--r--transport-helper.c1
-rw-r--r--transport.c5
-rw-r--r--tree-walk.c2
-rw-r--r--tree-walk.h4
-rw-r--r--tree.c1
-rw-r--r--unix-socket.c3
-rw-r--r--unix-stream-server.c2
-rw-r--r--unpack-trees.c1
-rw-r--r--upload-pack.c1
-rw-r--r--url.c4
-rw-r--r--urlmatch.c5
-rw-r--r--userdiff.c4
-rw-r--r--walker.c1
-rw-r--r--wildmatch.c2
-rw-r--r--worktree.c3
-rw-r--r--worktree.h1
-rw-r--r--wt-status.c1
-rw-r--r--xdiff-interface.c1
-rw-r--r--xdiff-interface.h2
322 files changed, 858 insertions, 529 deletions
diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines
index 9d5c27807a..003393ed16 100644
--- a/Documentation/CodingGuidelines
+++ b/Documentation/CodingGuidelines
@@ -442,8 +442,12 @@ For C programs:
detail.
- The first #include in C files, except in platform specific compat/
- implementations, must be either "git-compat-util.h", "cache.h" or
- "builtin.h". You do not have to include more than one of these.
+ implementations and sha1dc/, must be either "git-compat-util.h" or
+ one of the approved headers that includes it first for you. (The
+ approved headers currently include "cache.h", "builtin.h",
+ "t/helper/test-tool.h", "xdiff/xinclude.h", or
+ "reftable/system.h"). You do not have to include more than one of
+ these.
- A C file must directly include the header files that declare the
functions and the types it uses, except for the functions and types
diff --git a/add-interactive.c b/add-interactive.c
index 00a0f6f96f..ae25ec50bc 100644
--- a/add-interactive.c
+++ b/add-interactive.c
@@ -3,6 +3,7 @@
#include "color.h"
#include "config.h"
#include "diffcore.h"
+#include "hex.h"
#include "revision.h"
#include "refs.h"
#include "string-list.h"
diff --git a/add-patch.c b/add-patch.c
index a86a92e164..c6e451c136 100644
--- a/add-patch.c
+++ b/add-patch.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "add-interactive.h"
+#include "alloc.h"
#include "strbuf.h"
#include "run-command.h"
#include "strvec.h"
diff --git a/advice.c b/advice.c
index fd18968943..a5ea460ab8 100644
--- a/advice.c
+++ b/advice.c
@@ -1,6 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "advice.h"
#include "config.h"
#include "color.h"
+#include "gettext.h"
#include "help.h"
#include "string-list.h"
diff --git a/advice.h b/advice.h
index 07e0f76833..3e1b48bf68 100644
--- a/advice.h
+++ b/advice.h
@@ -1,8 +1,6 @@
#ifndef ADVICE_H
#define ADVICE_H
-#include "git-compat-util.h"
-
struct string_list;
/*
diff --git a/alias.c b/alias.c
index 00abde0817..e814948ced 100644
--- a/alias.c
+++ b/alias.c
@@ -1,6 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "alias.h"
+#include "alloc.h"
#include "config.h"
+#include "gettext.h"
#include "string-list.h"
struct config_alias_data {
diff --git a/alloc.c b/alloc.c
index 27f697e4c8..2886aa9354 100644
--- a/alloc.c
+++ b/alloc.c
@@ -8,7 +8,7 @@
* up with maximal alignment because it doesn't know what the object alignment
* for the new allocation is.
*/
-#include "cache.h"
+#include "git-compat-util.h"
#include "object.h"
#include "blob.h"
#include "tree.h"
diff --git a/alloc.h b/alloc.h
index 3f4a0ad310..4312db4bd0 100644
--- a/alloc.h
+++ b/alloc.h
@@ -17,4 +17,79 @@ void *alloc_object_node(struct repository *r);
struct alloc_state *allocate_alloc_state(void);
void clear_alloc_state(struct alloc_state *s);
+#define alloc_nr(x) (((x)+16)*3/2)
+
+/**
+ * Dynamically growing an array using realloc() is error prone and boring.
+ *
+ * Define your array with:
+ *
+ * - a pointer (`item`) that points at the array, initialized to `NULL`
+ * (although please name the variable based on its contents, not on its
+ * type);
+ *
+ * - an integer variable (`alloc`) that keeps track of how big the current
+ * allocation is, initialized to `0`;
+ *
+ * - another integer variable (`nr`) to keep track of how many elements the
+ * array currently has, initialized to `0`.
+ *
+ * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
+ * alloc)`. This ensures that the array can hold at least `n` elements by
+ * calling `realloc(3)` and adjusting `alloc` variable.
+ *
+ * ------------
+ * sometype *item;
+ * size_t nr;
+ * size_t alloc
+ *
+ * for (i = 0; i < nr; i++)
+ * if (we like item[i] already)
+ * return;
+ *
+ * // we did not like any existing one, so add one
+ * ALLOC_GROW(item, nr + 1, alloc);
+ * item[nr++] = value you like;
+ * ------------
+ *
+ * You are responsible for updating the `nr` variable.
+ *
+ * If you need to specify the number of elements to allocate explicitly
+ * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
+ *
+ * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
+ * added niceties.
+ *
+ * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
+ */
+#define ALLOC_GROW(x, nr, alloc) \
+ do { \
+ if ((nr) > alloc) { \
+ if (alloc_nr(alloc) < (nr)) \
+ alloc = (nr); \
+ else \
+ alloc = alloc_nr(alloc); \
+ REALLOC_ARRAY(x, alloc); \
+ } \
+ } while (0)
+
+/*
+ * Similar to ALLOC_GROW but handles updating of the nr value and
+ * zeroing the bytes of the newly-grown array elements.
+ *
+ * DO NOT USE any expression with side-effect for any of the
+ * arguments.
+ */
+#define ALLOC_GROW_BY(x, nr, increase, alloc) \
+ do { \
+ if (increase) { \
+ size_t new_nr = nr + (increase); \
+ if (new_nr < nr) \
+ BUG("negative growth in ALLOC_GROW_BY"); \
+ ALLOC_GROW(x, new_nr, alloc); \
+ memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
+ nr = new_nr; \
+ } \
+ } while (0)
+
#endif
diff --git a/apply.c b/apply.c
index 5cc5479c9c..8776ab939a 100644
--- a/apply.c
+++ b/apply.c
@@ -8,12 +8,14 @@
*/
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "object-store.h"
#include "blob.h"
#include "delta.h"
#include "diff.h"
#include "dir.h"
+#include "hex.h"
#include "xdiff-interface.h"
#include "ll-merge.h"
#include "lockfile.h"
diff --git a/archive-tar.c b/archive-tar.c
index f8fad2946e..ee27fa0b39 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -1,8 +1,10 @@
/*
* Copyright (c) 2005, 2006 Rene Scharfe
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "tar.h"
#include "archive.h"
#include "object-store.h"
diff --git a/archive-zip.c b/archive-zip.c
index 0456f1ebf1..c5d1f72eb8 100644
--- a/archive-zip.c
+++ b/archive-zip.c
@@ -4,6 +4,7 @@
#include "cache.h"
#include "config.h"
#include "archive.h"
+#include "hex.h"
#include "streaming.h"
#include "utf8.h"
#include "object-store.h"
diff --git a/archive.c b/archive.c
index 9aeaf2bd87..1c2ca78e52 100644
--- a/archive.c
+++ b/archive.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "refs.h"
#include "object-store.h"
#include "commit.h"
diff --git a/attr.c b/attr.c
index 1053dfcd4b..657ee52229 100644
--- a/attr.c
+++ b/attr.c
@@ -7,6 +7,7 @@
*/
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "exec-cmd.h"
#include "attr.h"
diff --git a/bisect.c b/bisect.c
index ef5ee5a643..1409150c5c 100644
--- a/bisect.c
+++ b/bisect.c
@@ -2,6 +2,7 @@
#include "config.h"
#include "commit.h"
#include "diff.h"
+#include "hex.h"
#include "revision.h"
#include "refs.h"
#include "list-objects.h"
diff --git a/blame.c b/blame.c
index 8bfeaa1c63..e45d8a3bf9 100644
--- a/blame.c
+++ b/blame.c
@@ -5,6 +5,7 @@
#include "mergesort.h"
#include "diff.h"
#include "diffcore.h"
+#include "hex.h"
#include "tag.h"
#include "blame.h"
#include "alloc.h"
diff --git a/blame.h b/blame.h
index 38bde535b3..b60d1d81e3 100644
--- a/blame.h
+++ b/blame.h
@@ -1,7 +1,6 @@
#ifndef BLAME_H
#define BLAME_H
-#include "cache.h"
#include "commit.h"
#include "xdiff-interface.h"
#include "revision.h"
diff --git a/blob.c b/blob.c
index 8f83523b0c..888e28a559 100644
--- a/blob.c
+++ b/blob.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "blob.h"
#include "repository.h"
#include "alloc.h"
diff --git a/branch.c b/branch.c
index e5614b53b3..5aaf073dce 100644
--- a/branch.c
+++ b/branch.c
@@ -2,6 +2,7 @@
#include "cache.h"
#include "config.h"
#include "branch.h"
+#include "hex.h"
#include "refs.h"
#include "refspec.h"
#include "remote.h"
diff --git a/builtin/am.c b/builtin/am.c
index e0848ddadf..3b5ea50cc5 100644
--- a/builtin/am.c
+++ b/builtin/am.c
@@ -8,6 +8,7 @@
#include "config.h"
#include "builtin.h"
#include "exec-cmd.h"
+#include "hex.h"
#include "parse-options.h"
#include "dir.h"
#include "run-command.h"
diff --git a/builtin/bisect.c b/builtin/bisect.c
index 7301740267..e8ee4a4dc8 100644
--- a/builtin/bisect.c
+++ b/builtin/bisect.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "hex.h"
#include "parse-options.h"
#include "bisect.h"
#include "refs.h"
diff --git a/builtin/blame.c b/builtin/blame.c
index 71f925e456..fdd9f0c0fc 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -5,10 +5,12 @@
* See COPYING for licensing conditions
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
#include "color.h"
#include "builtin.h"
+#include "hex.h"
#include "repository.h"
#include "commit.h"
#include "diff.h"
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index cc17635e76..b7a73acb07 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -5,9 +5,12 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "builtin.h"
#include "diff.h"
+#include "hex.h"
+#include "ident.h"
#include "parse-options.h"
#include "userdiff.h"
#include "streaming.h"
@@ -15,6 +18,7 @@
#include "oid-array.h"
#include "packfile.h"
#include "object-store.h"
+#include "replace-object.h"
#include "promisor-remote.h"
#include "mailmap.h"
diff --git a/builtin/check-mailmap.c b/builtin/check-mailmap.c
index 7dc47e4793..96db3ddb4b 100644
--- a/builtin/check-mailmap.c
+++ b/builtin/check-mailmap.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "config.h"
+#include "ident.h"
#include "mailmap.h"
#include "parse-options.h"
#include "string-list.h"
diff --git a/builtin/checkout--worker.c b/builtin/checkout--worker.c
index ede7dc32a4..0a7d762573 100644
--- a/builtin/checkout--worker.c
+++ b/builtin/checkout--worker.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "alloc.h"
#include "config.h"
#include "entry.h"
#include "parallel-checkout.h"
diff --git a/builtin/checkout.c b/builtin/checkout.c
index a5155cf55c..21a4335abb 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -9,6 +9,7 @@
#include "config.h"
#include "diff.h"
#include "dir.h"
+#include "hex.h"
#include "hook.h"
#include "ll-merge.h"
#include "lockfile.h"
diff --git a/builtin/clone.c b/builtin/clone.c
index 65b5b7db6d..462c286274 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -11,6 +11,7 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "parse-options.h"
#include "fetch-pack.h"
diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c
index 93704f95a9..d3be7f3b31 100644
--- a/builtin/commit-graph.c
+++ b/builtin/commit-graph.c
@@ -1,12 +1,14 @@
#include "builtin.h"
#include "config.h"
#include "dir.h"
+#include "hex.h"
#include "lockfile.h"
#include "parse-options.h"
#include "repository.h"
#include "commit-graph.h"
#include "object-store.h"
#include "progress.h"
+#include "replace-object.h"
#include "tag.h"
#define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \
diff --git a/builtin/commit-tree.c b/builtin/commit-tree.c
index cc8d584be2..fefeed5d4b 100644
--- a/builtin/commit-tree.c
+++ b/builtin/commit-tree.c
@@ -5,6 +5,7 @@
*/
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "object-store.h"
#include "repository.h"
#include "commit.h"
diff --git a/builtin/config.c b/builtin/config.c
index 060cf9f3e0..49d832d409 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -1,7 +1,8 @@
#include "builtin.h"
-#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "color.h"
+#include "ident.h"
#include "parse-options.h"
#include "urlmatch.h"
#include "quote.h"
diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c
index 338058be7f..6e509d02c3 100644
--- a/builtin/credential-cache--daemon.c
+++ b/builtin/credential-cache--daemon.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "alloc.h"
#include "parse-options.h"
#ifndef NO_UNIX_SOCKETS
diff --git a/builtin/describe.c b/builtin/describe.c
index eea1e330c0..5b5930f5c8 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -1,6 +1,7 @@
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "commit.h"
#include "tag.h"
diff --git a/builtin/diff-tree.c b/builtin/diff-tree.c
index 25b853b85c..a393efa4f0 100644
--- a/builtin/diff-tree.c
+++ b/builtin/diff-tree.c
@@ -3,6 +3,7 @@
#include "config.h"
#include "diff.h"
#include "commit.h"
+#include "hex.h"
#include "log-tree.h"
#include "builtin.h"
#include "submodule.h"
diff --git a/builtin/difftool.c b/builtin/difftool.c
index dbbfb19f19..01681d0fb8 100644
--- a/builtin/difftool.c
+++ b/builtin/difftool.c
@@ -17,6 +17,7 @@
#include "builtin.h"
#include "run-command.h"
#include "exec-cmd.h"
+#include "hex.h"
#include "parse-options.h"
#include "strvec.h"
#include "strbuf.h"
diff --git a/builtin/fast-export.c b/builtin/fast-export.c
index 39a890fc00..78493c6d2b 100644
--- a/builtin/fast-export.c
+++ b/builtin/fast-export.c
@@ -6,6 +6,7 @@
#include "builtin.h"
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "refs.h"
#include "refspec.h"
#include "object-store.h"
diff --git a/builtin/fast-import.c b/builtin/fast-import.c
index 7134683ab9..160e2eedb7 100644
--- a/builtin/fast-import.c
+++ b/builtin/fast-import.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "hex.h"
#include "repository.h"
#include "config.h"
#include "lockfile.h"
diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index afe679368d..702c9a3397 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -1,4 +1,6 @@
#include "builtin.h"
+#include "alloc.h"
+#include "hex.h"
#include "pkt-line.h"
#include "fetch-pack.h"
#include "remote.h"
diff --git a/builtin/fetch.c b/builtin/fetch.c
index a09606b472..b678a45baa 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -3,6 +3,7 @@
*/
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "repository.h"
#include "refs.h"
#include "refspec.h"
diff --git a/builtin/fsck.c b/builtin/fsck.c
index 64614b43b2..e468e55325 100644
--- a/builtin/fsck.c
+++ b/builtin/fsck.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "hex.h"
#include "repository.h"
#include "config.h"
#include "commit.h"
@@ -18,6 +19,7 @@
#include "decorate.h"
#include "packfile.h"
#include "object-store.h"
+#include "replace-object.h"
#include "resolve-undo.h"
#include "run-command.h"
#include "worktree.h"
diff --git a/builtin/fsmonitor--daemon.c b/builtin/fsmonitor--daemon.c
index 0feef8caf6..cae804a190 100644
--- a/builtin/fsmonitor--daemon.c
+++ b/builtin/fsmonitor--daemon.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "alloc.h"
#include "config.h"
#include "parse-options.h"
#include "fsmonitor.h"
diff --git a/builtin/gc.c b/builtin/gc.c
index 02455fdcd7..67c7fe8a6e 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -11,6 +11,7 @@
*/
#include "builtin.h"
+#include "hex.h"
#include "repository.h"
#include "config.h"
#include "tempfile.h"
diff --git a/builtin/grep.c b/builtin/grep.c
index f7821c5fbb..c590fcb19d 100644
--- a/builtin/grep.c
+++ b/builtin/grep.c
@@ -4,6 +4,8 @@
* Copyright (c) 2006 Junio C Hamano
*/
#include "cache.h"
+#include "alloc.h"
+#include "hex.h"
#include "repository.h"
#include "config.h"
#include "blob.h"
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index 44db83f07f..1848768b97 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -6,6 +6,7 @@
*/
#include "builtin.h"
#include "config.h"
+#include "hex.h"
#include "object-store.h"
#include "blob.h"
#include "quote.h"
diff --git a/builtin/index-pack.c b/builtin/index-pack.c
index 6648f2daef..b451755f40 100644
--- a/builtin/index-pack.c
+++ b/builtin/index-pack.c
@@ -1,6 +1,8 @@
#include "builtin.h"
+#include "alloc.h"
#include "config.h"
#include "delta.h"
+#include "hex.h"
#include "pack.h"
#include "csum-file.h"
#include "blob.h"
@@ -14,6 +16,7 @@
#include "thread-utils.h"
#include "packfile.h"
#include "object-store.h"
+#include "replace-object.h"
#include "promisor-remote.h"
static const char index_pack_usage[] =
diff --git a/builtin/log.c b/builtin/log.c
index a70fba198f..45bfa86fe2 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -4,8 +4,10 @@
* (C) Copyright 2006 Linus Torvalds
* 2006 Junio Hamano
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "refs.h"
#include "object-store.h"
#include "color.h"
diff --git a/builtin/ls-remote.c b/builtin/ls-remote.c
index 6516177348..2dfbd8ed9b 100644
--- a/builtin/ls-remote.c
+++ b/builtin/ls-remote.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "hex.h"
#include "transport.h"
#include "ref-filter.h"
#include "remote.h"
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 8cc8c995df..64d8e54318 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -5,6 +5,7 @@
*/
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "object-store.h"
#include "blob.h"
#include "tree.h"
diff --git a/builtin/merge-base.c b/builtin/merge-base.c
index 6f3941f2a4..be8f3b221c 100644
--- a/builtin/merge-base.c
+++ b/builtin/merge-base.c
@@ -2,6 +2,7 @@
#include "cache.h"
#include "config.h"
#include "commit.h"
+#include "hex.h"
#include "refs.h"
#include "diff.h"
#include "revision.h"
diff --git a/builtin/merge-index.c b/builtin/merge-index.c
index 452f833ac4..c875f5d37e 100644
--- a/builtin/merge-index.c
+++ b/builtin/merge-index.c
@@ -1,5 +1,6 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
+#include "hex.h"
#include "run-command.h"
static const char *pgm;
diff --git a/builtin/merge-tree.c b/builtin/merge-tree.c
index 828dc81c42..e782518164 100644
--- a/builtin/merge-tree.c
+++ b/builtin/merge-tree.c
@@ -3,6 +3,7 @@
#include "tree-walk.h"
#include "xdiff-interface.h"
#include "help.h"
+#include "hex.h"
#include "commit.h"
#include "commit-reach.h"
#include "merge-ort.h"
diff --git a/builtin/merge.c b/builtin/merge.c
index 0a3c10a096..7347b738e5 100644
--- a/builtin/merge.c
+++ b/builtin/merge.c
@@ -8,7 +8,9 @@
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "parse-options.h"
#include "builtin.h"
#include "lockfile.h"
diff --git a/builtin/mktag.c b/builtin/mktag.c
index 5d22909122..42c2457c70 100644
--- a/builtin/mktag.c
+++ b/builtin/mktag.c
@@ -1,4 +1,5 @@
#include "builtin.h"
+#include "hex.h"
#include "parse-options.h"
#include "tag.h"
#include "replace-object.h"
diff --git a/builtin/mktree.c b/builtin/mktree.c
index 06d81400f5..848c7b4747 100644
--- a/builtin/mktree.c
+++ b/builtin/mktree.c
@@ -4,6 +4,8 @@
* Copyright (c) Junio C Hamano, 2006, 2009
*/
#include "builtin.h"
+#include "alloc.h"
+#include "hex.h"
#include "quote.h"
#include "tree.h"
#include "parse-options.h"
diff --git a/builtin/mv.c b/builtin/mv.c
index edd7b931fd..8129050377 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -5,6 +5,7 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
+#include "alloc.h"
#include "config.h"
#include "pathspec.h"
#include "lockfile.h"
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index 97959bfaf9..723ba616a8 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -1,5 +1,6 @@
#include "builtin.h"
-#include "cache.h"
+#include "alloc.h"
+#include "hex.h"
#include "repository.h"
#include "config.h"
#include "commit.h"
diff --git a/builtin/notes.c b/builtin/notes.c
index 80d9dfd25c..bba4c2e39f 100644
--- a/builtin/notes.c
+++ b/builtin/notes.c
@@ -10,6 +10,7 @@
#include "cache.h"
#include "config.h"
#include "builtin.h"
+#include "hex.h"
#include "notes.h"
#include "object-store.h"
#include "repository.h"
diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
index 74a167a180..2e73284f10 100644
--- a/builtin/pack-objects.c
+++ b/builtin/pack-objects.c
@@ -1,5 +1,6 @@
#include "builtin.h"
-#include "cache.h"
+#include "alloc.h"
+#include "hex.h"
#include "repository.h"
#include "config.h"
#include "attr.h"
@@ -31,6 +32,7 @@
#include "list.h"
#include "packfile.h"
#include "object-store.h"
+#include "replace-object.h"
#include "dir.h"
#include "midx.h"
#include "trace2.h"
diff --git a/builtin/pack-redundant.c b/builtin/pack-redundant.c
index ecd49ca268..82115c5808 100644
--- a/builtin/pack-redundant.c
+++ b/builtin/pack-redundant.c
@@ -7,6 +7,7 @@
*/
#include "builtin.h"
+#include "hex.h"
#include "repository.h"
#include "packfile.h"
#include "object-store.h"
diff --git a/builtin/patch-id.c b/builtin/patch-id.c
index f840fbf1c7..338b15cd7b 100644
--- a/builtin/patch-id.c
+++ b/builtin/patch-id.c
@@ -2,6 +2,7 @@
#include "builtin.h"
#include "config.h"
#include "diff.h"
+#include "hex.h"
#include "parse-options.h"
static void flush_current_id(int patchlen, struct object_id *id, struct object_id *result)
diff --git a/builtin/prune.c b/builtin/prune.c
index 2719220108..f2ed45ccf0 100644
--- a/builtin/prune.c
+++ b/builtin/prune.c
@@ -1,12 +1,14 @@
#include "cache.h"
#include "commit.h"
#include "diff.h"
+#include "hex.h"
#include "revision.h"
#include "builtin.h"
#include "reachable.h"
#include "parse-options.h"
#include "progress.h"
#include "prune-packed.h"
+#include "replace-object.h"
#include "object-store.h"
#include "shallow.h"
diff --git a/builtin/pull.c b/builtin/pull.c
index 1ab4de0005..963a47f0b8 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -9,6 +9,7 @@
#include "cache.h"
#include "config.h"
#include "builtin.h"
+#include "hex.h"
#include "parse-options.h"
#include "exec-cmd.h"
#include "run-command.h"
diff --git a/builtin/read-tree.c b/builtin/read-tree.c
index 6034408d48..11759c415f 100644
--- a/builtin/read-tree.c
+++ b/builtin/read-tree.c
@@ -7,6 +7,7 @@
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "object.h"
#include "tree.h"
diff --git a/builtin/rebase.c b/builtin/rebase.c
index 6635f10d52..ef8ce2f72c 100644
--- a/builtin/rebase.c
+++ b/builtin/rebase.c
@@ -6,6 +6,7 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
+#include "hex.h"
#include "run-command.h"
#include "exec-cmd.h"
#include "strvec.h"
diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c
index cd5c7a28ef..3d2b4c8b4f 100644
--- a/builtin/receive-pack.c
+++ b/builtin/receive-pack.c
@@ -1,6 +1,7 @@
#include "builtin.h"
#include "repository.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "pack.h"
#include "refs.h"
diff --git a/builtin/repack.c b/builtin/repack.c
index f649379531..966430a465 100644
--- a/builtin/repack.c
+++ b/builtin/repack.c
@@ -1,7 +1,8 @@
#include "builtin.h"
-#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "dir.h"
+#include "hex.h"
#include "parse-options.h"
#include "run-command.h"
#include "sigchain.h"
diff --git a/builtin/replace.c b/builtin/replace.c
index a29e911d30..71d8e949e3 100644
--- a/builtin/replace.c
+++ b/builtin/replace.c
@@ -11,10 +11,12 @@
#include "cache.h"
#include "config.h"
#include "builtin.h"
+#include "hex.h"
#include "refs.h"
#include "parse-options.h"
#include "run-command.h"
#include "object-store.h"
+#include "replace-object.h"
#include "repository.h"
#include "tag.h"
diff --git a/builtin/reset.c b/builtin/reset.c
index 0697fa89de..58f567afd3 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -10,6 +10,7 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "tag.h"
#include "object.h"
diff --git a/builtin/rev-list.c b/builtin/rev-list.c
index d42db0b0cc..e4c9b74762 100644
--- a/builtin/rev-list.c
+++ b/builtin/rev-list.c
@@ -2,6 +2,7 @@
#include "config.h"
#include "commit.h"
#include "diff.h"
+#include "hex.h"
#include "revision.h"
#include "list-objects.h"
#include "list-objects-filter.h"
diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index e67999e5eb..e1fa9c6348 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -5,8 +5,10 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "commit.h"
+#include "hex.h"
#include "refs.h"
#include "quote.h"
#include "builtin.h"
diff --git a/builtin/revert.c b/builtin/revert.c
index 77d2035616..62986a7b1b 100644
--- a/builtin/revert.c
+++ b/builtin/revert.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
#include "builtin.h"
#include "parse-options.h"
diff --git a/builtin/rm.c b/builtin/rm.c
index 8844f90655..dc198f7908 100644
--- a/builtin/rm.c
+++ b/builtin/rm.c
@@ -5,6 +5,7 @@
*/
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
+#include "alloc.h"
#include "advice.h"
#include "config.h"
#include "lockfile.h"
diff --git a/builtin/send-pack.c b/builtin/send-pack.c
index 4c5d125fa0..127ced435d 100644
--- a/builtin/send-pack.c
+++ b/builtin/send-pack.c
@@ -1,6 +1,7 @@
#include "builtin.h"
#include "config.h"
#include "commit.h"
+#include "hex.h"
#include "refs.h"
#include "pkt-line.h"
#include "sideband.h"
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 358ac3e519..8342b68aef 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "pretty.h"
#include "refs.h"
#include "builtin.h"
diff --git a/builtin/show-index.c b/builtin/show-index.c
index 0e0b9fb95b..98ec40ddf4 100644
--- a/builtin/show-index.c
+++ b/builtin/show-index.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "cache.h"
+#include "hex.h"
#include "pack.h"
#include "parse-options.h"
diff --git a/builtin/show-ref.c b/builtin/show-ref.c
index 3af6a53ee9..1f28d7fe4b 100644
--- a/builtin/show-ref.c
+++ b/builtin/show-ref.c
@@ -1,6 +1,7 @@
#include "builtin.h"
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "refs.h"
#include "object-store.h"
#include "object.h"
diff --git a/builtin/stash.c b/builtin/stash.c
index 3a4f9fd566..6a12fed271 100644
--- a/builtin/stash.c
+++ b/builtin/stash.c
@@ -1,6 +1,7 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "config.h"
+#include "hex.h"
#include "parse-options.h"
#include "refs.h"
#include "lockfile.h"
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 4c173d8b37..2bbabbb28e 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -1,5 +1,7 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
+#include "alloc.h"
+#include "hex.h"
#include "repository.h"
#include "cache.h"
#include "config.h"
diff --git a/builtin/tag.c b/builtin/tag.c
index d428c45dc8..be094882d0 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -9,6 +9,7 @@
#include "cache.h"
#include "config.h"
#include "builtin.h"
+#include "hex.h"
#include "refs.h"
#include "object-store.h"
#include "tag.h"
diff --git a/builtin/unpack-file.c b/builtin/unpack-file.c
index 88de32b7d7..e9b105a539 100644
--- a/builtin/unpack-file.c
+++ b/builtin/unpack-file.c
@@ -1,5 +1,6 @@
#include "builtin.h"
#include "config.h"
+#include "hex.h"
#include "object-store.h"
static char *create_temp_file(struct object_id *oid)
diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c
index 43789b8ef2..1908dcfcff 100644
--- a/builtin/unpack-objects.c
+++ b/builtin/unpack-objects.c
@@ -2,12 +2,14 @@
#include "cache.h"
#include "bulk-checkin.h"
#include "config.h"
+#include "hex.h"
#include "object-store.h"
#include "object.h"
#include "delta.h"
#include "pack.h"
#include "blob.h"
#include "commit.h"
+#include "replace-object.h"
#include "tag.h"
#include "tree.h"
#include "tree-walk.h"
diff --git a/builtin/update-index.c b/builtin/update-index.c
index bf38885d54..11dc135271 100644
--- a/builtin/update-index.c
+++ b/builtin/update-index.c
@@ -7,6 +7,7 @@
#include "cache.h"
#include "bulk-checkin.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "quote.h"
#include "cache-tree.h"
diff --git a/builtin/upload-pack.c b/builtin/upload-pack.c
index 25b69da2bf..7a3c68720f 100644
--- a/builtin/upload-pack.c
+++ b/builtin/upload-pack.c
@@ -4,6 +4,7 @@
#include "pkt-line.h"
#include "parse-options.h"
#include "protocol.h"
+#include "replace-object.h"
#include "upload-pack.h"
#include "serve.h"
diff --git a/builtin/var.c b/builtin/var.c
index a80c1df86f..d9943be9af 100644
--- a/builtin/var.c
+++ b/builtin/var.c
@@ -5,6 +5,7 @@
*/
#include "builtin.h"
#include "config.h"
+#include "ident.h"
#include "refs.h"
static const char var_usage[] = "git var (-l | <variable>)";
diff --git a/builtin/worktree.c b/builtin/worktree.c
index 254283aa6f..80d05e246d 100644
--- a/builtin/worktree.c
+++ b/builtin/worktree.c
@@ -3,6 +3,7 @@
#include "config.h"
#include "builtin.h"
#include "dir.h"
+#include "hex.h"
#include "parse-options.h"
#include "strvec.h"
#include "branch.h"
diff --git a/builtin/write-tree.c b/builtin/write-tree.c
index 078010315f..7ad0d05945 100644
--- a/builtin/write-tree.c
+++ b/builtin/write-tree.c
@@ -7,6 +7,7 @@
#include "builtin.h"
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "tree.h"
#include "cache-tree.h"
#include "parse-options.h"
diff --git a/bulk-checkin.c b/bulk-checkin.c
index 855b68ec23..d64cd5c52d 100644
--- a/bulk-checkin.c
+++ b/bulk-checkin.c
@@ -1,8 +1,10 @@
/*
* Copyright (c) 2011, Google Inc.
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "bulk-checkin.h"
+#include "hex.h"
#include "lockfile.h"
#include "repository.h"
#include "csum-file.h"
diff --git a/bundle.c b/bundle.c
index 6ab6cd7378..99d7de97f6 100644
--- a/bundle.c
+++ b/bundle.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "lockfile.h"
#include "bundle.h"
+#include "hex.h"
#include "object-store.h"
#include "repository.h"
#include "object.h"
diff --git a/cache-tree.c b/cache-tree.c
index 88c2c04f87..9d46ecef09 100644
--- a/cache-tree.c
+++ b/cache-tree.c
@@ -1,4 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
+#include "hex.h"
#include "lockfile.h"
#include "tree.h"
#include "tree-walk.h"
diff --git a/cache-tree.h b/cache-tree.h
index bd97caa07b..faae88be63 100644
--- a/cache-tree.h
+++ b/cache-tree.h
@@ -1,7 +1,6 @@
#ifndef CACHE_TREE_H
#define CACHE_TREE_H
-#include "cache.h"
#include "tree.h"
#include "tree-walk.h"
diff --git a/cache.h b/cache.h
index 12789903e8..0221bc6d5c 100644
--- a/cache.h
+++ b/cache.h
@@ -14,8 +14,11 @@
#include "pack-revindex.h"
#include "hash.h"
#include "path.h"
+#include "pathspec.h"
+#include "object.h"
#include "oid-array.h"
#include "repository.h"
+#include "statinfo.h"
#include "mem-pool.h"
typedef struct git_zstream {
@@ -118,26 +121,6 @@ struct cache_header {
#define INDEX_FORMAT_LB 2
#define INDEX_FORMAT_UB 4
-/*
- * The "cache_time" is just the low 32 bits of the
- * time. It doesn't matter if it overflows - we only
- * check it for equality in the 32 bits we save.
- */
-struct cache_time {
- uint32_t sec;
- uint32_t nsec;
-};
-
-struct stat_data {
- struct cache_time sd_ctime;
- struct cache_time sd_mtime;
- unsigned int sd_dev;
- unsigned int sd_ino;
- unsigned int sd_uid;
- unsigned int sd_gid;
- unsigned int sd_size;
-};
-
struct cache_entry {
struct hashmap_entry ent;
struct stat_data ce_stat_data;
@@ -293,6 +276,15 @@ static inline unsigned int canon_mode(unsigned int mode)
return S_IFGITLINK;
}
+static inline int ce_path_match(struct index_state *istate,
+ const struct cache_entry *ce,
+ const struct pathspec *pathspec,
+ char *seen)
+{
+ return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
+ S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
+}
+
#define cache_entry_size(len) (offsetof(struct cache_entry,name) + (len) + 1)
#define SOMETHING_CHANGED (1 << 0) /* unclassified changes go here */
@@ -453,26 +445,6 @@ void prefetch_cache_entries(const struct index_state *istate,
extern struct index_state the_index;
#endif
-#define TYPE_BITS 3
-
-/*
- * Values in this enum (except those outside the 3 bit range) are part
- * of pack file format. See gitformat-pack(5) for more information.
- */
-enum object_type {
- OBJ_BAD = -1,
- OBJ_NONE = 0,
- OBJ_COMMIT = 1,
- OBJ_TREE = 2,
- OBJ_BLOB = 3,
- OBJ_TAG = 4,
- /* 5 for future expansion */
- OBJ_OFS_DELTA = 6,
- OBJ_REF_DELTA = 7,
- OBJ_ANY,
- OBJ_MAX
-};
-
static inline enum object_type object_type(unsigned int mode)
{
return S_ISDIR(mode) ? OBJ_TREE :
@@ -656,81 +628,6 @@ void initialize_repository_version(int hash_algo, int reinit);
void sanitize_stdfds(void);
int daemonize(void);
-#define alloc_nr(x) (((x)+16)*3/2)
-
-/**
- * Dynamically growing an array using realloc() is error prone and boring.
- *
- * Define your array with:
- *
- * - a pointer (`item`) that points at the array, initialized to `NULL`
- * (although please name the variable based on its contents, not on its
- * type);
- *
- * - an integer variable (`alloc`) that keeps track of how big the current
- * allocation is, initialized to `0`;
- *
- * - another integer variable (`nr`) to keep track of how many elements the
- * array currently has, initialized to `0`.
- *
- * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
- * alloc)`. This ensures that the array can hold at least `n` elements by
- * calling `realloc(3)` and adjusting `alloc` variable.
- *
- * ------------
- * sometype *item;
- * size_t nr;
- * size_t alloc
- *
- * for (i = 0; i < nr; i++)
- * if (we like item[i] already)
- * return;
- *
- * // we did not like any existing one, so add one
- * ALLOC_GROW(item, nr + 1, alloc);
- * item[nr++] = value you like;
- * ------------
- *
- * You are responsible for updating the `nr` variable.
- *
- * If you need to specify the number of elements to allocate explicitly
- * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
- *
- * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
- * added niceties.
- *
- * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
- */
-#define ALLOC_GROW(x, nr, alloc) \
- do { \
- if ((nr) > alloc) { \
- if (alloc_nr(alloc) < (nr)) \
- alloc = (nr); \
- else \
- alloc = alloc_nr(alloc); \
- REALLOC_ARRAY(x, alloc); \
- } \
- } while (0)
-
-/*
- * Similar to ALLOC_GROW but handles updating of the nr value and
- * zeroing the bytes of the newly-grown array elements.
- *
- * DO NOT USE any expression with side-effect for any of the
- * arguments.
- */
-#define ALLOC_GROW_BY(x, nr, increase, alloc) \
- do { \
- if (increase) { \
- size_t new_nr = nr + (increase); \
- if (new_nr < nr) \
- BUG("negative growth in ALLOC_GROW_BY"); \
- ALLOC_GROW(x, new_nr, alloc); \
- memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
- nr = new_nr; \
- } \
- } while (0)
-
/* Initialize and use the cache information */
struct lock_file;
void preload_index(struct index_state *index,
@@ -990,14 +887,6 @@ int get_shared_repository(void);
void reset_shared_repository(void);
/*
- * Do replace refs need to be checked this run? This variable is
- * initialized to true unless --no-replace-object is used or
- * $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some
- * commands that do not want replace references to be active.
- */
-extern int read_replace_refs;
-
-/*
* These values are used to help identify parts of a repository to fsync.
* FSYNC_COMPONENT_NONE identifies data that will not be a persistent part of the
* repository and so shouldn't be fsynced.
@@ -1400,22 +1289,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);
-extern const signed char hexval_table[256];
-static inline unsigned int hexval(unsigned char c)
-{
- return hexval_table[c];
-}
-
-/*
- * Convert two consecutive hexadecimal digits into a char. Return a
- * negative value on error. Don't run over the end of short strings.
- */
-static inline int hex2chr(const char *s)
-{
- unsigned int val = hexval(s[0]);
- return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
-}
-
/* Convert to/from hex/sha1 representation */
#define MINIMUM_ABBREV minimum_abbrev
#define DEFAULT_ABBREV default_abbrev
@@ -1438,40 +1311,6 @@ struct object_context {
char *path;
};
-#define GET_OID_QUIETLY 01
-#define GET_OID_COMMIT 02
-#define GET_OID_COMMITTISH 04
-#define GET_OID_TREE 010
-#define GET_OID_TREEISH 020
-#define GET_OID_BLOB 040
-#define GET_OID_FOLLOW_SYMLINKS 0100
-#define GET_OID_RECORD_PATH 0200
-#define GET_OID_ONLY_TO_DIE 04000
-#define GET_OID_REQUIRE_PATH 010000
-
-#define GET_OID_DISAMBIGUATORS \
- (GET_OID_COMMIT | GET_OID_COMMITTISH | \
- GET_OID_TREE | GET_OID_TREEISH | \
- GET_OID_BLOB)
-
-enum get_oid_result {
- FOUND = 0,
- MISSING_OBJECT = -1, /* The requested object is missing */
- SHORT_NAME_AMBIGUOUS = -2,
- /* The following only apply when symlinks are followed */
- DANGLING_SYMLINK = -4, /*
- * The initial symlink is there, but
- * (transitively) points to a missing
- * in-tree file
- */
- SYMLINK_LOOP = -5,
- NOT_DIR = -6, /*
- * Somewhere along the symlink chain, a path is
- * requested which contains a file as a
- * non-final element.
- */
-};
-
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, ...);
@@ -1503,68 +1342,6 @@ int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_f
int set_disambiguate_hint_config(const char *var, const char *value);
/*
- * Try to read a SHA1 in hexadecimal format from the 40 characters
- * starting at hex. Write the 20-byte result to sha1 in binary form.
- * Return 0 on success. Reading stops if a NUL is encountered in the
- * input, so it is safe to pass this function an arbitrary
- * null-terminated string.
- */
-int get_sha1_hex(const char *hex, unsigned char *sha1);
-int get_oid_hex(const char *hex, struct object_id *sha1);
-
-/* Like get_oid_hex, but for an arbitrary hash algorithm. */
-int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop);
-
-/*
- * Read `len` pairs of hexadecimal digits from `hex` and write the
- * values to `binary` as `len` bytes. Return 0 on success, or -1 if
- * the input does not consist of hex digits).
- */
-int hex_to_bytes(unsigned char *binary, const char *hex, size_t len);
-
-/*
- * Convert a binary hash in "unsigned char []" or an object name in
- * "struct object_id *" to its hex equivalent. The `_r` variant is reentrant,
- * and writes the NUL-terminated output to the buffer `out`, which must be at
- * least `GIT_MAX_HEXSZ + 1` bytes, and returns a pointer to out for
- * convenience.
- *
- * The non-`_r` variant returns a static buffer, but uses a ring of 4
- * buffers, making it safe to make multiple calls for a single statement, like:
- *
- * printf("%s -> %s", hash_to_hex(one), hash_to_hex(two));
- * printf("%s -> %s", oid_to_hex(one), oid_to_hex(two));
- */
-char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash, const struct git_hash_algo *);
-char *oid_to_hex_r(char *out, const struct object_id *oid);
-char *hash_to_hex_algop(const unsigned char *hash, const struct git_hash_algo *); /* static buffer result! */
-char *hash_to_hex(const unsigned char *hash); /* same static buffer */
-char *oid_to_hex(const struct object_id *oid); /* same static buffer */
-
-/*
- * Parse a 40-character hexadecimal object ID starting from hex, updating the
- * pointer specified by end when parsing stops. The resulting object ID is
- * stored in oid. Returns 0 on success. Parsing will stop on the first NUL or
- * other invalid character. end is only updated on success; otherwise, it is
- * unmodified.
- */
-int parse_oid_hex(const char *hex, struct object_id *oid, const char **end);
-
-/* Like parse_oid_hex, but for an arbitrary hash algorithm. */
-int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end,
- const struct git_hash_algo *algo);
-
-
-/*
- * These functions work like get_oid_hex and parse_oid_hex, but they will parse
- * a hex value for any algorithm. The algorithm is detected based on the length
- * and the algorithm in use is returned. If this is not a hex object ID in any
- * algorithm, returns GIT_HASH_UNKNOWN.
- */
-int get_oid_hex_any(const char *hex, struct object_id *oid);
-int parse_oid_hex_any(const char *hex, struct object_id *oid, const char **end);
-
-/*
* 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.
@@ -1632,65 +1409,10 @@ struct object *repo_peel_to_type(struct repository *r,
#define peel_to_type(name, namelen, obj, type) \
repo_peel_to_type(the_repository, name, namelen, obj, type)
-#define IDENT_STRICT 1
-#define IDENT_NO_DATE 2
-#define IDENT_NO_NAME 4
-
-enum want_ident {
- WANT_BLANK_IDENT,
- WANT_AUTHOR_IDENT,
- WANT_COMMITTER_IDENT
-};
-
-const char *git_author_info(int);
-const char *git_committer_info(int);
-const char *fmt_ident(const char *name, const char *email,
- enum want_ident whose_ident,
- const char *date_str, int);
-const char *fmt_name(enum want_ident);
-const char *ident_default_name(void);
-const char *ident_default_email(void);
const char *git_editor(void);
const char *git_sequence_editor(void);
const char *git_pager(int stdout_is_tty);
int is_terminal_dumb(void);
-int git_ident_config(const char *, const char *, void *);
-/*
- * Prepare an ident to fall back on if the user didn't configure it.
- */
-void prepare_fallback_ident(const char *name, const char *email);
-void reset_ident_date(void);
-
-struct ident_split {
- const char *name_begin;
- const char *name_end;
- const char *mail_begin;
- const char *mail_end;
- const char *date_begin;
- const char *date_end;
- const char *tz_begin;
- const char *tz_end;
-};
-/*
- * Signals an success with 0, but time part of the result may be NULL
- * if the input lacks timestamp and zone
- */
-int split_ident_line(struct ident_split *, const char *, int);
-
-/*
- * Given a commit or tag object buffer and the commit or tag headers, replaces
- * the idents in the headers with their canonical versions using the mailmap mechanism.
- */
-void apply_mailmap_to_header(struct strbuf *, const char **, struct string_list *);
-
-/*
- * Compare split idents for equality or strict ordering. Note that we
- * compare only the ident part of the line, ignoring any timestamp.
- *
- * Because there are two fields, we must choose one as the primary key; we
- * currently arbitrarily pick the email.
- */
-int ident_cmp(const struct ident_split *, const struct ident_split *);
struct cache_def {
struct strbuf path;
@@ -1757,9 +1479,6 @@ int update_server_info(int);
const char *get_log_output_encoding(void);
const char *get_commit_output_encoding(void);
-int committer_ident_sufficiently_given(void);
-int author_ident_sufficiently_given(void);
-
extern const char *git_commit_encoding;
extern const char *git_log_output_encoding;
extern const char *git_mailmap_file;
diff --git a/cbtree.c b/cbtree.c
index 336e46dbba..c1cc30a5dc 100644
--- a/cbtree.c
+++ b/cbtree.c
@@ -4,6 +4,7 @@
* Based on Adam Langley's adaptation of Dan Bernstein's public domain code
* git clone https://github.com/agl/critbit.git
*/
+#include "git-compat-util.h"
#include "cbtree.h"
static struct cb_node *cb_node_of(const void *p)
diff --git a/cbtree.h b/cbtree.h
index 0be14fb7ee..43193abdda 100644
--- a/cbtree.h
+++ b/cbtree.h
@@ -14,8 +14,6 @@
#ifndef CBTREE_H
#define CBTREE_H
-#include "git-compat-util.h"
-
struct cb_node;
struct cb_node {
struct cb_node *child[2];
diff --git a/checkout.h b/checkout.h
index 1152133bd7..1917f3b323 100644
--- a/checkout.h
+++ b/checkout.h
@@ -1,7 +1,7 @@
#ifndef CHECKOUT_H
#define CHECKOUT_H
-#include "cache.h"
+#include "hash.h"
/*
* Check if the branch name uniquely matches a branch name on a remote
diff --git a/chunk-format.c b/chunk-format.c
index 0275b74a89..f65e9a1e42 100644
--- a/chunk-format.c
+++ b/chunk-format.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "chunk-format.h"
#include "csum-file.h"
diff --git a/chunk-format.h b/chunk-format.h
index 7885aa0848..025c38f938 100644
--- a/chunk-format.h
+++ b/chunk-format.h
@@ -1,7 +1,6 @@
#ifndef CHUNK_FORMAT_H
#define CHUNK_FORMAT_H
-#include "git-compat-util.h"
#include "hash.h"
struct hashfile;
diff --git a/color.c b/color.c
index f05d8a81d7..6b577ce0a7 100644
--- a/color.c
+++ b/color.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "config.h"
#include "color.h"
+#include "hex.h"
static int git_use_color_default = GIT_COLOR_AUTO;
int color_stdout_is_tty = -1;
diff --git a/combine-diff.c b/combine-diff.c
index 1a39b5dde0..91051dc325 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -4,6 +4,7 @@
#include "blob.h"
#include "diff.h"
#include "diffcore.h"
+#include "hex.h"
#include "quote.h"
#include "xdiff-interface.h"
#include "xdiff/xmacros.h"
diff --git a/commit-graph.c b/commit-graph.c
index c11b59f28b..5e6098ff35 100644
--- a/commit-graph.c
+++ b/commit-graph.c
@@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "pack.h"
#include "packfile.h"
diff --git a/commit-graph.h b/commit-graph.h
index 37faee6b66..bb88bec7aa 100644
--- a/commit-graph.h
+++ b/commit-graph.h
@@ -1,7 +1,6 @@
#ifndef COMMIT_GRAPH_H
#define COMMIT_GRAPH_H
-#include "git-compat-util.h"
#include "object-store.h"
#include "oidset.h"
diff --git a/commit-reach.c b/commit-reach.c
index 2e33c599a8..5ba822a720 100644
--- a/commit-reach.c
+++ b/commit-reach.c
@@ -1,7 +1,9 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "commit.h"
#include "commit-graph.h"
#include "decorate.h"
+#include "hex.h"
#include "prio-queue.h"
#include "tree.h"
#include "ref-filter.h"
diff --git a/commit-slab-impl.h b/commit-slab-impl.h
index 557738df27..4a414ee905 100644
--- a/commit-slab-impl.h
+++ b/commit-slab-impl.h
@@ -1,8 +1,6 @@
#ifndef COMMIT_SLAB_IMPL_H
#define COMMIT_SLAB_IMPL_H
-#include "git-compat-util.h"
-
#define implement_static_commit_slab(slabname, elemtype) \
implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)
diff --git a/commit.c b/commit.c
index e433c33bb0..cb683a6df5 100644
--- a/commit.c
+++ b/commit.c
@@ -2,6 +2,7 @@
#include "tag.h"
#include "commit.h"
#include "commit-graph.h"
+#include "hex.h"
#include "repository.h"
#include "object-store.h"
#include "pkt-line.h"
diff --git a/commit.h b/commit.h
index cc2c5da7bd..06657b4c6e 100644
--- a/commit.h
+++ b/commit.h
@@ -205,7 +205,6 @@ void free_commit_list(struct commit_list *list);
struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
-int has_non_ascii(const char *text);
const char *logmsg_reencode(const struct commit *commit,
char **commit_encoding,
const char *output_encoding);
diff --git a/compat/fsmonitor/fsm-ipc-darwin.c b/compat/fsmonitor/fsm-ipc-darwin.c
index d67b0ee50d..eb25123fa1 100644
--- a/compat/fsmonitor/fsm-ipc-darwin.c
+++ b/compat/fsmonitor/fsm-ipc-darwin.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "strbuf.h"
#include "fsmonitor.h"
#include "fsmonitor-ipc.h"
diff --git a/compat/fsmonitor/fsm-ipc-win32.c b/compat/fsmonitor/fsm-ipc-win32.c
index e08c505c14..c9536dfb66 100644
--- a/compat/fsmonitor/fsm-ipc-win32.c
+++ b/compat/fsmonitor/fsm-ipc-win32.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "config.h"
#include "fsmonitor-ipc.h"
diff --git a/compat/fsmonitor/fsm-settings-darwin.c b/compat/fsmonitor/fsm-settings-darwin.c
index 6abbc7af3a..58b623fbb9 100644
--- a/compat/fsmonitor/fsm-settings-darwin.c
+++ b/compat/fsmonitor/fsm-settings-darwin.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "config.h"
#include "fsmonitor.h"
#include "fsmonitor-ipc.h"
diff --git a/compat/mingw.c b/compat/mingw.c
index e433740381..3afbde7894 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -7,6 +7,7 @@
#include "../strbuf.h"
#include "../run-command.h"
#include "../cache.h"
+#include "../alloc.h"
#include "win32/lazyload.h"
#include "../config.h"
#include "dir.h"
diff --git a/config.c b/config.c
index 00090a32fc..d0aff55fa6 100644
--- a/config.c
+++ b/config.c
@@ -5,11 +5,13 @@
* Copyright (C) Johannes Schindelin, 2005
*
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "date.h"
#include "branch.h"
#include "config.h"
#include "environment.h"
+#include "ident.h"
#include "repository.h"
#include "lockfile.h"
#include "exec-cmd.h"
@@ -21,6 +23,7 @@
#include "utf8.h"
#include "dir.h"
#include "color.h"
+#include "replace-object.h"
#include "refs.h"
#include "worktree.h"
diff --git a/connect.c b/connect.c
index 63e59641c0..134069574a 100644
--- a/connect.c
+++ b/connect.c
@@ -1,6 +1,7 @@
#include "git-compat-util.h"
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "pkt-line.h"
#include "quote.h"
#include "refs.h"
diff --git a/connected.c b/connected.c
index b90fd61790..39cb1e1074 100644
--- a/connected.c
+++ b/connected.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "object-store.h"
#include "run-command.h"
#include "sigchain.h"
diff --git a/convert.c b/convert.c
index a54d1690c0..349c7e4af1 100644
--- a/convert.c
+++ b/convert.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "object-store.h"
#include "attr.h"
#include "run-command.h"
diff --git a/daemon.c b/daemon.c
index 0ae7d12b5c..eb733d222f 100644
--- a/daemon.c
+++ b/daemon.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "pkt-line.h"
#include "run-command.h"
diff --git a/decorate.c b/decorate.c
index 2036d15967..71e79daa82 100644
--- a/decorate.c
+++ b/decorate.c
@@ -2,7 +2,8 @@
* decorate.c - decorate a git object with some arbitrary
* data.
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "hashmap.h"
#include "object.h"
#include "decorate.h"
diff --git a/delta-islands.c b/delta-islands.c
index afdec0a878..fe12c93005 100644
--- a/delta-islands.c
+++ b/delta-islands.c
@@ -1,8 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "attr.h"
#include "object.h"
#include "blob.h"
#include "commit.h"
+#include "hex.h"
#include "tag.h"
#include "tree.h"
#include "delta.h"
diff --git a/diagnose.c b/diagnose.c
index 8f26569896..4a8ee4e5cf 100644
--- a/diagnose.c
+++ b/diagnose.c
@@ -4,6 +4,7 @@
#include "archive.h"
#include "dir.h"
#include "help.h"
+#include "hex.h"
#include "strvec.h"
#include "object-store.h"
#include "packfile.h"
diff --git a/diff-lib.c b/diff-lib.c
index dec040c366..70b3578b90 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -6,6 +6,7 @@
#include "commit.h"
#include "diff.h"
#include "diffcore.h"
+#include "hex.h"
#include "revision.h"
#include "cache-tree.h"
#include "unpack-trees.h"
diff --git a/diff-merges.c b/diff-merges.c
index 85cbefa5af..ec97616db1 100644
--- a/diff-merges.c
+++ b/diff-merges.c
@@ -1,5 +1,7 @@
+#include "git-compat-util.h"
#include "diff-merges.h"
+#include "gettext.h"
#include "revision.h"
typedef void (*diff_merges_setup_func_t)(struct rev_info *);
diff --git a/diff-no-index.c b/diff-no-index.c
index 05fafd0019..a3cf358baf 100644
--- a/diff-no-index.c
+++ b/diff-no-index.c
@@ -13,7 +13,6 @@
#include "diffcore.h"
#include "revision.h"
#include "log-tree.h"
-#include "builtin.h"
#include "parse-options.h"
#include "string-list.h"
#include "dir.h"
diff --git a/diff.c b/diff.c
index 469e18aed2..00d47281a1 100644
--- a/diff.c
+++ b/diff.c
@@ -2,12 +2,14 @@
* Copyright (C) 2005 Junio C Hamano
*/
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "tempfile.h"
#include "quote.h"
#include "diff.h"
#include "diffcore.h"
#include "delta.h"
+#include "hex.h"
#include "xdiff-interface.h"
#include "color.h"
#include "attr.h"
diff --git a/diff.h b/diff.h
index 8d770b1d57..3520119b00 100644
--- a/diff.h
+++ b/diff.h
@@ -6,8 +6,8 @@
#include "tree-walk.h"
#include "pathspec.h"
-#include "object.h"
#include "oidset.h"
+#include "strbuf.h"
/**
* The diff API is for programs that compare two sets of files (e.g. two trees,
@@ -71,7 +71,6 @@ struct oid_array;
struct option;
struct repository;
struct rev_info;
-struct strbuf;
struct userdiff_driver;
typedef int (*pathchange_fn_t)(struct diff_options *options,
diff --git a/diffcore-delta.c b/diffcore-delta.c
index 18d8f766d7..c30b56e983 100644
--- a/diffcore-delta.c
+++ b/diffcore-delta.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "diff.h"
#include "diffcore.h"
diff --git a/diffcore-order.c b/diffcore-order.c
index 19e73311f9..57ccab2846 100644
--- a/diffcore-order.c
+++ b/diffcore-order.c
@@ -1,7 +1,8 @@
/*
* Copyright (C) 2005 Junio C Hamano
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "gettext.h"
#include "diff.h"
#include "diffcore.h"
diff --git a/diffcore-pickaxe.c b/diffcore-pickaxe.c
index 03fcbcb40b..13c98a7b5e 100644
--- a/diffcore-pickaxe.c
+++ b/diffcore-pickaxe.c
@@ -2,12 +2,12 @@
* Copyright (C) 2005 Junio C Hamano
* Copyright (C) 2010 Google Inc.
*/
-#include "cache.h"
+#include "git-compat-util.h"
#include "diff.h"
#include "diffcore.h"
#include "xdiff-interface.h"
#include "kwset.h"
-#include "commit.h"
+#include "pretty.h"
#include "quote.h"
typedef int (*pickaxe_fn)(mmfile_t *one, mmfile_t *two,
diff --git a/diffcore-rename.c b/diffcore-rename.c
index c0422d9e70..7e9ff96d43 100644
--- a/diffcore-rename.c
+++ b/diffcore-rename.c
@@ -2,14 +2,19 @@
*
* Copyright (C) 2005 Junio C Hamano
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "diff.h"
#include "diffcore.h"
#include "object-store.h"
#include "hashmap.h"
+#include "mem-pool.h"
+#include "oid-array.h"
#include "progress.h"
#include "promisor-remote.h"
+#include "string-list.h"
#include "strmap.h"
+#include "trace2.h"
/* Table of rename/copy destinations */
diff --git a/diffcore-rotate.c b/diffcore-rotate.c
index 445f060ab0..533986cf63 100644
--- a/diffcore-rotate.c
+++ b/diffcore-rotate.c
@@ -2,7 +2,8 @@
* Copyright (C) 2021, Google LLC.
* Based on diffcore-order.c, which is Copyright (C) 2005, Junio C Hamano
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "gettext.h"
#include "diff.h"
#include "diffcore.h"
diff --git a/diffcore.h b/diffcore.h
index 9b588a1ee1..1701ed50b9 100644
--- a/diffcore.h
+++ b/diffcore.h
@@ -4,9 +4,11 @@
#ifndef DIFFCORE_H
#define DIFFCORE_H
-#include "cache.h"
+#include "hash.h"
struct diff_options;
+struct mem_pool;
+struct oid_array;
struct repository;
struct strintmap;
struct strmap;
diff --git a/dir-iterator.c b/dir-iterator.c
index cedd304759..fb7c47f0e8 100644
--- a/dir-iterator.c
+++ b/dir-iterator.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "dir.h"
#include "iterator.h"
#include "dir-iterator.h"
diff --git a/dir.c b/dir.c
index 7adf242026..d5bb199f4b 100644
--- a/dir.c
+++ b/dir.c
@@ -5,7 +5,8 @@
* Copyright (C) Linus Torvalds, 2005-2006
* Junio Hamano, 2005-2006
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
#include "dir.h"
#include "object-store.h"
diff --git a/dir.h b/dir.h
index e8106e1eca..3d6c87387e 100644
--- a/dir.h
+++ b/dir.h
@@ -1,8 +1,9 @@
#ifndef DIR_H
#define DIR_H
-#include "cache.h"
#include "hashmap.h"
+#include "pathspec.h"
+#include "statinfo.h"
#include "strbuf.h"
/**
@@ -373,10 +374,6 @@ int count_slashes(const char *s);
int simple_length(const char *match);
int no_wildcard(const char *string);
char *common_prefix(const struct pathspec *pathspec);
-int match_pathspec(struct index_state *istate,
- const struct pathspec *pathspec,
- const char *name, int namelen,
- int prefix, char *seen, int is_dir);
int report_path_error(const char *ps_matched, const struct pathspec *pathspec);
int within_depth(const char *name, int namelen, int depth, int max_depth);
@@ -543,15 +540,6 @@ int submodule_path_match(struct index_state *istate,
const char *submodule_name,
char *seen);
-static inline int ce_path_match(struct index_state *istate,
- const struct cache_entry *ce,
- const struct pathspec *pathspec,
- char *seen)
-{
- return match_pathspec(istate, pathspec, ce->name, ce_namelen(ce), 0, seen,
- S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode));
-}
-
static inline int dir_path_match(struct index_state *istate,
const struct dir_entry *ent,
const struct pathspec *pathspec,
diff --git a/entry.c b/entry.c
index 971ab26871..c97cfa833b 100644
--- a/entry.c
+++ b/entry.c
@@ -2,6 +2,7 @@
#include "blob.h"
#include "object-store.h"
#include "dir.h"
+#include "hex.h"
#include "streaming.h"
#include "submodule.h"
#include "progress.h"
diff --git a/entry.h b/entry.h
index 2d4fbb88c8..7329f918a9 100644
--- a/entry.h
+++ b/entry.h
@@ -1,9 +1,11 @@
#ifndef ENTRY_H
#define ENTRY_H
-#include "cache.h"
#include "convert.h"
+struct cache_entry;
+struct index_state;
+
struct checkout {
struct index_state *istate;
const char *base_dir;
diff --git a/environment.c b/environment.c
index 1ee3686fd8..89d89110e4 100644
--- a/environment.c
+++ b/environment.c
@@ -17,6 +17,7 @@
#include "commit.h"
#include "strvec.h"
#include "object-store.h"
+#include "replace-object.h"
#include "tmp-objdir.h"
#include "chdir-notify.h"
#include "shallow.h"
diff --git a/ewah/bitmap.c b/ewah/bitmap.c
index ac61864163..12d6aa398e 100644
--- a/ewah/bitmap.c
+++ b/ewah/bitmap.c
@@ -16,7 +16,8 @@
* You should have received a copy of the GNU General Public License
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "ewok.h"
#define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD))
diff --git a/ewah/ewah_bitmap.c b/ewah/ewah_bitmap.c
index 6fe48d3ae0..c6d4ffc87c 100644
--- a/ewah/ewah_bitmap.c
+++ b/ewah/ewah_bitmap.c
@@ -17,9 +17,9 @@
* along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "git-compat-util.h"
+#include "alloc.h"
#include "ewok.h"
#include "ewok_rlw.h"
-#include "cache.h"
static inline size_t min_size(size_t a, size_t b)
{
diff --git a/fetch-pack.c b/fetch-pack.c
index 04016d1e32..95a992bcd4 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -1,6 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "repository.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "refs.h"
#include "pkt-line.h"
diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c
index f48f44f9cd..9609eb3cef 100644
--- a/fmt-merge-msg.c
+++ b/fmt-merge-msg.c
@@ -1,8 +1,11 @@
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
#include "refs.h"
#include "object-store.h"
#include "diff.h"
#include "diff-merges.h"
+#include "hex.h"
#include "revision.h"
#include "tag.h"
#include "string-list.h"
diff --git a/fsck.c b/fsck.c
index 2b18717ee8..871c0a9a25 100644
--- a/fsck.c
+++ b/fsck.c
@@ -1,4 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
+#include "hex.h"
#include "object-store.h"
#include "repository.h"
#include "object.h"
diff --git a/fsck.h b/fsck.h
index 668330880e..e17730e9da 100644
--- a/fsck.h
+++ b/fsck.h
@@ -1,6 +1,7 @@
#ifndef GIT_FSCK_H
#define GIT_FSCK_H
+#include "object.h"
#include "oidset.h"
enum fsck_msg_type {
diff --git a/fsmonitor-settings.c b/fsmonitor-settings.c
index 899bfe9c81..b62acf44ae 100644
--- a/fsmonitor-settings.c
+++ b/fsmonitor-settings.c
@@ -1,5 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "config.h"
+#include "gettext.h"
#include "repository.h"
#include "fsmonitor-ipc.h"
#include "fsmonitor-settings.h"
diff --git a/git-compat-util.h b/git-compat-util.h
index 4f0028ce60..f77f986fbf 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -1225,6 +1225,7 @@ extern const unsigned char tolower_trans_tbl[256];
#undef isxdigit
extern const unsigned char sane_ctype[256];
+extern const signed char hexval_table[256];
#define GIT_SPACE 0x01
#define GIT_DIGIT 0x02
#define GIT_ALPHA 0x04
diff --git a/git.c b/git.c
index 6171fd6769..ae2134f29a 100644
--- a/git.c
+++ b/git.c
@@ -4,6 +4,7 @@
#include "help.h"
#include "run-command.h"
#include "alias.h"
+#include "replace-object.h"
#include "shallow.h"
#define RUN_SETUP (1<<0)
diff --git a/gpg-interface.c b/gpg-interface.c
index 5cd66d3a78..0c13990a42 100644
--- a/gpg-interface.c
+++ b/gpg-interface.c
@@ -4,6 +4,7 @@
#include "run-command.h"
#include "strbuf.h"
#include "dir.h"
+#include "ident.h"
#include "gpg-interface.h"
#include "sigchain.h"
#include "tempfile.h"
diff --git a/graph.c b/graph.c
index 568b6e7cd4..2a9dc430fa 100644
--- a/graph.c
+++ b/graph.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "gettext.h"
#include "config.h"
#include "commit.h"
#include "color.h"
diff --git a/grep.c b/grep.c
index cee44a78d0..68e9328dfd 100644
--- a/grep.c
+++ b/grep.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "config.h"
#include "grep.h"
+#include "hex.h"
#include "object-store.h"
#include "userdiff.h"
#include "xdiff-interface.h"
diff --git a/hash.h b/hash.h
index 36b64165fc..d39f73618c 100644
--- a/hash.h
+++ b/hash.h
@@ -1,7 +1,6 @@
#ifndef HASH_H
#define HASH_H
-#include "git-compat-util.h"
#include "repository.h"
#if defined(SHA1_APPLE)
@@ -124,6 +123,40 @@ struct object_id {
int algo; /* XXX requires 4-byte alignment */
};
+#define GET_OID_QUIETLY 01
+#define GET_OID_COMMIT 02
+#define GET_OID_COMMITTISH 04
+#define GET_OID_TREE 010
+#define GET_OID_TREEISH 020
+#define GET_OID_BLOB 040
+#define GET_OID_FOLLOW_SYMLINKS 0100
+#define GET_OID_RECORD_PATH 0200
+#define GET_OID_ONLY_TO_DIE 04000
+#define GET_OID_REQUIRE_PATH 010000
+
+#define GET_OID_DISAMBIGUATORS \
+ (GET_OID_COMMIT | GET_OID_COMMITTISH | \
+ GET_OID_TREE | GET_OID_TREEISH | \
+ GET_OID_BLOB)
+
+enum get_oid_result {
+ FOUND = 0,
+ MISSING_OBJECT = -1, /* The requested object is missing */
+ SHORT_NAME_AMBIGUOUS = -2,
+ /* The following only apply when symlinks are followed */
+ DANGLING_SYMLINK = -4, /*
+ * The initial symlink is there, but
+ * (transitively) points to a missing
+ * in-tree file
+ */
+ SYMLINK_LOOP = -5,
+ NOT_DIR = -6, /*
+ * Somewhere along the symlink chain, a path is
+ * requested which contains a file as a
+ * non-final element.
+ */
+};
+
/* A suitably aligned type for stack allocations of hash contexts. */
union git_hash_ctx {
git_SHA_CTX sha1;
diff --git a/hashmap.c b/hashmap.c
index cf5fea87eb..ee45ef0085 100644
--- a/hashmap.c
+++ b/hashmap.c
@@ -1,7 +1,7 @@
/*
* Generic implementation of hash-based key value mappings.
*/
-#include "cache.h"
+#include "git-compat-util.h"
#include "hashmap.h"
#define FNV32_BASE ((unsigned int) 0x811c9dc5)
diff --git a/help.c b/help.c
index 812af4cdea..216777d2bf 100644
--- a/help.c
+++ b/help.c
@@ -1,9 +1,11 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
#include "builtin.h"
#include "exec-cmd.h"
#include "run-command.h"
#include "levenshtein.h"
+#include "gettext.h"
#include "help.h"
#include "command-list.h"
#include "string-list.h"
diff --git a/hex.c b/hex.c
index 4f64d34696..0a1bddc128 100644
--- a/hex.c
+++ b/hex.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "hex.h"
const signed char hexval_table[256] = {
-1, -1, -1, -1, -1, -1, -1, -1, /* 00-07 */
diff --git a/hex.h b/hex.h
new file mode 100644
index 0000000000..e2abfc56fa
--- /dev/null
+++ b/hex.h
@@ -0,0 +1,84 @@
+#ifndef HEX_H
+#define HEX_H
+
+#include "hash.h"
+
+extern const signed char hexval_table[256];
+static inline unsigned int hexval(unsigned char c)
+{
+ return hexval_table[c];
+}
+
+/*
+ * Convert two consecutive hexadecimal digits into a char. Return a
+ * negative value on error. Don't run over the end of short strings.
+ */
+static inline int hex2chr(const char *s)
+{
+ unsigned int val = hexval(s[0]);
+ return (val & ~0xf) ? val : (val << 4) | hexval(s[1]);
+}
+
+/*
+ * Try to read a SHA1 in hexadecimal format from the 40 characters
+ * starting at hex. Write the 20-byte result to sha1 in binary form.
+ * Return 0 on success. Reading stops if a NUL is encountered in the
+ * input, so it is safe to pass this function an arbitrary
+ * null-terminated string.
+ */
+int get_sha1_hex(const char *hex, unsigned char *sha1);
+int get_oid_hex(const char *hex, struct object_id *sha1);
+
+/* Like get_oid_hex, but for an arbitrary hash algorithm. */
+int get_oid_hex_algop(const char *hex, struct object_id *oid, const struct git_hash_algo *algop);
+
+/*
+ * Read `len` pairs of hexadecimal digits from `hex` and write the
+ * values to `binary` as `len` bytes. Return 0 on success, or -1 if
+ * the input does not consist of hex digits).
+ */
+int hex_to_bytes(unsigned char *binary, const char *hex, size_t len);
+
+/*
+ * Convert a binary hash in "unsigned char []" or an object name in
+ * "struct object_id *" to its hex equivalent. The `_r` variant is reentrant,
+ * and writes the NUL-terminated output to the buffer `out`, which must be at
+ * least `GIT_MAX_HEXSZ + 1` bytes, and returns a pointer to out for
+ * convenience.
+ *
+ * The non-`_r` variant returns a static buffer, but uses a ring of 4
+ * buffers, making it safe to make multiple calls for a single statement, like:
+ *
+ * printf("%s -> %s", hash_to_hex(one), hash_to_hex(two));
+ * printf("%s -> %s", oid_to_hex(one), oid_to_hex(two));
+ */
+char *hash_to_hex_algop_r(char *buffer, const unsigned char *hash, const struct git_hash_algo *);
+char *oid_to_hex_r(char *out, const struct object_id *oid);
+char *hash_to_hex_algop(const unsigned char *hash, const struct git_hash_algo *); /* static buffer result! */
+char *hash_to_hex(const unsigned char *hash); /* same static buffer */
+char *oid_to_hex(const struct object_id *oid); /* same static buffer */
+
+/*
+ * Parse a 40-character hexadecimal object ID starting from hex, updating the
+ * pointer specified by end when parsing stops. The resulting object ID is
+ * stored in oid. Returns 0 on success. Parsing will stop on the first NUL or
+ * other invalid character. end is only updated on success; otherwise, it is
+ * unmodified.
+ */
+int parse_oid_hex(const char *hex, struct object_id *oid, const char **end);
+
+/* Like parse_oid_hex, but for an arbitrary hash algorithm. */
+int parse_oid_hex_algop(const char *hex, struct object_id *oid, const char **end,
+ const struct git_hash_algo *algo);
+
+
+/*
+ * These functions work like get_oid_hex and parse_oid_hex, but they will parse
+ * a hex value for any algorithm. The algorithm is detected based on the length
+ * and the algorithm in use is returned. If this is not a hex object ID in any
+ * algorithm, returns GIT_HASH_UNKNOWN.
+ */
+int get_oid_hex_any(const char *hex, struct object_id *oid);
+int parse_oid_hex_any(const char *hex, struct object_id *oid, const char **end);
+
+#endif
diff --git a/hook.c b/hook.c
index 1a84831863..f6ddd79098 100644
--- a/hook.c
+++ b/hook.c
@@ -1,7 +1,10 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "advice.h"
+#include "gettext.h"
#include "hook.h"
#include "run-command.h"
#include "config.h"
+#include "strbuf.h"
const char *find_hook(const char *name)
{
diff --git a/http-backend.c b/http-backend.c
index 8ab58e55f8..45290031e0 100644
--- a/http-backend.c
+++ b/http-backend.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "repository.h"
#include "refs.h"
#include "pkt-line.h"
diff --git a/http-fetch.c b/http-fetch.c
index 258fec2068..8db35b9767 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "config.h"
#include "exec-cmd.h"
+#include "hex.h"
#include "http.h"
#include "walker.h"
#include "strvec.h"
diff --git a/http-push.c b/http-push.c
index 7f71316456..88aa045ecb 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "repository.h"
#include "commit.h"
#include "tag.h"
diff --git a/http-walker.c b/http-walker.c
index b8f0f98ae1..c3e902c40e 100644
--- a/http-walker.c
+++ b/http-walker.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "repository.h"
#include "commit.h"
+#include "hex.h"
#include "walker.h"
#include "http.h"
#include "list.h"
diff --git a/http.c b/http.c
index c4b6ddef28..86b0745af9 100644
--- a/http.c
+++ b/http.c
@@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "git-curl-compat.h"
+#include "hex.h"
#include "http.h"
#include "config.h"
#include "pack.h"
diff --git a/ident.c b/ident.c
index 6de76f9421..8fad92d700 100644
--- a/ident.c
+++ b/ident.c
@@ -5,10 +5,13 @@
*
* Copyright (C) 2005 Linus Torvalds
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "ident.h"
#include "config.h"
#include "date.h"
+#include "gettext.h"
#include "mailmap.h"
+#include "strbuf.h"
static struct strbuf git_default_name = STRBUF_INIT;
static struct strbuf git_default_email = STRBUF_INIT;
diff --git a/ident.h b/ident.h
new file mode 100644
index 0000000000..96a64896a0
--- /dev/null
+++ b/ident.h
@@ -0,0 +1,67 @@
+#ifndef IDENT_H
+#define IDENT_H
+
+#include "string-list.h"
+
+struct ident_split {
+ const char *name_begin;
+ const char *name_end;
+ const char *mail_begin;
+ const char *mail_end;
+ const char *date_begin;
+ const char *date_end;
+ const char *tz_begin;
+ const char *tz_end;
+};
+
+#define IDENT_STRICT 1
+#define IDENT_NO_DATE 2
+#define IDENT_NO_NAME 4
+
+enum want_ident {
+ WANT_BLANK_IDENT,
+ WANT_AUTHOR_IDENT,
+ WANT_COMMITTER_IDENT
+};
+
+const char *ident_default_name(void);
+const char *ident_default_email(void);
+/*
+ * Prepare an ident to fall back on if the user didn't configure it.
+ */
+void prepare_fallback_ident(const char *name, const char *email);
+void reset_ident_date(void);
+/*
+ * Signals an success with 0, but time part of the result may be NULL
+ * if the input lacks timestamp and zone
+ */
+int split_ident_line(struct ident_split *, const char *, int);
+
+/*
+ * Given a commit or tag object buffer and the commit or tag headers, replaces
+ * the idents in the headers with their canonical versions using the mailmap mechanism.
+ */
+void apply_mailmap_to_header(struct strbuf *, const char **, struct string_list *);
+
+/*
+ * Compare split idents for equality or strict ordering. Note that we
+ * compare only the ident part of the line, ignoring any timestamp.
+ *
+ * Because there are two fields, we must choose one as the primary key; we
+ * currently arbitrarily pick the email.
+ */
+int ident_cmp(const struct ident_split *, const struct ident_split *);
+
+const char *git_author_info(int);
+const char *git_committer_info(int);
+const char *fmt_ident(const char *name, const char *email,
+ enum want_ident whose_ident,
+ const char *date_str, int);
+const char *fmt_name(enum want_ident);
+
+int committer_ident_sufficiently_given(void);
+int author_ident_sufficiently_given(void);
+
+int git_ident_config(const char *, const char *, void *);
+
+#endif
diff --git a/imap-send.c b/imap-send.c
index a50af56b82..93e9018439 100644
--- a/imap-send.c
+++ b/imap-send.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 "config.h"
#include "credential.h"
#include "exec-cmd.h"
diff --git a/json-writer.c b/json-writer.c
index f1cfd8fa8c..005c820aa4 100644
--- a/json-writer.c
+++ b/json-writer.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "json-writer.h"
void jw_init(struct json_writer *jw)
diff --git a/khash.h b/khash.h
index cb79bf8856..85362718c5 100644
--- a/khash.h
+++ b/khash.h
@@ -26,7 +26,6 @@
#ifndef __AC_KHASH_H
#define __AC_KHASH_H
-#include "cache.h"
#include "hashmap.h"
#define AC_VERSION_KHASH_H "0.2.8"
diff --git a/kwset.c b/kwset.c
index 08aadf0311..4b14d4f86b 100644
--- a/kwset.c
+++ b/kwset.c
@@ -32,7 +32,7 @@
String Matching: An Aid to Bibliographic Search," CACM June 1975,
Vol. 18, No. 6, which describes the failure function used below. */
-#include "cache.h"
+#include "git-compat-util.h"
#include "kwset.h"
#include "compat/obstack.h"
diff --git a/levenshtein.c b/levenshtein.c
index d2632690d5..fd8026fe20 100644
--- a/levenshtein.c
+++ b/levenshtein.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "levenshtein.h"
/*
diff --git a/line-log.c b/line-log.c
index a7f3e7f6ce..1bf89c9acc 100644
--- a/line-log.c
+++ b/line-log.c
@@ -1,6 +1,8 @@
#include "git-compat-util.h"
+#include "alloc.h"
#include "line-range.h"
#include "cache.h"
+#include "hex.h"
#include "tag.h"
#include "blob.h"
#include "tree.h"
diff --git a/line-log.h b/line-log.h
index 82ae8d98a4..adff361b1b 100644
--- a/line-log.h
+++ b/line-log.h
@@ -5,6 +5,7 @@
struct rev_info;
struct commit;
+struct string_list;
/* A range [start,end]. Lines are numbered starting at 0, and the
* ranges include start but exclude end. */
diff --git a/linear-assignment.c b/linear-assignment.c
index ecffc09be6..5416cbcf40 100644
--- a/linear-assignment.c
+++ b/linear-assignment.c
@@ -3,7 +3,7 @@
* algorithm for dense and sparse linear assignment problems</i>. Computing,
* 38(4), 325-340.
*/
-#include "cache.h"
+#include "git-compat-util.h"
#include "linear-assignment.h"
#define COST(column, row) cost[(column) + column_count * (row)]
diff --git a/list-objects-filter-options.c b/list-objects-filter-options.c
index ee01bcd2cc..1d25a5737d 100644
--- a/list-objects-filter-options.c
+++ b/list-objects-filter-options.c
@@ -1,6 +1,8 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "commit.h"
#include "config.h"
+#include "gettext.h"
#include "revision.h"
#include "strvec.h"
#include "list-objects.h"
diff --git a/list-objects-filter-options.h b/list-objects-filter-options.h
index 1fe393f447..ef03b45132 100644
--- a/list-objects-filter-options.h
+++ b/list-objects-filter-options.h
@@ -1,9 +1,10 @@
#ifndef LIST_OBJECTS_FILTER_OPTIONS_H
#define LIST_OBJECTS_FILTER_OPTIONS_H
-#include "cache.h"
+#include "object.h"
#include "parse-options.h"
#include "string-list.h"
+#include "strbuf.h"
/*
* The list of defined filters for list-objects.
diff --git a/list-objects-filter.c b/list-objects-filter.c
index 7ed21cb299..5d7b331660 100644
--- a/list-objects-filter.c
+++ b/list-objects-filter.c
@@ -1,5 +1,7 @@
#include "cache.h"
+#include "alloc.h"
#include "dir.h"
+#include "hex.h"
#include "tag.h"
#include "commit.h"
#include "tree.h"
diff --git a/list-objects.c b/list-objects.c
index 7528fe1db2..ab5745bbfe 100644
--- a/list-objects.c
+++ b/list-objects.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "tag.h"
#include "commit.h"
+#include "hex.h"
#include "tree.h"
#include "blob.h"
#include "diff.h"
diff --git a/log-tree.c b/log-tree.c
index 1dd5fcbf7b..043e0df685 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -2,6 +2,7 @@
#include "commit-reach.h"
#include "config.h"
#include "diff.h"
+#include "hex.h"
#include "object-store.h"
#include "repository.h"
#include "tmp-objdir.h"
@@ -12,6 +13,7 @@
#include "merge-ort.h"
#include "reflog-walk.h"
#include "refs.h"
+#include "replace-object.h"
#include "string-list.h"
#include "color.h"
#include "gpg-interface.h"
diff --git a/ls-refs.c b/ls-refs.c
index 697d4beb8d..f4c6b9b762 100644
--- a/ls-refs.c
+++ b/ls-refs.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "repository.h"
#include "refs.h"
#include "remote.h"
diff --git a/mailinfo.c b/mailinfo.c
index 833d28612f..9f1495ddcf 100644
--- a/mailinfo.c
+++ b/mailinfo.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "config.h"
+#include "gettext.h"
+#include "hex.h"
#include "utf8.h"
#include "strbuf.h"
#include "mailinfo.h"
diff --git a/match-trees.c b/match-trees.c
index 49398e599f..c38dcbac7c 100644
--- a/match-trees.c
+++ b/match-trees.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "tree.h"
#include "tree-walk.h"
#include "object-store.h"
diff --git a/mem-pool.c b/mem-pool.c
index 599d8e895f..c34846d176 100644
--- a/mem-pool.c
+++ b/mem-pool.c
@@ -2,7 +2,7 @@
* Memory Pool implementation logic.
*/
-#include "cache.h"
+#include "git-compat-util.h"
#include "mem-pool.h"
#define BLOCK_GROWTH_SIZE (1024 * 1024 - sizeof(struct mp_block))
diff --git a/merge-blobs.c b/merge-blobs.c
index 8138090f81..aedcab8113 100644
--- a/merge-blobs.c
+++ b/merge-blobs.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "run-command.h"
#include "xdiff-interface.h"
#include "ll-merge.h"
diff --git a/merge-ort.c b/merge-ort.c
index d1611ca400..4c5be8ed91 100644
--- a/merge-ort.c
+++ b/merge-ort.c
@@ -26,6 +26,7 @@
#include "diff.h"
#include "diffcore.h"
#include "dir.h"
+#include "hex.h"
#include "entry.h"
#include "ll-merge.h"
#include "object-store.h"
diff --git a/merge-recursive.c b/merge-recursive.c
index ae469f8cc8..89731f4090 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -10,7 +10,6 @@
#include "alloc.h"
#include "attr.h"
#include "blob.h"
-#include "builtin.h"
#include "cache-tree.h"
#include "commit.h"
#include "commit-reach.h"
@@ -18,6 +17,7 @@
#include "diff.h"
#include "diffcore.h"
#include "dir.h"
+#include "hex.h"
#include "ll-merge.h"
#include "lockfile.h"
#include "object-store.h"
diff --git a/merge.c b/merge.c
index 445b4f19aa..2c8b845684 100644
--- a/merge.c
+++ b/merge.c
@@ -1,6 +1,7 @@
#include "cache.h"
#include "diff.h"
#include "diffcore.h"
+#include "hex.h"
#include "lockfile.h"
#include "commit.h"
#include "run-command.h"
diff --git a/midx.c b/midx.c
index 7cfad04a24..24799bef51 100644
--- a/midx.c
+++ b/midx.c
@@ -1,7 +1,9 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
#include "csum-file.h"
#include "dir.h"
+#include "hex.h"
#include "lockfile.h"
#include "packfile.h"
#include "object-store.h"
diff --git a/negotiator/noop.c b/negotiator/noop.c
index 60569b8350..7b72937686 100644
--- a/negotiator/noop.c
+++ b/negotiator/noop.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "noop.h"
#include "../commit.h"
#include "../fetch-negotiator.h"
diff --git a/negotiator/skipping.c b/negotiator/skipping.c
index 0f5ac48e87..28f8769bd4 100644
--- a/negotiator/skipping.c
+++ b/negotiator/skipping.c
@@ -2,6 +2,7 @@
#include "skipping.h"
#include "../commit.h"
#include "../fetch-negotiator.h"
+#include "../hex.h"
#include "../prio-queue.h"
#include "../refs.h"
#include "../tag.h"
diff --git a/notes-merge.c b/notes-merge.c
index b4cc594a79..5b1a9ff13f 100644
--- a/notes-merge.c
+++ b/notes-merge.c
@@ -5,6 +5,7 @@
#include "repository.h"
#include "diff.h"
#include "diffcore.h"
+#include "hex.h"
#include "xdiff-interface.h"
#include "ll-merge.h"
#include "dir.h"
diff --git a/notes.c b/notes.c
index f2805d51bb..c9e4b8b4a5 100644
--- a/notes.c
+++ b/notes.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "notes.h"
#include "object-store.h"
#include "blob.h"
diff --git a/object-file.c b/object-file.c
index 939865c1ae..43a39dd8d3 100644
--- a/object-file.c
+++ b/object-file.c
@@ -6,8 +6,10 @@
* This handles basic git object files - packing, unpacking,
* creation etc.
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "string-list.h"
#include "lockfile.h"
#include "delta.h"
diff --git a/object-name.c b/object-name.c
index 2dd1a0f56e..97bb94d226 100644
--- a/object-name.c
+++ b/object-name.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "tag.h"
#include "commit.h"
#include "tree.h"
diff --git a/object-store.h b/object-store.h
index 1a713d89d7..82201ec3e7 100644
--- a/object-store.h
+++ b/object-store.h
@@ -1,7 +1,7 @@
#ifndef OBJECT_STORE_H
#define OBJECT_STORE_H
-#include "cache.h"
+#include "object.h"
#include "oidmap.h"
#include "list.h"
#include "oid-array.h"
@@ -284,6 +284,69 @@ int pretend_object_file(void *, unsigned long, enum object_type,
int force_object_loose(const struct object_id *oid, time_t mtime);
+struct object_info {
+ /* Request */
+ enum object_type *typep;
+ unsigned long *sizep;
+ off_t *disk_sizep;
+ struct object_id *delta_base_oid;
+ struct strbuf *type_name;
+ void **contentp;
+
+ /* Response */
+ enum {
+ OI_CACHED,
+ OI_LOOSE,
+ OI_PACKED,
+ OI_DBCACHED
+ } whence;
+ union {
+ /*
+ * struct {
+ * ... Nothing to expose in this case
+ * } cached;
+ * struct {
+ * ... Nothing to expose in this case
+ * } loose;
+ */
+ struct {
+ struct packed_git *pack;
+ off_t offset;
+ unsigned int is_delta;
+ } packed;
+ } u;
+};
+
+/*
+ * Initializer for a "struct object_info" that wants no items. You may
+ * also memset() the memory to all-zeroes.
+ */
+#define OBJECT_INFO_INIT { 0 }
+
+/* Invoke lookup_replace_object() on the given hash */
+#define OBJECT_INFO_LOOKUP_REPLACE 1
+/* Allow reading from a loose object file of unknown/bogus type */
+#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2
+/* Do not retry packed storage after checking packed and loose storage */
+#define OBJECT_INFO_QUICK 8
+/*
+ * Do not attempt to fetch the object if missing (even if fetch_is_missing is
+ * nonzero).
+ */
+#define OBJECT_INFO_SKIP_FETCH_OBJECT 16
+/*
+ * This is meant for bulk prefetching of missing blobs in a partial
+ * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
+ */
+#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)
+
+/* Die if object corruption (not just an object being missing) was detected. */
+#define OBJECT_INFO_DIE_IF_CORRUPT 32
+
+int oid_object_info_extended(struct repository *r,
+ const struct object_id *,
+ struct object_info *, unsigned flags);
+
/*
* Open the loose object at path, check its hash, and return the contents,
* use the "oi" argument to assert things about the object, or e.g. populate its
@@ -381,69 +444,6 @@ static inline void obj_read_unlock(void)
pthread_mutex_unlock(&obj_read_mutex);
}
-struct object_info {
- /* Request */
- enum object_type *typep;
- unsigned long *sizep;
- off_t *disk_sizep;
- struct object_id *delta_base_oid;
- struct strbuf *type_name;
- void **contentp;
-
- /* Response */
- enum {
- OI_CACHED,
- OI_LOOSE,
- OI_PACKED,
- OI_DBCACHED
- } whence;
- union {
- /*
- * struct {
- * ... Nothing to expose in this case
- * } cached;
- * struct {
- * ... Nothing to expose in this case
- * } loose;
- */
- struct {
- struct packed_git *pack;
- off_t offset;
- unsigned int is_delta;
- } packed;
- } u;
-};
-
-/*
- * Initializer for a "struct object_info" that wants no items. You may
- * also memset() the memory to all-zeroes.
- */
-#define OBJECT_INFO_INIT { 0 }
-
-/* Invoke lookup_replace_object() on the given hash */
-#define OBJECT_INFO_LOOKUP_REPLACE 1
-/* Allow reading from a loose object file of unknown/bogus type */
-#define OBJECT_INFO_ALLOW_UNKNOWN_TYPE 2
-/* Do not retry packed storage after checking packed and loose storage */
-#define OBJECT_INFO_QUICK 8
-/*
- * Do not attempt to fetch the object if missing (even if fetch_is_missing is
- * nonzero).
- */
-#define OBJECT_INFO_SKIP_FETCH_OBJECT 16
-/*
- * This is meant for bulk prefetching of missing blobs in a partial
- * clone. Implies OBJECT_INFO_SKIP_FETCH_OBJECT and OBJECT_INFO_QUICK
- */
-#define OBJECT_INFO_FOR_PREFETCH (OBJECT_INFO_SKIP_FETCH_OBJECT | OBJECT_INFO_QUICK)
-
-/* Die if object corruption (not just an object being missing) was detected. */
-#define OBJECT_INFO_DIE_IF_CORRUPT 32
-
-int oid_object_info_extended(struct repository *r,
- const struct object_id *,
- struct object_info *, unsigned flags);
-
/*
* Iterate over the files in the loose-object parts of the object
* directory "path", triggering the following callbacks:
diff --git a/object.c b/object.c
index 344087de4d..609fed1b73 100644
--- a/object.c
+++ b/object.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "object.h"
#include "replace-object.h"
#include "object-store.h"
diff --git a/object.h b/object.h
index 31ebe11458..fc45b158da 100644
--- a/object.h
+++ b/object.h
@@ -1,7 +1,7 @@
#ifndef OBJECT_H
#define OBJECT_H
-#include "cache.h"
+#include "hash.h"
struct buffer_slab;
@@ -81,6 +81,26 @@ struct object_array {
*/
#define FLAG_BITS 28
+#define TYPE_BITS 3
+
+/*
+ * Values in this enum (except those outside the 3 bit range) are part
+ * of pack file format. See gitformat-pack(5) for more information.
+ */
+enum object_type {
+ OBJ_BAD = -1,
+ OBJ_NONE = 0,
+ OBJ_COMMIT = 1,
+ OBJ_TREE = 2,
+ OBJ_BLOB = 3,
+ OBJ_TAG = 4,
+ /* 5 for future expansion */
+ OBJ_OFS_DELTA = 6,
+ OBJ_REF_DELTA = 7,
+ OBJ_ANY,
+ OBJ_MAX
+};
+
/*
* The object type is stored in 3 bits.
*/
diff --git a/oid-array.c b/oid-array.c
index 73ba76e9e9..e8228c777b 100644
--- a/oid-array.c
+++ b/oid-array.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "oid-array.h"
#include "hash-lookup.h"
diff --git a/oidmap.c b/oidmap.c
index 49965fe856..8c1a139c97 100644
--- a/oidmap.c
+++ b/oidmap.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "oidmap.h"
static int oidmap_neq(const void *hashmap_cmp_fn_data UNUSED,
diff --git a/oidmap.h b/oidmap.h
index c66a83ab1d..c1642927fa 100644
--- a/oidmap.h
+++ b/oidmap.h
@@ -1,7 +1,6 @@
#ifndef OIDMAP_H
#define OIDMAP_H
-#include "cache.h"
#include "hashmap.h"
/*
diff --git a/oidset.c b/oidset.c
index b36a2bae86..d1e5376316 100644
--- a/oidset.c
+++ b/oidset.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "oidset.h"
+#include "hex.h"
+#include "strbuf.h"
void oidset_init(struct oidset *set, size_t initial_size)
{
diff --git a/oidtree.c b/oidtree.c
index 0d39389bee..7d57b7b19e 100644
--- a/oidtree.c
+++ b/oidtree.c
@@ -2,6 +2,7 @@
* A wrapper around cbtree which stores oids
* May be used to replace oid-array for prefix (abbreviation) matches
*/
+#include "git-compat-util.h"
#include "oidtree.h"
#include "alloc.h"
#include "hash.h"
diff --git a/oss-fuzz/fuzz-commit-graph.c b/oss-fuzz/fuzz-commit-graph.c
index 914026f5d8..2992079dd9 100644
--- a/oss-fuzz/fuzz-commit-graph.c
+++ b/oss-fuzz/fuzz-commit-graph.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "commit-graph.h"
#include "repository.h"
diff --git a/oss-fuzz/fuzz-pack-headers.c b/oss-fuzz/fuzz-pack-headers.c
index 99da1d0fd3..150c0f5fa2 100644
--- a/oss-fuzz/fuzz-pack-headers.c
+++ b/oss-fuzz/fuzz-pack-headers.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "packfile.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
diff --git a/oss-fuzz/fuzz-pack-idx.c b/oss-fuzz/fuzz-pack-idx.c
index 0c3d777aac..609a343ee3 100644
--- a/oss-fuzz/fuzz-pack-idx.c
+++ b/oss-fuzz/fuzz-pack-idx.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "object-store.h"
#include "packfile.h"
diff --git a/pack-bitmap-write.c b/pack-bitmap-write.c
index cfa67a510f..891d9d2772 100644
--- a/pack-bitmap-write.c
+++ b/pack-bitmap-write.c
@@ -1,4 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
+#include "hex.h"
#include "object-store.h"
#include "commit.h"
#include "tag.h"
diff --git a/pack-bitmap.c b/pack-bitmap.c
index d2a42abf28..a321d6fae8 100644
--- a/pack-bitmap.c
+++ b/pack-bitmap.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "commit.h"
+#include "hex.h"
#include "strbuf.h"
#include "tag.h"
#include "diff.h"
diff --git a/pack-check.c b/pack-check.c
index bfb593ba72..7ed594d667 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "repository.h"
#include "pack.h"
#include "pack-revindex.h"
diff --git a/pack-mtimes.h b/pack-mtimes.h
index cc957b3e85..107327cec0 100644
--- a/pack-mtimes.h
+++ b/pack-mtimes.h
@@ -1,8 +1,6 @@
#ifndef PACK_MTIMES_H
#define PACK_MTIMES_H
-#include "git-compat-util.h"
-
#define MTIMES_SIGNATURE 0x4d544d45 /* "MTME" */
#define MTIMES_VERSION 1
diff --git a/pack-objects.c b/pack-objects.c
index 272e8d4517..ccab09fe65 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "object.h"
#include "pack.h"
#include "pack-objects.h"
diff --git a/pack-write.c b/pack-write.c
index 3363729748..041e573bc1 100644
--- a/pack-write.c
+++ b/pack-write.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "pack.h"
#include "csum-file.h"
#include "remote.h"
diff --git a/packfile.c b/packfile.c
index 79e21ab18e..4088735a7d 100644
--- a/packfile.c
+++ b/packfile.c
@@ -1,4 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
+#include "hex.h"
#include "list.h"
#include "pack.h"
#include "repository.h"
diff --git a/parallel-checkout.c b/parallel-checkout.c
index 4f6819f240..2455aa356d 100644
--- a/parallel-checkout.c
+++ b/parallel-checkout.c
@@ -1,6 +1,8 @@
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "entry.h"
+#include "hex.h"
#include "parallel-checkout.h"
#include "pkt-line.h"
#include "progress.h"
diff --git a/patch-ids.c b/patch-ids.c
index 3153446626..a4473a88fa 100644
--- a/patch-ids.c
+++ b/patch-ids.c
@@ -2,6 +2,7 @@
#include "diff.h"
#include "commit.h"
#include "hash-lookup.h"
+#include "hex.h"
#include "patch-ids.h"
static int patch_id_defined(struct commit *commit)
diff --git a/path.c b/path.c
index 492e17ad12..97561c3b14 100644
--- a/path.c
+++ b/path.c
@@ -2,6 +2,7 @@
* Utilities for paths and pathnames
*/
#include "cache.h"
+#include "hex.h"
#include "repository.h"
#include "strbuf.h"
#include "string-list.h"
diff --git a/pathspec.h b/pathspec.h
index 41f6adfbb4..a5b38e0907 100644
--- a/pathspec.h
+++ b/pathspec.h
@@ -171,6 +171,11 @@ int match_pathspec_attrs(struct index_state *istate,
const char *name, int namelen,
const struct pathspec_item *item);
+int match_pathspec(struct index_state *istate,
+ const struct pathspec *pathspec,
+ const char *name, int namelen,
+ int prefix, char *seen, int is_dir);
+
/*
* Determine whether a pathspec will match only entire index entries (non-sparse
* files and/or entire sparse directories). If the pathspec has the potential to
diff --git a/pkt-line.c b/pkt-line.c
index ce4e73b683..1ea7f8600e 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "pkt-line.h"
+#include "hex.h"
#include "run-command.h"
char packet_buffer[LARGE_PACKET_MAX];
diff --git a/pkt-line.h b/pkt-line.h
index 79c538b99e..8e9846f315 100644
--- a/pkt-line.h
+++ b/pkt-line.h
@@ -1,7 +1,6 @@
#ifndef PKTLINE_H
#define PKTLINE_H
-#include "git-compat-util.h"
#include "strbuf.h"
#include "sideband.h"
diff --git a/pretty.c b/pretty.c
index 1e1e21878c..2401e3ed36 100644
--- a/pretty.c
+++ b/pretty.c
@@ -1,6 +1,8 @@
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "commit.h"
+#include "hex.h"
#include "utf8.h"
#include "diff.h"
#include "revision.h"
diff --git a/pretty.h b/pretty.h
index f34e24c53a..921dd6e0ca 100644
--- a/pretty.h
+++ b/pretty.h
@@ -1,11 +1,11 @@
#ifndef PRETTY_H
#define PRETTY_H
-#include "cache.h"
#include "date.h"
#include "string-list.h"
struct commit;
+struct repository;
struct strbuf;
struct process_trailer_options;
@@ -153,6 +153,8 @@ int commit_format_is_empty(enum cmit_fmt);
/* Make subject of commit message suitable for filename */
void format_sanitized_subject(struct strbuf *sb, const char *msg, size_t len);
+int has_non_ascii(const char *text);
+
/*
* Set values of fields in "struct process_trailer_options"
* according to trailers arguments.
diff --git a/prio-queue.c b/prio-queue.c
index d31b48e725..dc2476be53 100644
--- a/prio-queue.c
+++ b/prio-queue.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "prio-queue.h"
static inline int compare(struct prio_queue *queue, int i, int j)
diff --git a/promisor-remote.c b/promisor-remote.c
index faa7612941..1db566982e 100644
--- a/promisor-remote.c
+++ b/promisor-remote.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "object-store.h"
#include "promisor-remote.h"
#include "config.h"
diff --git a/protocol-caps.c b/protocol-caps.c
index bbde91810a..874bc815b4 100644
--- a/protocol-caps.c
+++ b/protocol-caps.c
@@ -1,9 +1,11 @@
#include "git-compat-util.h"
#include "protocol-caps.h"
#include "gettext.h"
+#include "hex.h"
#include "pkt-line.h"
#include "strvec.h"
#include "hash.h"
+#include "hex.h"
#include "object.h"
#include "object-store.h"
#include "string-list.h"
diff --git a/prune-packed.c b/prune-packed.c
index 261520b472..d2813f6a40 100644
--- a/prune-packed.c
+++ b/prune-packed.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "object-store.h"
#include "packfile.h"
#include "progress.h"
diff --git a/quote.c b/quote.c
index 26719d21d1..7ccb5a06cd 100644
--- a/quote.c
+++ b/quote.c
@@ -1,5 +1,7 @@
#include "cache.h"
+#include "alloc.h"
#include "quote.h"
+#include "strbuf.h"
#include "strvec.h"
int quote_path_fully = 1;
diff --git a/reachable.c b/reachable.c
index aba63ebeb3..be9d40923d 100644
--- a/reachable.c
+++ b/reachable.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "refs.h"
#include "tag.h"
#include "commit.h"
diff --git a/read-cache.c b/read-cache.c
index 35e5657877..1bcf673271 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -4,9 +4,11 @@
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "diff.h"
#include "diffcore.h"
+#include "hex.h"
#include "tempfile.h"
#include "lockfile.h"
#include "cache-tree.h"
diff --git a/rebase.c b/rebase.c
index 6775cddb28..17a570f1ff 100644
--- a/rebase.c
+++ b/rebase.c
@@ -1,3 +1,4 @@
+#include "git-compat-util.h"
#include "rebase.h"
#include "config.h"
#include "gettext.h"
diff --git a/ref-filter.c b/ref-filter.c
index f8203c6b05..d862718508 100644
--- a/ref-filter.c
+++ b/ref-filter.c
@@ -1,5 +1,6 @@
-#include "builtin.h"
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
+#include "hex.h"
#include "parse-options.h"
#include "refs.h"
#include "wildmatch.h"
@@ -13,7 +14,6 @@
#include "ref-filter.h"
#include "revision.h"
#include "utf8.h"
-#include "git-compat-util.h"
#include "version.h"
#include "trailer.h"
#include "wt-status.h"
diff --git a/reflog-walk.c b/reflog-walk.c
index 8a4d8fa3bd..4ba1a10c82 100644
--- a/reflog-walk.c
+++ b/reflog-walk.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "commit.h"
#include "refs.h"
#include "diff.h"
diff --git a/reflog-walk.h b/reflog-walk.h
index 8076f10d9f..4d93a26957 100644
--- a/reflog-walk.h
+++ b/reflog-walk.h
@@ -1,8 +1,6 @@
#ifndef REFLOG_WALK_H
#define REFLOG_WALK_H
-#include "cache.h"
-
struct commit;
struct reflog_walk_info;
struct date_mode;
diff --git a/refs.c b/refs.c
index aeae31c972..53240bcc07 100644
--- a/refs.c
+++ b/refs.c
@@ -2,9 +2,11 @@
* The backend-independent part of the reference module.
*/
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
#include "hashmap.h"
+#include "hex.h"
#include "lockfile.h"
#include "iterator.h"
#include "refs.h"
diff --git a/refs/debug.c b/refs/debug.c
index eed8bc94b0..adc34c836f 100644
--- a/refs/debug.c
+++ b/refs/debug.c
@@ -1,4 +1,5 @@
-
+#include "git-compat-util.h"
+#include "hex.h"
#include "refs-internal.h"
#include "trace.h"
diff --git a/refs/files-backend.c b/refs/files-backend.c
index b89954355d..31bc5c45ee 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -1,9 +1,11 @@
#include "../cache.h"
#include "../config.h"
+#include "../hex.h"
#include "../refs.h"
#include "refs-internal.h"
#include "ref-cache.h"
#include "packed-backend.h"
+#include "../ident.h"
#include "../iterator.h"
#include "../dir-iterator.h"
#include "../lockfile.h"
diff --git a/refs/packed-backend.c b/refs/packed-backend.c
index 6f5a0709fb..b665d0f7d9 100644
--- a/refs/packed-backend.c
+++ b/refs/packed-backend.c
@@ -1,5 +1,7 @@
-#include "../cache.h"
+#include "../git-compat-util.h"
+#include "../alloc.h"
#include "../config.h"
+#include "../hex.h"
#include "../refs.h"
#include "refs-internal.h"
#include "packed-backend.h"
diff --git a/refs/ref-cache.c b/refs/ref-cache.c
index 32afd8a40b..dc1ca49c85 100644
--- a/refs/ref-cache.c
+++ b/refs/ref-cache.c
@@ -1,4 +1,5 @@
-#include "../cache.h"
+#include "../git-compat-util.h"
+#include "../alloc.h"
#include "../refs.h"
#include "refs-internal.h"
#include "ref-cache.h"
diff --git a/refs/refs-internal.h b/refs/refs-internal.h
index 69f93b0e2a..a85d113123 100644
--- a/refs/refs-internal.h
+++ b/refs/refs-internal.h
@@ -1,7 +1,6 @@
#ifndef REFS_REFS_INTERNAL_H
#define REFS_REFS_INTERNAL_H
-#include "cache.h"
#include "refs.h"
#include "iterator.h"
diff --git a/refspec.c b/refspec.c
index 63e3112104..28d90911aa 100644
--- a/refspec.c
+++ b/refspec.c
@@ -1,4 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
+#include "hex.h"
#include "strvec.h"
#include "refs.h"
#include "refspec.h"
diff --git a/remote-curl.c b/remote-curl.c
index a76b6405eb..ed7e3a043a 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "remote.h"
#include "connect.h"
#include "strbuf.h"
diff --git a/remote.c b/remote.c
index 60869beebe..b04e5da338 100644
--- a/remote.c
+++ b/remote.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "remote.h"
#include "urlmatch.h"
#include "refs.h"
diff --git a/remote.h b/remote.h
index 1ebbe42792..5b38ee20b8 100644
--- a/remote.h
+++ b/remote.h
@@ -1,7 +1,6 @@
#ifndef REMOTE_H
#define REMOTE_H
-#include "cache.h"
#include "parse-options.h"
#include "hashmap.h"
#include "refspec.h"
diff --git a/replace-object.c b/replace-object.c
index 320be2522d..0cf056c4fb 100644
--- a/replace-object.c
+++ b/replace-object.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "oidmap.h"
#include "object-store.h"
#include "replace-object.h"
diff --git a/replace-object.h b/replace-object.h
index 3fbc32eb7b..500482b02b 100644
--- a/replace-object.h
+++ b/replace-object.h
@@ -5,6 +5,14 @@
#include "repository.h"
#include "object-store.h"
+/*
+ * Do replace refs need to be checked this run? This variable is
+ * initialized to true unless --no-replace-object is used or
+ * $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some
+ * commands that do not want replace references to be active.
+ */
+extern int read_replace_refs;
+
struct replace_object {
struct oidmap_entry original;
struct object_id replacement;
diff --git a/repo-settings.c b/repo-settings.c
index 3dbd3f0e2e..0a6c0b381f 100644
--- a/repo-settings.c
+++ b/repo-settings.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "config.h"
#include "repository.h"
#include "midx.h"
diff --git a/repository.h b/repository.h
index e8c67ffe16..15a8afc5fb 100644
--- a/repository.h
+++ b/repository.h
@@ -1,7 +1,6 @@
#ifndef REPOSITORY_H
#define REPOSITORY_H
-#include "git-compat-util.h"
#include "path.h"
struct config_set;
diff --git a/rerere.c b/rerere.c
index 876ab435da..a67abaab07 100644
--- a/rerere.c
+++ b/rerere.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "string-list.h"
#include "rerere.h"
diff --git a/reset.c b/reset.c
index 5ded23611f..58b3829ff7 100644
--- a/reset.c
+++ b/reset.c
@@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "cache-tree.h"
+#include "hex.h"
#include "lockfile.h"
#include "refs.h"
#include "reset.h"
diff --git a/revision.c b/revision.c
index 21f5f572c2..e356bc4aae 100644
--- a/revision.c
+++ b/revision.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "object-store.h"
#include "tag.h"
#include "blob.h"
diff --git a/revision.h b/revision.h
index 30febad09a..ab71443696 100644
--- a/revision.h
+++ b/revision.h
@@ -8,6 +8,7 @@
#include "pretty.h"
#include "diff.h"
#include "commit-slab-decl.h"
+#include "ident.h"
#include "list-objects-filter-options.h"
/**
diff --git a/send-pack.c b/send-pack.c
index f2e19838c9..423a5cfe22 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -1,6 +1,7 @@
-#include "builtin.h"
+#include "git-compat-util.h"
#include "config.h"
#include "commit.h"
+#include "hex.h"
#include "refs.h"
#include "object-store.h"
#include "pkt-line.h"
diff --git a/sequencer.c b/sequencer.c
index 1c96a75b1e..675dee7b8f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -1,5 +1,7 @@
#include "cache.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "lockfile.h"
#include "dir.h"
#include "object-store.h"
diff --git a/sequencer.h b/sequencer.h
index 3bcdfa1b58..33dbaf5b66 100644
--- a/sequencer.h
+++ b/sequencer.h
@@ -1,11 +1,11 @@
#ifndef SEQUENCER_H
#define SEQUENCER_H
-#include "cache.h"
#include "strbuf.h"
#include "wt-status.h"
struct commit;
+struct index_state;
struct repository;
const char *git_path_commit_editmsg(void);
diff --git a/serve.c b/serve.c
index cbf4a143cf..d128822347 100644
--- a/serve.c
+++ b/serve.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "repository.h"
#include "config.h"
#include "pkt-line.h"
@@ -8,6 +8,7 @@
#include "serve.h"
#include "upload-pack.h"
#include "bundle-uri.h"
+#include "trace2.h"
static int advertise_sid = -1;
static int client_hash_algo = GIT_HASH_SHA1;
diff --git a/server-info.c b/server-info.c
index 0ec6c0c165..4043689202 100644
--- a/server-info.c
+++ b/server-info.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "dir.h"
+#include "hex.h"
#include "repository.h"
#include "refs.h"
#include "object.h"
diff --git a/sha1dc_git.c b/sha1dc_git.c
index 5c300e812e..9b675a046e 100644
--- a/sha1dc_git.c
+++ b/sha1dc_git.c
@@ -1,4 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "sha1dc_git.h"
+#include "hex.h"
#ifdef DC_SHA1_EXTERNAL
/*
diff --git a/shallow.c b/shallow.c
index 17f9bcdb5f..1cbb05ba0e 100644
--- a/shallow.c
+++ b/shallow.c
@@ -1,4 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
+#include "hex.h"
#include "repository.h"
#include "tempfile.h"
#include "lockfile.h"
diff --git a/shallow.h b/shallow.h
index aba6ff5829..e9ca7e4bc8 100644
--- a/shallow.h
+++ b/shallow.h
@@ -6,6 +6,8 @@
#include "repository.h"
#include "strbuf.h"
+struct oid_array;
+
void set_alternate_shallow_file(struct repository *r, const char *path, int override);
int register_shallow(struct repository *r, const struct object_id *oid);
int unregister_shallow(const struct object_id *oid);
diff --git a/shell.c b/shell.c
index af0d7c734f..5c67e7bd97 100644
--- a/shell.c
+++ b/shell.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "quote.h"
#include "exec-cmd.h"
#include "strbuf.h"
diff --git a/sigchain.c b/sigchain.c
index 022677b6ab..ee778c0580 100644
--- a/sigchain.c
+++ b/sigchain.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "sigchain.h"
#define SIGCHAIN_MAX_SIGNALS 32
diff --git a/sparse-index.c b/sparse-index.c
index 147a13386a..63216b3e57 100644
--- a/sparse-index.c
+++ b/sparse-index.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "alloc.h"
#include "repository.h"
#include "sparse-index.h"
#include "tree.h"
diff --git a/split-index.c b/split-index.c
index 5d0f04763e..95ecfa5319 100644
--- a/split-index.c
+++ b/split-index.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "alloc.h"
#include "split-index.h"
#include "ewah/ewok.h"
diff --git a/statinfo.h b/statinfo.h
new file mode 100644
index 0000000000..e49e3054ea
--- /dev/null
+++ b/statinfo.h
@@ -0,0 +1,24 @@
+#ifndef STATINFO_H
+#define STATINFO_H
+
+/*
+ * The "cache_time" is just the low 32 bits of the
+ * time. It doesn't matter if it overflows - we only
+ * check it for equality in the 32 bits we save.
+ */
+struct cache_time {
+ uint32_t sec;
+ uint32_t nsec;
+};
+
+struct stat_data {
+ struct cache_time sd_ctime;
+ struct cache_time sd_mtime;
+ unsigned int sd_dev;
+ unsigned int sd_ino;
+ unsigned int sd_uid;
+ unsigned int sd_gid;
+ unsigned int sd_size;
+};
+
+#endif
diff --git a/strbuf.c b/strbuf.c
index c383f41a3c..1c57ac6574 100644
--- a/strbuf.c
+++ b/strbuf.c
@@ -1,4 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
+#include "hex.h"
#include "refs.h"
#include "string-list.h"
#include "utf8.h"
diff --git a/string-list.c b/string-list.c
index 42bacaec55..db473f273e 100644
--- a/string-list.c
+++ b/string-list.c
@@ -1,5 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "string-list.h"
+#include "alloc.h"
void string_list_init_nodup(struct string_list *list)
{
diff --git a/strvec.c b/strvec.c
index 61a76ce6cb..17d54b6c3b 100644
--- a/strvec.c
+++ b/strvec.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "strvec.h"
+#include "alloc.h"
+#include "hex.h"
#include "strbuf.h"
const char *empty_strvec[] = { NULL };
diff --git a/sub-process.c b/sub-process.c
index 6d4232294d..1daf5a9752 100644
--- a/sub-process.c
+++ b/sub-process.c
@@ -1,6 +1,7 @@
/*
* Generic implementation of background process infrastructure.
*/
+#include "git-compat-util.h"
#include "sub-process.h"
#include "sigchain.h"
#include "pkt-line.h"
diff --git a/sub-process.h b/sub-process.h
index e85f21fa1a..6a61638a8a 100644
--- a/sub-process.h
+++ b/sub-process.h
@@ -1,7 +1,6 @@
#ifndef SUBPROCESS_H
#define SUBPROCESS_H
-#include "git-compat-util.h"
#include "hashmap.h"
#include "run-command.h"
diff --git a/submodule-config.c b/submodule-config.c
index 4dc61b3a78..89a7bf0a93 100644
--- a/submodule-config.c
+++ b/submodule-config.c
@@ -1,5 +1,7 @@
#include "cache.h"
+#include "alloc.h"
#include "dir.h"
+#include "hex.h"
#include "repository.h"
#include "config.h"
#include "submodule-config.h"
diff --git a/submodule-config.h b/submodule-config.h
index 28a8ca6bf4..c2045875bb 100644
--- a/submodule-config.h
+++ b/submodule-config.h
@@ -1,7 +1,6 @@
#ifndef SUBMODULE_CONFIG_CACHE_H
#define SUBMODULE_CONFIG_CACHE_H
-#include "cache.h"
#include "config.h"
#include "hashmap.h"
#include "submodule.h"
diff --git a/submodule.c b/submodule.c
index 3a0dfc417c..9d89299772 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1,5 +1,5 @@
-
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "repository.h"
#include "config.h"
#include "submodule-config.h"
@@ -7,6 +7,7 @@
#include "dir.h"
#include "diff.h"
#include "commit.h"
+#include "hex.h"
#include "revision.h"
#include "run-command.h"
#include "diffcore.h"
diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c
index 6c900ca668..127f134a2a 100644
--- a/t/helper/test-bloom.c
+++ b/t/helper/test-bloom.c
@@ -1,5 +1,6 @@
-#include "git-compat-util.h"
+#include "cache.h"
#include "bloom.h"
+#include "hex.h"
#include "test-tool.h"
#include "commit.h"
diff --git a/t/helper/test-cache-tree.c b/t/helper/test-cache-tree.c
index 9159a17301..615e648e55 100644
--- a/t/helper/test-cache-tree.c
+++ b/t/helper/test-cache-tree.c
@@ -1,6 +1,7 @@
#define USE_THE_INDEX_VARIABLE
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
#include "tree.h"
#include "cache-tree.h"
#include "parse-options.h"
diff --git a/t/helper/test-crontab.c b/t/helper/test-crontab.c
index e6c1b1e22b..597027a96e 100644
--- a/t/helper/test-crontab.c
+++ b/t/helper/test-crontab.c
@@ -1,5 +1,4 @@
#include "test-tool.h"
-#include "cache.h"
/*
* Usage: test-tool crontab <file> -l|<input>
diff --git a/t/helper/test-ctype.c b/t/helper/test-ctype.c
index b21bd672d9..534ca66441 100644
--- a/t/helper/test-ctype.c
+++ b/t/helper/test-ctype.c
@@ -1,5 +1,4 @@
#include "test-tool.h"
-#include "cache.h"
static int rc;
diff --git a/t/helper/test-dump-cache-tree.c b/t/helper/test-dump-cache-tree.c
index 454f17b1a0..92dfc1aa8c 100644
--- a/t/helper/test-dump-cache-tree.c
+++ b/t/helper/test-dump-cache-tree.c
@@ -1,6 +1,7 @@
#define USE_THE_INDEX_VARIABLE
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
#include "tree.h"
#include "cache-tree.h"
diff --git a/t/helper/test-dump-split-index.c b/t/helper/test-dump-split-index.c
index 0ea97b8407..813d0a38fa 100644
--- a/t/helper/test-dump-split-index.c
+++ b/t/helper/test-dump-split-index.c
@@ -1,6 +1,7 @@
#define USE_THE_INDEX_VARIABLE
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
#include "split-index.h"
#include "ewah/ewok.h"
diff --git a/t/helper/test-dump-untracked-cache.c b/t/helper/test-dump-untracked-cache.c
index 6d53683f13..af953fabe8 100644
--- a/t/helper/test-dump-untracked-cache.c
+++ b/t/helper/test-dump-untracked-cache.c
@@ -2,6 +2,7 @@
#include "test-tool.h"
#include "cache.h"
#include "dir.h"
+#include "hex.h"
static int compare_untracked(const void *a_, const void *b_)
{
diff --git a/t/helper/test-example-decorate.c b/t/helper/test-example-decorate.c
index b9d1200eb9..7c7fc8efc1 100644
--- a/t/helper/test-example-decorate.c
+++ b/t/helper/test-example-decorate.c
@@ -1,5 +1,5 @@
#include "test-tool.h"
-#include "cache.h"
+#include "git-compat-util.h"
#include "object.h"
#include "decorate.h"
diff --git a/t/helper/test-fast-rebase.c b/t/helper/test-fast-rebase.c
index efc82dd80c..b1edb92a03 100644
--- a/t/helper/test-fast-rebase.c
+++ b/t/helper/test-fast-rebase.c
@@ -15,6 +15,7 @@
#include "cache-tree.h"
#include "commit.h"
+#include "hex.h"
#include "lockfile.h"
#include "merge-ort.h"
#include "refs.h"
diff --git a/t/helper/test-hash.c b/t/helper/test-hash.c
index 5860dab0ff..016248106a 100644
--- a/t/helper/test-hash.c
+++ b/t/helper/test-hash.c
@@ -1,5 +1,6 @@
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
int cmd_hash_impl(int ac, const char **av, int algo)
{
diff --git a/t/helper/test-json-writer.c b/t/helper/test-json-writer.c
index 8c3edacc00..86887f5320 100644
--- a/t/helper/test-json-writer.c
+++ b/t/helper/test-json-writer.c
@@ -1,5 +1,4 @@
#include "test-tool.h"
-#include "cache.h"
#include "json-writer.h"
static const char *expect_obj1 = "{\"a\":\"abc\",\"b\":42,\"c\":true}";
diff --git a/t/helper/test-match-trees.c b/t/helper/test-match-trees.c
index 4079fdee06..04bc2563f3 100644
--- a/t/helper/test-match-trees.c
+++ b/t/helper/test-match-trees.c
@@ -1,5 +1,6 @@
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
#include "tree.h"
int cmd__match_trees(int ac, const char **av)
diff --git a/t/helper/test-oid-array.c b/t/helper/test-oid-array.c
index d1324d086a..0906993ad5 100644
--- a/t/helper/test-oid-array.c
+++ b/t/helper/test-oid-array.c
@@ -1,5 +1,6 @@
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
#include "oid-array.h"
static int print_oid(const struct object_id *oid, void *data)
diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c
index 0acf99931e..883d40efd4 100644
--- a/t/helper/test-oidmap.c
+++ b/t/helper/test-oidmap.c
@@ -1,5 +1,6 @@
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
#include "oidmap.h"
#include "strbuf.h"
diff --git a/t/helper/test-oidtree.c b/t/helper/test-oidtree.c
index d48a409f4e..0b82431a70 100644
--- a/t/helper/test-oidtree.c
+++ b/t/helper/test-oidtree.c
@@ -1,5 +1,6 @@
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
#include "oidtree.h"
static enum cb_next print_oid(const struct object_id *oid, void *data)
diff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c
index f7b79daf4c..f68b3761b6 100644
--- a/t/helper/test-pack-mtimes.c
+++ b/t/helper/test-pack-mtimes.c
@@ -1,5 +1,6 @@
#include "git-compat-util.h"
#include "test-tool.h"
+#include "hex.h"
#include "strbuf.h"
#include "object-store.h"
#include "packfile.h"
diff --git a/t/helper/test-partial-clone.c b/t/helper/test-partial-clone.c
index 3f102cfddd..da17fd37eb 100644
--- a/t/helper/test-partial-clone.c
+++ b/t/helper/test-partial-clone.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "test-tool.h"
#include "repository.h"
#include "object-store.h"
diff --git a/t/helper/test-pcre2-config.c b/t/helper/test-pcre2-config.c
index 5258fdddba..5d0b2a2e10 100644
--- a/t/helper/test-pcre2-config.c
+++ b/t/helper/test-pcre2-config.c
@@ -1,5 +1,4 @@
#include "test-tool.h"
-#include "cache.h"
#include "grep.h"
int cmd__pcre2_config(int argc, const char **argv)
diff --git a/t/helper/test-prio-queue.c b/t/helper/test-prio-queue.c
index 133b5e6f4a..ac4c65d705 100644
--- a/t/helper/test-prio-queue.c
+++ b/t/helper/test-prio-queue.c
@@ -1,5 +1,4 @@
#include "test-tool.h"
-#include "cache.h"
#include "prio-queue.h"
static int intcmp(const void *va, const void *vb, void *data)
diff --git a/t/helper/test-proc-receive.c b/t/helper/test-proc-receive.c
index a4b305f494..7e12d4f9aa 100644
--- a/t/helper/test-proc-receive.c
+++ b/t/helper/test-proc-receive.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "connect.h"
+#include "hex.h"
#include "parse-options.h"
#include "pkt-line.h"
#include "sigchain.h"
diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c
index 2f65c7f6a5..de8f26639d 100644
--- a/t/helper/test-reach.c
+++ b/t/helper/test-reach.c
@@ -1,8 +1,9 @@
#include "test-tool.h"
-#include "cache.h"
+#include "alloc.h"
#include "commit.h"
#include "commit-reach.h"
#include "config.h"
+#include "hex.h"
#include "parse-options.h"
#include "ref-filter.h"
#include "string-list.h"
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index 27072ba94d..0a883cdf26 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -1,5 +1,6 @@
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
#include "midx.h"
#include "repository.h"
#include "object-store.h"
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index ae8a5648da..1745b088b7 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -1,5 +1,6 @@
#include "test-tool.h"
#include "cache.h"
+#include "hex.h"
#include "refs.h"
#include "worktree.h"
#include "object-store.h"
diff --git a/t/helper/test-repository.c b/t/helper/test-repository.c
index 56f0e3c1be..10a6dfc216 100644
--- a/t/helper/test-repository.c
+++ b/t/helper/test-repository.c
@@ -3,6 +3,7 @@
#include "commit-graph.h"
#include "commit.h"
#include "config.h"
+#include "hex.h"
#include "object-store.h"
#include "object.h"
#include "repository.h"
diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
index 3ecb830f4a..67b42ef50e 100644
--- a/t/helper/test-run-command.c
+++ b/t/helper/test-run-command.c
@@ -9,8 +9,6 @@
*/
#include "test-tool.h"
-#include "git-compat-util.h"
-#include "cache.h"
#include "run-command.h"
#include "strvec.h"
#include "strbuf.h"
diff --git a/t/helper/test-sigchain.c b/t/helper/test-sigchain.c
index d013bccdda..d1cf7377b7 100644
--- a/t/helper/test-sigchain.c
+++ b/t/helper/test-sigchain.c
@@ -1,5 +1,4 @@
#include "test-tool.h"
-#include "cache.h"
#include "sigchain.h"
#define X(f) \
diff --git a/t/helper/test-simple-ipc.c b/t/helper/test-simple-ipc.c
index 28365ff85b..3d1436da59 100644
--- a/t/helper/test-simple-ipc.c
+++ b/t/helper/test-simple-ipc.c
@@ -3,13 +3,14 @@
*/
#include "test-tool.h"
-#include "cache.h"
+#include "gettext.h"
#include "strbuf.h"
#include "simple-ipc.h"
#include "parse-options.h"
#include "thread-utils.h"
#include "strvec.h"
#include "run-command.h"
+#include "trace2.h"
#ifndef SUPPORTS_SIMPLE_IPC
int cmd__simple_ipc(int argc, const char **argv)
diff --git a/t/helper/test-submodule-nested-repo-config.c b/t/helper/test-submodule-nested-repo-config.c
index dc1c14bde3..a3848a8b66 100644
--- a/t/helper/test-submodule-nested-repo-config.c
+++ b/t/helper/test-submodule-nested-repo-config.c
@@ -1,4 +1,5 @@
#include "test-tool.h"
+#include "cache.h"
#include "submodule-config.h"
static void die_usage(const char **argv, const char *msg)
diff --git a/t/helper/test-wildmatch.c b/t/helper/test-wildmatch.c
index 2c103d1824..a95bb4da9b 100644
--- a/t/helper/test-wildmatch.c
+++ b/t/helper/test-wildmatch.c
@@ -1,5 +1,4 @@
#include "test-tool.h"
-#include "cache.h"
int cmd__wildmatch(int argc, const char **argv)
{
diff --git a/tag.c b/tag.c
index dfbcd7fcc2..18b718cca6 100644
--- a/tag.c
+++ b/tag.c
@@ -6,6 +6,7 @@
#include "blob.h"
#include "alloc.h"
#include "gpg-interface.h"
+#include "hex.h"
#include "packfile.h"
const char *tag_type = "tag";
diff --git a/thread-utils.c b/thread-utils.c
index 5329845691..1f89ffab4c 100644
--- a/thread-utils.c
+++ b/thread-utils.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "thread-utils.h"
#if defined(hpux) || defined(__hpux) || defined(_hpux)
diff --git a/trace.h b/trace.h
index b6e35b9470..d304d55aa1 100644
--- a/trace.h
+++ b/trace.h
@@ -1,7 +1,6 @@
#ifndef TRACE_H
#define TRACE_H
-#include "git-compat-util.h"
#include "strbuf.h"
/**
diff --git a/trace2.c b/trace2.c
index 279bddf53b..e8ba62c0c3 100644
--- a/trace2.c
+++ b/trace2.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "config.h"
#include "json-writer.h"
#include "quote.h"
@@ -6,6 +6,7 @@
#include "sigchain.h"
#include "thread-utils.h"
#include "version.h"
+#include "trace.h"
#include "trace2/tr2_cfg.h"
#include "trace2/tr2_cmd_name.h"
#include "trace2/tr2_ctr.h"
diff --git a/trace2/tr2_ctr.c b/trace2/tr2_ctr.c
index 483ca7c308..b342d3b1a3 100644
--- a/trace2/tr2_ctr.c
+++ b/trace2/tr2_ctr.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "thread-utils.h"
#include "trace2/tr2_tgt.h"
#include "trace2/tr2_tls.h"
diff --git a/trace2/tr2_sid.c b/trace2/tr2_sid.c
index dc6e75ef13..5f1ce6f85c 100644
--- a/trace2/tr2_sid.c
+++ b/trace2/tr2_sid.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "trace2/tr2_tbuf.h"
#include "trace2/tr2_sid.h"
diff --git a/trace2/tr2_sysenv.c b/trace2/tr2_sysenv.c
index a380dcf910..069786cb92 100644
--- a/trace2/tr2_sysenv.c
+++ b/trace2/tr2_sysenv.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "config.h"
#include "dir.h"
#include "tr2_sysenv.h"
diff --git a/trace2/tr2_tbuf.c b/trace2/tr2_tbuf.c
index 2498482d9a..c3b3822ed7 100644
--- a/trace2/tr2_tbuf.c
+++ b/trace2/tr2_tbuf.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "tr2_tbuf.h"
void tr2_tbuf_local_time(struct tr2_tbuf *tb)
diff --git a/trace2/tr2_tgt_event.c b/trace2/tr2_tgt_event.c
index 16f6332755..9e7aab6d51 100644
--- a/trace2/tr2_tgt_event.c
+++ b/trace2/tr2_tgt_event.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "config.h"
#include "json-writer.h"
#include "run-command.h"
diff --git a/trace2/tr2_tgt_normal.c b/trace2/tr2_tgt_normal.c
index fbbef68dfc..8672c2c2d0 100644
--- a/trace2/tr2_tgt_normal.c
+++ b/trace2/tr2_tgt_normal.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "config.h"
#include "run-command.h"
#include "quote.h"
diff --git a/trace2/tr2_tgt_perf.c b/trace2/tr2_tgt_perf.c
index adae803263..3f2b2d5311 100644
--- a/trace2/tr2_tgt_perf.c
+++ b/trace2/tr2_tgt_perf.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "config.h"
#include "run-command.h"
#include "quote.h"
diff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c
index 04900bb4c3..9f46ae12f5 100644
--- a/trace2/tr2_tls.c
+++ b/trace2/tr2_tls.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "thread-utils.h"
+#include "trace.h"
#include "trace2/tr2_tls.h"
/*
diff --git a/trace2/tr2_tmr.c b/trace2/tr2_tmr.c
index 786762dfd2..31d0e4d1bd 100644
--- a/trace2/tr2_tmr.c
+++ b/trace2/tr2_tmr.c
@@ -1,8 +1,9 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "thread-utils.h"
#include "trace2/tr2_tgt.h"
#include "trace2/tr2_tls.h"
#include "trace2/tr2_tmr.h"
+#include "trace.h"
#define MY_MAX(a, b) ((a) > (b) ? (a) : (b))
#define MY_MIN(a, b) ((a) < (b) ? (a) : (b))
diff --git a/trailer.c b/trailer.c
index 0fd5b142a3..72c3fed5c6 100644
--- a/trailer.c
+++ b/trailer.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "alloc.h"
#include "config.h"
#include "string-list.h"
#include "run-command.h"
diff --git a/transport-helper.c b/transport-helper.c
index 3ea7c2bb5a..82ac63e260 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -4,6 +4,7 @@
#include "run-command.h"
#include "commit.h"
#include "diff.h"
+#include "hex.h"
#include "revision.h"
#include "remote.h"
#include "string-list.h"
diff --git a/transport.c b/transport.c
index 77a61a9d7b..906dbad5a0 100644
--- a/transport.c
+++ b/transport.c
@@ -1,5 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
+#include "hex.h"
#include "transport.h"
#include "hook.h"
#include "pkt-line.h"
@@ -10,6 +12,7 @@
#include "walker.h"
#include "bundle.h"
#include "dir.h"
+#include "gettext.h"
#include "refs.h"
#include "refspec.h"
#include "branch.h"
diff --git a/tree-walk.c b/tree-walk.c
index 74f4d710e8..0e2f5ceb71 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -1,6 +1,8 @@
#include "cache.h"
#include "tree-walk.h"
+#include "alloc.h"
#include "dir.h"
+#include "hex.h"
#include "object-store.h"
#include "tree.h"
#include "pathspec.h"
diff --git a/tree-walk.h b/tree-walk.h
index 6305d53150..25fe27e352 100644
--- a/tree-walk.h
+++ b/tree-walk.h
@@ -1,7 +1,9 @@
#ifndef TREE_WALK_H
#define TREE_WALK_H
-#include "cache.h"
+#include "hash.h"
+
+struct index_state;
#define MAX_TRAVERSE_TREES 8
diff --git a/tree.c b/tree.c
index 410e3b477e..76a6534f67 100644
--- a/tree.c
+++ b/tree.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "cache-tree.h"
+#include "hex.h"
#include "tree.h"
#include "object-store.h"
#include "blob.h"
diff --git a/unix-socket.c b/unix-socket.c
index e0be1badb5..79800d8063 100644
--- a/unix-socket.c
+++ b/unix-socket.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "strbuf.h"
#include "unix-socket.h"
#define DEFAULT_UNIX_STREAM_LISTEN_BACKLOG (5)
diff --git a/unix-stream-server.c b/unix-stream-server.c
index efa2a207ab..22ac2373e0 100644
--- a/unix-stream-server.c
+++ b/unix-stream-server.c
@@ -1,4 +1,4 @@
-#include "cache.h"
+#include "git-compat-util.h"
#include "lockfile.h"
#include "unix-socket.h"
#include "unix-stream-server.h"
diff --git a/unpack-trees.c b/unpack-trees.c
index a37ab292bb..a75fb9f05b 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -3,6 +3,7 @@
#include "repository.h"
#include "config.h"
#include "dir.h"
+#include "hex.h"
#include "tree.h"
#include "tree-walk.h"
#include "cache-tree.h"
diff --git a/upload-pack.c b/upload-pack.c
index 551f22ffa5..fa4bb61e4f 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "refs.h"
#include "pkt-line.h"
#include "sideband.h"
diff --git a/url.c b/url.c
index e04bd60b6b..2e1a9f6fee 100644
--- a/url.c
+++ b/url.c
@@ -1,4 +1,6 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "hex.h"
+#include "strbuf.h"
#include "url.h"
int is_urlschemechar(int first_flag, int ch)
diff --git a/urlmatch.c b/urlmatch.c
index 620a648efc..eba0bdd77f 100644
--- a/urlmatch.c
+++ b/urlmatch.c
@@ -1,4 +1,7 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "gettext.h"
+#include "hex.h"
+#include "strbuf.h"
#include "urlmatch.h"
#define URL_ALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
diff --git a/userdiff.c b/userdiff.c
index 58a3d59ef8..09203fbc35 100644
--- a/userdiff.c
+++ b/userdiff.c
@@ -1,7 +1,9 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "config.h"
#include "userdiff.h"
#include "attr.h"
+#include "strbuf.h"
static struct userdiff_driver *drivers;
static int ndrivers;
diff --git a/walker.c b/walker.c
index 99d0e0eae0..c046936378 100644
--- a/walker.c
+++ b/walker.c
@@ -1,4 +1,5 @@
#include "cache.h"
+#include "hex.h"
#include "walker.h"
#include "repository.h"
#include "object-store.h"
diff --git a/wildmatch.c b/wildmatch.c
index 7e5a7ea1ea..42e38e3459 100644
--- a/wildmatch.c
+++ b/wildmatch.c
@@ -9,7 +9,7 @@
** work differently than '*', and to fix the character-class code.
*/
-#include "cache.h"
+#include "git-compat-util.h"
#include "wildmatch.h"
typedef unsigned char uchar;
diff --git a/worktree.c b/worktree.c
index aa43c64119..c99939a4d1 100644
--- a/worktree.c
+++ b/worktree.c
@@ -1,4 +1,5 @@
-#include "cache.h"
+#include "git-compat-util.h"
+#include "alloc.h"
#include "repository.h"
#include "refs.h"
#include "strbuf.h"
diff --git a/worktree.h b/worktree.h
index 9dcea6fc8c..2baeca2a8a 100644
--- a/worktree.h
+++ b/worktree.h
@@ -1,7 +1,6 @@
#ifndef WORKTREE_H
#define WORKTREE_H
-#include "cache.h"
#include "refs.h"
struct strbuf;
diff --git a/wt-status.c b/wt-status.c
index 3162241a57..90525bd26f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -4,6 +4,7 @@
#include "dir.h"
#include "commit.h"
#include "diff.h"
+#include "hex.h"
#include "revision.h"
#include "diffcore.h"
#include "quote.h"
diff --git a/xdiff-interface.c b/xdiff-interface.c
index e87950de32..5baf6ceb94 100644
--- a/xdiff-interface.c
+++ b/xdiff-interface.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "config.h"
+#include "hex.h"
#include "object-store.h"
#include "xdiff-interface.h"
#include "xdiff/xtypes.h"
diff --git a/xdiff-interface.h b/xdiff-interface.h
index 4301a7eef2..3750794afe 100644
--- a/xdiff-interface.h
+++ b/xdiff-interface.h
@@ -1,7 +1,7 @@
#ifndef XDIFF_INTERFACE_H
#define XDIFF_INTERFACE_H
-#include "cache.h"
+#include "hash.h"
#include "xdiff/xdiff.h"
/*