diff --git a/Documentation/CodingGuidelines b/Documentation/CodingGuidelines index 9d5c27807a4..003393ed161 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 00a0f6f96f3..ae25ec50bce 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 a86a92e1646..c6e451c136c 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 fd189689437..a5ea460ab86 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 07e0f76833e..3e1b48bf68d 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 00abde08173..e814948ced3 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 27f697e4c87..2886aa93543 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 3f4a0ad310a..4312db4bd08 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 5cc5479c9c3..8776ab939ad 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 f8fad2946ef..ee27fa0b39b 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 0456f1ebf15..c5d1f72eb80 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 9aeaf2bd87d..1c2ca78e52a 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 1053dfcd4b6..657ee52229e 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 ef5ee5a6436..1409150c5c3 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 8bfeaa1c63a..e45d8a3bf92 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 38bde535b3d..b60d1d81e30 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 8f83523b0cd..888e28a5594 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 e5614b53b36..5aaf073dce1 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 e0848ddadfe..3b5ea50cc56 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 73017402671..e8ee4a4dc8d 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 71f925e456c..fdd9f0c0fc7 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 cc17635e765..b7a73acb074 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 7dc47e47932..96db3ddb4bb 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 ede7dc32a43..0a7d762573c 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 a5155cf55c1..21a4335abb0 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 65b5b7db6de..462c286274c 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 93704f95a9d..d3be7f3b318 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 cc8d584be2f..fefeed5d4bd 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 060cf9f3e05..49d832d4093 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 338058be7f9..6e509d02c37 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 eea1e330c00..5b5930f5c8c 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 25b853b85ca..a393efa4f08 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 dbbfb19f192..01681d0fb88 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 39a890fc005..78493c6d2bf 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 7134683ab93..160e2eedb77 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 afe679368de..702c9a3397e 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 a09606b4726..b678a45baa2 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 64614b43b2e..e468e55325b 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 0feef8caf6d..cae804a1908 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 02455fdcd73..67c7fe8a6ea 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 f7821c5fbba..c590fcb19dd 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 44db83f07fd..1848768b97c 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 6648f2daef5..b451755f405 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 a70fba198f9..45bfa86fe2a 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 65161773489..2dfbd8ed9b9 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 8cc8c995df9..64d8e54318c 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 6f3941f2a49..be8f3b221c9 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 452f833ac46..c875f5d37ee 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 828dc81c426..e7825181648 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 0a3c10a0966..7347b738e50 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 5d22909122d..42c2457c705 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 06d81400f55..848c7b47476 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 edd7b931fdb..81290503775 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 97959bfaf9e..723ba616a88 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 80d9dfd25ca..bba4c2e39f8 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 74a167a180c..2e73284f107 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 ecd49ca268f..82115c5808c 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 f840fbf1c7e..338b15cd7b0 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 27192201086..f2ed45ccf03 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 1ab4de0005d..963a47f0b82 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 6034408d486..11759c415f3 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 6635f10d529..ef8ce2f72cd 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 cd5c7a28eff..3d2b4c8b4fc 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 f6493795318..966430a465f 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 a29e911d309..71d8e949e35 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 0697fa89de2..58f567afd3e 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 d42db0b0cc9..e4c9b747625 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 e67999e5ebc..e1fa9c6348c 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 77d2035616e..62986a7b1b0 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 8844f906557..dc198f79082 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 4c5d125fa0a..127ced435dc 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 358ac3e519a..8342b68aef7 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 0e0b9fb95bc..98ec40ddf46 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 3af6a53ee97..1f28d7fe4b9 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 3a4f9fd566d..6a12fed2713 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 4c173d8b37a..2bbabbb28e3 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 d428c45dc8d..be094882d0f 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 88de32b7d7e..e9b105a5397 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 43789b8ef29..1908dcfcffb 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 bf38885d546..11dc1352716 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 25b69da2bf2..7a3c68720f1 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 a80c1df86fd..d9943be9afd 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 | )"; diff --git a/builtin/worktree.c b/builtin/worktree.c index 254283aa6f5..80d05e246d8 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 078010315f0..7ad0d059453 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 855b68ec23b..d64cd5c52d0 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 6ab6cd7378d..99d7de97f6c 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 88c2c04f87f..9d46ecef091 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 bd97caa07b0..faae88be63c 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 12789903e88..0221bc6d5c9 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, @@ -989,14 +886,6 @@ void set_shared_repository(int value); 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 @@ -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, ...); @@ -1502,68 +1341,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 @@ -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 336e46dbba5..c1cc30a5dc7 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 0be14fb7ee4..43193abdda2 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 1152133bd77..1917f3b3230 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 0275b74a895..f65e9a1e429 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 7885aa08487..025c38f938e 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 f05d8a81d72..6b577ce0a75 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 1a39b5dde09..91051dc3258 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 c11b59f28b3..5e6098ff356 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 37faee6b66d..bb88bec7aa3 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 2e33c599a82..5ba822a7200 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 557738df271..4a414ee905d 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 e433c33bb01..cb683a6df5d 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 cc2c5da7bdb..06657b4c6e7 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 d67b0ee50d3..eb25123fa12 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 e08c505c148..c9536dfb666 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 6abbc7af3ab..58b623fbb9a 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 e433740381b..3afbde78944 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 00090a32fc3..d0aff55fa66 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 63e59641c0d..134069574a2 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 b90fd61790c..39cb1e1074d 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 a54d1690c08..349c7e4af15 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 0ae7d12b5c1..eb733d222fa 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 2036d159671..71e79daa825 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 afdec0a878d..fe12c93005b 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 8f265698966..4a8ee4e5cff 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 dec040c366c..70b3578b907 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 85cbefa5afd..ec97616db1d 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 05fafd0019b..a3cf358baf0 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 469e18aed20..00d47281a1d 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 8d770b1d579..3520119b001 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 18d8f766d70..c30b56e983b 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 19e73311f9c..57ccab28464 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 03fcbcb40ba..13c98a7b5e7 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 c0422d9e709..7e9ff96d435 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 445f060ab00..533986cf632 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 9b588a1ee15..1701ed50b9c 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 cedd3047599..fb7c47f0e8a 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 7adf242026e..d5bb199f4b4 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 e8106e1ecac..3d6c87387e9 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 971ab268714..c97cfa833bb 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 2d4fbb88c8f..7329f918a97 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 1ee3686fd8a..89d89110e41 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 ac618641632..12d6aa398e9 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 6fe48d3ae04..c6d4ffc87ca 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 04016d1e325..95a992bcd43 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 f48f44f9cd1..9609eb3cef1 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 2b18717ee80..871c0a9a252 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 668330880ef..e17730e9da9 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 899bfe9c813..b62acf44aee 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 4f0028ce60c..f77f986fbf1 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 6171fd6769d..ae2134f29a8 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 5cd66d3a786..0c13990a42c 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 568b6e7cd41..2a9dc430fae 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 cee44a78d04..68e9328dfd4 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 36b64165fc9..d39f73618cb 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 cf5fea87eb0..ee45ef00852 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 812af4cdea6..216777d2bf4 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 4f64d346963..0a1bddc1284 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 00000000000..e2abfc56fae --- /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 1a848318634..f6ddd790988 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 8ab58e55f85..45290031e00 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 258fec20682..8db35b9767d 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 7f71316456c..88aa045ecba 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 b8f0f98ae14..c3e902c40e6 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 c4b6ddef287..86b0745af90 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 6de76f9421d..8fad92d7007 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 00000000000..96a64896a01 --- /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 a50af56b827..93e9018439c 100644 --- a/imap-send.c +++ b/imap-send.c @@ -21,7 +21,7 @@ * along with this program; if not, see . */ -#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 f1cfd8fa8c6..005c820aa42 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 cb79bf88567..85362718c56 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 08aadf03117..4b14d4f86b8 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 d2632690d51..fd8026fe201 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 a7f3e7f6ce4..1bf89c9acc1 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 82ae8d98a40..adff361b1bc 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 ecffc09be6e..5416cbcf409 100644 --- a/linear-assignment.c +++ b/linear-assignment.c @@ -3,7 +3,7 @@ * algorithm for dense and sparse linear assignment problems. 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 ee01bcd2cc3..1d25a5737db 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 1fe393f4473..ef03b45132e 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 7ed21cb299c..5d7b3316608 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 7528fe1db2c..ab5745bbfe4 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 1dd5fcbf7be..043e0df685b 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 697d4beb8de..f4c6b9b7621 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 833d28612f7..9f1495ddcf1 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 49398e599fe..c38dcbac7c6 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 599d8e895f8..c34846d176c 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 8138090f81c..aedcab81138 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 d1611ca400a..4c5be8ed910 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 ae469f8cc81..89731f40908 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 445b4f19aa8..2c8b8456842 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 7cfad04a240..24799bef511 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 60569b83501..7b729376867 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 0f5ac48e876..28f8769bd40 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 b4cc594a790..5b1a9ff13f7 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 f2805d51bb1..c9e4b8b4a55 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 939865c1ae0..43a39dd8d31 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 2dd1a0f56e1..97bb94d226c 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 1a713d89d7c..82201ec3e7b 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 344087de4de..609fed1b73d 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 31ebe114585..fc45b158da0 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 73ba76e9e9a..e8228c777b1 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 49965fe8568..8c1a139c974 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 c66a83ab1d6..c1642927fa6 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 b36a2bae864..d1e5376316e 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 0d39389bee2..7d57b7b19e3 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 914026f5d80..2992079dd97 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 99da1d0fd38..150c0f5fa2d 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 0c3d777aac8..609a343ee3e 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 cfa67a510fd..891d9d2772e 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 d2a42abf28c..a321d6fae83 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 bfb593ba726..7ed594d6679 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 cc957b3e852..107327cec0b 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 272e8d45173..ccab09fe654 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 33637297487..041e573bc16 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 79e21ab18e7..4088735a7da 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 4f6819f2406..2455aa356db 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 31534466266..a4473a88fa2 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 492e17ad121..97561c3b14d 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 41f6adfbb42..a5b38e0907a 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 ce4e73b6833..1ea7f8600ec 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 79c538b99e4..8e9846f3151 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 1e1e21878c8..2401e3ed36b 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 f34e24c53a4..921dd6e0cae 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 d31b48e7250..dc2476be53a 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 faa7612941c..1db566982ec 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 bbde91810ac..874bc815b4f 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 261520b472c..d2813f6a405 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 26719d21d1e..7ccb5a06cd1 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 aba63ebeb3b..be9d40923de 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 35e5657877c..1bcf6732718 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 6775cddb284..17a570f1ff9 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 f8203c6b052..d8627185089 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 8a4d8fa3bd5..4ba1a10c82c 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 8076f10d9fb..4d93a269571 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 aeae31c972f..53240bcc07b 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 eed8bc94b04..adc34c836fc 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 b89954355de..31bc5c45ee6 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 6f5a0709fba..b665d0f7d9b 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 32afd8a40b0..dc1ca49c85f 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 69f93b0e2ac..a85d113123c 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 63e3112104a..28d90911aa5 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 a76b6405eb2..ed7e3a043ac 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 60869beebe7..b04e5da3383 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 1ebbe42792e..5b38ee20b84 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 320be2522d8..0cf056c4fbf 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 3fbc32eb7b7..500482b02b3 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 3dbd3f0e2ec..0a6c0b381fe 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 e8c67ffe165..15a8afc5fb5 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 876ab435da9..a67abaab077 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 5ded23611f3..58b3829ff73 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 21f5f572c22..e356bc4aae7 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 30febad09a1..ab71443696d 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 f2e19838c9c..423a5cfe22d 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 1c96a75b1e9..675dee7b8fe 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 3bcdfa1b586..33dbaf5b66d 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 cbf4a143cfe..d128822347d 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 0ec6c0c1654..40436892023 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 5c300e812e0..9b675a046ee 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 17f9bcdb5f3..1cbb05ba0e4 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 aba6ff58294..e9ca7e4bc80 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 af0d7c734f8..5c67e7bd97e 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 022677b6aba..ee778c0580b 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 147a13386a4..63216b3e57f 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 5d0f04763ea..95ecfa53195 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 00000000000..e49e3054eaa --- /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 c383f41a3c5..1c57ac6574f 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 42bacaec55b..db473f273e1 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 61a76ce6cb9..17d54b6c3bc 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 6d4232294db..1daf5a97525 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 e85f21fa1a7..6a61638a8ac 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 4dc61b3a78a..89a7bf0a93d 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 28a8ca6bf46..c2045875bbb 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 3a0dfc417c0..9d89299772e 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 6c900ca6684..127f134a2a6 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 9159a173015..615e648e555 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 e6c1b1e22bb..597027a96e9 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 -l| diff --git a/t/helper/test-ctype.c b/t/helper/test-ctype.c index b21bd672d9f..534ca66441c 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 454f17b1a0c..92dfc1aa8c4 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 0ea97b84072..813d0a38fae 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 6d53683f13b..af953fabe87 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 b9d1200eb98..7c7fc8efc13 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 efc82dd80c5..b1edb92a032 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 5860dab0ffa..016248106a7 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 8c3edacc000..86887f53203 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 4079fdee067..04bc2563f3e 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 d1324d086a2..0906993ad59 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 0acf99931ee..883d40efd45 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 d48a409f4e4..0b82431a70f 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 f7b79daf4c0..f68b3761b68 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 3f102cfddd3..da17fd37eb1 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 5258fdddba0..5d0b2a2e10f 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 133b5e6f4ae..ac4c65d7056 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 a4b305f4947..7e12d4f9aa2 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 2f65c7f6a55..de8f26639d4 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 27072ba94d7..0a883cdf26b 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 ae8a5648daf..1745b088b7c 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 56f0e3c1bef..10a6dfc2160 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 3ecb830f4a8..67b42ef50eb 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 d013bccddae..d1cf7377b7c 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 28365ff85b6..3d1436da598 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 dc1c14bde37..a3848a8b668 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 2c103d1824c..a95bb4da9b1 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 dfbcd7fcc24..18b718cca66 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 53298456913..1f89ffab4c3 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 b6e35b94700..d304d55aa1d 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 279bddf53b4..e8ba62c0c3d 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 483ca7c308f..b342d3b1a3c 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 dc6e75ef131..5f1ce6f85cf 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 a380dcf9105..069786cb927 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 2498482d9ad..c3b3822ed7e 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 16f6332755e..9e7aab6d510 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 fbbef68dfc0..8672c2c2d04 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 adae8032639..3f2b2d53118 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 04900bb4c3a..9f46ae12f50 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 786762dfd26..31d0e4d1bd1 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 0fd5b142a37..72c3fed5c6e 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 3ea7c2bb5ad..82ac63e2609 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 77a61a9d7bb..906dbad5a08 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 74f4d710e8f..0e2f5ceb71d 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 6305d531503..25fe27e3529 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 410e3b477e5..76a6534f678 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 e0be1badb58..79800d80636 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 efa2a207abc..22ac2373e07 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 a37ab292bbd..a75fb9f05b4 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 551f22ffa5d..fa4bb61e4f1 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 e04bd60b6be..2e1a9f6feec 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 620a648efc5..eba0bdd77fe 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 58a3d59ef8f..09203fbc354 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 99d0e0eae04..c0469363789 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 7e5a7ea1eaa..42e38e34590 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 aa43c641191..c99939a4d1f 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 9dcea6fc8c1..2baeca2a8a6 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 3162241a570..90525bd26fd 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 e87950de32e..5baf6ceb947 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 4301a7eef27..3750794afe9 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" /*