alloc.h: move ALLOC_GROW() functions from cache.h

This allows us to replace includes of cache.h with includes of the much smaller alloc.h in many places. It does mean that we also need to add includes of alloc.h in a number of C files. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Feb 24, 2023 at 00:09 UTC 36bf19589055fb71aac0ed6719dfe5b385adc2bf
91 files changed +219 -134
add-patch.c
+1
@@ -1,5 +1,6 @@
1 #include "cache.h"
2 #include "add-interactive.h"
3 +#include "alloc.h"
4 #include "strbuf.h"
5 #include "run-command.h"
6 #include "strvec.h"
alias.c
+3 -1
@@ -1,6 +1,8 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 #include "alias.h"
3 +#include "alloc.h"
4 #include "config.h"
5 +#include "gettext.h"
6 #include "string-list.h"
7
8 struct config_alias_data {
alloc.h
+75
@@ -17,4 +17,79 @@ void *alloc_object_node(struct repository *r);
17 struct alloc_state *allocate_alloc_state(void);
18 void clear_alloc_state(struct alloc_state *s);
19
20 +#define alloc_nr(x) (((x)+16)*3/2)
21 +
22 +/**
23 + * Dynamically growing an array using realloc() is error prone and boring.
24 + *
25 + * Define your array with:
26 + *
27 + * - a pointer (`item`) that points at the array, initialized to `NULL`
28 + * (although please name the variable based on its contents, not on its
29 + * type);
30 + *
31 + * - an integer variable (`alloc`) that keeps track of how big the current
32 + * allocation is, initialized to `0`;
33 + *
34 + * - another integer variable (`nr`) to keep track of how many elements the
35 + * array currently has, initialized to `0`.
36 + *
37 + * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
38 + * alloc)`. This ensures that the array can hold at least `n` elements by
39 + * calling `realloc(3)` and adjusting `alloc` variable.
40 + *
41 + * ------------
42 + * sometype *item;
43 + * size_t nr;
44 + * size_t alloc
45 + *
46 + * for (i = 0; i < nr; i++)
47 + * if (we like item[i] already)
48 + * return;
49 + *
50 + * // we did not like any existing one, so add one
51 + * ALLOC_GROW(item, nr + 1, alloc);
52 + * item[nr++] = value you like;
53 + * ------------
54 + *
55 + * You are responsible for updating the `nr` variable.
56 + *
57 + * If you need to specify the number of elements to allocate explicitly
58 + * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
59 + *
60 + * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
61 + * added niceties.
62 + *
63 + * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
64 + */
65 +#define ALLOC_GROW(x, nr, alloc) \
66 + do { \
67 + if ((nr) > alloc) { \
68 + if (alloc_nr(alloc) < (nr)) \
69 + alloc = (nr); \
70 + else \
71 + alloc = alloc_nr(alloc); \
72 + REALLOC_ARRAY(x, alloc); \
73 + } \
74 + } while (0)
75 +
76 +/*
77 + * Similar to ALLOC_GROW but handles updating of the nr value and
78 + * zeroing the bytes of the newly-grown array elements.
79 + *
80 + * DO NOT USE any expression with side-effect for any of the
81 + * arguments.
82 + */
83 +#define ALLOC_GROW_BY(x, nr, increase, alloc) \
84 + do { \
85 + if (increase) { \
86 + size_t new_nr = nr + (increase); \
87 + if (new_nr < nr) \
88 + BUG("negative growth in ALLOC_GROW_BY"); \
89 + ALLOC_GROW(x, new_nr, alloc); \
90 + memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
91 + nr = new_nr; \
92 + } \
93 + } while (0)
94 +
95 #endif
apply.c
+1
@@ -8,6 +8,7 @@
8 */
9
10 #include "cache.h"
11 +#include "alloc.h"
12 #include "config.h"
13 #include "object-store.h"
14 #include "blob.h"
archive-tar.c
+2 -1
@@ -1,7 +1,8 @@
1 /*
2 * Copyright (c) 2005, 2006 Rene Scharfe
3 */
4 -#include "cache.h"
4 +#include "git-compat-util.h"
5 +#include "alloc.h"
6 #include "config.h"
7 #include "tar.h"
8 #include "archive.h"
archive.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "refs.h"
5 #include "object-store.h"
attr.c
+1
@@ -7,6 +7,7 @@
7 */
8
9 #include "cache.h"
10 +#include "alloc.h"
11 #include "config.h"
12 #include "exec-cmd.h"
13 #include "attr.h"
builtin/blame.c
+2 -1
@@ -5,7 +5,8 @@
5 * See COPYING for licensing conditions
6 */
7
8 -#include "cache.h"
8 +#include "git-compat-util.h"
9 +#include "alloc.h"
10 #include "config.h"
11 #include "color.h"
12 #include "builtin.h"
builtin/cat-file.c
+1
@@ -5,6 +5,7 @@
5 */
6 #define USE_THE_INDEX_VARIABLE
7 #include "cache.h"
8 +#include "alloc.h"
9 #include "config.h"
10 #include "builtin.h"
11 #include "diff.h"
builtin/checkout--worker.c
+1
@@ -1,4 +1,5 @@
1 #include "builtin.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "entry.h"
5 #include "parallel-checkout.h"
builtin/config.c
+1 -1
@@ -1,5 +1,5 @@
1 #include "builtin.h"
2 -#include "cache.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "color.h"
5 #include "parse-options.h"
builtin/credential-cache--daemon.c
+1
@@ -1,4 +1,5 @@
1 #include "builtin.h"
2 +#include "alloc.h"
3 #include "parse-options.h"
4
5 #ifndef NO_UNIX_SOCKETS
builtin/fetch-pack.c
+1
@@ -1,4 +1,5 @@
1 #include "builtin.h"
2 +#include "alloc.h"
3 #include "pkt-line.h"
4 #include "fetch-pack.h"
5 #include "remote.h"
builtin/fsmonitor--daemon.c
+1
@@ -1,4 +1,5 @@
1 #include "builtin.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "parse-options.h"
5 #include "fsmonitor.h"
builtin/grep.c
+1
@@ -4,6 +4,7 @@
4 * Copyright (c) 2006 Junio C Hamano
5 */
6 #include "cache.h"
7 +#include "alloc.h"
8 #include "repository.h"
9 #include "config.h"
10 #include "blob.h"
builtin/index-pack.c
+1
@@ -1,4 +1,5 @@
1 #include "builtin.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "delta.h"
5 #include "pack.h"
builtin/log.c
+2 -1
@@ -4,7 +4,8 @@
4 * (C) Copyright 2006 Linus Torvalds
5 * 2006 Junio Hamano
6 */
7 -#include "cache.h"
7 +#include "git-compat-util.h"
8 +#include "alloc.h"
9 #include "config.h"
10 #include "refs.h"
11 #include "object-store.h"
builtin/merge.c
+1
@@ -8,6 +8,7 @@
8
9 #define USE_THE_INDEX_VARIABLE
10 #include "cache.h"
11 +#include "alloc.h"
12 #include "config.h"
13 #include "parse-options.h"
14 #include "builtin.h"
builtin/mktree.c
+1
@@ -4,6 +4,7 @@
4 * Copyright (c) Junio C Hamano, 2006, 2009
5 */
6 #include "builtin.h"
7 +#include "alloc.h"
8 #include "quote.h"
9 #include "tree.h"
10 #include "parse-options.h"
builtin/mv.c
+1
@@ -5,6 +5,7 @@
5 */
6 #define USE_THE_INDEX_VARIABLE
7 #include "builtin.h"
8 +#include "alloc.h"
9 #include "config.h"
10 #include "pathspec.h"
11 #include "lockfile.h"
builtin/name-rev.c
+1 -1
@@ -1,5 +1,5 @@
1 #include "builtin.h"
2 -#include "cache.h"
2 +#include "alloc.h"
3 #include "repository.h"
4 #include "config.h"
5 #include "commit.h"
builtin/pack-objects.c
+1 -1
@@ -1,5 +1,5 @@
1 #include "builtin.h"
2 -#include "cache.h"
2 +#include "alloc.h"
3 #include "repository.h"
4 #include "config.h"
5 #include "attr.h"
builtin/repack.c
+1 -1
@@ -1,5 +1,5 @@
1 #include "builtin.h"
2 -#include "cache.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "dir.h"
5 #include "parse-options.h"
builtin/rev-parse.c
+1
@@ -5,6 +5,7 @@
5 */
6 #define USE_THE_INDEX_VARIABLE
7 #include "cache.h"
8 +#include "alloc.h"
9 #include "config.h"
10 #include "commit.h"
11 #include "refs.h"
builtin/revert.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "builtin.h"
5 #include "parse-options.h"
builtin/rm.c
+1
@@ -5,6 +5,7 @@
5 */
6 #define USE_THE_INDEX_VARIABLE
7 #include "builtin.h"
8 +#include "alloc.h"
9 #include "advice.h"
10 #include "config.h"
11 #include "lockfile.h"
builtin/submodule--helper.c
+1
@@ -1,5 +1,6 @@
1 #define USE_THE_INDEX_VARIABLE
2 #include "builtin.h"
3 +#include "alloc.h"
4 #include "repository.h"
5 #include "cache.h"
6 #include "config.h"
bulk-checkin.c
+2 -1
@@ -1,7 +1,8 @@
1 /*
2 * Copyright (c) 2011, Google Inc.
3 */
4 -#include "cache.h"
4 +#include "git-compat-util.h"
5 +#include "alloc.h"
6 #include "bulk-checkin.h"
7 #include "lockfile.h"
8 #include "repository.h"
cache-tree.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "lockfile.h"
4 #include "tree.h"
5 #include "tree-walk.h"
cache.h
-75
@@ -656,81 +656,6 @@ void initialize_repository_version(int hash_algo, int reinit);
656 void sanitize_stdfds(void);
657 int daemonize(void);
658
659 -#define alloc_nr(x) (((x)+16)*3/2)
660 -
661 -/**
662 - * Dynamically growing an array using realloc() is error prone and boring.
663 - *
664 - * Define your array with:
665 - *
666 - * - a pointer (`item`) that points at the array, initialized to `NULL`
667 - * (although please name the variable based on its contents, not on its
668 - * type);
669 - *
670 - * - an integer variable (`alloc`) that keeps track of how big the current
671 - * allocation is, initialized to `0`;
672 - *
673 - * - another integer variable (`nr`) to keep track of how many elements the
674 - * array currently has, initialized to `0`.
675 - *
676 - * Then before adding `n`th element to the item, call `ALLOC_GROW(item, n,
677 - * alloc)`. This ensures that the array can hold at least `n` elements by
678 - * calling `realloc(3)` and adjusting `alloc` variable.
679 - *
680 - * ------------
681 - * sometype *item;
682 - * size_t nr;
683 - * size_t alloc
684 - *
685 - * for (i = 0; i < nr; i++)
686 - * if (we like item[i] already)
687 - * return;
688 - *
689 - * // we did not like any existing one, so add one
690 - * ALLOC_GROW(item, nr + 1, alloc);
691 - * item[nr++] = value you like;
692 - * ------------
693 - *
694 - * You are responsible for updating the `nr` variable.
695 - *
696 - * If you need to specify the number of elements to allocate explicitly
697 - * then use the macro `REALLOC_ARRAY(item, alloc)` instead of `ALLOC_GROW`.
698 - *
699 - * Consider using ALLOC_GROW_BY instead of ALLOC_GROW as it has some
700 - * added niceties.
701 - *
702 - * DO NOT USE any expression with side-effect for 'x', 'nr', or 'alloc'.
703 - */
704 -#define ALLOC_GROW(x, nr, alloc) \
705 - do { \
706 - if ((nr) > alloc) { \
707 - if (alloc_nr(alloc) < (nr)) \
708 - alloc = (nr); \
709 - else \
710 - alloc = alloc_nr(alloc); \
711 - REALLOC_ARRAY(x, alloc); \
712 - } \
713 - } while (0)
714 -
715 -/*
716 - * Similar to ALLOC_GROW but handles updating of the nr value and
717 - * zeroing the bytes of the newly-grown array elements.
718 - *
719 - * DO NOT USE any expression with side-effect for any of the
720 - * arguments.
721 - */
722 -#define ALLOC_GROW_BY(x, nr, increase, alloc) \
723 - do { \
724 - if (increase) { \
725 - size_t new_nr = nr + (increase); \
726 - if (new_nr < nr) \
727 - BUG("negative growth in ALLOC_GROW_BY"); \
728 - ALLOC_GROW(x, new_nr, alloc); \
729 - memset((x) + nr, 0, sizeof(*(x)) * (increase)); \
730 - nr = new_nr; \
731 - } \
732 - } while (0)
733 -
659 /* Initialize and use the cache information */
660 struct lock_file;
661 void preload_index(struct index_state *index,
chunk-format.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "chunk-format.h"
4 #include "csum-file.h"
5
commit-reach.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "commit.h"
4 #include "commit-graph.h"
5 #include "decorate.h"
compat/mingw.c
+1
@@ -7,6 +7,7 @@
7 #include "../strbuf.h"
8 #include "../run-command.h"
9 #include "../cache.h"
10 +#include "../alloc.h"
11 #include "win32/lazyload.h"
12 #include "../config.h"
13 #include "dir.h"
config.c
+2 -1
@@ -5,7 +5,8 @@
5 * Copyright (C) Johannes Schindelin, 2005
6 *
7 */
8 -#include "cache.h"
8 +#include "git-compat-util.h"
9 +#include "alloc.h"
10 #include "date.h"
11 #include "branch.h"
12 #include "config.h"
daemon.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "pkt-line.h"
5 #include "run-command.h"
delta-islands.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "attr.h"
4 #include "object.h"
5 #include "blob.h"
diff.c
+1
@@ -2,6 +2,7 @@
2 * Copyright (C) 2005 Junio C Hamano
3 */
4 #include "cache.h"
5 +#include "alloc.h"
6 #include "config.h"
7 #include "tempfile.h"
8 #include "quote.h"
diffcore-rename.c
+1
@@ -3,6 +3,7 @@
3 * Copyright (C) 2005 Junio C Hamano
4 */
5 #include "cache.h"
6 +#include "alloc.h"
7 #include "diff.h"
8 #include "diffcore.h"
9 #include "object-store.h"
dir-iterator.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "dir.h"
4 #include "iterator.h"
5 #include "dir-iterator.h"
dir.c
+2 -1
@@ -5,7 +5,8 @@
5 * Copyright (C) Linus Torvalds, 2005-2006
6 * Junio Hamano, 2005-2006
7 */
8 -#include "cache.h"
8 +#include "git-compat-util.h"
9 +#include "alloc.h"
10 #include "config.h"
11 #include "dir.h"
12 #include "object-store.h"
ewah/bitmap.c
+2 -1
@@ -16,7 +16,8 @@
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19 -#include "cache.h"
19 +#include "git-compat-util.h"
20 +#include "alloc.h"
21 #include "ewok.h"
22
23 #define EWAH_MASK(x) ((eword_t)1 << (x % BITS_IN_EWORD))
ewah/ewah_bitmap.c
+1 -1
@@ -17,9 +17,9 @@
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19 #include "git-compat-util.h"
20 +#include "alloc.h"
21 #include "ewok.h"
22 #include "ewok_rlw.h"
22 -#include "cache.h"
23
24 static inline size_t min_size(size_t a, size_t b)
25 {
fetch-pack.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "repository.h"
4 #include "config.h"
5 #include "lockfile.h"
fmt-merge-msg.c
+1
@@ -1,4 +1,5 @@
1 #include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "refs.h"
5 #include "object-store.h"
fsck.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "object-store.h"
4 #include "repository.h"
5 #include "object.h"
fsmonitor-settings.c
+2 -1
@@ -1,5 +1,6 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 #include "config.h"
3 +#include "gettext.h"
4 #include "repository.h"
5 #include "fsmonitor-ipc.h"
6 #include "fsmonitor-settings.h"
help.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "builtin.h"
5 #include "exec-cmd.h"
http-backend.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "repository.h"
5 #include "refs.h"
line-log.c
+1
@@ -1,4 +1,5 @@
1 #include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "line-range.h"
4 #include "cache.h"
5 #include "tag.h"
list-objects-filter-options.c
+3 -1
@@ -1,6 +1,8 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "commit.h"
4 #include "config.h"
5 +#include "gettext.h"
6 #include "revision.h"
7 #include "strvec.h"
8 #include "list-objects.h"
list-objects-filter.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "dir.h"
4 #include "tag.h"
5 #include "commit.h"
midx.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "csum-file.h"
5 #include "dir.h"
object-file.c
+2 -1
@@ -6,7 +6,8 @@
6 * This handles basic git object files - packing, unpacking,
7 * creation etc.
8 */
9 -#include "cache.h"
9 +#include "git-compat-util.h"
10 +#include "alloc.h"
11 #include "config.h"
12 #include "string-list.h"
13 #include "lockfile.h"
oid-array.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "oid-array.h"
4 #include "hash-lookup.h"
5
pack-bitmap-write.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "object-store.h"
4 #include "commit.h"
5 #include "tag.h"
pack-bitmap.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "commit.h"
4 #include "strbuf.h"
5 #include "tag.h"
pack-objects.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "object.h"
4 #include "pack.h"
5 #include "pack-objects.h"
packfile.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "list.h"
4 #include "pack.h"
5 #include "repository.h"
parallel-checkout.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "entry.h"
5 #include "parallel-checkout.h"
pretty.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "commit.h"
5 #include "utf8.h"
prio-queue.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "prio-queue.h"
4
5 static inline int compare(struct prio_queue *queue, int i, int j)
quote.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "quote.h"
4 #include "strvec.h"
5
read-cache.c
+1
@@ -4,6 +4,7 @@
4 * Copyright (C) Linus Torvalds, 2005
5 */
6 #include "cache.h"
7 +#include "alloc.h"
8 #include "config.h"
9 #include "diff.h"
10 #include "diffcore.h"
ref-filter.c
+2 -3
@@ -1,5 +1,5 @@
1 -#include "builtin.h"
2 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "parse-options.h"
4 #include "refs.h"
5 #include "wildmatch.h"
@@ -13,7 +13,6 @@
13 #include "ref-filter.h"
14 #include "revision.h"
15 #include "utf8.h"
16 -#include "git-compat-util.h"
16 #include "version.h"
17 #include "trailer.h"
18 #include "wt-status.h"
reflog-walk.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "commit.h"
4 #include "refs.h"
5 #include "diff.h"
refs.c
+2 -1
@@ -2,7 +2,8 @@
2 * The backend-independent part of the reference module.
3 */
4
5 -#include "cache.h"
5 +#include "git-compat-util.h"
6 +#include "alloc.h"
7 #include "config.h"
8 #include "hashmap.h"
9 #include "lockfile.h"
refs/packed-backend.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "../cache.h"
1 +#include "../git-compat-util.h"
2 +#include "../alloc.h"
3 #include "../config.h"
4 #include "../refs.h"
5 #include "refs-internal.h"
refs/ref-cache.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "../cache.h"
1 +#include "../git-compat-util.h"
2 +#include "../alloc.h"
3 #include "../refs.h"
4 #include "refs-internal.h"
5 #include "ref-cache.h"
refspec.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "strvec.h"
4 #include "refs.h"
5 #include "refspec.h"
remote-curl.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "remote.h"
5 #include "connect.h"
remote.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "remote.h"
5 #include "urlmatch.h"
rerere.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "lockfile.h"
5 #include "string-list.h"
revision.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "object-store.h"
5 #include "tag.h"
sequencer.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "lockfile.h"
5 #include "dir.h"
server-info.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "dir.h"
4 #include "repository.h"
5 #include "refs.h"
shallow.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "repository.h"
4 #include "tempfile.h"
5 #include "lockfile.h"
sigchain.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "sigchain.h"
4
5 #define SIGCHAIN_MAX_SIGNALS 32
sparse-index.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "repository.h"
4 #include "sparse-index.h"
5 #include "tree.h"
split-index.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "split-index.h"
4 #include "ewah/ewok.h"
5
strbuf.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "refs.h"
4 #include "string-list.h"
5 #include "utf8.h"
string-list.c
+2 -1
@@ -1,5 +1,6 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 #include "string-list.h"
3 +#include "alloc.h"
4
5 void string_list_init_nodup(struct string_list *list)
6 {
strvec.c
+2 -1
@@ -1,5 +1,6 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 #include "strvec.h"
3 +#include "alloc.h"
4 #include "strbuf.h"
5
6 const char *empty_strvec[] = { NULL };
submodule-config.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "dir.h"
4 #include "repository.h"
5 #include "config.h"
submodule.c
+2 -2
@@ -1,5 +1,5 @@
1 -
2 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "repository.h"
4 #include "config.h"
5 #include "submodule-config.h"
t/helper/test-reach.c
+1 -1
@@ -1,5 +1,5 @@
1 #include "test-tool.h"
2 -#include "cache.h"
2 +#include "alloc.h"
3 #include "commit.h"
4 #include "commit-reach.h"
5 #include "config.h"
trace2/tr2_tls.c
+3 -1
@@ -1,5 +1,7 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "thread-utils.h"
4 +#include "trace.h"
5 #include "trace2/tr2_tls.h"
6
7 /*
trailer.c
+1
@@ -1,4 +1,5 @@
1 #include "cache.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "string-list.h"
5 #include "run-command.h"
transport.c
+3 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "transport.h"
5 #include "hook.h"
@@ -10,6 +11,7 @@
11 #include "walker.h"
12 #include "bundle.h"
13 #include "dir.h"
14 +#include "gettext.h"
15 #include "refs.h"
16 #include "refspec.h"
17 #include "branch.h"
tree-walk.c
+1
@@ -1,5 +1,6 @@
1 #include "cache.h"
2 #include "tree-walk.h"
3 +#include "alloc.h"
4 #include "dir.h"
5 #include "object-store.h"
6 #include "tree.h"
userdiff.c
+3 -1
@@ -1,7 +1,9 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "config.h"
4 #include "userdiff.h"
5 #include "attr.h"
6 +#include "strbuf.h"
7
8 static struct userdiff_driver *drivers;
9 static int ndrivers;
worktree.c
+2 -1
@@ -1,4 +1,5 @@
1 -#include "cache.h"
1 +#include "git-compat-util.h"
2 +#include "alloc.h"
3 #include "repository.h"
4 #include "refs.h"
5 #include "strbuf.h"