From 36bf19589055fb71aac0ed6719dfe5b385adc2bf Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Fri, 24 Feb 2023 00:09:24 +0000 Subject: [PATCH] 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 Signed-off-by: Junio C Hamano --- add-patch.c | 1 + alias.c | 4 +- alloc.h | 75 ++++++++++++++++++++++++++++++ apply.c | 1 + archive-tar.c | 3 +- archive.c | 3 +- attr.c | 1 + builtin/blame.c | 3 +- builtin/cat-file.c | 1 + builtin/checkout--worker.c | 1 + builtin/config.c | 2 +- builtin/credential-cache--daemon.c | 1 + builtin/fetch-pack.c | 1 + builtin/fsmonitor--daemon.c | 1 + builtin/grep.c | 1 + builtin/index-pack.c | 1 + builtin/log.c | 3 +- builtin/merge.c | 1 + builtin/mktree.c | 1 + builtin/mv.c | 1 + builtin/name-rev.c | 2 +- builtin/pack-objects.c | 2 +- builtin/repack.c | 2 +- builtin/rev-parse.c | 1 + builtin/revert.c | 3 +- builtin/rm.c | 1 + builtin/submodule--helper.c | 1 + bulk-checkin.c | 3 +- cache-tree.c | 3 +- cache.h | 75 ------------------------------ chunk-format.c | 3 +- commit-reach.c | 3 +- compat/mingw.c | 1 + config.c | 3 +- daemon.c | 1 + delta-islands.c | 3 +- diff.c | 1 + diffcore-rename.c | 1 + dir-iterator.c | 3 +- dir.c | 3 +- ewah/bitmap.c | 3 +- ewah/ewah_bitmap.c | 2 +- fetch-pack.c | 3 +- fmt-merge-msg.c | 1 + fsck.c | 3 +- fsmonitor-settings.c | 3 +- help.c | 3 +- http-backend.c | 3 +- line-log.c | 1 + list-objects-filter-options.c | 4 +- list-objects-filter.c | 1 + midx.c | 3 +- object-file.c | 3 +- oid-array.c | 3 +- pack-bitmap-write.c | 3 +- pack-bitmap.c | 3 +- pack-objects.c | 3 +- packfile.c | 3 +- parallel-checkout.c | 1 + pretty.c | 1 + prio-queue.c | 3 +- quote.c | 1 + read-cache.c | 1 + ref-filter.c | 5 +- reflog-walk.c | 3 +- refs.c | 3 +- refs/packed-backend.c | 3 +- refs/ref-cache.c | 3 +- refspec.c | 3 +- remote-curl.c | 3 +- remote.c | 3 +- rerere.c | 3 +- revision.c | 3 +- sequencer.c | 1 + server-info.c | 3 +- shallow.c | 3 +- sigchain.c | 3 +- sparse-index.c | 1 + split-index.c | 1 + strbuf.c | 3 +- string-list.c | 3 +- strvec.c | 3 +- submodule-config.c | 1 + submodule.c | 4 +- t/helper/test-reach.c | 2 +- trace2/tr2_tls.c | 4 +- trailer.c | 1 + transport.c | 4 +- tree-walk.c | 1 + userdiff.c | 4 +- worktree.c | 3 +- 91 files changed, 219 insertions(+), 134 deletions(-) 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/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.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..7f12ebf04c 100644 --- a/apply.c +++ b/apply.c @@ -8,6 +8,7 @@ */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "object-store.h" #include "blob.h" diff --git a/archive-tar.c b/archive-tar.c index f8fad2946e..9406f03e80 100644 --- a/archive-tar.c +++ b/archive-tar.c @@ -1,7 +1,8 @@ /* * Copyright (c) 2005, 2006 Rene Scharfe */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "tar.h" #include "archive.h" diff --git a/archive.c b/archive.c index f2a8756d84..35719e5e36 100644 --- a/archive.c +++ b/archive.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.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/builtin/blame.c b/builtin/blame.c index 71f925e456..4d1609c9ac 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -5,7 +5,8 @@ * 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" diff --git a/builtin/cat-file.c b/builtin/cat-file.c index cc17635e76..5b8be7cb63 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -5,6 +5,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "builtin.h" #include "diff.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/config.c b/builtin/config.c index 060cf9f3e0..ca006e9cc1 100644 --- a/builtin/config.c +++ b/builtin/config.c @@ -1,5 +1,5 @@ #include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "config.h" #include "color.h" #include "parse-options.h" diff --git a/builtin/credential-cache--daemon.c b/builtin/credential-cache--daemon.c index f3c89831d4..590aefc6ea 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/fetch-pack.c b/builtin/fetch-pack.c index afe679368d..113f22c09d 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "alloc.h" #include "pkt-line.h" #include "fetch-pack.h" #include "remote.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/grep.c b/builtin/grep.c index f7821c5fbb..a08e5841dd 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -4,6 +4,7 @@ * Copyright (c) 2006 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "blob.h" diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 6648f2daef..7e4b69f9a3 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -1,4 +1,5 @@ #include "builtin.h" +#include "alloc.h" #include "config.h" #include "delta.h" #include "pack.h" diff --git a/builtin/log.c b/builtin/log.c index 04412dd9c9..85540963d9 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -4,7 +4,8 @@ * (C) Copyright 2006 Linus Torvalds * 2006 Junio Hamano */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h" diff --git a/builtin/merge.c b/builtin/merge.c index 0a3c10a096..716a23f880 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -8,6 +8,7 @@ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "parse-options.h" #include "builtin.h" diff --git a/builtin/mktree.c b/builtin/mktree.c index 06d81400f5..ec721ffb94 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -4,6 +4,7 @@ * Copyright (c) Junio C Hamano, 2006, 2009 */ #include "builtin.h" +#include "alloc.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..29752e7afe 100644 --- a/builtin/name-rev.c +++ b/builtin/name-rev.c @@ -1,5 +1,5 @@ #include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "commit.h" diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 74a167a180..72c33fd739 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -1,5 +1,5 @@ #include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "attr.h" diff --git a/builtin/repack.c b/builtin/repack.c index f649379531..545b368168 100644 --- a/builtin/repack.c +++ b/builtin/repack.c @@ -1,5 +1,5 @@ #include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "config.h" #include "dir.h" #include "parse-options.h" diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c index e67999e5eb..fd4f59ff2b 100644 --- a/builtin/rev-parse.c +++ b/builtin/rev-parse.c @@ -5,6 +5,7 @@ */ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "commit.h" #include "refs.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/submodule--helper.c b/builtin/submodule--helper.c index 4c173d8b37..9edc785d8d 100644 --- a/builtin/submodule--helper.c +++ b/builtin/submodule--helper.c @@ -1,5 +1,6 @@ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "repository.h" #include "cache.h" #include "config.h" diff --git a/bulk-checkin.c b/bulk-checkin.c index 855b68ec23..62ed104c7e 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -1,7 +1,8 @@ /* * Copyright (c) 2011, Google Inc. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "bulk-checkin.h" #include "lockfile.h" #include "repository.h" diff --git a/cache-tree.c b/cache-tree.c index 88c2c04f87..256f98c3c3 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "lockfile.h" #include "tree.h" #include "tree-walk.h" diff --git a/cache.h b/cache.h index 12789903e8..0f1f9dde56 100644 --- a/cache.h +++ b/cache.h @@ -656,81 +656,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, 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/commit-reach.c b/commit-reach.c index 2e33c599a8..1f0ddc5c88 100644 --- a/commit-reach.c +++ b/commit-reach.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "commit-graph.h" #include "decorate.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..1d22f23251 100644 --- a/config.c +++ b/config.c @@ -5,7 +5,8 @@ * 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" 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/delta-islands.c b/delta-islands.c index 8b234cb85b..1cfdc2cc04 100644 --- a/delta-islands.c +++ b/delta-islands.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "attr.h" #include "object.h" #include "blob.h" diff --git a/diff.c b/diff.c index 329eebf16a..3c3565995d 100644 --- a/diff.c +++ b/diff.c @@ -2,6 +2,7 @@ * Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "tempfile.h" #include "quote.h" diff --git a/diffcore-rename.c b/diffcore-rename.c index c0422d9e70..62c0299984 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -3,6 +3,7 @@ * Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "diff.h" #include "diffcore.h" #include "object-store.h" diff --git a/dir-iterator.c b/dir-iterator.c index 3764dd81a1..87364d68a2 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 4e99f0c868..d3f1aeaca3 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/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 . */ -#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 . */ #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..271e2a6fbd 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "lockfile.h" diff --git a/fmt-merge-msg.c b/fmt-merge-msg.c index f317f12990..d4d6fd3d9d 100644 --- a/fmt-merge-msg.c +++ b/fmt-merge-msg.c @@ -1,4 +1,5 @@ #include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h" diff --git a/fsck.c b/fsck.c index 2b18717ee8..20e1aac39a 100644 --- a/fsck.c +++ b/fsck.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "object-store.h" #include "repository.h" #include "object.h" 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/help.c b/help.c index 812af4cdea..5f84a50b94 100644 --- a/help.c +++ b/help.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "builtin.h" #include "exec-cmd.h" diff --git a/http-backend.c b/http-backend.c index 8ab58e55f8..d756d120dc 100644 --- a/http-backend.c +++ b/http-backend.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "repository.h" #include "refs.h" diff --git a/line-log.c b/line-log.c index a7f3e7f6ce..4956eae748 100644 --- a/line-log.c +++ b/line-log.c @@ -1,4 +1,5 @@ #include "git-compat-util.h" +#include "alloc.h" #include "line-range.h" #include "cache.h" #include "tag.h" 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.c b/list-objects-filter.c index 7ed21cb299..e40ea9b0a8 100644 --- a/list-objects-filter.c +++ b/list-objects-filter.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "dir.h" #include "tag.h" #include "commit.h" diff --git a/midx.c b/midx.c index 7cfad04a24..84d7a53d66 100644 --- a/midx.c +++ b/midx.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "csum-file.h" #include "dir.h" diff --git a/object-file.c b/object-file.c index 939865c1ae..18d65220d7 100644 --- a/object-file.c +++ b/object-file.c @@ -6,7 +6,8 @@ * 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 "string-list.h" #include "lockfile.h" 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/pack-bitmap-write.c b/pack-bitmap-write.c index cfa67a510f..155939e77b 100644 --- a/pack-bitmap-write.c +++ b/pack-bitmap-write.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "object-store.h" #include "commit.h" #include "tag.h" diff --git a/pack-bitmap.c b/pack-bitmap.c index d2a42abf28..5a97834120 100644 --- a/pack-bitmap.c +++ b/pack-bitmap.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "strbuf.h" #include "tag.h" 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/packfile.c b/packfile.c index 79e21ab18e..3e3063de44 100644 --- a/packfile.c +++ b/packfile.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "list.h" #include "pack.h" #include "repository.h" diff --git a/parallel-checkout.c b/parallel-checkout.c index 4f6819f240..decdc8d8a1 100644 --- a/parallel-checkout.c +++ b/parallel-checkout.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "config.h" #include "entry.h" #include "parallel-checkout.h" diff --git a/pretty.c b/pretty.c index 1e1e21878c..b608084449 100644 --- a/pretty.c +++ b/pretty.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "config.h" #include "commit.h" #include "utf8.h" 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/quote.c b/quote.c index 26719d21d1..2453397fbb 100644 --- a/quote.c +++ b/quote.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "quote.h" #include "strvec.h" diff --git a/read-cache.c b/read-cache.c index 35e5657877..3cc8e312dc 100644 --- a/read-cache.c +++ b/read-cache.c @@ -4,6 +4,7 @@ * Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "diff.h" #include "diffcore.h" diff --git a/ref-filter.c b/ref-filter.c index f8203c6b05..c8230a0858 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1,5 +1,5 @@ -#include "builtin.h" -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "parse-options.h" #include "refs.h" #include "wildmatch.h" @@ -13,7 +13,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/refs.c b/refs.c index e31dbcda59..f90f953551 100644 --- a/refs.c +++ b/refs.c @@ -2,7 +2,8 @@ * 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 "lockfile.h" diff --git a/refs/packed-backend.c b/refs/packed-backend.c index 6f5a0709fb..186dcafcd0 100644 --- a/refs/packed-backend.c +++ b/refs/packed-backend.c @@ -1,4 +1,5 @@ -#include "../cache.h" +#include "../git-compat-util.h" +#include "../alloc.h" #include "../config.h" #include "../refs.h" #include "refs-internal.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/refspec.c b/refspec.c index 63e3112104..ec336ec5e9 100644 --- a/refspec.c +++ b/refspec.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "strvec.h" #include "refs.h" #include "refspec.h" diff --git a/remote-curl.c b/remote-curl.c index a76b6405eb..380ef3fccf 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "remote.h" #include "connect.h" diff --git a/remote.c b/remote.c index 60869beebe..daade49a6f 100644 --- a/remote.c +++ b/remote.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "remote.h" #include "urlmatch.h" diff --git a/rerere.c b/rerere.c index 876ab435da..d4bcb90853 100644 --- a/rerere.c +++ b/rerere.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "lockfile.h" #include "string-list.h" diff --git a/revision.c b/revision.c index 21f5f572c2..b8f925f088 100644 --- a/revision.c +++ b/revision.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "object-store.h" #include "tag.h" diff --git a/sequencer.c b/sequencer.c index 65a34f9676..fcf8740ce1 100644 --- a/sequencer.c +++ b/sequencer.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "config.h" #include "lockfile.h" #include "dir.h" diff --git a/server-info.c b/server-info.c index 0ec6c0c165..f07daa16f3 100644 --- a/server-info.c +++ b/server-info.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "dir.h" #include "repository.h" #include "refs.h" diff --git a/shallow.c b/shallow.c index 17f9bcdb5f..7dc73fb898 100644 --- a/shallow.c +++ b/shallow.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "tempfile.h" #include "lockfile.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/strbuf.c b/strbuf.c index c383f41a3c..bc4c2c09e6 100644 --- a/strbuf.c +++ b/strbuf.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.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..94d504e380 100644 --- a/strvec.c +++ b/strvec.c @@ -1,5 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" #include "strvec.h" +#include "alloc.h" #include "strbuf.h" const char *empty_strvec[] = { NULL }; diff --git a/submodule-config.c b/submodule-config.c index 4dc61b3a78..bb7c35fc31 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -1,4 +1,5 @@ #include "cache.h" +#include "alloc.h" #include "dir.h" #include "repository.h" #include "config.h" diff --git a/submodule.c b/submodule.c index 3a0dfc417c..340ffad1c2 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" diff --git a/t/helper/test-reach.c b/t/helper/test-reach.c index 2f65c7f6a5..883d8e20a8 100644 --- a/t/helper/test-reach.c +++ b/t/helper/test-reach.c @@ -1,5 +1,5 @@ #include "test-tool.h" -#include "cache.h" +#include "alloc.h" #include "commit.h" #include "commit-reach.h" #include "config.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/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.c b/transport.c index 77a61a9d7b..ac9e06a6ce 100644 --- a/transport.c +++ b/transport.c @@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "transport.h" #include "hook.h" @@ -10,6 +11,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..d22f3fe5b0 100644 --- a/tree-walk.c +++ b/tree-walk.c @@ -1,5 +1,6 @@ #include "cache.h" #include "tree-walk.h" +#include "alloc.h" #include "dir.h" #include "object-store.h" #include "tree.h" diff --git a/userdiff.c b/userdiff.c index 94cca1a2a8..7f0ecbffbb 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/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" -- 2.39.2