Skip to content

Commit

Permalink
cache.h: remove this no-longer-used header
Browse files Browse the repository at this point in the history
Since this header showed up in some places besides just #include
statements, update/clean-up/remove those other places as well.

Note that compat/fsmonitor/fsm-path-utils-darwin.c previously got
away with violating the rule that all files must start with an include
of git-compat-util.h (or a short-list of alternate headers that happen
to include it first).  This change exposed the violation and caused it
to stop building correctly; fix it by having it include
git-compat-util.h first, as per policy.

Signed-off-by: Elijah Newren <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
newren authored and gitster committed Jun 21, 2023
1 parent 08c46a4 commit bc5c5ec
Show file tree
Hide file tree
Showing 150 changed files with 100 additions and 206 deletions.
2 changes: 1 addition & 1 deletion Documentation/CodingGuidelines
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ For C programs:
- The first #include in C files, except in platform specific compat/
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",
approved headers currently include "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.
Expand Down
2 changes: 1 addition & 1 deletion Documentation/MyFirstObjectWalk.txt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ parameters provided by the user over the CLI.

`nr` represents the number of `rev_cmdline_entry` present in the array.

`alloc` is used by the `ALLOC_GROW` macro. Check `cache.h` - this variable is
`alloc` is used by the `ALLOC_GROW` macro. Check `alloc.h` - this variable is
used to track the allocated size of the list.

Per entry, we find:
Expand Down
18 changes: 8 additions & 10 deletions Documentation/user-manual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4129,13 +4129,11 @@ Note that terminology has changed since that revision. For example, the
README in that revision uses the word "changeset" to describe what we
now call a <<def_commit_object,commit>>.

Also, we do not call it "cache" any more, but rather "index"; however, the
file is still called `cache.h`. Remark: Not much reason to change it now,
especially since there is no good single name for it anyway, because it is
basically _the_ header file which is included by _all_ of Git's C sources.
Also, we do not call it "cache" any more, but rather "index"; however,
the file is still called `read-cache.h`.

If you grasp the ideas in that initial commit, you should check out a
more recent version and skim `cache.h`, `object.h` and `commit.h`.
more recent version and skim `read-cache-ll.h`, `object.h` and `commit.h`.

In the early days, Git (in the tradition of UNIX) was a bunch of programs
which were extremely simple, and which you used in scripts, piping the
Expand All @@ -4146,11 +4144,11 @@ many of these parts have become builtins, and some of the core has been
and to avoid code duplication.

By now, you know what the index is (and find the corresponding data
structures in `cache.h`), and that there are just a couple of object types
(blobs, trees, commits and tags) which inherit their common structure from
`struct object`, which is their first member (and thus, you can cast e.g.
`(struct object *)commit` to achieve the _same_ as `&commit->object`, i.e.
get at the object name and flags).
structures in `read-cache-ll.h`), and that there are just a couple of
object types (blobs, trees, commits and tags) which inherit their
common structure from `struct object`, which is their first member
(and thus, you can cast e.g. `(struct object *)commit` to achieve the
_same_ as `&commit->object`, i.e. get at the object name and flags).

Now is a good point to take a break to let this information sink in.

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1952,7 +1952,7 @@ endif
BASIC_CFLAGS += \
-DSHA1DC_NO_STANDARD_INCLUDES \
-DSHA1DC_INIT_SAFE_HASH_DEFAULT=0 \
-DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"cache.h\"" \
-DSHA1DC_CUSTOM_INCLUDE_SHA1_C="\"git-compat-util.h\"" \
-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="\"git-compat-util.h\""
endif
endif
Expand Down
2 changes: 1 addition & 1 deletion add-interactive.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "add-interactive.h"
#include "color.h"
#include "config.h"
Expand Down
2 changes: 1 addition & 1 deletion add-patch.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "add-interactive.h"
#include "advice.h"
#include "alloc.h"
Expand Down
2 changes: 1 addition & 1 deletion apply.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*
*/

#include "cache.h"
#include "git-compat-util.h"
#include "abspath.h"
#include "alloc.h"
#include "base85.h"
Expand Down
2 changes: 1 addition & 1 deletion attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* an insanely large number of attributes.
*/

#include "cache.h"
#include "git-compat-util.h"
#include "alloc.h"
#include "config.h"
#include "environment.h"
Expand Down
2 changes: 1 addition & 1 deletion blame.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "cache.h"
#include "git-compat-util.h"
#include "refs.h"
#include "object-store.h"
#include "cache-tree.h"
Expand Down
1 change: 0 additions & 1 deletion builtin.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "git-compat-util.h"
#include "strbuf.h"
#include "cache.h"
#include "commit.h"

/*
Expand Down
3 changes: 1 addition & 2 deletions builtin/add.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
* Copyright (C) 2006 Linus Torvalds
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "builtin.h"
#include "advice.h"
#include "config.h"
#include "builtin.h"
#include "lockfile.h"
#include "editor.h"
#include "dir.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/am.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* Based on git-am.sh by Junio C Hamano.
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "builtin.h"
#include "abspath.h"
#include "advice.h"
#include "config.h"
#include "builtin.h"
#include "editor.h"
#include "environment.h"
#include "exec-cmd.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/apply.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#include "cache.h"
#include "builtin.h"
#include "gettext.h"
#include "parse-options.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/archive.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* Copyright (c) 2006 Franck Bui-Huu
* Copyright (c) 2006 Rene Scharfe
*/
#include "cache.h"
#include "builtin.h"
#include "archive.h"
#include "gettext.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/bisect.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "builtin.h"
#include "cache.h"
#include "copy.h"
#include "environment.h"
#include "gettext.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/branch.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
* Based on git-branch.sh by Junio C Hamano.
*/

#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "color.h"
#include "editor.h"
#include "environment.h"
#include "refs.h"
#include "commit.h"
#include "builtin.h"
#include "gettext.h"
#include "object-name.h"
#include "remote.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/bundle.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
#include "parse-options.h"
#include "pkt-line.h"
#include "repository.h"
#include "cache.h"
#include "bundle.h"

/*
Expand Down
3 changes: 1 addition & 2 deletions builtin/cat-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* Copyright (C) Linus Torvalds, 2005
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "builtin.h"
#include "alloc.h"
#include "config.h"
#include "convert.h"
#include "builtin.h"
#include "diff.h"
#include "environment.h"
#include "gettext.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/check-attr.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "cache.h"
#include "config.h"
#include "attr.h"
#include "environment.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/check-ignore.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "cache.h"
#include "config.h"
#include "dir.h"
#include "gettext.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/check-ref-format.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
* GIT - The information manager from hell
*/

#include "cache.h"
#include "refs.h"
#include "builtin.h"
#include "refs.h"
#include "setup.h"
#include "strbuf.h"

Expand Down
1 change: 0 additions & 1 deletion builtin/clean.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#define USE_THE_INDEX_VARIABLE
#include "builtin.h"
#include "abspath.h"
#include "cache.h"
#include "config.h"
#include "dir.h"
#include "gettext.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/column.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "builtin.h"
#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "strbuf.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/commit-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
Expand All @@ -12,7 +12,6 @@
#include "repository.h"
#include "commit.h"
#include "tree.h"
#include "builtin.h"
#include "utf8.h"
#include "gpg-interface.h"
#include "parse-options.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "builtin.h"
#include "advice.h"
#include "config.h"
#include "lockfile.h"
Expand All @@ -15,7 +15,6 @@
#include "dir.h"
#include "editor.h"
#include "environment.h"
#include "builtin.h"
#include "diff.h"
#include "diffcore.h"
#include "commit.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/count-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
* Copyright (c) 2006 Junio C Hamano
*/

#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "dir.h"
#include "environment.h"
#include "gettext.h"
#include "repository.h"
#include "builtin.h"
#include "parse-options.h"
#include "quote.h"
#include "packfile.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/describe.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "environment.h"
#include "gettext.h"
Expand All @@ -9,7 +9,6 @@
#include "tag.h"
#include "blob.h"
#include "refs.h"
#include "builtin.h"
#include "exec-cmd.h"
#include "object-name.h"
#include "parse-options.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/diff-files.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@
*
* Copyright (C) Linus Torvalds, 2005
*/
#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "diff.h"
#include "diff-merges.h"
#include "commit.h"
#include "preload-index.h"
#include "revision.h"
#include "builtin.h"
#include "submodule.h"

static const char diff_files_usage[] =
Expand Down
3 changes: 1 addition & 2 deletions builtin/diff-index.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "diff.h"
#include "diff-merges.h"
#include "commit.h"
#include "preload-index.h"
#include "revision.h"
#include "builtin.h"
#include "setup.h"
#include "submodule.h"

Expand Down
3 changes: 1 addition & 2 deletions builtin/diff-tree.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "diff.h"
#include "commit.h"
#include "gettext.h"
#include "hex.h"
#include "log-tree.h"
#include "builtin.h"
#include "submodule.h"
#include "read-cache-ll.h"
#include "repository.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright (c) 2006 Junio C Hamano
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "builtin.h"
#include "config.h"
#include "ewah/ewok.h"
#include "lockfile.h"
Expand All @@ -20,7 +20,6 @@
#include "read-cache-ll.h"
#include "revision.h"
#include "log-tree.h"
#include "builtin.h"
#include "setup.h"
#include "submodule.h"
#include "oid-array.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/difftool.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@
* Copyright (C) 2016 Johannes Schindelin
*/
#define USE_THE_INDEX_VARIABLE
#include "cache.h"
#include "builtin.h"
#include "abspath.h"
#include "config.h"
#include "copy.h"
#include "builtin.h"
#include "run-command.h"
#include "environment.h"
#include "exec-cmd.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/fast-export.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* Copyright (C) 2007 Johannes E. Schindelin
*/
#include "builtin.h"
#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "hex.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/fast-import.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "builtin.h"
#include "abspath.h"
#include "cache.h"
#include "environment.h"
#include "gettext.h"
#include "hex.h"
Expand Down
3 changes: 1 addition & 2 deletions builtin/fetch.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* "git fetch"
*/
#include "cache.h"
#include "builtin.h"
#include "advice.h"
#include "config.h"
#include "gettext.h"
Expand All @@ -15,7 +15,6 @@
#include "oidset.h"
#include "oid-array.h"
#include "commit.h"
#include "builtin.h"
#include "string-list.h"
#include "remote.h"
#include "transport.h"
Expand Down
1 change: 0 additions & 1 deletion builtin/for-each-ref.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "builtin.h"
#include "cache.h"
#include "config.h"
#include "gettext.h"
#include "refs.h"
Expand Down
Loading

0 comments on commit bc5c5ec

Please sign in to comment.