treewide: remove unnecessary includes of cache.h

The last several commits were geared at replacing the include of cache.h in strbuf.c with an include of git-compat-util.h. Unfortunately, I had to drop a patch moving some functions from cache.h to object-name.h, due to excessive conflicts with other in-flight topics. However, even without that patch, the series of patches so far allows us to modify a number of C files to replace an include of cache.h with git-compat-util.h. Do that to reduce our dependencies. (If we could have kept our object-name.h patch in this series, it would have also let us reduce the includes in checkout.c and fmt-merge-msg.c in addition to strbuf.c). Just to ensure that nothing else was bringing in cache.h, all of the affected files have been checked to ensure that gcc -E -I. $SOURCE_FILE | grep '"cache.h"' found no hits and that make DEVELOPER=1 ${OBJECT_FILE_FOR_SOURCE_FILE} successfully compiles without warnings. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Mar 21, 2023 at 06:26 UTC a64acf7298e87740a596123d2b39fefe623fd46f
12 files changed +17 -12
compat/terminal.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 #include "compat/terminal.h"
3 #include "gettext.h"
4 #include "sigchain.h"
gpg-interface.c
+1 -1
@@ -1,4 +1,4 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 #include "commit.h"
3 #include "config.h"
4 #include "gettext.h"
lockfile.c
+1 -1
@@ -2,7 +2,7 @@
2 * Copyright (c) 2005, Junio C Hamano
3 */
4
5 -#include "cache.h"
5 +#include "git-compat-util.h"
6 #include "abspath.h"
7 #include "gettext.h"
8 #include "lockfile.h"
parse-options.c
-1
@@ -1,7 +1,6 @@
1 #include "git-compat-util.h"
2 #include "parse-options.h"
3 #include "abspath.h"
4 -#include "cache.h"
4 #include "config.h"
5 #include "commit.h"
6 #include "color.h"
t/helper/test-delta.c
-1
@@ -11,7 +11,6 @@
11 #include "test-tool.h"
12 #include "git-compat-util.h"
13 #include "delta.h"
14 -#include "cache.h"
14 #include "wrapper.h"
15
16 static const char usage_str[] =
t/helper/test-trace2.c
+1 -1
@@ -1,9 +1,9 @@
1 #include "test-tool.h"
2 -#include "cache.h"
2 #include "strvec.h"
3 #include "run-command.h"
4 #include "exec-cmd.h"
5 #include "config.h"
6 +#include "trace2.h"
7
8 typedef int(fn_unit_test)(int argc, const char **argv);
9
tempfile.c
+2 -1
@@ -42,7 +42,8 @@
42 * file created by its parent.
43 */
44
45 -#include "cache.h"
45 +#include "git-compat-util.h"
46 +#include "path.h"
47 #include "tempfile.h"
48 #include "sigchain.h"
49 #include "wrapper.h"
trace2/tr2_cfg.c
+3 -1
@@ -1,5 +1,7 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 #include "config.h"
3 +#include "strbuf.h"
4 +#include "trace2.h"
5 #include "trace2/tr2_cfg.h"
6 #include "trace2/tr2_sysenv.h"
7
trace2/tr2_cmd_name.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "strbuf.h"
3 #include "trace2/tr2_cmd_name.h"
4
5 #define TR2_ENVVAR_PARENT_NAME "GIT_TRACE2_PARENT_NAME"
trace2/tr2_dst.c
+2 -1
@@ -1,6 +1,7 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 #include "abspath.h"
3 #include "sigchain.h"
4 +#include "strbuf.h"
5 #include "trace2/tr2_dst.h"
6 #include "trace2/tr2_sid.h"
7 #include "trace2/tr2_sysenv.h"
trace2/tr2_sid.c
+2 -1
@@ -1,5 +1,6 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 #include "hex.h"
3 +#include "strbuf.h"
4 #include "trace2/tr2_tbuf.h"
5 #include "trace2/tr2_sid.h"
6
usage.c
+2 -1
@@ -3,8 +3,9 @@
3 *
4 * Copyright (C) Linus Torvalds, 2005
5 */
6 -#include "cache.h"
6 +#include "git-compat-util.h"
7 #include "gettext.h"
8 +#include "trace2.h"
9 #include "wrapper.h"
10
11 static void vreportf(const char *prefix, const char *err, va_list params)