Header cleanups
cover Header cleanups
Maintainer note: This series cleanly merges with next, but has a minor conflict with ed/fsmonitor-inotify. The correct resolution is to take ed/fsmonitor-inotify's copy of compat/fsmonitor/fsm-settings-darwin.c, but to add a #include "git-compat-util.h" line at the top of compat/fsmonitor/fsm-settings-unix.c.
This series cleans up headers a bit, trying to remove excessive dependency on "cache.h". I created this series a while ago, but decided to clean it up and submit it due to Emily's recent thread and suggestion that this might be helpful to their efforts[1].
There are many more cleanups I could do in this area, but the series is already a good size.
Notes:
* Big props to Dscho for gitgitgadget; being able to test on a bunch of platforms with a variety of configurations easily is a big win in general but especially for series like this one.
* I used the scripts at
https://github.com/newren/git/commit/db81c8d7fb554b3edf04320e218bddeb98bb6194,
and some tweaks thereof, repeatedly while making this series (though they are prone to produce both false positive and false negatives, so if you use them, only use them to generate hints about which files to look at).
[1] Search for "Extremely yes" in
https://lore.kernel.org/git/CAJoAoZm+TkCL0Jpg_qFgKottxbtiG2QOiY0qGrz3-uQy+=waPg@mail.gmail.com/
Elijah Newren (16):
treewide: ensure one of the appropriate headers is sourced first
treewide: remove unnecessary git-compat-util.h includes in headers
treewide: remove unnecessary cache.h includes
treewide: remove unnecessary cache.h includes in source files alloc.h: move ALLOC_GROW() functions from cache.h
hash.h: move some oid-related declarations from cache.h hex.h: move some hex-related declarations from cache.h pretty.h: move has_non_ascii() declaration from commit.h ident.h: move ident-related declarations out of cache.h object.h: stop depending on cache.h; make cache.h depend on object.h dir.h: refactor to no longer need to include cache.h object-store.h: move struct object_info from cache.h replace-object.h: move read_replace_refs declaration from cache.h to
here
treewide: replace cache.h with more direct headers, where possible Remove unnecessary includes of builtin.h
diff.h: remove unnecessary include of object.h
Documentation/CodingGuidelines | 8 +- add-patch.c | 2 + advice.c | 4 +- advice.h | 2 - alias.c | 4 +- alloc.c | 2 +- alloc.h | 75 +++++ apply.c | 1 + archive-tar.c | 3 +- archive.c | 3 +- attr.c | 1 + blame.h | 1 - blob.c | 2 +- builtin/blame.c | 3 +- builtin/cat-file.c | 3 + builtin/check-mailmap.c | 1 + builtin/checkout--worker.c | 1 + builtin/commit-graph.c | 1 + builtin/config.c | 3 +- builtin/credential-cache--daemon.c | 1 + builtin/fetch-pack.c | 1 + builtin/fsck.c | 1 + builtin/fsmonitor--daemon.c | 1 + builtin/grep.c | 1 + builtin/index-pack.c | 2 + builtin/log.c | 3 +- builtin/merge.c | 1 + builtin/mktree.c | 1 + builtin/mv.c | 1 + builtin/name-rev.c | 2 +- builtin/pack-objects.c | 3 +- builtin/prune.c | 1 + builtin/repack.c | 2 +- builtin/replace.c | 1 + builtin/rev-parse.c | 1 + builtin/revert.c | 3 +- builtin/rm.c | 1 + builtin/submodule--helper.c | 1 + builtin/unpack-objects.c | 1 + builtin/upload-pack.c | 1 + builtin/var.c | 1 + bulk-checkin.c | 3 +- cache-tree.c | 3 +- cache-tree.h | 1 - cache.h | 306 +------------------ cbtree.c | 1 + cbtree.h | 2 - checkout.h | 2 +- chunk-format.c | 3 +- chunk-format.h | 1 - commit-graph.h | 1 - commit-reach.c | 3 +- commit-slab-impl.h | 2 - commit.h | 1 - compat/fsmonitor/fsm-ipc-win32.c | 1 + compat/fsmonitor/fsm-settings-darwin.c | 1 + compat/mingw.c | 1 + config.c | 5 +- daemon.c | 1 + decorate.c | 3 +- delta-islands.c | 3 +- diff-merges.c | 2 + diff-no-index.c | 1 - diff.c | 1 + diff.h | 3 +- diffcore-delta.c | 2 +- diffcore-order.c | 3 +- diffcore-pickaxe.c | 4 +- diffcore-rename.c | 7 +- diffcore-rotate.c | 3 +- diffcore.h | 4 +- dir-iterator.c | 3 +- dir.c | 3 +- dir.h | 16 +- entry.h | 4 +- environment.c | 1 + ewah/bitmap.c | 3 +- ewah/ewah_bitmap.c | 2 +- fetch-pack.c | 3 +- fmt-merge-msg.c | 2 + fsck.c | 3 +- fsck.h | 1 + fsmonitor-settings.c | 3 +- git-compat-util.h | 1 + git.c | 1 + gpg-interface.c | 1 + graph.c | 3 +- hash.h | 35 ++- hashmap.c | 2 +- help.c | 4 +- hex.c | 3 +- hex.h | 84 +++++ hook.c | 5 +- http-backend.c | 3 +- ident.c | 5 +- ident.h | 67 ++++ imap-send.c | 2 +- json-writer.c | 2 +- khash.h | 1 - kwset.c | 2 +- levenshtein.c | 2 +- line-log.c | 1 + line-log.h | 1 + linear-assignment.c | 2 +- list-objects-filter-options.c | 4 +- list-objects-filter-options.h | 3 +- list-objects-filter.c | 1 + log-tree.c | 1 + mailinfo.c | 4 +- mem-pool.c | 2 +- merge-blobs.c | 2 +- merge-recursive.c | 1 - midx.c | 3 +- negotiator/noop.c | 2 +- object-file.c | 3 +- object-store.h | 128 ++++---- object.h | 22 +- oid-array.c | 3 +- oidmap.c | 2 +- oidmap.h | 1 - oidset.c | 4 +- oidtree.c | 1 + oss-fuzz/fuzz-commit-graph.c | 1 + oss-fuzz/fuzz-pack-headers.c | 1 + oss-fuzz/fuzz-pack-idx.c | 1 + pack-bitmap-write.c | 3 +- pack-bitmap.c | 3 +- pack-mtimes.h | 2 - pack-objects.c | 3 +- packfile.c | 3 +- parallel-checkout.c | 1 + pathspec.h | 5 + pkt-line.h | 1 - pretty.c | 1 + pretty.h | 4 +- prio-queue.c | 3 +- protocol-caps.c | 1 + prune-packed.c | 1 + quote.c | 2 + read-cache.c | 1 + rebase.c | 1 + ref-filter.c | 5 +- reflog-walk.c | 3 +- reflog-walk.h | 2 - refs.c | 3 +- refs/debug.c | 2 +- refs/files-backend.c | 1 + refs/packed-backend.c | 3 +- refs/ref-cache.c | 3 +- refs/refs-internal.h | 1 - refspec.c | 3 +- remote-curl.c | 3 +- remote.c | 3 +- remote.h | 1 - replace-object.h | 8 + repo-settings.c | 2 +- repository.h | 1 - rerere.c | 3 +- revision.c | 3 +- revision.h | 1 + send-pack.c | 2 +- sequencer.c | 1 + sequencer.h | 2 +- serve.c | 3 +- server-info.c | 3 +- sha1dc_git.c | 4 +- shallow.c | 3 +- shallow.h | 2 + shell.c | 2 +- sigchain.c | 3 +- sparse-index.c | 1 + split-index.c | 1 + statinfo.h | 24 ++ strbuf.c | 3 +- string-list.c | 3 +- strvec.c | 3 +- sub-process.c | 1 + sub-process.h | 1 - submodule-config.c | 1 + submodule-config.h | 1 - submodule.c | 4 +- t/helper/test-bloom.c | 2 +- t/helper/test-crontab.c | 1 - t/helper/test-ctype.c | 1 - t/helper/test-example-decorate.c | 2 +- t/helper/test-json-writer.c | 1 - t/helper/test-pcre2-config.c | 1 - t/helper/test-prio-queue.c | 1 - t/helper/test-reach.c | 2 +- t/helper/test-run-command.c | 2 - t/helper/test-sigchain.c | 1 - t/helper/test-simple-ipc.c | 3 +- t/helper/test-submodule-nested-repo-config.c | 1 + t/helper/test-wildmatch.c | 1 - thread-utils.c | 2 +- trace.h | 1 - trace2.c | 3 +- trace2/tr2_ctr.c | 2 +- trace2/tr2_sysenv.c | 2 +- trace2/tr2_tbuf.c | 2 +- trace2/tr2_tgt_event.c | 2 +- trace2/tr2_tgt_normal.c | 2 +- trace2/tr2_tgt_perf.c | 2 +- trace2/tr2_tls.c | 4 +- trace2/tr2_tmr.c | 3 +- trailer.c | 1 + transport.c | 4 +- tree-walk.c | 1 + tree-walk.h | 4 +- unix-socket.c | 3 +- unix-stream-server.c | 2 +- url.c | 4 +- urlmatch.c | 5 +- userdiff.c | 4 +- wildmatch.c | 2 +- worktree.c | 3 +- worktree.h | 1 - xdiff-interface.h | 2 +- 218 files changed, 691 insertions(+), 529 deletions(-) create mode 100644 hex.h create mode 100644 ident.h create mode 100644 statinfo.h
base-commit: 06dd2baa8da4a73421b959ec026a43711b9d77f9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1485%2Fnewren%2Fheader-cleanups-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1485/newren/header-cleanups-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1485
Signature · 1 line
gitgitgadget
PATCH 1/16 treewide: ensure one of the appropriate headers is sourced first
From: Elijah Newren <[email protected]>
We had several C files ignoring the rule to include one of the appropriate headers first; fix that.
While at it, the rule in Documentation/CodingGuidelines about which header to include has also fallen out of sync, so update the wording to mention other allowed headers.
Unfortunately, C files in reftable/ don't actually follow the previous or updated rule. If you follow the #include chain in its C files, reftable/system.h _tends_ to be first (i.e. record.c first includes record.h, which first includes basics.h, which first includees system.h), but not always (e.g. publicbasics.c includes another header first that does not include system.h). However, I'm going to punt on making actual changes to the C files in reftable/ since I do not want to risk bringing it out-of-sync with any version being used externally.
--- Documentation/CodingGuidelines | 8 ++++++-- cbtree.c | 1 + diff-merges.c | 1 + fmt-merge-msg.c | 1 + oidtree.c | 1 + oss-fuzz/fuzz-commit-graph.c | 1 + oss-fuzz/fuzz-pack-headers.c | 1 + oss-fuzz/fuzz-pack-idx.c | 1 + prune-packed.c | 1 + rebase.c | 1 + refs/debug.c | 2 +- sub-process.c | 1 + 12 files changed, 17 insertions(+), 3 deletions(-)
Documentation/CodingGuidelines +6 -2
@@ -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
cbtree.c +1 -0
@@ -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-merges.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "diff-merges.h" #include "revision.h"
fmt-merge-msg.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "config.h" #include "refs.h" #include "object-store.h"
oidtree.c +1 -0
@@ -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"
oss-fuzz/fuzz-commit-graph.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "commit-graph.h" #include "repository.h"
oss-fuzz/fuzz-pack-headers.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "packfile.h" int LLVMFuzzerTestOneInput (const uint8_t *data,size_t size);
oss-fuzz/fuzz-pack-idx.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "object-store.h" #include "packfile.h"
prune-packed.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "object-store.h" #include "packfile.h" #include "progress.h"
rebase.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "rebase.h" #include "config.h" #include "gettext.h"
refs/debug.c +1 -1
@@ -1,4 +1,4 @@ - +#include "git-compat-util.h" #include "refs-internal.h" #include "trace.h"
sub-process.c +1 -0
@@ -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"
Signature · 1 line
gitgitgadget
PATCH 2/16 treewide: remove unnecessary git-compat-util.h includes in headers
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
Since git-compat-util.h needs to be included first in C files, having it appear in header files is unnecessary. More importantly, having it included in header files seems to lead to folks leaving it out of C files, which makes it harder to verify that the rule is being followed. Remove it from header files, other than the ones that have been approved as alternate first includes.
--- advice.h | 2 -- cbtree.h | 2 -- chunk-format.h | 1 - commit-graph.h | 1 - commit-slab-impl.h | 2 -- compat/fsmonitor/fsm-ipc-win32.c | 1 + compat/fsmonitor/fsm-settings-darwin.c | 1 + hash.h | 1 - pack-mtimes.h | 2 -- pkt-line.h | 1 - repository.h | 1 - sub-process.h | 1 - trace.h | 1 - 13 files changed, 2 insertions(+), 15 deletions(-)
advice.h +0 -2
@@ -1,8 +1,6 @@#ifndef ADVICE_H #define ADVICE_H -#include "git-compat-util.h" -struct string_list ;/*
cbtree.h +0 -2
@@ -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];
chunk-format.h +0 -1
@@ -1,7 +1,6 @@#ifndef CHUNK_FORMAT_H #define CHUNK_FORMAT_H -#include "git-compat-util.h" #include "hash.h" struct hashfile ;
commit-graph.h +0 -1
@@ -1,7 +1,6 @@#ifndef COMMIT_GRAPH_H #define COMMIT_GRAPH_H -#include "git-compat-util.h" #include "object-store.h" #include "oidset.h"
commit-slab-impl.h +0 -2
@@ -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)
compat/fsmonitor/fsm-ipc-win32.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "config.h" #include "fsmonitor-ipc.h"
compat/fsmonitor/fsm-settings-darwin.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "config.h" #include "fsmonitor.h" #include "fsmonitor-ipc.h"
hash.h +0 -1
@@ -1,7 +1,6 @@#ifndef HASH_H #define HASH_H -#include "git-compat-util.h" #include "repository.h" #if defined(SHA1_APPLE )
pack-mtimes.h +0 -2
@@ -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
pkt-line.h +0 -1
@@ -1,7 +1,6 @@#ifndef PKTLINE_H #define PKTLINE_H -#include "git-compat-util.h" #include "strbuf.h" #include "sideband.h"
repository.h +0 -1
@@ -1,7 +1,6 @@#ifndef REPOSITORY_H #define REPOSITORY_H -#include "git-compat-util.h" #include "path.h" struct config_set ;
sub-process.h +0 -1
@@ -1,7 +1,6 @@#ifndef SUBPROCESS_H #define SUBPROCESS_H -#include "git-compat-util.h" #include "hashmap.h" #include "run-command.h"
trace.h +0 -1
@@ -1,7 +1,6 @@#ifndef TRACE_H #define TRACE_H -#include "git-compat-util.h" #include "strbuf.h" /**
Signature · 1 line
gitgitgadget
Re: [PATCH 02/16] treewide: remove unnecessary git-compat-util.h includes in headers
Quoted 8 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
Since
git-compat-util.hneeds to be included first in C files, having it appear in header files is unnecessary. More importantly, having it included in header files seems to lead to folks leaving it out of C files, which makes it harder to verify that the rule is being followed. Remove it from header files, other than the ones that have been approved as alternate first includes.
...
Quoted 2 lines
compat/fsmonitor/fsm-ipc-win32.c | 1 + compat/fsmonitor/fsm-settings-darwin.c | 1 +
It looks like you have a couple .c files here that belong in the previous patch.
Thanks,
-Stolee
Re: [PATCH 02/16] treewide: remove unnecessary git-compat-util.h includes in headers
Quoted 10 lines · Derrick Stolee
Quoted 8 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
Since
git-compat-util.hneeds to be included first in C files, having it appear in header files is unnecessary. More importantly, having it included in header files seems to lead to folks leaving it out of C files, which makes it harder to verify that the rule is being followed. Remove it from header files, other than the ones that have been approved as alternate first includes.
Quoted 6 lines
...
Quoted 2 lines
compat/fsmonitor/fsm-ipc-win32.c | 1 + compat/fsmonitor/fsm-settings-darwin.c | 1 +It looks like you have a couple .c files here that belong in the previous patch.
Oops, indeed. Bad squash. (I tended to ignore files under compat/ thinking they were special, but then later found out they also needed to be fixed so that things would work right.)
Thanks for catching; will fix.
Re: [PATCH 02/16] treewide: remove unnecessary git-compat-util.h includes in headers
In reply to Elijah Newren via GitGitGadgetQuoted 8 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
Since
git-compat-util.hneeds to be included first in C files, having it appear in header files is unnecessary. More importantly, having it included in header files seems to lead to folks leaving it out of C files, which makes it harder to verify that the rule is being followed. Remove it from header files, other than the ones that have been approved as alternate first includes.
Hmph, doesn't this cut both ways?
I like the idea that the removal of compat-util from other header files may increase the likelihood that a C file that includes such header files without including compat-util fail to compile, because it would fail to find what is defined or declared in compat-util.
But from "include what you use" point of view, shouldn't a header that defines or declares its own stuff using what is defined or declared in compat-util be including compat-util itself?
Or do I misunderstand what "make hdr-check" is trying to achieve?
Granted that the check does not fail with this patch in place, but I suspect that it is by accident (i.e. there happens to be nobody who depends on what is defined/declared in compat-util for their own definition or declaration). Also I am not sure how to interpret the fact that "make hdr-check" succeeds with this patch. Does it mean C files that include these header files while forgetting to include compat-util may not be caught by the compiler after all?
So, I dunno.
Re: [PATCH 02/16] treewide: remove unnecessary git-compat-util.h includes in headers
Quoted 34 lines · Junio C Hamano
Quoted 8 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
Since
git-compat-util.hneeds to be included first in C files, having it appear in header files is unnecessary. More importantly, having it included in header files seems to lead to folks leaving it out of C files, which makes it harder to verify that the rule is being followed. Remove it from header files, other than the ones that have been approved as alternate first includes.Hmph, doesn't this cut both ways?
I like the idea that the removal of compat-util from other header files may increase the likelihood that a C file that includes such header files without including compat-util fail to compile, because it would fail to find what is defined or declared in compat-util.
But from "include what you use" point of view, shouldn't a header that defines or declares its own stuff using what is defined or declared in compat-util be including compat-util itself?
Or do I misunderstand what "make hdr-check" is trying to achieve?
Granted that the check does not fail with this patch in place, but I suspect that it is by accident (i.e. there happens to be nobody who depends on what is defined/declared in compat-util for their own definition or declaration). Also I am not sure how to interpret the fact that "make hdr-check" succeeds with this patch. Does it mean C files that include these header files while forgetting to include compat-util may not be caught by the compiler after all?
Quoted 1 line
So, I dunno.
I did something like that before, and Peff objected; see
https://lore.kernel.org/git/[email protected]/
and https://lore.kernel.org/git/[email protected]/.
I think for sanity we should do one of the following:
(a) make C and header files both depend upon everything they need
(b) consistently exclude git-compat-util.h from headers and require it be the first include in C files
I think things get really messy if we let half the headers follow (a) and the other half are forced to do (b). I was pushed towards (b) before, but now that I've worked on this series, I think there is even more reason to go this direction: this work I did during this series shows that if we allow a mixture of (a) and (b), then empirically we end up with C files that don't include git-compat-util.h directly, and those same C files likely include some headers that don't include git-compat-util.h at all, and if the other headers are included before the indirect inclusion of git-compat-util.h then there are risks that things will break in very subtle ways (as pointed out by Peff in the above-linked emails). So, I'm inclined to go towards (b).
Re: [PATCH 02/16] treewide: remove unnecessary git-compat-util.h includes in headers
Quoted 6 lines · Elijah Newren
I think for sanity we should do one of the following:
(a) make C and header files both depend upon everything they need
(b) consistently excludegit-compat-util.hfrom headers and require it be the first include in C files
Quoted 11 lines
I think things get really messy if we let half the headers follow (a) and the other half are forced to do (b). I was pushed towards (b) before, but now that I've worked on this series, I think there is even more reason to go this direction: this work I did during this series shows that if we allow a mixture of (a) and (b), then empirically we end up with C files that don't include
git-compat-util.hdirectly, and those same C files likely include some headers that don't includegit-compat-util.hat all, and if the other headers are included before the indirect inclusion ofgit-compat-util.hthen there are risks that things will break in very subtle ways (as pointed out by Peff in the above-linked emails). So, I'm inclined to go towards (b).
Perfect. Can some of that reasoning be captured in the proposed log message of [02/16] to help future developers?
Thanks.
Re: [PATCH 02/16] treewide: remove unnecessary git-compat-util.h includes in headers
Quoted 21 lines · Junio C Hamano
Quoted 6 lines · Elijah Newren
I think for sanity we should do one of the following:
(a) make C and header files both depend upon everything they need
(b) consistently excludegit-compat-util.hfrom headers and require it be the first include in C filesQuoted 11 lines
I think things get really messy if we let half the headers follow (a) and the other half are forced to do (b). I was pushed towards (b) before, but now that I've worked on this series, I think there is even more reason to go this direction: this work I did during this series shows that if we allow a mixture of (a) and (b), then empirically we end up with C files that don't include
git-compat-util.hdirectly, and those same C files likely include some headers that don't includegit-compat-util.hat all, and if the other headers are included before the indirect inclusion ofgit-compat-util.hthen there are risks that things will break in very subtle ways (as pointed out by Peff in the above-linked emails). So, I'm inclined to go towards (b).
Quoted 2 lines
Perfect. Can some of that reasoning be captured in the proposed log message of [02/16] to help future developers?
Yep, will do.
PATCH 3/16 treewide: remove unnecessary cache.h includes
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
We had several header files include cache.h unnecessarily. Remove those. These have all been verified via both ensuring that
gcc -E $HEADER | grep '"cache.h"'
found no hits and that
cat >temp.c <<EOF &&
#include "git-compat-util.h"
#include "$HEADER"
int main() {}
EOF
gcc -c temp.csuccessfully compiles without warnings.
--- checkout.h | 2 +- entry.h | 4 +++- khash.h | 1 - oidmap.h | 1 - pretty.h | 2 +- reflog-walk.h | 2 -- refs/refs-internal.h | 1 - remote.h | 1 - sequencer.h | 2 +- xdiff-interface.h | 2 +- 10 files changed, 7 insertions(+), 11 deletions(-)
checkout.h +1 -1
@@ -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
entry.h +3 -1
@@ -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;
khash.h +0 -1
@@ -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"
oidmap.h +0 -1
@@ -1,7 +1,6 @@#ifndef OIDMAP_H #define OIDMAP_H -#include "cache.h" #include "hashmap.h" /*
pretty.h +1 -1
@@ -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 ;
reflog-walk.h +0 -2
@@ -1,8 +1,6 @@#ifndef REFLOG_WALK_H #define REFLOG_WALK_H -#include "cache.h" -struct commit ;struct reflog_walk_info ;struct date_mode ;
refs/refs-internal.h +0 -1
@@ -1,7 +1,6 @@#ifndef REFS_REFS_INTERNAL_H #define REFS_REFS_INTERNAL_H -#include "cache.h" #include "refs.h" #include "iterator.h"
remote.h +0 -1
@@ -1,7 +1,6 @@#ifndef REMOTE_H #define REMOTE_H -#include "cache.h" #include "parse-options.h" #include "hashmap.h" #include "refspec.h"
sequencer.h +1 -1
@@ -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 );
xdiff-interface.h +1 -1
@@ -1,7 +1,7 @@#ifndef XDIFF_INTERFACE_H #define XDIFF_INTERFACE_H -#include "cache.h" +#include "hash.h" #include "xdiff/xdiff.h" /*
Signature · 1 line
gitgitgadget
PATCH 4/16 treewide: remove unnecessary cache.h includes in source files
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
We had several C files include cache.h unnecessarily. Replace those with an include of "git-compat-util.h" instead. Much like the previous commit, these have all been verified via both ensuring that
gcc -E $SOURCE_FILE | grep '"cache.h"'
found no hits and that
make DEVELOPER=1 ${OBJECT_FILE_FOR_SOURCE_FILE}successfully compiles without warnings.
--- hashmap.c | 2 +- imap-send.c | 2 +- json-writer.c | 2 +- kwset.c | 2 +- levenshtein.c | 2 +- linear-assignment.c | 2 +- mem-pool.c | 2 +- oidmap.c | 2 +- repo-settings.c | 2 +- serve.c | 3 ++- shell.c | 2 +- t/helper/test-crontab.c | 1 - t/helper/test-ctype.c | 1 - t/helper/test-json-writer.c | 1 - t/helper/test-pcre2-config.c | 1 - t/helper/test-prio-queue.c | 1 - t/helper/test-run-command.c | 2 -- t/helper/test-sigchain.c | 1 - t/helper/test-simple-ipc.c | 3 ++- t/helper/test-wildmatch.c | 1 - thread-utils.c | 2 +- trace2.c | 3 ++- trace2/tr2_ctr.c | 2 +- trace2/tr2_tbuf.c | 2 +- trace2/tr2_tgt_event.c | 2 +- trace2/tr2_tgt_normal.c | 2 +- trace2/tr2_tgt_perf.c | 2 +- trace2/tr2_tmr.c | 3 ++- unix-stream-server.c | 2 +- 29 files changed, 25 insertions(+), 30 deletions(-)
hashmap.c +1 -1
@@ -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)
imap-send.c +1 -1
@@ -21,7 +21,7 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "credential.h" #include "exec-cmd.h"
json-writer.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "json-writer.h" void jw_init (struct json_writer *jw)
kwset.c +1 -1
@@ -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"
levenshtein.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "levenshtein.h" /*
linear-assignment.c +1 -1
@@ -3,7 +3,7 @@* algorithm for dense and sparse linear assignment problems</i>. 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)]
mem-pool.c +1 -1
@@ -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))
oidmap.c +1 -1
@@ -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,
repo-settings.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "repository.h" #include "midx.h"
serve.c +2 -1
@@ -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 ;
shell.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "quote.h" #include "exec-cmd.h" #include "strbuf.h"
t/helper/test-crontab.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" /* * Usage: test-tool crontab <file> -l|<input>
t/helper/test-ctype.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" static int rc;
t/helper/test-json-writer.c +0 -1
@@ -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}" ;
t/helper/test-pcre2-config.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" #include "grep.h" int cmd__pcre2_config (int argc,const char **argv)
t/helper/test-prio-queue.c +0 -1
@@ -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)
t/helper/test-run-command.c +0 -2
@@ -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"
t/helper/test-sigchain.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" #include "sigchain.h" #define X (f) \
t/helper/test-simple-ipc.c +2 -1
@@ -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)
t/helper/test-wildmatch.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" int cmd__wildmatch (int argc,const char **argv) {
thread-utils.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "thread-utils.h" #if defined(hpux) || defined(__hpux) || defined(_hpux)
trace2.c +2 -1
@@ -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"
trace2/tr2_ctr.c +1 -1
@@ -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"
trace2/tr2_tbuf.c +1 -1
@@ -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)
trace2/tr2_tgt_event.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "json-writer.h" #include "run-command.h"
trace2/tr2_tgt_normal.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "run-command.h" #include "quote.h"
trace2/tr2_tgt_perf.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "run-command.h" #include "quote.h"
trace2/tr2_tmr.c +2 -1
@@ -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))
unix-stream-server.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "lockfile.h" #include "unix-socket.h" #include "unix-stream-server.h"
Signature · 1 line
gitgitgadget
Re: [PATCH 04/16] treewide: remove unnecessary cache.h includes in source files
Quoted 16 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
We had several C files include
cache.hunnecessarily. Replace those with an include of "git-compat-util.h" instead. Much like the previous commit, these have all been verified via both ensuring that
gcc -E $SOURCE_FILE | grep '"cache.h"'
found no hits and thatmake DEVELOPER=1 ${OBJECT_FILE_FOR_SOURCE_FILE}successfully compiles without warnings.
t/helper/test-run-command.c +0
-0
t/helper/test-run-command.c line 13
Quoted 5 lines
t/helper/test-run-command.c +0
-2@@ -9,8 +9,6 @@*/ #include "test-tool.h" -#include "git-compat-util.h" -#include "cache.h"
This double-deletion initially caught me off guard, but then I double-checked your first patch where "test-tool.h" was an acceptable first include.
Thanks,
-Stolee
PATCH 5/16 alloc.h: move ALLOC_GROW() functions from cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
This allows us to replace includes of cache.h with includes of the much smaller alloc.h in many places.
--- add-patch.c | 2 + alias.c | 4 +- alloc.h | 75 ++++++++++++++++++++++++++++++ apply.c | 1 + archive-tar.c | 3 +- archive.c | 3 +- attr.c | 1 + builtin/blame.c | 3 +- builtin/cat-file.c | 1 + builtin/checkout--worker.c | 1 + builtin/config.c | 2 +- builtin/credential-cache--daemon.c | 1 + builtin/fetch-pack.c | 1 + builtin/fsmonitor--daemon.c | 1 + builtin/grep.c | 1 + builtin/index-pack.c | 1 + builtin/log.c | 3 +- builtin/merge.c | 1 + builtin/mktree.c | 1 + builtin/mv.c | 1 + builtin/name-rev.c | 2 +- builtin/pack-objects.c | 2 +- builtin/repack.c | 2 +- builtin/rev-parse.c | 1 + builtin/revert.c | 3 +- builtin/rm.c | 1 + builtin/submodule--helper.c | 1 + bulk-checkin.c | 3 +- cache-tree.c | 3 +- cache.h | 75 ------------------------------ chunk-format.c | 3 +- commit-reach.c | 3 +- compat/mingw.c | 1 + config.c | 3 +- daemon.c | 1 + delta-islands.c | 3 +- diff.c | 1 + diffcore-rename.c | 1 + dir-iterator.c | 3 +- dir.c | 3 +- ewah/bitmap.c | 3 +- ewah/ewah_bitmap.c | 2 +- fetch-pack.c | 3 +- fmt-merge-msg.c | 1 + fsck.c | 3 +- fsmonitor-settings.c | 3 +- help.c | 3 +- http-backend.c | 3 +- line-log.c | 1 + list-objects-filter-options.c | 4 +- list-objects-filter.c | 1 + midx.c | 3 +- object-file.c | 3 +- oid-array.c | 3 +- pack-bitmap-write.c | 3 +- pack-bitmap.c | 3 +- pack-objects.c | 3 +- packfile.c | 3 +- parallel-checkout.c | 1 + pretty.c | 1 + prio-queue.c | 3 +- quote.c | 1 + read-cache.c | 1 + ref-filter.c | 5 +- reflog-walk.c | 3 +- refs.c | 3 +- refs/packed-backend.c | 3 +- refs/ref-cache.c | 3 +- refspec.c | 3 +- remote-curl.c | 3 +- remote.c | 3 +- rerere.c | 3 +- revision.c | 3 +- sequencer.c | 1 + server-info.c | 3 +- shallow.c | 3 +- sigchain.c | 3 +- sparse-index.c | 1 + split-index.c | 1 + strbuf.c | 3 +- string-list.c | 3 +- strvec.c | 3 +- submodule-config.c | 1 + submodule.c | 4 +- t/helper/test-reach.c | 2 +- trace2/tr2_tls.c | 4 +- trailer.c | 1 + transport.c | 4 +- tree-walk.c | 1 + userdiff.c | 4 +- worktree.c | 3 +- 91 files changed, 220 insertions(+), 134 deletions(-)
add-patch.c +2 -0
@@ -1,5 +1,7 @@#include "cache.h" #include "add-interactive.h" +#include "alloc.h" +#include "gettext.h" #include "strbuf.h" #include "run-command.h" #include "strvec.h"
alias.c +3 -1
@@ -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 {
alloc.h +75 -0
79 lines not on this page · raw message
apply.c +1 -0
@@ -8,6 +8,7 @@*/ #include "cache.h" +#include "alloc.h" #include "config.h" #include "object-store.h" #include "blob.h"
archive-tar.c +2 -1
@@ -1,7 +1,8 @@/* * Copyright (c) 2005, 2006 Rene Scharfe */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "tar.h" #include "archive.h"
archive.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h"
attr.c +1 -0
@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "alloc.h" #include "config.h" #include "exec-cmd.h" #include "attr.h"
builtin/blame.c +2 -1
@@ -5,7 +5,8 @@* See COPYING for licensing conditions */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "color.h" #include "builtin.h"
builtin/cat-file.c +1 -0
@@ -5,6 +5,7 @@*/ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "builtin.h" #include "diff.h"
builtin/checkout--worker.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "config.h" #include "entry.h" #include "parallel-checkout.h"
builtin/config.c +1 -1
@@ -1,5 +1,5 @@#include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "config.h" #include "color.h" #include "parse-options.h"
builtin/credential-cache--daemon.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "parse-options.h" #ifndef NO_UNIX_SOCKETS
builtin/fetch-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "pkt-line.h" #include "fetch-pack.h" #include "remote.h"
builtin/fsmonitor--daemon.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "config.h" #include "parse-options.h" #include "fsmonitor.h"
builtin/grep.c +1 -0
@@ -4,6 +4,7 @@* Copyright (c) 2006 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "blob.h"
builtin/index-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "config.h" #include "delta.h" #include "pack.h"
builtin/log.c +2 -1
@@ -4,7 +4,8 @@* (C) Copyright 2006 Linus Torvalds * 2006 Junio Hamano */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h"
builtin/merge.c +1 -0
@@ -8,6 +8,7 @@#define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "parse-options.h" #include "builtin.h"
builtin/mktree.c +1 -0
@@ -4,6 +4,7 @@* Copyright (c) Junio C Hamano, 2006, 2009 */ #include "builtin.h" +#include "alloc.h" #include "quote.h" #include "tree.h" #include "parse-options.h"
builtin/mv.c +1 -0
@@ -5,6 +5,7 @@*/ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "config.h" #include "pathspec.h" #include "lockfile.h"
builtin/name-rev.c +1 -1
@@ -1,5 +1,5 @@#include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "commit.h"
builtin/pack-objects.c +1 -1
@@ -1,5 +1,5 @@#include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "attr.h"
builtin/repack.c +1 -1
@@ -1,5 +1,5 @@#include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "config.h" #include "dir.h" #include "parse-options.h"
builtin/rev-parse.c +1 -0
@@ -5,6 +5,7 @@*/ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "commit.h" #include "refs.h"
builtin/revert.c +2 -1
@@ -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"
builtin/rm.c +1 -0
@@ -5,6 +5,7 @@*/ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "advice.h" #include "config.h" #include "lockfile.h"
builtin/submodule--helper.c +1 -0
@@ -1,5 +1,6 @@#define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "repository.h" #include "cache.h" #include "config.h"
bulk-checkin.c +2 -1
@@ -1,7 +1,8 @@/* * Copyright (c) 2011, Google Inc. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "bulk-checkin.h" #include "lockfile.h" #include "repository.h"
cache-tree.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "lockfile.h" #include "tree.h" #include "tree-walk.h"
cache.h +0 -75
81 lines not on this page · raw message
chunk-format.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "chunk-format.h" #include "csum-file.h"
commit-reach.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "commit-graph.h" #include "decorate.h"
compat/mingw.c +1 -0
@@ -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"
config.c +2 -1
@@ -5,7 +5,8 @@* Copyright (C) Johannes Schindelin, 2005 * */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "date.h" #include "branch.h" #include "config.h"
daemon.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "pkt-line.h" #include "run-command.h"
delta-islands.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "attr.h" #include "object.h" #include "blob.h"
diff.c +1 -0
@@ -2,6 +2,7 @@* Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "tempfile.h" #include "quote.h"
diffcore-rename.c +1 -0
@@ -3,6 +3,7 @@* Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "diff.h" #include "diffcore.h" #include "object-store.h"
dir-iterator.c +2 -1
@@ -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"
dir.c +2 -1
@@ -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"
ewah/bitmap.c +2 -1
@@ -16,7 +16,8 @@* You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#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))
ewah/ewah_bitmap.c +1 -1
@@ -17,9 +17,9 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ #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) {
fetch-pack.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "lockfile.h"
fmt-merge-msg.c +1 -0
@@ -1,4 +1,5 @@#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h"
fsck.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "object-store.h" #include "repository.h" #include "object.h"
fsmonitor-settings.c +2 -1
@@ -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"
help.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "builtin.h" #include "exec-cmd.h"
http-backend.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "repository.h" #include "refs.h"
line-log.c +1 -0
@@ -1,4 +1,5 @@#include "git-compat-util.h" +#include "alloc.h" #include "line-range.h" #include "cache.h" #include "tag.h"
list-objects-filter-options.c +3 -1
@@ -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"
list-objects-filter.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "dir.h" #include "tag.h" #include "commit.h"
midx.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "csum-file.h" #include "dir.h"
object-file.c +2 -1
@@ -6,7 +6,8 @@* This handles basic git object files - packing, unpacking, * creation etc. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "string-list.h" #include "lockfile.h"
oid-array.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "oid-array.h" #include "hash-lookup.h"
pack-bitmap-write.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "object-store.h" #include "commit.h" #include "tag.h"
pack-bitmap.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "strbuf.h" #include "tag.h"
pack-objects.c +2 -1
@@ -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"
packfile.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "list.h" #include "pack.h" #include "repository.h"
parallel-checkout.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "entry.h" #include "parallel-checkout.h"
pretty.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "commit.h" #include "utf8.h"
prio-queue.c +2 -1
@@ -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)
quote.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "quote.h" #include "strvec.h"
read-cache.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "diff.h" #include "diffcore.h"
ref-filter.c +2 -3
@@ -1,5 +1,5 @@ -#include "builtin.h" -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "parse-options.h" #include "refs.h" #include "wildmatch.h"
@@ -13,7 +13,6 @@#include "ref-filter.h" #include "revision.h" #include "utf8.h" -#include "git-compat-util.h" #include "version.h" #include "trailer.h" #include "wt-status.h"
reflog-walk.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "refs.h" #include "diff.h"
refs.c +2 -1
@@ -2,7 +2,8 @@* The backend-independent part of the reference module. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "hashmap.h" #include "lockfile.h"
refs/packed-backend.c +2 -1
@@ -1,4 +1,5 @@ -#include "../cache.h" +#include "../git-compat-util.h" +#include "../alloc.h" #include "../config.h" #include "../refs.h" #include "refs-internal.h"
refs/ref-cache.c +2 -1
@@ -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"
refspec.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "strvec.h" #include "refs.h" #include "refspec.h"
remote-curl.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "remote.h" #include "connect.h"
remote.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "remote.h" #include "urlmatch.h"
rerere.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "lockfile.h" #include "string-list.h"
revision.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "object-store.h" #include "tag.h"
sequencer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "lockfile.h" #include "dir.h"
server-info.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "dir.h" #include "repository.h" #include "refs.h"
shallow.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "tempfile.h" #include "lockfile.h"
sigchain.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "sigchain.h" #define SIGCHAIN_MAX_SIGNALS 32
sparse-index.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "repository.h" #include "sparse-index.h" #include "tree.h"
split-index.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "split-index.h" #include "ewah/ewok.h"
strbuf.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "refs.h" #include "string-list.h" #include "utf8.h"
string-list.c +2 -1
@@ -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) {
strvec.c +2 -1
@@ -1,5 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" #include "strvec.h" +#include "alloc.h" #include "strbuf.h" const char *empty_strvec[] = {NULL };
submodule-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "dir.h" #include "repository.h" #include "config.h"
submodule.c +2 -2
@@ -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"
t/helper/test-reach.c +1 -1
@@ -1,5 +1,5 @@#include "test-tool.h" -#include "cache.h" +#include "alloc.h" #include "commit.h" #include "commit-reach.h" #include "config.h"
trace2/tr2_tls.c +3 -1
@@ -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" /*
trailer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "string-list.h" #include "run-command.h"
transport.c +3 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "transport.h" #include "hook.h"
@@ -10,6 +11,7 @@#include "walker.h" #include "bundle.h" #include "dir.h" +#include "gettext.h" #include "refs.h" #include "refspec.h" #include "branch.h"
tree-walk.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "tree-walk.h" +#include "alloc.h" #include "dir.h" #include "object-store.h" #include "tree.h"
userdiff.c +3 -1
@@ -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;
worktree.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "refs.h" #include "strbuf.h"
Signature · 1 line
gitgitgadget
Re: [PATCH 05/16] alloc.h: move ALLOC_GROW() functions from cache.h
Quoted 10 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
This allows us to replace includes of
cache.hwith includes of the much smalleralloc.hin many places.add-patch.c +0
-0
add-patch.c line 4
Quoted 4 lines
add-patch.c +2
-0@@ -1,5 +1,7 @@#include "cache.h" #include "add-interactive.h" +#include "alloc.h" +#include "gettext.h"
I see here that you are not dropping cache.h, but are also adding gettext.h, too? Did you mean to replace cache.h with git-compat-util.h here, or will I see that change happen in a future patch?
attr.c line 10
Quoted 9 lines
attr.c +1
-0@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "alloc.h"
(Here's another example. Makes it more likely that this is on purpose in preparation for a full swap in the future. I'll stop mentioning this when I see it.)
I also manually verified that the macros are an exact move from cache.h to alloc.h.
Thanks,
-Stolee
Re: [PATCH 05/16] alloc.h: move ALLOC_GROW() functions from cache.h
Quoted 7 lines · Derrick Stolee
Quoted 4 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
This allows us to replace includes of
cache.hwith includes of the much smalleralloc.hin many places.
Quoted 13 lines
add-patch.c line 4
Quoted 9 lines
add-patch.c +2
-0@@ -1,5 +1,7 @@#include "cache.h" #include "add-interactive.h" +#include "alloc.h" +#include "gettext.h" I see here that you are not dropping
cache.h, but are also addinggettext.h, too? Did you mean to replacecache.hwithgit-compat-util.hhere, or will I see that change happen in a future patch?
Not intentional. Often as I made changes, I also flipped cache.h to git-compat-util.h manually, then found out what was missing and started adding other headers. Sometimes that worked, sometimes I found that there was still more stuff directly in cache.h that was needed. When I backed out the change, I forgot to remove the gettext.h inclusion. (Though leaving it in doesn't hurt either, since the file does clearly depend upon it.)
Quoted 14 lines
attr.c line 10
Quoted 9 lines
attr.c +1
-0@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "alloc.h" (Here's another example. Makes it more likely that this is on purpose in preparation for a full swap in the future. I'll stop mentioning this when I see it.)
Quoted 2 lines
I also manually verified that the macros are an exact move from
cache.htoalloc.h.
Yeah, since I moved code out of cache.h into alloc.h, and didn't make cache.h depend upon alloc.h (because it really doesn't depend on it), that means each file that does depend upon alloc.h needs to explicitly include it. I guess I could have made that more clear in the commit message.
Re: [PATCH 05/16] alloc.h: move ALLOC_GROW() functions from cache.h
In reply to Derrick StoleeQuoted 6 lines · Derrick Stolee
Quoted 4 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
This allows us to replace includes of
cache.hwith includes of the much smalleralloc.hin many places.
Quoted 13 lines
add-patch.c line 4
Quoted 9 lines
add-patch.c +2
-0@@ -1,5 +1,7 @@#include "cache.h" #include "add-interactive.h" +#include "alloc.h" +#include "gettext.h" I see here that you are not dropping
cache.h, but are also addinggettext.h, too? Did you mean to replacecache.hwithgit-compat-util.hhere, or will I see that change happen in a future patch?
Thanks for reading very carefully.
Quoted 19 lines
attr.c line 10
Quoted 9 lines
attr.c +1
-0@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "alloc.h" (Here's another example. Makes it more likely that this is on purpose in preparation for a full swap in the future. I'll stop mentioning this when I see it.)
I also manually verified that the macros are an exact move from
cache.htoalloc.h.Thanks,
-Stolee
Re: [PATCH 05/16] alloc.h: move ALLOC_GROW() functions from cache.h
In reply to Elijah Newren via GitGitGadgetQuoted 4 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
This allows us to replace includes of
cache.hwith includes of the much smalleralloc.hin many places.
Yes! This is a very logical thing to do. Allocation and reallocation, especially in the modern world where "memory is tight, let's unmap some packfiles" no longer happens, does not have to be very "git" specific operation and should not have to depend on the rest of "git". Having to include "cache.h" is one trait I consider anything is part of the implementation of "git" that has to be intimate with its internal.
PATCH 6/16 hash.h: move some oid-related declarations from cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
These defines and enum are all oid-related and as such seem to make more sense being included in hash.h. Further, moving them there allows us to remove some includes of cache.h in other files.
--- cache.h | 34 -------------------- diffcore.h | 4 ++- hash.h | 34 ++++++++++++++++++++ line-log.h | 1 + submodule-config.h | 1 - t/helper/test-submodule-nested-repo-config.c | 1 + tree-walk.h | 4 ++- 7 files changed, 42 insertions(+), 37 deletions(-)
cache.h +0 -34
@@ -1363,40 +1363,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, ...);
diffcore.h +3 -1
@@ -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 ;
hash.h +34 -0
@@ -123,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;
line-log.h +1 -0
@@ -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. */
submodule-config.h +0 -1
@@ -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"
t/helper/test-submodule-nested-repo-config.c +1 -0
@@ -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)
tree-walk.h +3 -1
@@ -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
Signature · 1 line
gitgitgadget
Re: [PATCH 06/16] hash.h: move some oid-related declarations from cache.h
Quoted 12 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
These defines and enum are all oid-related and as such seem to make more sense being included in
hash.h. Further, moving them there allows us to remove some includes ofcache.hin other files.line-log.h +0
-0
line-log.h line 11
Quoted 7 lines
line-log.h +1
-0@@ -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. */
This hunk seems unrelated to the current patch. Perhaps misplaced?
Thanks,
-Stolee
Re: [PATCH 06/16] hash.h: move some oid-related declarations from cache.h
Quoted 15 lines · Derrick Stolee
Quoted 13 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
These defines and enum are all oid-related and as such seem to make more sense being included in
hash.h. Further, moving them there allows us to remove some includes ofcache.hin other files.line-log.h +0
-0@@ -5,6 +5,7 @@
Quoted 8 lines
line-log.h line 11
Quoted 6 lines
line-log.h +1
-0struct 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. */ This hunk seems unrelated to the current patch. Perhaps misplaced?
Yeah, I can see how it might be surprising, but this is necessary. line-log.h includes diffcore.h, which prior to this patch included cache.h, which includes the kitchen sink. With this patch, diffcore.h stopped including cache.h, and suddenly line-log.h has some 'struct string_list *' parameters to functions that the compiler will complain about. Adding a forward declaration fixes it.
Re: [PATCH 06/16] hash.h: move some oid-related declarations from cache.h
In reply to Elijah Newren via GitGitGadgetQuoted 17 lines · Elijah Newren via GitGitGadget
submodule-config.h +0
-1@@ -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" t/helper/test-submodule-nested-repo-config.c +0
-0
t/helper/test-submodule-nested-repo-config.c line 3
Quoted 3 lines
t/helper/test-submodule-nested-repo-config.c +1
-0@@ -1,4 +1,5 @@#include "test-tool.h" +#include "cache.h" #include "submodule-config.h"
This addition of including cache.h caught me a bit off-guard, but I can see that it is because submodule-config.h lost its own include of cache.h. Thanks - the patches up to and including this patch look good.
PATCH 7/16 hex.h: move some hex-related declarations from cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
hex.c contains code for hex-related functions, but for some reason these functions were declared in the catch-all cache.h. Move the function declarations into a hex.h header instead.
This also allows us to remove includes of cache.h from a few C files.
Note that reviewing the header changes in this commit might be simplified via
git log --no-walk -p --color-moved $COMMIT -- '*.h'`
In particular, it highlights the simple movement of code in .h files rather nicely.
--- cache.h | 79 +------------------------------------------- git-compat-util.h | 1 + hex.c | 3 +- hex.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++ mailinfo.c | 4 ++- oidset.c | 4 ++- wildmatch.c | 2 +- 7 files changed, 95 insertions(+), 82 deletions(-) create mode 100644 hex.h
cache.h +1 -78
@@ -13,6 +13,7 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" +#include "hex.h" #include "path.h" #include "oid-array.h" #include "repository.h"
@@ -1325,22 +1326,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
@@ -1393,68 +1378,6 @@ int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fint 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
git-compat-util.h +1 -0
@@ -1225,6 +1225,7 @@ extern const unsigned char tolower_trans_tbl[256];#undef isxdigitextern 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
hex.c +2 -1
@@ -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 */
hex.h new file +84 -0
84 lines not on this page · raw message
mailinfo.c +3 -1
@@ -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"
oidset.c +3 -1
@@ -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) {
wildmatch.c +1 -1
@@ -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 ;
Signature · 1 line
gitgitgadget
Re: [PATCH 07/16] hex.h: move some hex-related declarations from cache.h
Quoted 13 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
hex.ccontains code for hex-related functions, but for some reason these functions were declared in the catch-allcache.h. Move the function declarations into ahex.hheader instead.This also allows us to remove includes of
cache.hfrom a few C files.cache.h +0
-0
cache.h line 16
Quoted 4 lines
cache.h +1
-0@@ -13,6 +13,7 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" +#include "hex.h"
Adding this to cache.h is definitely safe, but it makes it so .c files that consume the moved code do not _need_ to include hex.h like I think you want to imply at the end of this patch.
What changes if you drop this from your change?
Thanks,
-Stolee
Re: [PATCH 07/16] hex.h: move some hex-related declarations from cache.h
Quoted 24 lines · Derrick Stolee
Quoted 13 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
hex.ccontains code for hex-related functions, but for some reason these functions were declared in the catch-allcache.h. Move the function declarations into ahex.hheader instead.This also allows us to remove includes of
cache.hfrom a few C files.cache.h +0
-0cache.h line 16
Quoted 4 lines
cache.h +1
-0@@ -13,6 +13,7 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" +#include "hex.h" Adding this to
cache.his definitely safe, but it makes it so .c files that consume the moved code do not _need_ to includehex.hlike I think you want to imply at the end of this patch.
Quoted 1 line
What changes if you drop this from your change?
I need to add a #include "hex.h" in 171 C files. I was worried previously that the sheer number of locations that I need to add such a header would cause my series to heavily conflict with next and seen, but it appears that these changes do not introduce any new conflicts. So, I guess I should have done it all along.
I think I'll do that in a separate follow-on commit instead of combining it with this one (so that this commit doesn't become excessively hard to review).
PATCH 8/16 pretty.h: move has_non_ascii() declaration from commit.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
The function is defined in pretty.c, so this moves the declaration to a more logical place.
--- commit.h | 1 - diffcore-pickaxe.c | 4 ++-- pretty.h | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-)
commit.h +0 -1
@@ -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);
diffcore-pickaxe.c +2 -2
@@ -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,
pretty.h +2 -0
@@ -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.
Signature · 1 line
gitgitgadget
PATCH 9/16 ident.h: move ident-related declarations out of cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
These functions were all defined in a separate ident.c already, so create ident.h and move the declarations into that file.
--- builtin/cat-file.c | 1 + builtin/check-mailmap.c | 1 + builtin/config.c | 1 + builtin/var.c | 1 + cache.h | 58 ----------------------------------- config.c | 1 + gpg-interface.c | 1 + ident.c | 5 ++- ident.h | 67 +++++++++++++++++++++++++++++++++++++++++ refs/files-backend.c | 1 + revision.h | 1 + 11 files changed, 79 insertions(+), 59 deletions(-) create mode 100644 ident.h
builtin/cat-file.c +1 -0
@@ -9,6 +9,7 @@#include "config.h" #include "builtin.h" #include "diff.h" +#include "ident.h" #include "parse-options.h" #include "userdiff.h" #include "streaming.h"
builtin/check-mailmap.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "config.h" +#include "ident.h" #include "mailmap.h" #include "parse-options.h" #include "string-list.h"
builtin/config.c +1 -0
@@ -2,6 +2,7 @@#include "alloc.h" #include "config.h" #include "color.h" +#include "ident.h" #include "parse-options.h" #include "urlmatch.h" #include "quote.h"
builtin/var.c +1 -0
@@ -5,6 +5,7 @@*/ #include "builtin.h" #include "config.h" +#include "ident.h" #include "refs.h" static const char var_usage[] ="git var (-l | <variable>)" ;
cache.h +0 -58
74 lines not on this page · raw message
config.c +1 -0
@@ -11,6 +11,7 @@#include "branch.h" #include "config.h" #include "environment.h" +#include "ident.h" #include "repository.h" #include "lockfile.h" #include "exec-cmd.h"
gpg-interface.c +1 -0
@@ -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"
ident.c +4 -1
@@ -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 ;
ident.h new file +67 -0
67 lines not on this page · raw message
refs/files-backend.c +1 -0
@@ -4,6 +4,7 @@#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"
revision.h +1 -0
@@ -8,6 +8,7 @@#include "pretty.h" #include "diff.h" #include "commit-slab-decl.h" +#include "ident.h" #include "list-objects-filter-options.h" /**
Signature · 1 line
gitgitgadget
PATCH 10/16 object.h: stop depending on cache.h; make cache.h depend on object.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
Things should be able to depend on object.h without pulling in all of cache.h. Move an enum to allow this.
Note that a couple files previously depended on things brought in through cache.h indirectly (revision.h -> commit.h -> object.h -> cache.h). As such, this change requires making existing dependencies more explicit in two files.
--- alloc.c | 2 +- blame.h | 1 - blob.c | 2 +- cache-tree.h | 1 - cache.h | 21 +-------------------- diff-merges.c | 1 + diff.h | 2 +- diffcore-delta.c | 2 +- fsck.h | 1 + help.c | 1 + list-objects-filter-options.h | 3 ++- negotiator/noop.c | 2 +- object.h | 22 +++++++++++++++++++++- shallow.h | 2 ++ t/helper/test-bloom.c | 2 +- t/helper/test-example-decorate.c | 2 +- worktree.h | 1 - 17 files changed, 36 insertions(+), 32 deletions(-)
alloc.c +1 -1
@@ -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"
blame.h +0 -1
@@ -1,7 +1,6 @@#ifndef BLAME_H #define BLAME_H -#include "cache.h" #include "commit.h" #include "xdiff-interface.h" #include "revision.h"
blob.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "blob.h" #include "repository.h" #include "alloc.h"
cache-tree.h +0 -1
@@ -1,7 +1,6 @@#ifndef CACHE_TREE_H #define CACHE_TREE_H -#include "cache.h" #include "tree.h" #include "tree-walk.h"
cache.h +1 -20
@@ -15,6 +15,7 @@#include "hash.h" #include "hex.h" #include "path.h" +#include "object.h" #include "oid-array.h" #include "repository.h" #include "mem-pool.h"
@@ -454,26 +455,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 :
diff-merges.c +1 -0
@@ -1,6 +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.h +1 -1
@@ -8,6 +8,7 @@#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 +72,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,
diffcore-delta.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "diff.h" #include "diffcore.h"
fsck.h +1 -0
@@ -1,6 +1,7 @@#ifndef GIT_FSCK_H #define GIT_FSCK_H +#include "object.h" #include "oidset.h" enum fsck_msg_type {
help.c +1 -0
@@ -5,6 +5,7 @@#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"
list-objects-filter-options.h +2 -1
@@ -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.
negotiator/noop.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "noop.h" #include "../commit.h" #include "../fetch-negotiator.h"
object.h +21 -1
@@ -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. */
shallow.h +2 -0
@@ -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);
t/helper/test-bloom.c +1 -1
@@ -1,4 +1,4 @@ -#include "git-compat-util.h" +#include "cache.h" #include "bloom.h" #include "test-tool.h" #include "commit.h"
t/helper/test-example-decorate.c +1 -1
@@ -1,5 +1,5 @@#include "test-tool.h" -#include "cache.h" +#include "git-compat-util.h" #include "object.h" #include "decorate.h"
worktree.h +0 -1
@@ -1,7 +1,6 @@#ifndef WORKTREE_H #define WORKTREE_H -#include "cache.h" #include "refs.h" struct strbuf ;
Signature · 1 line
gitgitgadget
Re: [PATCH 10/16] object.h: stop depending on cache.h; make cache.h depend on object.h
Quoted 23 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
Things should be able to depend on
object.hwithout pulling in all ofcache.h. Move an enum to allow this.Note that a couple files previously depended on things brought in through
cache.hindirectly (revision.h->commit.h->object.h->cache.h). As such, this change requires making existing dependencies more explicit in two files.diff.h +1
-0@@ -8,6 +8,7 @@#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,
diff.h struct oid_array; · line 75
Quoted 5 lines
diff.h +0
-1@@ -71,7 +72,6 @@ struct oid_array;struct option ;struct repository ;struct rev_info ; -struct strbuf ;struct userdiff_driver ;
This inclusion of strbuf.h in diff.h seems like a step in the opposite direction. What caused you to need to do this?
Looking ahead at the patch titles, I see you will revisit diff.h in the final patch, so I'll try to see if there are effects there.
list-objects-filter-options.h line 7
Quoted 13 lines
list-objects-filter-options.h +2
-1@@ -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"
Here's another case of including strbuf.h instead of declaring 'struct strbuf'. However, it makes a bit more sense because you are deleting the cache.h include in this change. It would still be nice if we didn't need to do it.
Thanks,
-Stolee
Re: [PATCH 10/16] object.h: stop depending on cache.h; make cache.h depend on object.h
Quoted 34 lines · Derrick Stolee
Quoted 23 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
Things should be able to depend on
object.hwithout pulling in all ofcache.h. Move an enum to allow this.Note that a couple files previously depended on things brought in through
cache.hindirectly (revision.h->commit.h->object.h->cache.h). As such, this change requires making existing dependencies more explicit in two files.diff.h +1
-0@@ -8,6 +8,7 @@#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, diff.h struct oid_array; · line 75
Quoted 5 lines
diff.h +0
-1@@ -71,7 +72,6 @@ struct oid_array;struct option ;struct repository ;struct rev_info ; -struct strbuf ;struct userdiff_driver ;This inclusion of
strbuf.hindiff.hseems like a step in the opposite direction. What caused you to need to do this?
Quoted 2 lines
Looking ahead at the patch titles, I see you will revisit
diff.hin the final patch, so I'll try to see if there are effects there.
Later in diff.h there is a struct defined which includes a direct 'struct strbuf'. As such, a forward declaration is incorrect, and the code only worked previously because diff.h included strbuf.h indirectly (through object.h -> cache.h -> strbuf.h). Now that object.h no longer includes cache.h, we have to correct this error.
Quoted 8 lines
Quoted 8 lines
list-objects-filter-options.h +0
-0@@ -1,9 +1,10 @@#ifndef LIST_OBJECTS_FILTER_OPTIONS_H #define LIST_OBJECTS_FILTER_OPTIONS_H
Quoted 10 lines
list-objects-filter-options.h line 7
Quoted 5 lines
list-objects-filter-options.h +2
-1-#include "cache.h" +#include "object.h" #include "parse-options.h" #include "string-list.h" +#include "strbuf.h" Here's another case of including
strbuf.hinstead of declaring 'struct strbuf'. However, it makes a bit more sense because you are deleting thecache.hinclude in this change. It would still be nice if we didn't need to do it.
Same issue; struct list_objects_filter_options includes an embedded struct strbuf, so the strbuf header needs to be included.
I'll call these out specifically in the commit message.
PATCH 11/16 dir.h: refactor to no longer need to include cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
Moving a few functions around allows us to make dir.h no longer need to include cache.h. This commit is best viewed with:
git log -1 -p --color-moved
--- cache.h | 31 +++++++++++-------------------- dir.h | 16 ++-------------- pathspec.h | 5 +++++ statinfo.h | 24 ++++++++++++++++++++++++ trace2/tr2_sysenv.c | 2 +- 5 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 statinfo.h
cache.h +11 -20
@@ -15,9 +15,11 @@#include "hash.h" #include "hex.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 {
@@ -120,26 +122,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;
@@ -295,6 +277,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 */
dir.h +2 -14
@@ -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" /**
@@ -363,10 +364,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);
@@ -533,15 +530,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,
pathspec.h +5 -0
@@ -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
statinfo.h new file +24 -0
@@ -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
trace2/tr2_sysenv.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "dir.h" #include "tr2_sysenv.h"
Signature · 1 line
gitgitgadget
PATCH 12/16 object-store.h: move struct object_info from cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
Move struct object_info, and a few related #define's from cache.h to object-store.h.
--- merge-blobs.c | 2 +- object-store.h | 128 +++++++++++++++++++++++------------------------ protocol-caps.c | 1 + replace-object.h | 1 + 4 files changed, 67 insertions(+), 65 deletions(-)
merge-blobs.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "run-command.h" #include "xdiff-interface.h" #include "ll-merge.h"
object-store.h +64 -64
146 lines not on this page · raw message
protocol-caps.c +1 -0
@@ -4,6 +4,7 @@#include "pkt-line.h" #include "strvec.h" #include "hash.h" +#include "hex.h" #include "object.h" #include "object-store.h" #include "string-list.h"
replace-object.h +1 -0
@@ -1,6 +1,7 @@#ifndef REPLACE_OBJECT_H #define REPLACE_OBJECT_H +#include "cache.h" #include "oidmap.h" #include "repository.h" #include "object-store.h"
Signature · 1 line
gitgitgadget
Re: [PATCH 12/16] object-store.h: move struct object_info from cache.h
Quoted 10 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
Move struct
object_info, and a few related #define's fromcache.htoobject-store.h.replace-object.h +0
-0
replace-object.h line 7
Quoted 7 lines
replace-object.h +1
-0@@ -1,6 +1,7 @@#ifndef REPLACE_OBJECT_H #define REPLACE_OBJECT_H +#include "cache.h" #include "oidmap.h" #include "repository.h" #include "object-store.h"
This seems like an unlikely side-effect of the changes you're making. What is the reason we need this?
Thanks,
-Stolee
Re: [PATCH 12/16] object-store.h: move struct object_info from cache.h
Quoted 15 lines · Derrick Stolee
Quoted 13 lines · Elijah Newren via GitGitGadget
From: Elijah Newren <[email protected]>
Move struct
object_info, and a few related #define's fromcache.htoobject-store.h.replace-object.h +0
-0@@ -1,6 +1,7 @@#ifndef REPLACE_OBJECT_H #define REPLACE_OBJECT_H
Quoted 7 lines
replace-object.h line 7
Quoted 4 lines
replace-object.h +1
-0+#include "cache.h" #include "oidmap.h" #include "repository.h" #include "object-store.h" This seems like an unlikely side-effect of the changes you're making. What is the reason we need this?
I'll add the following to the commit message:
A surprising effect of this change is that replace-object.h, which includes object-store.h, now needs to directly include cache.h since that is where read_replace_refs is declared and that variable is used in one of its inline functions. The next commit will move that declaration and fix that unfortunate new direct inclusion of cache.h.
PATCH 13/16 replace-object.h: move read_replace_refs declaration from cache.h to here
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
Adjust several files to be more explicit about their dependency on replace-objects to accommodate this change.
--- builtin/cat-file.c | 1 + builtin/commit-graph.c | 1 + builtin/fsck.c | 1 + builtin/index-pack.c | 1 + builtin/pack-objects.c | 1 + builtin/prune.c | 1 + builtin/replace.c | 1 + builtin/unpack-objects.c | 1 + builtin/upload-pack.c | 1 + cache.h | 8 -------- config.c | 1 + environment.c | 1 + git.c | 1 + log-tree.c | 1 + replace-object.h | 9 ++++++++- 15 files changed, 21 insertions(+), 9 deletions(-)
builtin/cat-file.c +1 -0
@@ -17,6 +17,7 @@#include "oid-array.h" #include "packfile.h" #include "object-store.h" +#include "replace-object.h" #include "promisor-remote.h" #include "mailmap.h"
builtin/commit-graph.c +1 -0
@@ -7,6 +7,7 @@#include "commit-graph.h" #include "object-store.h" #include "progress.h" +#include "replace-object.h" #include "tag.h" #define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \
builtin/fsck.c +1 -0
@@ -19,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"
builtin/index-pack.c +1 -0
@@ -15,6 +15,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[] =
builtin/pack-objects.c +1 -0
@@ -31,6 +31,7 @@#include "list.h" #include "packfile.h" #include "object-store.h" +#include "replace-object.h" #include "dir.h" #include "midx.h" #include "trace2.h"
builtin/prune.c +1 -0
@@ -7,6 +7,7 @@#include "parse-options.h" #include "progress.h" #include "prune-packed.h" +#include "replace-object.h" #include "object-store.h" #include "shallow.h"
builtin/replace.c +1 -0
@@ -15,6 +15,7 @@#include "parse-options.h" #include "run-command.h" #include "object-store.h" +#include "replace-object.h" #include "repository.h" #include "tag.h"
builtin/unpack-objects.c +1 -0
@@ -8,6 +8,7 @@#include "pack.h" #include "blob.h" #include "commit.h" +#include "replace-object.h" #include "tag.h" #include "tree.h" #include "tree-walk.h"
builtin/upload-pack.c +1 -0
@@ -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"
cache.h +0 -8
@@ -887,14 +887,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
config.c +1 -0
@@ -23,6 +23,7 @@#include "utf8.h" #include "dir.h" #include "color.h" +#include "replace-object.h" #include "refs.h" #include "worktree.h"
environment.c +1 -0
@@ -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"
git.c +1 -0
@@ -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)
log-tree.c +1 -0
@@ -12,6 +12,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"
replace-object.h +8 -1
@@ -1,11 +1,18 @@ #ifndef REPLACE_OBJECT_H #define REPLACE_OBJECT_H -#include "cache.h" #include "oidmap.h" #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;
Signature · 1 line
gitgitgadget
PATCH 14/16 treewide: replace cache.h with more direct headers, where possible
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
--- advice.c | 4 +++- decorate.c | 3 ++- diffcore-order.c | 3 ++- diffcore-rename.c | 6 +++++- diffcore-rotate.c | 3 ++- graph.c | 3 ++- hook.c | 5 ++++- quote.c | 1 + sha1dc_git.c | 4 +++- unix-socket.c | 3 ++- url.c | 4 +++- urlmatch.c | 5 ++++- 12 files changed, 33 insertions(+), 11 deletions(-)
advice.c +3 -1
@@ -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"
decorate.c +2 -1
@@ -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"
diffcore-order.c +2 -1
@@ -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"
diffcore-rename.c +5 -1
@@ -2,15 +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 */
diffcore-rotate.c +2 -1
@@ -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"
graph.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "gettext.h" #include "config.h" #include "commit.h" #include "color.h"
hook.c +4 -1
@@ -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) {
quote.c +1 -0
@@ -1,6 +1,7 @@#include "cache.h" #include "alloc.h" #include "quote.h" +#include "strbuf.h" #include "strvec.h" int quote_path_fully =1 ;
sha1dc_git.c +3 -1
@@ -1,4 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "sha1dc_git.h" +#include "hex.h" #ifdef DC_SHA1_EXTERNAL /*
unix-socket.c +2 -1
@@ -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)
url.c +3 -1
@@ -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)
urlmatch.c +4 -1
@@ -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"
Signature · 1 line
gitgitgadget
PATCH 15/16 Remove unnecessary includes of builtin.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
--- diff-no-index.c | 1 - merge-recursive.c | 1 - send-pack.c | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-)
diff-no-index.c +0 -1
@@ -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"
merge-recursive.c +0 -1
@@ -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"
send-pack.c +1 -1
@@ -1,4 +1,4 @@ -#include "builtin.h" +#include "git-compat-util.h" #include "config.h" #include "commit.h" #include "refs.h"
Signature · 1 line
gitgitgadget
PATCH 16/16 diff.h: remove unnecessary include of object.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
--- diff.h | 1 - 1 file changed, 1 deletion(-)
diff.h +0 -1
@@ -6,7 +6,6 @@#include "tree-walk.h" #include "pathspec.h" -#include "object.h" #include "oidset.h" #include "strbuf.h"
Signature · 1 line
gitgitgadget
Quoted 4 lines · Elijah Newren via GitGitGadget
This series cleans up headers a bit, trying to remove excessive dependency on "
cache.h". I created this series a while ago, but decided to clean it up and submit it due to Emily's recent thread and suggestion that this might be helpful to their efforts[1].
Thanks for doing this cleanup. It certainly doesn't look like an easy task.
I read the patches carefully and tried to point out anything that looked fishy and not fully supported by the commit message. However, some things are probably only fishy because it was the least-complicated time to make that change.
I'd be happy with this series as-is, allowing further improvements on top. I just wanted to poke a little at these bits that were not super-clear in case there was a possible improvement.
Thanks,
-Stolee
v2 cover Header cleanups
In reply to Elijah Newren via GitGitGadgetMaintainer note: This series cleanly merges with next, but has TWO minor conflicts with ed/fsmonitor-inotify. The correct resolution is to take ed/fsmonitor-inotify's copy of both compat/fsmonitor/fsm-settings-darwin.c and compat/fsmonitor/fsm-ipc-darwin.c, but to add a #include "git-compat-util.h" line at the top of compat/fsmonitor/fsm-settings-unix.c and a #include "hex.h" somewhere near the top of compat/fsmonitor/fsm-ipc-unix.c
Changes since v1:
* Fixed a bad squash; moved the changes to the right commit
* More thorough justification in the commit message for the 2nd commit
* Removed an accidental added include of gettext.h (the file was used, but it makes it harder to review that patch)
* Add some explanation of surprising changes to commit messages
* Add a new commit which removes the include of hex.h from cache.h, and instead makes C files include it directly, as suggested by Stolee
This series cleans up headers a bit, trying to remove excessive dependency on "cache.h". I created this series a while ago, but decided to clean it up and submit it due to Emily's recent thread and suggestion that this might be helpful to their efforts[1].
There are many more cleanups I could do in this area, but the series is already a good size.
Notes:
* Big props to Dscho for gitgitgadget; being able to test on a bunch of platforms with a variety of configurations easily is a big win in general but especially for series like this one.
* I used the scripts at
https://github.com/newren/git/commit/db81c8d7fb554b3edf04320e218bddeb98bb6194,
and some tweaks thereof, repeatedly while making this series (though they are prone to produce both false positive and false negatives, so if you use them, only use them to generate hints about which files to look at).
[1] Search for "Extremely yes" in
https://lore.kernel.org/git/CAJoAoZm+TkCL0Jpg_qFgKottxbtiG2QOiY0qGrz3-uQy+=waPg@mail.gmail.com/
Elijah Newren (17):
treewide: ensure one of the appropriate headers is sourced first
treewide: remove unnecessary git-compat-util.h includes in headers
treewide: remove unnecessary cache.h includes
treewide: remove unnecessary cache.h includes in source files alloc.h: move ALLOC_GROW() functions from cache.h
hash.h: move some oid-related declarations from cache.h hex.h: move some hex-related declarations from cache.h cache.h: remove dependence on hex.h; make other files include it
explicitly
pretty.h: move has_non_ascii() declaration from commit.h ident.h: move ident-related declarations out of cache.h object.h: stop depending on cache.h; make cache.h depend on object.h dir.h: refactor to no longer need to include cache.h object-store.h: move struct object_info from cache.h replace-object.h: move read_replace_refs declaration from cache.h to
here
treewide: replace cache.h with more direct headers, where possible Remove unnecessary includes of builtin.h
diff.h: remove unnecessary include of object.h
Documentation/CodingGuidelines | 8 +- add-interactive.c | 1 + add-patch.c | 1 + advice.c | 4 +- advice.h | 2 - alias.c | 4 +- alloc.c | 2 +- alloc.h | 75 +++++ apply.c | 2 + archive-tar.c | 4 +- archive-zip.c | 1 + archive.c | 4 +- attr.c | 1 + bisect.c | 1 + blame.c | 1 + blame.h | 1 - blob.c | 2 +- branch.c | 1 + builtin/am.c | 1 + builtin/bisect.c | 1 + builtin/blame.c | 4 +- builtin/cat-file.c | 4 + builtin/check-mailmap.c | 1 + builtin/checkout--worker.c | 1 + builtin/checkout.c | 1 + builtin/clone.c | 1 + builtin/commit-graph.c | 2 + builtin/commit-tree.c | 1 + builtin/config.c | 3 +- builtin/credential-cache--daemon.c | 1 + builtin/describe.c | 1 + builtin/diff-tree.c | 1 + builtin/difftool.c | 1 + builtin/fast-export.c | 1 + builtin/fast-import.c | 1 + builtin/fetch-pack.c | 2 + builtin/fetch.c | 1 + builtin/fsck.c | 2 + builtin/fsmonitor--daemon.c | 1 + builtin/gc.c | 1 + builtin/grep.c | 2 + builtin/hash-object.c | 1 + builtin/index-pack.c | 3 + builtin/log.c | 4 +- builtin/ls-remote.c | 1 + builtin/ls-tree.c | 1 + builtin/merge-base.c | 1 + builtin/merge-index.c | 1 + builtin/merge-tree.c | 1 + builtin/merge.c | 2 + builtin/mktag.c | 1 + builtin/mktree.c | 2 + builtin/mv.c | 1 + builtin/name-rev.c | 3 +- builtin/notes.c | 1 + builtin/pack-objects.c | 4 +- builtin/pack-redundant.c | 1 + builtin/patch-id.c | 1 + builtin/prune.c | 2 + builtin/pull.c | 1 + builtin/read-tree.c | 1 + builtin/rebase.c | 1 + builtin/receive-pack.c | 1 + builtin/repack.c | 3 +- builtin/replace.c | 2 + builtin/reset.c | 1 + builtin/rev-list.c | 1 + builtin/rev-parse.c | 2 + builtin/revert.c | 3 +- builtin/rm.c | 1 + builtin/send-pack.c | 1 + builtin/show-branch.c | 1 + builtin/show-index.c | 1 + builtin/show-ref.c | 1 + builtin/stash.c | 1 + builtin/submodule--helper.c | 2 + builtin/tag.c | 1 + builtin/unpack-file.c | 1 + builtin/unpack-objects.c | 2 + builtin/update-index.c | 1 + builtin/upload-pack.c | 1 + builtin/var.c | 1 + builtin/worktree.c | 1 + builtin/write-tree.c | 1 + bulk-checkin.c | 4 +- bundle.c | 1 + cache-tree.c | 4 +- cache-tree.h | 1 - cache.h | 305 +------------------ cbtree.c | 1 + cbtree.h | 2 - checkout.h | 2 +- chunk-format.c | 3 +- chunk-format.h | 1 - color.c | 1 + combine-diff.c | 1 + commit-graph.c | 1 + commit-graph.h | 1 - commit-reach.c | 4 +- commit-slab-impl.h | 2 - commit.c | 1 + commit.h | 1 - compat/fsmonitor/fsm-ipc-darwin.c | 1 + compat/fsmonitor/fsm-ipc-win32.c | 1 + compat/fsmonitor/fsm-settings-darwin.c | 1 + compat/mingw.c | 1 + config.c | 5 +- connect.c | 1 + connected.c | 1 + convert.c | 1 + daemon.c | 1 + decorate.c | 3 +- delta-islands.c | 4 +- diagnose.c | 1 + diff-lib.c | 1 + diff-merges.c | 2 + diff-no-index.c | 1 - diff.c | 2 + diff.h | 3 +- diffcore-delta.c | 2 +- diffcore-order.c | 3 +- diffcore-pickaxe.c | 4 +- diffcore-rename.c | 7 +- diffcore-rotate.c | 3 +- diffcore.h | 4 +- dir-iterator.c | 3 +- dir.c | 3 +- dir.h | 16 +- entry.c | 1 + entry.h | 4 +- environment.c | 1 + ewah/bitmap.c | 3 +- ewah/ewah_bitmap.c | 2 +- fetch-pack.c | 4 +- fmt-merge-msg.c | 3 + fsck.c | 4 +- fsck.h | 1 + fsmonitor-settings.c | 3 +- git-compat-util.h | 1 + git.c | 1 + gpg-interface.c | 1 + graph.c | 3 +- grep.c | 1 + hash.h | 35 ++- hashmap.c | 2 +- help.c | 4 +- hex.c | 3 +- hex.h | 84 +++++ hook.c | 5 +- http-backend.c | 4 +- http-fetch.c | 1 + http-push.c | 1 + http-walker.c | 1 + http.c | 1 + ident.c | 5 +- ident.h | 67 ++++ imap-send.c | 2 +- json-writer.c | 2 +- khash.h | 1 - kwset.c | 2 +- levenshtein.c | 2 +- line-log.c | 2 + line-log.h | 1 + linear-assignment.c | 2 +- list-objects-filter-options.c | 4 +- list-objects-filter-options.h | 3 +- list-objects-filter.c | 2 + list-objects.c | 1 + log-tree.c | 2 + ls-refs.c | 1 + mailinfo.c | 4 +- match-trees.c | 1 + mem-pool.c | 2 +- merge-blobs.c | 2 +- merge-ort.c | 1 + merge-recursive.c | 2 +- merge.c | 1 + midx.c | 4 +- negotiator/noop.c | 2 +- negotiator/skipping.c | 1 + notes-merge.c | 1 + notes.c | 1 + object-file.c | 4 +- object-name.c | 1 + object-store.h | 128 ++++---- object.c | 1 + object.h | 22 +- oid-array.c | 3 +- oidmap.c | 2 +- oidmap.h | 1 - oidset.c | 4 +- oidtree.c | 1 + oss-fuzz/fuzz-commit-graph.c | 1 + oss-fuzz/fuzz-pack-headers.c | 1 + oss-fuzz/fuzz-pack-idx.c | 1 + pack-bitmap-write.c | 4 +- pack-bitmap.c | 4 +- pack-check.c | 1 + pack-mtimes.h | 2 - pack-objects.c | 3 +- pack-write.c | 1 + packfile.c | 4 +- parallel-checkout.c | 2 + patch-ids.c | 1 + path.c | 1 + pathspec.h | 5 + pkt-line.c | 1 + pkt-line.h | 1 - pretty.c | 2 + pretty.h | 4 +- prio-queue.c | 3 +- promisor-remote.c | 1 + protocol-caps.c | 2 + prune-packed.c | 1 + quote.c | 2 + reachable.c | 1 + read-cache.c | 2 + rebase.c | 1 + ref-filter.c | 6 +- reflog-walk.c | 3 +- reflog-walk.h | 2 - refs.c | 4 +- refs/debug.c | 3 +- refs/files-backend.c | 2 + refs/packed-backend.c | 4 +- refs/ref-cache.c | 3 +- refs/refs-internal.h | 1 - refspec.c | 4 +- remote-curl.c | 4 +- remote.c | 4 +- remote.h | 1 - replace-object.c | 1 + replace-object.h | 8 + repo-settings.c | 2 +- repository.h | 1 - rerere.c | 4 +- reset.c | 1 + revision.c | 4 +- revision.h | 1 + send-pack.c | 3 +- sequencer.c | 2 + sequencer.h | 2 +- serve.c | 3 +- server-info.c | 4 +- sha1dc_git.c | 4 +- shallow.c | 4 +- shallow.h | 2 + shell.c | 2 +- sigchain.c | 3 +- sparse-index.c | 1 + split-index.c | 1 + statinfo.h | 24 ++ strbuf.c | 4 +- string-list.c | 3 +- strvec.c | 4 +- sub-process.c | 1 + sub-process.h | 1 - submodule-config.c | 2 + submodule-config.h | 1 - submodule.c | 5 +- t/helper/test-bloom.c | 3 +- t/helper/test-cache-tree.c | 1 + t/helper/test-crontab.c | 1 - t/helper/test-ctype.c | 1 - t/helper/test-dump-cache-tree.c | 1 + t/helper/test-dump-split-index.c | 1 + t/helper/test-dump-untracked-cache.c | 1 + t/helper/test-example-decorate.c | 2 +- t/helper/test-fast-rebase.c | 1 + t/helper/test-hash.c | 1 + t/helper/test-json-writer.c | 1 - t/helper/test-match-trees.c | 1 + t/helper/test-oid-array.c | 1 + t/helper/test-oidmap.c | 1 + t/helper/test-oidtree.c | 1 + t/helper/test-pack-mtimes.c | 1 + t/helper/test-partial-clone.c | 1 + t/helper/test-pcre2-config.c | 1 - t/helper/test-prio-queue.c | 1 - t/helper/test-proc-receive.c | 1 + t/helper/test-reach.c | 3 +- t/helper/test-read-midx.c | 1 + t/helper/test-ref-store.c | 1 + t/helper/test-repository.c | 1 + t/helper/test-run-command.c | 2 - t/helper/test-sigchain.c | 1 - t/helper/test-simple-ipc.c | 3 +- t/helper/test-submodule-nested-repo-config.c | 1 + t/helper/test-wildmatch.c | 1 - tag.c | 1 + thread-utils.c | 2 +- trace.h | 1 - trace2.c | 3 +- trace2/tr2_ctr.c | 2 +- trace2/tr2_sid.c | 1 + trace2/tr2_sysenv.c | 2 +- trace2/tr2_tbuf.c | 2 +- trace2/tr2_tgt_event.c | 2 +- trace2/tr2_tgt_normal.c | 2 +- trace2/tr2_tgt_perf.c | 2 +- trace2/tr2_tls.c | 4 +- trace2/tr2_tmr.c | 3 +- trailer.c | 1 + transport-helper.c | 1 + transport.c | 5 +- tree-walk.c | 2 + tree-walk.h | 4 +- tree.c | 1 + unix-socket.c | 3 +- unix-stream-server.c | 2 +- unpack-trees.c | 1 + upload-pack.c | 1 + url.c | 4 +- urlmatch.c | 5 +- userdiff.c | 4 +- walker.c | 1 + wildmatch.c | 2 +- worktree.c | 3 +- worktree.h | 1 - wt-status.c | 1 + xdiff-interface.c | 1 + xdiff-interface.h | 2 +- 322 files changed, 858 insertions(+), 529 deletions(-) create mode 100644 hex.h create mode 100644 ident.h create mode 100644 statinfo.h
base-commit: 06dd2baa8da4a73421b959ec026a43711b9d77f9
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1485%2Fnewren%2Fheader-cleanups-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1485/newren/header-cleanups-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/1485
Range-diff vs v1:
1: a143d624724 ! 1: aede32dcb30 treewide: ensure one of the appropriate headers is sourced first
@@ cbtree.c
static struct cb_node *cb_node_of(const void *p)
+ ## compat/fsmonitor/fsm-ipc-win32.c ##
+@@
++#include "git-compat-util.h"
+ #include "config.h"
+ #include "fsmonitor-ipc.h"
+
+
+ ## compat/fsmonitor/fsm-settings-darwin.c ##
+@@
++#include "git-compat-util.h"
+ #include "config.h"
+ #include "fsmonitor.h"
+ #include "fsmonitor-ipc.h"
+
## diff-merges.c ##
@@
+#include "git-compat-util.h" 2: adafa655432 ! 2: e1c2b55ac67 treewide: remove unnecessary git-compat-util.h includes in headers
@@ Metadata
## Commit message ##
treewide: remove unnecessary git-compat-util.h includes in headers
- Since git-compat-util.h needs to be included first in C files, having it
- appear in header files is unnecessary. More importantly, having it
- included in header files seems to lead to folks leaving it out of C
- files, which makes it harder to verify that the rule is being followed.
- Remove it from header files, other than the ones that have been approved
- as alternate first includes.
+ For sanity, we should probably do one of the following:
+
+ (a) make C and header files both depend upon everything they need
+ (b) consistently exclude git-compat-util.h from headers and require it
+ be the first include in C files
+
+ Currently, we have some of the headers following (a) and others
+ following (b), which makes things messy. In the past I was pushed
+ towards (b), as per [1] and [2]. Further, during this series I
+ discovered that this mixture empirically will mean that we end up with C
+ files that do not directly include git-compat-util.h, and do include
+ headers that don't include git-compat-util.h, with the result that we
+ likely have headers included before an indirect inclusion of
+ git-compat-util.h. Since git-compat-util.h has tricky platform-specific
+ stuff that is meant to be included before everything else, this state of
+ affairs is risky and may lead to things breaking in subtle ways (and
+ only on some platforms) as per [1] and [2].
+
+ Since including git-compat-util.h in existing header files makes it
+ harder for us to catch C files that are missing that include, let's
+ switch to (b) to make the enforcement of this rule easier. Remove the
+ inclusion of git-compat-util.h from header files other than the ones
+ that have been approved as alternate first includes.
+
+ [1] https://lore.kernel.org/git/[email protected]/
+ [2] https://lore.kernel.org/git/[email protected]/
@@ commit-slab-impl.h
implement_commit_slab(slabname, elemtype, MAYBE_UNUSED static)
- ## compat/fsmonitor/fsm-ipc-win32.c ## -@@
-+#include "git-compat-util.h"
- #include "config.h"
- #include "fsmonitor-ipc.h"
-
-
- ## compat/fsmonitor/fsm-settings-darwin.c ## -@@
-+#include "git-compat-util.h"
- #include "config.h"
- #include "fsmonitor.h"
- #include "fsmonitor-ipc.h"
-
## hash.h ##
@@
#ifndef HASH_H
3: 73d012f631a = 3: b9ffac2d122 treewide: remove unnecessary cache.h includes 4: bec6f89d82c = 4: 00dceb5b467 treewide: remove unnecessary cache.h includes in source files 5: ec6f2518b9d ! 5: 9344a94fd92 alloc.h: move ALLOC_GROW() functions from cache.h
@@ Metadata
## Commit message ##
alloc.h: move ALLOC_GROW() functions from cache.h
- This allows us to replace includes of cache.h with includes
- of the much smaller alloc.h in many places.
+ This allows us to replace includes of cache.h with includes of the much
+ smaller alloc.h in many places. It does mean that we also need to add
+ includes of alloc.h in a number of C files.
@@ add-patch.c
#include "cache.h"
#include "add-interactive.h"
+#include "alloc.h"
-+#include "gettext.h"
#include "strbuf.h"
#include "run-command.h"
#include "strvec.h"
6: 9f78f0f2155 ! 6: b5046b7aaa6 hash.h: move some oid-related declarations from cache.h
@@ Commit message
more sense being included in hash.h. Further, moving them there allows us to remove some includes of cache.h in other files.
+ The change to line-log.h might look unrelated, but line-log.h includes
+ diffcore.h, which previously included cache.h, which included the
+ kitchen sink. Since this patch makes diffcore.h no longer include
+ cache.h, the compiler complains about the 'struct string_list *'
+ function parameter. Add a forward declaration for struct string_list to
+ address this.
+
## cache.h ##
7: c9b1b278092 ! 7: 6d5c13c4693 hex.h: move some hex-related declarations from cache.h
@@ Commit message
declarations into a hex.h header instead.
This also allows us to remove includes of cache.h from a few C files.
+ For now, we make cache.h include hex.h, so that it is easier to review
+ the direct changes being made by this patch. In the next patch, we will
+ remove that, and add the necessary direct '#include "hex.h"' in the
+ hundreds of C files that need it.
Note that reviewing the header changes in this commit might be simplified via
-: ----------- > 8: c23dd309ce3 cache.h: remove dependence on hex.h; make other files include it explicitly
8: a3759d887d2 = 9: f1e9b324234 pretty.h: move has_non_ascii() declaration from commit.h
9: 9fc48fe4844 ! 10: de1e29132de ident.h: move ident-related declarations out of cache.h
@@ Commit message
## builtin/cat-file.c ##
@@
- #include "config.h"
#include "builtin.h"
#include "diff.h"
+ #include "hex.h"
+#include "ident.h"
#include "parse-options.h"
#include "userdiff.h" 10: 1357f18db56 ! 11: 1636615ca73 object.h: stop depending on cache.h; make cache.h depend on object.h
@@ Commit message
Note that a couple files previously depended on things brought in
through cache.h indirectly (revision.h -> commit.h -> object.h ->
cache.h). As such, this change requires making existing dependencies
- more explicit in two files.
+ more explicit in half a dozen files. The inclusion of strbuf.h in
+ some headers if of particular note: these headers directly embedded a
+ strbuf in some new structs, meaning they should have been including
+ strbuf.h all along but were indirectly getting the necessary
+ definitions.
@@ cache-tree.h
## cache.h ##
@@
+ #include "pack-revindex.h"
#include "hash.h"
- #include "hex.h"
#include "path.h"
+#include "object.h"
#include "oid-array.h"
@@ t/helper/test-bloom.c
-#include "git-compat-util.h"
+#include "cache.h"
#include "bloom.h"
+ #include "hex.h"
#include "test-tool.h"
- #include "commit.h"
## t/helper/test-example-decorate.c ##
@@
11: 0446ab61d6f ! 12: 856d3dbcc6e dir.h: refactor to no longer need to include cache.h
@@ Commit message
## cache.h ##
@@
+ #include "pack-revindex.h"
#include "hash.h"
- #include "hex.h"
#include "path.h"
+#include "pathspec.h"
#include "object.h" 12: c42261483cf ! 13: 12eb68b1ba3 object-store.h: move struct object_info from cache.h
@@ Commit message
Move struct object_info, and a few related #define's from cache.h to object-store.h.
+ A surprising effect of this change is that replace-object.h, which
+ includes object-store.h, now needs to directly include cache.h since
+ that is where read_replace_refs is declared and that variable is used
+ in one of its inline functions. The next commit will move that
+ declaration and fix that unfortunate new direct inclusion of cache.h.
+
## merge-blobs.c ##
13: 1abea7621ee = 14: c4f86b77e71 replace-object.h: move read_replace_refs declaration from cache.h to here
14: 3d99495aff3 ! 15: 814d60ec94e treewide: replace cache.h with more direct headers, where possible
@@ sha1dc_git.c
-#include "cache.h"
+#include "git-compat-util.h"
+#include "sha1dc_git.h"
-+#include "hex.h"
+ #include "hex.h"
#ifdef DC_SHA1_EXTERNAL
- /*
## unix-socket.c ##
@@
@@ url.c
@@
-#include "cache.h"
+#include "git-compat-util.h"
-+#include "hex.h"
+ #include "hex.h"
+#include "strbuf.h"
#include "url.h"
@@ urlmatch.c
-#include "cache.h"
+#include "git-compat-util.h"
+#include "gettext.h"
-+#include "hex.h"
+ #include "hex.h"
+#include "strbuf.h"
#include "urlmatch.h" 15: 2931a0a8c78 ! 16: 97d3032346f Remove unnecessary includes of builtin.h
@@ send-pack.c
+#include "git-compat-util.h"
#include "config.h"
#include "commit.h"
- #include "refs.h"
+ #include "hex.h" 16: faeb191198a = 17: a172801bbf0 diff.h: remove unnecessary include of object.h
Signature · 1 line
gitgitgadget
PATCH v2 1/17 treewide: ensure one of the appropriate headers is sourced first
From: Elijah Newren <[email protected]>
We had several C files ignoring the rule to include one of the appropriate headers first; fix that.
While at it, the rule in Documentation/CodingGuidelines about which header to include has also fallen out of sync, so update the wording to mention other allowed headers.
Unfortunately, C files in reftable/ don't actually follow the previous or updated rule. If you follow the #include chain in its C files, reftable/system.h _tends_ to be first (i.e. record.c first includes record.h, which first includes basics.h, which first includees system.h), but not always (e.g. publicbasics.c includes another header first that does not include system.h). However, I'm going to punt on making actual changes to the C files in reftable/ since I do not want to risk bringing it out-of-sync with any version being used externally.
--- Documentation/CodingGuidelines | 8 ++++++-- cbtree.c | 1 + compat/fsmonitor/fsm-ipc-win32.c | 1 + compat/fsmonitor/fsm-settings-darwin.c | 1 + diff-merges.c | 1 + fmt-merge-msg.c | 1 + oidtree.c | 1 + oss-fuzz/fuzz-commit-graph.c | 1 + oss-fuzz/fuzz-pack-headers.c | 1 + oss-fuzz/fuzz-pack-idx.c | 1 + prune-packed.c | 1 + rebase.c | 1 + refs/debug.c | 2 +- sub-process.c | 1 + 14 files changed, 19 insertions(+), 3 deletions(-)
Documentation/CodingGuidelines +6 -2
@@ -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
cbtree.c +1 -0
@@ -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)
compat/fsmonitor/fsm-ipc-win32.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "config.h" #include "fsmonitor-ipc.h"
compat/fsmonitor/fsm-settings-darwin.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "config.h" #include "fsmonitor.h" #include "fsmonitor-ipc.h"
diff-merges.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "diff-merges.h" #include "revision.h"
fmt-merge-msg.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "config.h" #include "refs.h" #include "object-store.h"
oidtree.c +1 -0
@@ -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"
oss-fuzz/fuzz-commit-graph.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "commit-graph.h" #include "repository.h"
oss-fuzz/fuzz-pack-headers.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "packfile.h" int LLVMFuzzerTestOneInput (const uint8_t *data,size_t size);
oss-fuzz/fuzz-pack-idx.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "object-store.h" #include "packfile.h"
prune-packed.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "object-store.h" #include "packfile.h" #include "progress.h"
rebase.c +1 -0
@@ -1,3 +1,4 @@ +#include "git-compat-util.h" #include "rebase.h" #include "config.h" #include "gettext.h"
refs/debug.c +1 -1
@@ -1,4 +1,4 @@ - +#include "git-compat-util.h" #include "refs-internal.h" #include "trace.h"
sub-process.c +1 -0
@@ -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"
Signature · 1 line
gitgitgadget
PATCH v2 2/17 treewide: remove unnecessary git-compat-util.h includes in headers
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
For sanity, we should probably do one of the following:
(a) make C and header files both depend upon everything they need
(b) consistently exclude git-compat-util.h from headers and require it be the first include in C files
Currently, we have some of the headers following (a) and others following (b), which makes things messy. In the past I was pushed towards (b), as per [1] and [2]. Further, during this series I discovered that this mixture empirically will mean that we end up with C files that do not directly include git-compat-util.h, and do include headers that don't include git-compat-util.h, with the result that we likely have headers included before an indirect inclusion of git-compat-util.h. Since git-compat-util.h has tricky platform-specific stuff that is meant to be included before everything else, this state of affairs is risky and may lead to things breaking in subtle ways (and only on some platforms) as per [1] and [2].
Since including git-compat-util.h in existing header files makes it harder for us to catch C files that are missing that include, let's switch to (b) to make the enforcement of this rule easier. Remove the inclusion of git-compat-util.h from header files other than the ones that have been approved as alternate first includes.
[1] https://lore.kernel.org/git/[email protected]/
[2] https://lore.kernel.org/git/[email protected]/
--- advice.h | 2 -- cbtree.h | 2 -- chunk-format.h | 1 - commit-graph.h | 1 - commit-slab-impl.h | 2 -- hash.h | 1 - pack-mtimes.h | 2 -- pkt-line.h | 1 - repository.h | 1 - sub-process.h | 1 - trace.h | 1 - 11 files changed, 15 deletions(-)
advice.h +0 -2
@@ -1,8 +1,6 @@#ifndef ADVICE_H #define ADVICE_H -#include "git-compat-util.h" -struct string_list ;/*
cbtree.h +0 -2
@@ -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];
chunk-format.h +0 -1
@@ -1,7 +1,6 @@#ifndef CHUNK_FORMAT_H #define CHUNK_FORMAT_H -#include "git-compat-util.h" #include "hash.h" struct hashfile ;
commit-graph.h +0 -1
@@ -1,7 +1,6 @@#ifndef COMMIT_GRAPH_H #define COMMIT_GRAPH_H -#include "git-compat-util.h" #include "object-store.h" #include "oidset.h"
commit-slab-impl.h +0 -2
@@ -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)
hash.h +0 -1
@@ -1,7 +1,6 @@#ifndef HASH_H #define HASH_H -#include "git-compat-util.h" #include "repository.h" #if defined(SHA1_APPLE )
pack-mtimes.h +0 -2
@@ -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
pkt-line.h +0 -1
@@ -1,7 +1,6 @@#ifndef PKTLINE_H #define PKTLINE_H -#include "git-compat-util.h" #include "strbuf.h" #include "sideband.h"
repository.h +0 -1
@@ -1,7 +1,6 @@#ifndef REPOSITORY_H #define REPOSITORY_H -#include "git-compat-util.h" #include "path.h" struct config_set ;
sub-process.h +0 -1
@@ -1,7 +1,6 @@#ifndef SUBPROCESS_H #define SUBPROCESS_H -#include "git-compat-util.h" #include "hashmap.h" #include "run-command.h"
trace.h +0 -1
@@ -1,7 +1,6 @@#ifndef TRACE_H #define TRACE_H -#include "git-compat-util.h" #include "strbuf.h" /**
Signature · 1 line
gitgitgadget
PATCH v2 3/17 treewide: remove unnecessary cache.h includes
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
We had several header files include cache.h unnecessarily. Remove those. These have all been verified via both ensuring that
gcc -E $HEADER | grep '"cache.h"'
found no hits and that
cat >temp.c <<EOF &&
#include "git-compat-util.h"
#include "$HEADER"
int main() {}
EOF
gcc -c temp.csuccessfully compiles without warnings.
--- checkout.h | 2 +- entry.h | 4 +++- khash.h | 1 - oidmap.h | 1 - pretty.h | 2 +- reflog-walk.h | 2 -- refs/refs-internal.h | 1 - remote.h | 1 - sequencer.h | 2 +- xdiff-interface.h | 2 +- 10 files changed, 7 insertions(+), 11 deletions(-)
checkout.h +1 -1
@@ -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
entry.h +3 -1
@@ -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;
khash.h +0 -1
@@ -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"
oidmap.h +0 -1
@@ -1,7 +1,6 @@#ifndef OIDMAP_H #define OIDMAP_H -#include "cache.h" #include "hashmap.h" /*
pretty.h +1 -1
@@ -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 ;
reflog-walk.h +0 -2
@@ -1,8 +1,6 @@#ifndef REFLOG_WALK_H #define REFLOG_WALK_H -#include "cache.h" -struct commit ;struct reflog_walk_info ;struct date_mode ;
refs/refs-internal.h +0 -1
@@ -1,7 +1,6 @@#ifndef REFS_REFS_INTERNAL_H #define REFS_REFS_INTERNAL_H -#include "cache.h" #include "refs.h" #include "iterator.h"
remote.h +0 -1
@@ -1,7 +1,6 @@#ifndef REMOTE_H #define REMOTE_H -#include "cache.h" #include "parse-options.h" #include "hashmap.h" #include "refspec.h"
sequencer.h +1 -1
@@ -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 );
xdiff-interface.h +1 -1
@@ -1,7 +1,7 @@#ifndef XDIFF_INTERFACE_H #define XDIFF_INTERFACE_H -#include "cache.h" +#include "hash.h" #include "xdiff/xdiff.h" /*
Signature · 1 line
gitgitgadget
PATCH v2 4/17 treewide: remove unnecessary cache.h includes in source files
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
We had several C files include cache.h unnecessarily. Replace those with an include of "git-compat-util.h" instead. Much like the previous commit, these have all been verified via both ensuring that
gcc -E $SOURCE_FILE | grep '"cache.h"'
found no hits and that
make DEVELOPER=1 ${OBJECT_FILE_FOR_SOURCE_FILE}successfully compiles without warnings.
--- hashmap.c | 2 +- imap-send.c | 2 +- json-writer.c | 2 +- kwset.c | 2 +- levenshtein.c | 2 +- linear-assignment.c | 2 +- mem-pool.c | 2 +- oidmap.c | 2 +- repo-settings.c | 2 +- serve.c | 3 ++- shell.c | 2 +- t/helper/test-crontab.c | 1 - t/helper/test-ctype.c | 1 - t/helper/test-json-writer.c | 1 - t/helper/test-pcre2-config.c | 1 - t/helper/test-prio-queue.c | 1 - t/helper/test-run-command.c | 2 -- t/helper/test-sigchain.c | 1 - t/helper/test-simple-ipc.c | 3 ++- t/helper/test-wildmatch.c | 1 - thread-utils.c | 2 +- trace2.c | 3 ++- trace2/tr2_ctr.c | 2 +- trace2/tr2_tbuf.c | 2 +- trace2/tr2_tgt_event.c | 2 +- trace2/tr2_tgt_normal.c | 2 +- trace2/tr2_tgt_perf.c | 2 +- trace2/tr2_tmr.c | 3 ++- unix-stream-server.c | 2 +- 29 files changed, 25 insertions(+), 30 deletions(-)
hashmap.c +1 -1
@@ -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)
imap-send.c +1 -1
@@ -21,7 +21,7 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "credential.h" #include "exec-cmd.h"
json-writer.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "json-writer.h" void jw_init (struct json_writer *jw)
kwset.c +1 -1
@@ -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"
levenshtein.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "levenshtein.h" /*
linear-assignment.c +1 -1
@@ -3,7 +3,7 @@* algorithm for dense and sparse linear assignment problems</i>. 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)]
mem-pool.c +1 -1
@@ -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))
oidmap.c +1 -1
@@ -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,
repo-settings.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "repository.h" #include "midx.h"
serve.c +2 -1
@@ -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 ;
shell.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "quote.h" #include "exec-cmd.h" #include "strbuf.h"
t/helper/test-crontab.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" /* * Usage: test-tool crontab <file> -l|<input>
t/helper/test-ctype.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" static int rc;
t/helper/test-json-writer.c +0 -1
@@ -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}" ;
t/helper/test-pcre2-config.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" #include "grep.h" int cmd__pcre2_config (int argc,const char **argv)
t/helper/test-prio-queue.c +0 -1
@@ -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)
t/helper/test-run-command.c +0 -2
@@ -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"
t/helper/test-sigchain.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" #include "sigchain.h" #define X (f) \
t/helper/test-simple-ipc.c +2 -1
@@ -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)
t/helper/test-wildmatch.c +0 -1
@@ -1,5 +1,4 @@#include "test-tool.h" -#include "cache.h" int cmd__wildmatch (int argc,const char **argv) {
thread-utils.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "thread-utils.h" #if defined(hpux) || defined(__hpux) || defined(_hpux)
trace2.c +2 -1
@@ -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"
trace2/tr2_ctr.c +1 -1
@@ -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"
trace2/tr2_tbuf.c +1 -1
@@ -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)
trace2/tr2_tgt_event.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "json-writer.h" #include "run-command.h"
trace2/tr2_tgt_normal.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "run-command.h" #include "quote.h"
trace2/tr2_tgt_perf.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "run-command.h" #include "quote.h"
trace2/tr2_tmr.c +2 -1
@@ -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))
unix-stream-server.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "lockfile.h" #include "unix-socket.h" #include "unix-stream-server.h"
Signature · 1 line
gitgitgadget
PATCH v2 5/17 alloc.h: move ALLOC_GROW() functions from cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
This allows us to replace includes of cache.h with includes of the much smaller alloc.h in many places. It does mean that we also need to add includes of alloc.h in a number of C files.
--- add-patch.c | 1 + alias.c | 4 +- alloc.h | 75 ++++++++++++++++++++++++++++++ apply.c | 1 + archive-tar.c | 3 +- archive.c | 3 +- attr.c | 1 + builtin/blame.c | 3 +- builtin/cat-file.c | 1 + builtin/checkout--worker.c | 1 + builtin/config.c | 2 +- builtin/credential-cache--daemon.c | 1 + builtin/fetch-pack.c | 1 + builtin/fsmonitor--daemon.c | 1 + builtin/grep.c | 1 + builtin/index-pack.c | 1 + builtin/log.c | 3 +- builtin/merge.c | 1 + builtin/mktree.c | 1 + builtin/mv.c | 1 + builtin/name-rev.c | 2 +- builtin/pack-objects.c | 2 +- builtin/repack.c | 2 +- builtin/rev-parse.c | 1 + builtin/revert.c | 3 +- builtin/rm.c | 1 + builtin/submodule--helper.c | 1 + bulk-checkin.c | 3 +- cache-tree.c | 3 +- cache.h | 75 ------------------------------ chunk-format.c | 3 +- commit-reach.c | 3 +- compat/mingw.c | 1 + config.c | 3 +- daemon.c | 1 + delta-islands.c | 3 +- diff.c | 1 + diffcore-rename.c | 1 + dir-iterator.c | 3 +- dir.c | 3 +- ewah/bitmap.c | 3 +- ewah/ewah_bitmap.c | 2 +- fetch-pack.c | 3 +- fmt-merge-msg.c | 1 + fsck.c | 3 +- fsmonitor-settings.c | 3 +- help.c | 3 +- http-backend.c | 3 +- line-log.c | 1 + list-objects-filter-options.c | 4 +- list-objects-filter.c | 1 + midx.c | 3 +- object-file.c | 3 +- oid-array.c | 3 +- pack-bitmap-write.c | 3 +- pack-bitmap.c | 3 +- pack-objects.c | 3 +- packfile.c | 3 +- parallel-checkout.c | 1 + pretty.c | 1 + prio-queue.c | 3 +- quote.c | 1 + read-cache.c | 1 + ref-filter.c | 5 +- reflog-walk.c | 3 +- refs.c | 3 +- refs/packed-backend.c | 3 +- refs/ref-cache.c | 3 +- refspec.c | 3 +- remote-curl.c | 3 +- remote.c | 3 +- rerere.c | 3 +- revision.c | 3 +- sequencer.c | 1 + server-info.c | 3 +- shallow.c | 3 +- sigchain.c | 3 +- sparse-index.c | 1 + split-index.c | 1 + strbuf.c | 3 +- string-list.c | 3 +- strvec.c | 3 +- submodule-config.c | 1 + submodule.c | 4 +- t/helper/test-reach.c | 2 +- trace2/tr2_tls.c | 4 +- trailer.c | 1 + transport.c | 4 +- tree-walk.c | 1 + userdiff.c | 4 +- worktree.c | 3 +- 91 files changed, 219 insertions(+), 134 deletions(-)
add-patch.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "add-interactive.h" +#include "alloc.h" #include "strbuf.h" #include "run-command.h" #include "strvec.h"
alias.c +3 -1
@@ -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 {
alloc.h +75 -0
79 lines not on this page · raw message
apply.c +1 -0
@@ -8,6 +8,7 @@*/ #include "cache.h" +#include "alloc.h" #include "config.h" #include "object-store.h" #include "blob.h"
archive-tar.c +2 -1
@@ -1,7 +1,8 @@/* * Copyright (c) 2005, 2006 Rene Scharfe */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "tar.h" #include "archive.h"
archive.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h"
attr.c +1 -0
@@ -7,6 +7,7 @@*/ #include "cache.h" +#include "alloc.h" #include "config.h" #include "exec-cmd.h" #include "attr.h"
builtin/blame.c +2 -1
@@ -5,7 +5,8 @@* See COPYING for licensing conditions */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "color.h" #include "builtin.h"
builtin/cat-file.c +1 -0
@@ -5,6 +5,7 @@*/ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "builtin.h" #include "diff.h"
builtin/checkout--worker.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "config.h" #include "entry.h" #include "parallel-checkout.h"
builtin/config.c +1 -1
@@ -1,5 +1,5 @@#include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "config.h" #include "color.h" #include "parse-options.h"
builtin/credential-cache--daemon.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "parse-options.h" #ifndef NO_UNIX_SOCKETS
builtin/fetch-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "pkt-line.h" #include "fetch-pack.h" #include "remote.h"
builtin/fsmonitor--daemon.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "config.h" #include "parse-options.h" #include "fsmonitor.h"
builtin/grep.c +1 -0
@@ -4,6 +4,7 @@* Copyright (c) 2006 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "blob.h"
builtin/index-pack.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "alloc.h" #include "config.h" #include "delta.h" #include "pack.h"
builtin/log.c +2 -1
@@ -4,7 +4,8 @@* (C) Copyright 2006 Linus Torvalds * 2006 Junio Hamano */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h"
builtin/merge.c +1 -0
@@ -8,6 +8,7 @@#define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "parse-options.h" #include "builtin.h"
builtin/mktree.c +1 -0
@@ -4,6 +4,7 @@* Copyright (c) Junio C Hamano, 2006, 2009 */ #include "builtin.h" +#include "alloc.h" #include "quote.h" #include "tree.h" #include "parse-options.h"
builtin/mv.c +1 -0
@@ -5,6 +5,7 @@*/ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "config.h" #include "pathspec.h" #include "lockfile.h"
builtin/name-rev.c +1 -1
@@ -1,5 +1,5 @@#include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "commit.h"
builtin/pack-objects.c +1 -1
@@ -1,5 +1,5 @@#include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "attr.h"
builtin/repack.c +1 -1
@@ -1,5 +1,5 @@#include "builtin.h" -#include "cache.h" +#include "alloc.h" #include "config.h" #include "dir.h" #include "parse-options.h"
builtin/rev-parse.c +1 -0
@@ -5,6 +5,7 @@*/ #define USE_THE_INDEX_VARIABLE #include "cache.h" +#include "alloc.h" #include "config.h" #include "commit.h" #include "refs.h"
builtin/revert.c +2 -1
@@ -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"
builtin/rm.c +1 -0
@@ -5,6 +5,7 @@*/ #define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "advice.h" #include "config.h" #include "lockfile.h"
builtin/submodule--helper.c +1 -0
@@ -1,5 +1,6 @@#define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "alloc.h" #include "repository.h" #include "cache.h" #include "config.h"
bulk-checkin.c +2 -1
@@ -1,7 +1,8 @@/* * Copyright (c) 2011, Google Inc. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "bulk-checkin.h" #include "lockfile.h" #include "repository.h"
cache-tree.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "lockfile.h" #include "tree.h" #include "tree-walk.h"
cache.h +0 -75
81 lines not on this page · raw message
chunk-format.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "chunk-format.h" #include "csum-file.h"
commit-reach.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "commit-graph.h" #include "decorate.h"
compat/mingw.c +1 -0
@@ -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"
config.c +2 -1
@@ -5,7 +5,8 @@* Copyright (C) Johannes Schindelin, 2005 * */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "date.h" #include "branch.h" #include "config.h"
daemon.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "pkt-line.h" #include "run-command.h"
delta-islands.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "attr.h" #include "object.h" #include "blob.h"
diff.c +1 -0
@@ -2,6 +2,7 @@* Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "tempfile.h" #include "quote.h"
diffcore-rename.c +1 -0
@@ -3,6 +3,7 @@* Copyright (C) 2005 Junio C Hamano */ #include "cache.h" +#include "alloc.h" #include "diff.h" #include "diffcore.h" #include "object-store.h"
dir-iterator.c +2 -1
@@ -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"
dir.c +2 -1
@@ -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"
ewah/bitmap.c +2 -1
@@ -16,7 +16,8 @@* You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses/>. */ -#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))
ewah/ewah_bitmap.c +1 -1
@@ -17,9 +17,9 @@* along with this program; if not, see <http://www.gnu.org/licenses/>. */ #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) {
fetch-pack.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "config.h" #include "lockfile.h"
fmt-merge-msg.c +1 -0
@@ -1,4 +1,5 @@#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "refs.h" #include "object-store.h"
fsck.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "object-store.h" #include "repository.h" #include "object.h"
fsmonitor-settings.c +2 -1
@@ -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"
help.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "builtin.h" #include "exec-cmd.h"
http-backend.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "repository.h" #include "refs.h"
line-log.c +1 -0
@@ -1,4 +1,5 @@#include "git-compat-util.h" +#include "alloc.h" #include "line-range.h" #include "cache.h" #include "tag.h"
list-objects-filter-options.c +3 -1
@@ -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"
list-objects-filter.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "dir.h" #include "tag.h" #include "commit.h"
midx.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "csum-file.h" #include "dir.h"
object-file.c +2 -1
@@ -6,7 +6,8 @@* This handles basic git object files - packing, unpacking, * creation etc. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "string-list.h" #include "lockfile.h"
oid-array.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "oid-array.h" #include "hash-lookup.h"
pack-bitmap-write.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "object-store.h" #include "commit.h" #include "tag.h"
pack-bitmap.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "strbuf.h" #include "tag.h"
pack-objects.c +2 -1
@@ -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"
packfile.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "list.h" #include "pack.h" #include "repository.h"
parallel-checkout.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "entry.h" #include "parallel-checkout.h"
pretty.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "commit.h" #include "utf8.h"
prio-queue.c +2 -1
@@ -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)
quote.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "quote.h" #include "strvec.h"
read-cache.c +1 -0
@@ -4,6 +4,7 @@* Copyright (C) Linus Torvalds, 2005 */ #include "cache.h" +#include "alloc.h" #include "config.h" #include "diff.h" #include "diffcore.h"
ref-filter.c +2 -3
@@ -1,5 +1,5 @@ -#include "builtin.h" -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "parse-options.h" #include "refs.h" #include "wildmatch.h"
@@ -13,7 +13,6 @@#include "ref-filter.h" #include "revision.h" #include "utf8.h" -#include "git-compat-util.h" #include "version.h" #include "trailer.h" #include "wt-status.h"
reflog-walk.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "commit.h" #include "refs.h" #include "diff.h"
refs.c +2 -1
@@ -2,7 +2,8 @@* The backend-independent part of the reference module. */ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "hashmap.h" #include "lockfile.h"
refs/packed-backend.c +2 -1
@@ -1,4 +1,5 @@ -#include "../cache.h" +#include "../git-compat-util.h" +#include "../alloc.h" #include "../config.h" #include "../refs.h" #include "refs-internal.h"
refs/ref-cache.c +2 -1
@@ -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"
refspec.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "strvec.h" #include "refs.h" #include "refspec.h"
remote-curl.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "remote.h" #include "connect.h"
remote.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "remote.h" #include "urlmatch.h"
rerere.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "lockfile.h" #include "string-list.h"
revision.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "object-store.h" #include "tag.h"
sequencer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "lockfile.h" #include "dir.h"
server-info.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "dir.h" #include "repository.h" #include "refs.h"
shallow.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "tempfile.h" #include "lockfile.h"
sigchain.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "sigchain.h" #define SIGCHAIN_MAX_SIGNALS 32
sparse-index.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "repository.h" #include "sparse-index.h" #include "tree.h"
split-index.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "split-index.h" #include "ewah/ewok.h"
strbuf.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "refs.h" #include "string-list.h" #include "utf8.h"
string-list.c +2 -1
@@ -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) {
strvec.c +2 -1
@@ -1,5 +1,6 @@ -#include "cache.h" +#include "git-compat-util.h" #include "strvec.h" +#include "alloc.h" #include "strbuf.h" const char *empty_strvec[] = {NULL };
submodule-config.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "dir.h" #include "repository.h" #include "config.h"
submodule.c +2 -2
@@ -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"
t/helper/test-reach.c +1 -1
@@ -1,5 +1,5 @@#include "test-tool.h" -#include "cache.h" +#include "alloc.h" #include "commit.h" #include "commit-reach.h" #include "config.h"
trace2/tr2_tls.c +3 -1
@@ -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" /*
trailer.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "alloc.h" #include "config.h" #include "string-list.h" #include "run-command.h"
transport.c +3 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "config.h" #include "transport.h" #include "hook.h"
@@ -10,6 +11,7 @@#include "walker.h" #include "bundle.h" #include "dir.h" +#include "gettext.h" #include "refs.h" #include "refspec.h" #include "branch.h"
tree-walk.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "tree-walk.h" +#include "alloc.h" #include "dir.h" #include "object-store.h" #include "tree.h"
userdiff.c +3 -1
@@ -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;
worktree.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "alloc.h" #include "repository.h" #include "refs.h" #include "strbuf.h"
Signature · 1 line
gitgitgadget
PATCH v2 6/17 hash.h: move some oid-related declarations from cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
These defines and enum are all oid-related and as such seem to make more sense being included in hash.h. Further, moving them there allows us to remove some includes of cache.h in other files.
The change to line-log.h might look unrelated, but line-log.h includes diffcore.h, which previously included cache.h, which included the kitchen sink. Since this patch makes diffcore.h no longer include cache.h, the compiler complains about the 'struct string_list *' function parameter. Add a forward declaration for struct string_list to address this.
--- cache.h | 34 -------------------- diffcore.h | 4 ++- hash.h | 34 ++++++++++++++++++++ line-log.h | 1 + submodule-config.h | 1 - t/helper/test-submodule-nested-repo-config.c | 1 + tree-walk.h | 4 ++- 7 files changed, 42 insertions(+), 37 deletions(-)
cache.h +0 -34
@@ -1363,40 +1363,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, ...);
diffcore.h +3 -1
@@ -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 ;
hash.h +34 -0
@@ -123,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;
line-log.h +1 -0
@@ -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. */
submodule-config.h +0 -1
@@ -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"
t/helper/test-submodule-nested-repo-config.c +1 -0
@@ -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)
tree-walk.h +3 -1
@@ -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
Signature · 1 line
gitgitgadget
PATCH v2 7/17 hex.h: move some hex-related declarations from cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
hex.c contains code for hex-related functions, but for some reason these functions were declared in the catch-all cache.h. Move the function declarations into a hex.h header instead.
This also allows us to remove includes of cache.h from a few C files. For now, we make cache.h include hex.h, so that it is easier to review the direct changes being made by this patch. In the next patch, we will remove that, and add the necessary direct '#include "hex.h"' in the hundreds of C files that need it.
Note that reviewing the header changes in this commit might be simplified via
git log --no-walk -p --color-moved $COMMIT -- '*.h'`
In particular, it highlights the simple movement of code in .h files rather nicely.
--- cache.h | 79 +------------------------------------------- git-compat-util.h | 1 + hex.c | 3 +- hex.h | 84 +++++++++++++++++++++++++++++++++++++++++++++++ mailinfo.c | 4 ++- oidset.c | 4 ++- wildmatch.c | 2 +- 7 files changed, 95 insertions(+), 82 deletions(-) create mode 100644 hex.h
cache.h +1 -78
@@ -13,6 +13,7 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" +#include "hex.h" #include "path.h" #include "oid-array.h" #include "repository.h"
@@ -1325,22 +1326,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
@@ -1393,68 +1378,6 @@ int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fint 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
git-compat-util.h +1 -0
@@ -1225,6 +1225,7 @@ extern const unsigned char tolower_trans_tbl[256];#undef isxdigitextern 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
hex.c +2 -1
@@ -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 */
hex.h new file +84 -0
84 lines not on this page · raw message
mailinfo.c +3 -1
@@ -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"
oidset.c +3 -1
@@ -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) {
wildmatch.c +1 -1
@@ -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 ;
Signature · 1 line
gitgitgadget
PATCH v2 8/17 cache.h: remove dependence on hex.h; make other files include it explicitly
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
--- add-interactive.c | 1 + apply.c | 1 + archive-tar.c | 1 + archive-zip.c | 1 + archive.c | 1 + bisect.c | 1 + blame.c | 1 + branch.c | 1 + builtin/am.c | 1 + builtin/bisect.c | 1 + builtin/blame.c | 1 + builtin/cat-file.c | 1 + builtin/checkout.c | 1 + builtin/clone.c | 1 + builtin/commit-graph.c | 1 + builtin/commit-tree.c | 1 + builtin/describe.c | 1 + builtin/diff-tree.c | 1 + builtin/difftool.c | 1 + builtin/fast-export.c | 1 + builtin/fast-import.c | 1 + builtin/fetch-pack.c | 1 + builtin/fetch.c | 1 + builtin/fsck.c | 1 + builtin/gc.c | 1 + builtin/grep.c | 1 + builtin/hash-object.c | 1 + builtin/index-pack.c | 1 + builtin/log.c | 1 + builtin/ls-remote.c | 1 + builtin/ls-tree.c | 1 + builtin/merge-base.c | 1 + builtin/merge-index.c | 1 + builtin/merge-tree.c | 1 + builtin/merge.c | 1 + builtin/mktag.c | 1 + builtin/mktree.c | 1 + builtin/name-rev.c | 1 + builtin/notes.c | 1 + builtin/pack-objects.c | 1 + builtin/pack-redundant.c | 1 + builtin/patch-id.c | 1 + builtin/prune.c | 1 + builtin/pull.c | 1 + builtin/read-tree.c | 1 + builtin/rebase.c | 1 + builtin/receive-pack.c | 1 + builtin/repack.c | 1 + builtin/replace.c | 1 + builtin/reset.c | 1 + builtin/rev-list.c | 1 + builtin/rev-parse.c | 1 + builtin/send-pack.c | 1 + builtin/show-branch.c | 1 + builtin/show-index.c | 1 + builtin/show-ref.c | 1 + builtin/stash.c | 1 + builtin/submodule--helper.c | 1 + builtin/tag.c | 1 + builtin/unpack-file.c | 1 + builtin/unpack-objects.c | 1 + builtin/update-index.c | 1 + builtin/worktree.c | 1 + builtin/write-tree.c | 1 + bulk-checkin.c | 1 + bundle.c | 1 + cache-tree.c | 1 + cache.h | 1 - color.c | 1 + combine-diff.c | 1 + commit-graph.c | 1 + commit-reach.c | 1 + commit.c | 1 + compat/fsmonitor/fsm-ipc-darwin.c | 1 + connect.c | 1 + connected.c | 1 + convert.c | 1 + delta-islands.c | 1 + diagnose.c | 1 + diff-lib.c | 1 + diff.c | 1 + entry.c | 1 + fetch-pack.c | 1 + fmt-merge-msg.c | 1 + fsck.c | 1 + grep.c | 1 + http-backend.c | 1 + http-fetch.c | 1 + http-push.c | 1 + http-walker.c | 1 + http.c | 1 + line-log.c | 1 + list-objects-filter.c | 1 + list-objects.c | 1 + log-tree.c | 1 + ls-refs.c | 1 + match-trees.c | 1 + merge-ort.c | 1 + merge-recursive.c | 1 + merge.c | 1 + midx.c | 1 + negotiator/skipping.c | 1 + notes-merge.c | 1 + notes.c | 1 + object-file.c | 1 + object-name.c | 1 + object.c | 1 + pack-bitmap-write.c | 1 + pack-bitmap.c | 1 + pack-check.c | 1 + pack-write.c | 1 + packfile.c | 1 + parallel-checkout.c | 1 + patch-ids.c | 1 + path.c | 1 + pkt-line.c | 1 + pretty.c | 1 + promisor-remote.c | 1 + protocol-caps.c | 1 + reachable.c | 1 + read-cache.c | 1 + ref-filter.c | 1 + refs.c | 1 + refs/debug.c | 1 + refs/files-backend.c | 1 + refs/packed-backend.c | 1 + refspec.c | 1 + remote-curl.c | 1 + remote.c | 1 + replace-object.c | 1 + rerere.c | 1 + reset.c | 1 + revision.c | 1 + send-pack.c | 1 + sequencer.c | 1 + server-info.c | 1 + sha1dc_git.c | 1 + shallow.c | 1 + strbuf.c | 1 + strvec.c | 1 + submodule-config.c | 1 + submodule.c | 1 + t/helper/test-bloom.c | 1 + t/helper/test-cache-tree.c | 1 + t/helper/test-dump-cache-tree.c | 1 + t/helper/test-dump-split-index.c | 1 + t/helper/test-dump-untracked-cache.c | 1 + t/helper/test-fast-rebase.c | 1 + t/helper/test-hash.c | 1 + t/helper/test-match-trees.c | 1 + t/helper/test-oid-array.c | 1 + t/helper/test-oidmap.c | 1 + t/helper/test-oidtree.c | 1 + t/helper/test-pack-mtimes.c | 1 + t/helper/test-partial-clone.c | 1 + t/helper/test-proc-receive.c | 1 + t/helper/test-reach.c | 1 + t/helper/test-read-midx.c | 1 + t/helper/test-ref-store.c | 1 + t/helper/test-repository.c | 1 + tag.c | 1 + trace2/tr2_sid.c | 1 + transport-helper.c | 1 + transport.c | 1 + tree-walk.c | 1 + tree.c | 1 + unpack-trees.c | 1 + upload-pack.c | 1 + url.c | 1 + urlmatch.c | 1 + walker.c | 1 + wt-status.c | 1 + xdiff-interface.c | 1 + 173 files changed, 172 insertions(+), 1 deletion(-)
add-interactive.c +1 -0
@@ -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"
apply.c +1 -0
@@ -15,6 +15,7 @@#include "delta.h" #include "diff.h" #include "dir.h" +#include "hex.h" #include "xdiff-interface.h" #include "ll-merge.h" #include "lockfile.h"
archive-tar.c +1 -0
@@ -4,6 +4,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "tar.h" #include "archive.h" #include "object-store.h"
archive-zip.c +1 -0
@@ -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"
archive.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "refs.h" #include "object-store.h" #include "commit.h"
bisect.c +1 -0
@@ -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"
blame.c +1 -0
@@ -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"
branch.c +1 -0
@@ -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"
builtin/am.c +1 -0
@@ -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"
builtin/bisect.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "hex.h" #include "parse-options.h" #include "bisect.h" #include "refs.h"
builtin/blame.c +1 -0
@@ -10,6 +10,7 @@#include "config.h" #include "color.h" #include "builtin.h" +#include "hex.h" #include "repository.h" #include "commit.h" #include "diff.h"
builtin/cat-file.c +1 -0
@@ -9,6 +9,7 @@#include "config.h" #include "builtin.h" #include "diff.h" +#include "hex.h" #include "parse-options.h" #include "userdiff.h" #include "streaming.h"
builtin/checkout.c +1 -0
@@ -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"
builtin/clone.c +1 -0
@@ -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"
builtin/commit-graph.c +1 -0
@@ -1,6 +1,7 @@#include "builtin.h" #include "config.h" #include "dir.h" +#include "hex.h" #include "lockfile.h" #include "parse-options.h" #include "repository.h"
builtin/commit-tree.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "repository.h" #include "commit.h"
builtin/describe.c +1 -0
@@ -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"
builtin/diff-tree.c +1 -0
@@ -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"
builtin/difftool.c +1 -0
@@ -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"
builtin/fast-export.c +1 -0
@@ -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"
builtin/fast-import.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "lockfile.h"
builtin/fetch-pack.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "alloc.h" +#include "hex.h" #include "pkt-line.h" #include "fetch-pack.h" #include "remote.h"
builtin/fetch.c +1 -0
@@ -3,6 +3,7 @@*/ #include "cache.h" #include "config.h" +#include "hex.h" #include "repository.h" #include "refs.h" #include "refspec.h"
builtin/fsck.c +1 -0
@@ -1,6 +1,7 @@#define USE_THE_INDEX_VARIABLE #include "builtin.h" #include "cache.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "commit.h"
builtin/gc.c +1 -0
@@ -11,6 +11,7 @@*/ #include "builtin.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "tempfile.h"
builtin/grep.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" #include "alloc.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "blob.h"
builtin/hash-object.c +1 -0
@@ -6,6 +6,7 @@*/ #include "builtin.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "blob.h" #include "quote.h"
builtin/index-pack.c +1 -0
@@ -2,6 +2,7 @@#include "alloc.h" #include "config.h" #include "delta.h" +#include "hex.h" #include "pack.h" #include "csum-file.h" #include "blob.h"
builtin/log.c +1 -0
@@ -7,6 +7,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "refs.h" #include "object-store.h" #include "color.h"
builtin/ls-remote.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "hex.h" #include "transport.h" #include "ref-filter.h" #include "remote.h"
builtin/ls-tree.c +1 -0
@@ -5,6 +5,7 @@*/ #include "cache.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "blob.h" #include "tree.h"
builtin/merge-base.c +1 -0
@@ -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"
builtin/merge-index.c +1 -0
@@ -1,5 +1,6 @@#define USE_THE_INDEX_VARIABLE #include "builtin.h" +#include "hex.h" #include "run-command.h" static const char *pgm;
builtin/merge-tree.c +1 -0
@@ -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"
builtin/merge.c +1 -0
@@ -10,6 +10,7 @@#include "cache.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "parse-options.h" #include "builtin.h" #include "lockfile.h"
builtin/mktag.c +1 -0
@@ -1,4 +1,5 @@#include "builtin.h" +#include "hex.h" #include "parse-options.h" #include "tag.h" #include "replace-object.h"
builtin/mktree.c +1 -0
@@ -5,6 +5,7 @@*/ #include "builtin.h" #include "alloc.h" +#include "hex.h" #include "quote.h" #include "tree.h" #include "parse-options.h"
builtin/name-rev.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "alloc.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "commit.h"
builtin/notes.c +1 -0
@@ -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"
builtin/pack-objects.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "alloc.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "attr.h"
builtin/pack-redundant.c +1 -0
@@ -7,6 +7,7 @@*/ #include "builtin.h" +#include "hex.h" #include "repository.h" #include "packfile.h" #include "object-store.h"
builtin/patch-id.c +1 -0
@@ -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)
builtin/prune.c +1 -0
@@ -1,6 +1,7 @@#include "cache.h" #include "commit.h" #include "diff.h" +#include "hex.h" #include "revision.h" #include "builtin.h" #include "reachable.h"
builtin/pull.c +1 -0
@@ -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"
builtin/read-tree.c +1 -0
@@ -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"
builtin/rebase.c +1 -0
@@ -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"
builtin/receive-pack.c +1 -0
@@ -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"
builtin/repack.c +1 -0
@@ -2,6 +2,7 @@#include "alloc.h" #include "config.h" #include "dir.h" +#include "hex.h" #include "parse-options.h" #include "run-command.h" #include "sigchain.h"
builtin/replace.c +1 -0
@@ -11,6 +11,7 @@#include "cache.h" #include "config.h" #include "builtin.h" +#include "hex.h" #include "refs.h" #include "parse-options.h" #include "run-command.h"
builtin/reset.c +1 -0
@@ -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"
builtin/rev-list.c +1 -0
@@ -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"
builtin/rev-parse.c +1 -0
@@ -8,6 +8,7 @@#include "alloc.h" #include "config.h" #include "commit.h" +#include "hex.h" #include "refs.h" #include "quote.h" #include "builtin.h"
builtin/send-pack.c +1 -0
@@ -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"
builtin/show-branch.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "config.h" +#include "hex.h" #include "pretty.h" #include "refs.h" #include "builtin.h"
builtin/show-index.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "cache.h" +#include "hex.h" #include "pack.h" #include "parse-options.h"
builtin/show-ref.c +1 -0
@@ -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"
builtin/stash.c +1 -0
@@ -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"
builtin/submodule--helper.c +1 -0
@@ -1,6 +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"
builtin/tag.c +1 -0
@@ -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"
builtin/unpack-file.c +1 -0
@@ -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)
builtin/unpack-objects.c +1 -0
@@ -2,6 +2,7 @@#include "cache.h" #include "bulk-checkin.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "object.h" #include "delta.h"
builtin/update-index.c +1 -0
@@ -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"
builtin/worktree.c +1 -0
@@ -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"
builtin/write-tree.c +1 -0
@@ -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"
bulk-checkin.c +1 -0
@@ -4,6 +4,7 @@#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"
bundle.c +1 -0
@@ -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"
cache-tree.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "lockfile.h" #include "tree.h" #include "tree-walk.h"
cache.h +0 -1
@@ -13,7 +13,6 @@#include "string-list.h" #include "pack-revindex.h" #include "hash.h" -#include "hex.h" #include "path.h" #include "oid-array.h" #include "repository.h"
color.c +1 -0
@@ -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 ;
combine-diff.c +1 -0
@@ -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"
commit-graph.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "pack.h" #include "packfile.h"
commit-reach.c +1 -0
@@ -3,6 +3,7 @@#include "commit.h" #include "commit-graph.h" #include "decorate.h" +#include "hex.h" #include "prio-queue.h" #include "tree.h" #include "ref-filter.h"
commit.c +1 -0
@@ -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"
compat/fsmonitor/fsm-ipc-darwin.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "config.h" +#include "hex.h" #include "strbuf.h" #include "fsmonitor.h" #include "fsmonitor-ipc.h"
connect.c +1 -0
@@ -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"
connected.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "object-store.h" #include "run-command.h" #include "sigchain.h"
convert.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "attr.h" #include "run-command.h"
delta-islands.c +1 -0
@@ -4,6 +4,7 @@#include "object.h" #include "blob.h" #include "commit.h" +#include "hex.h" #include "tag.h" #include "tree.h" #include "delta.h"
diagnose.c +1 -0
@@ -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-lib.c +1 -0
@@ -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.c +1 -0
@@ -9,6 +9,7 @@#include "diff.h" #include "diffcore.h" #include "delta.h" +#include "hex.h" #include "xdiff-interface.h" #include "color.h" #include "attr.h"
entry.c +1 -0
@@ -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"
fetch-pack.c +1 -0
@@ -2,6 +2,7 @@#include "alloc.h" #include "repository.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "refs.h" #include "pkt-line.h"
fmt-merge-msg.c +1 -0
@@ -5,6 +5,7 @@#include "object-store.h" #include "diff.h" #include "diff-merges.h" +#include "hex.h" #include "revision.h" #include "tag.h" #include "string-list.h"
fsck.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "object-store.h" #include "repository.h" #include "object.h"
grep.c +1 -0
@@ -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"
http-backend.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "repository.h" #include "refs.h" #include "pkt-line.h"
http-fetch.c +1 -0
@@ -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"
http-push.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "repository.h" #include "commit.h" #include "tag.h"
http-walker.c +1 -0
@@ -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"
http.c +1 -0
@@ -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"
line-log.c +1 -0
@@ -2,6 +2,7 @@#include "alloc.h" #include "line-range.h" #include "cache.h" +#include "hex.h" #include "tag.h" #include "blob.h" #include "tree.h"
list-objects-filter.c +1 -0
@@ -1,6 +1,7 @@#include "cache.h" #include "alloc.h" #include "dir.h" +#include "hex.h" #include "tag.h" #include "commit.h" #include "tree.h"
list-objects.c +1 -0
@@ -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"
log-tree.c +1 -0
@@ -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"
ls-refs.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "repository.h" #include "refs.h" #include "remote.h"
match-trees.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "tree.h" #include "tree-walk.h" #include "object-store.h"
merge-ort.c +1 -0
@@ -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"
merge-recursive.c +1 -0
@@ -18,6 +18,7 @@#include "diff.h" #include "diffcore.h" #include "dir.h" +#include "hex.h" #include "ll-merge.h" #include "lockfile.h" #include "object-store.h"
merge.c +1 -0
@@ -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"
midx.c +1 -0
@@ -3,6 +3,7 @@#include "config.h" #include "csum-file.h" #include "dir.h" +#include "hex.h" #include "lockfile.h" #include "packfile.h" #include "object-store.h"
negotiator/skipping.c +1 -0
@@ -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"
notes-merge.c +1 -0
@@ -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"
notes.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "config.h" +#include "hex.h" #include "notes.h" #include "object-store.h" #include "blob.h"
object-file.c +1 -0
@@ -9,6 +9,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "string-list.h" #include "lockfile.h" #include "delta.h"
object-name.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "config.h" +#include "hex.h" #include "tag.h" #include "commit.h" #include "tree.h"
object.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "object.h" #include "replace-object.h" #include "object-store.h"
pack-bitmap-write.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "object-store.h" #include "commit.h" #include "tag.h"
pack-bitmap.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "alloc.h" #include "commit.h" +#include "hex.h" #include "strbuf.h" #include "tag.h" #include "diff.h"
pack-check.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "repository.h" #include "pack.h" #include "pack-revindex.h"
pack-write.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "pack.h" #include "csum-file.h" #include "remote.h"
packfile.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "list.h" #include "pack.h" #include "repository.h"
parallel-checkout.c +1 -0
@@ -2,6 +2,7 @@#include "alloc.h" #include "config.h" #include "entry.h" +#include "hex.h" #include "parallel-checkout.h" #include "pkt-line.h" #include "progress.h"
patch-ids.c +1 -0
@@ -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)
path.c +1 -0
@@ -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"
pkt-line.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "pkt-line.h" +#include "hex.h" #include "run-command.h" char packet_buffer[LARGE_PACKET_MAX ];
pretty.c +1 -0
@@ -2,6 +2,7 @@#include "alloc.h" #include "config.h" #include "commit.h" +#include "hex.h" #include "utf8.h" #include "diff.h" #include "revision.h"
promisor-remote.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "object-store.h" #include "promisor-remote.h" #include "config.h"
protocol-caps.c +1 -0
@@ -1,6 +1,7 @@#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"
reachable.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "refs.h" #include "tag.h" #include "commit.h"
read-cache.c +1 -0
@@ -8,6 +8,7 @@#include "config.h" #include "diff.h" #include "diffcore.h" +#include "hex.h" #include "tempfile.h" #include "lockfile.h" #include "cache-tree.h"
ref-filter.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "parse-options.h" #include "refs.h" #include "wildmatch.h"
refs.c +1 -0
@@ -6,6 +6,7 @@#include "alloc.h" #include "config.h" #include "hashmap.h" +#include "hex.h" #include "lockfile.h" #include "iterator.h" #include "refs.h"
refs/debug.c +1 -0
@@ -1,4 +1,5 @@#include "git-compat-util.h" +#include "hex.h" #include "refs-internal.h" #include "trace.h"
refs/files-backend.c +1 -0
@@ -1,5 +1,6 @@#include "../cache.h" #include "../config.h" +#include "../hex.h" #include "../refs.h" #include "refs-internal.h" #include "ref-cache.h"
refs/packed-backend.c +1 -0
@@ -1,6 +1,7 @@#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"
refspec.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "strvec.h" #include "refs.h" #include "refspec.h"
remote-curl.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "remote.h" #include "connect.h" #include "strbuf.h"
remote.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "remote.h" #include "urlmatch.h" #include "refs.h"
replace-object.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "oidmap.h" #include "object-store.h" #include "replace-object.h"
rerere.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "string-list.h" #include "rerere.h"
reset.c +1 -0
@@ -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"
revision.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "object-store.h" #include "tag.h" #include "blob.h"
send-pack.c +1 -0
@@ -1,6 +1,7 @@#include "builtin.h" #include "config.h" #include "commit.h" +#include "hex.h" #include "refs.h" #include "object-store.h" #include "pkt-line.h"
sequencer.c +1 -0
@@ -1,6 +1,7 @@#include "cache.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "lockfile.h" #include "dir.h" #include "object-store.h"
server-info.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "alloc.h" #include "dir.h" +#include "hex.h" #include "repository.h" #include "refs.h" #include "object.h"
sha1dc_git.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #ifdef DC_SHA1_EXTERNAL /*
shallow.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "repository.h" #include "tempfile.h" #include "lockfile.h"
strbuf.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "alloc.h" +#include "hex.h" #include "refs.h" #include "string-list.h" #include "utf8.h"
strvec.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "strvec.h" #include "alloc.h" +#include "hex.h" #include "strbuf.h" const char *empty_strvec[] = {NULL };
submodule-config.c +1 -0
@@ -1,6 +1,7 @@#include "cache.h" #include "alloc.h" #include "dir.h" +#include "hex.h" #include "repository.h" #include "config.h" #include "submodule-config.h"
submodule.c +1 -0
@@ -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"
t/helper/test-bloom.c +1 -0
@@ -1,5 +1,6 @@#include "git-compat-util.h" #include "bloom.h" +#include "hex.h" #include "test-tool.h" #include "commit.h"
t/helper/test-cache-tree.c +1 -0
@@ -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"
t/helper/test-dump-cache-tree.c +1 -0
@@ -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"
t/helper/test-dump-split-index.c +1 -0
@@ -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"
t/helper/test-dump-untracked-cache.c +1 -0
@@ -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_) {
t/helper/test-fast-rebase.c +1 -0
@@ -15,6 +15,7 @@#include "cache-tree.h" #include "commit.h" +#include "hex.h" #include "lockfile.h" #include "merge-ort.h" #include "refs.h"
t/helper/test-hash.c +1 -0
@@ -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) {
t/helper/test-match-trees.c +1 -0
@@ -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)
t/helper/test-oid-array.c +1 -0
@@ -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)
t/helper/test-oidmap.c +1 -0
@@ -1,5 +1,6 @@#include "test-tool.h" #include "cache.h" +#include "hex.h" #include "oidmap.h" #include "strbuf.h"
t/helper/test-oidtree.c +1 -0
@@ -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)
t/helper/test-pack-mtimes.c +1 -0
@@ -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"
t/helper/test-partial-clone.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "test-tool.h" #include "repository.h" #include "object-store.h"
t/helper/test-proc-receive.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "connect.h" +#include "hex.h" #include "parse-options.h" #include "pkt-line.h" #include "sigchain.h"
t/helper/test-reach.c +1 -0
@@ -3,6 +3,7 @@#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"
t/helper/test-read-midx.c +1 -0
@@ -1,5 +1,6 @@#include "test-tool.h" #include "cache.h" +#include "hex.h" #include "midx.h" #include "repository.h" #include "object-store.h"
t/helper/test-ref-store.c +1 -0
@@ -1,5 +1,6 @@#include "test-tool.h" #include "cache.h" +#include "hex.h" #include "refs.h" #include "worktree.h" #include "object-store.h"
t/helper/test-repository.c +1 -0
@@ -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"
tag.c +1 -0
@@ -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" ;
trace2/tr2_sid.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "trace2/tr2_tbuf.h" #include "trace2/tr2_sid.h"
transport-helper.c +1 -0
@@ -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"
transport.c +1 -0
@@ -1,6 +1,7 @@#include "git-compat-util.h" #include "alloc.h" #include "config.h" +#include "hex.h" #include "transport.h" #include "hook.h" #include "pkt-line.h"
tree-walk.c +1 -0
@@ -2,6 +2,7 @@#include "tree-walk.h" #include "alloc.h" #include "dir.h" +#include "hex.h" #include "object-store.h" #include "tree.h" #include "pathspec.h"
tree.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "cache-tree.h" +#include "hex.h" #include "tree.h" #include "object-store.h" #include "blob.h"
unpack-trees.c +1 -0
@@ -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"
upload-pack.c +1 -0
@@ -1,5 +1,6 @@#include "cache.h" #include "config.h" +#include "hex.h" #include "refs.h" #include "pkt-line.h" #include "sideband.h"
url.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "url.h" int is_urlschemechar (int first_flag,int ch)
urlmatch.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "urlmatch.h" #define URL_ALPHA "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
walker.c +1 -0
@@ -1,4 +1,5 @@#include "cache.h" +#include "hex.h" #include "walker.h" #include "repository.h" #include "object-store.h"
wt-status.c +1 -0
@@ -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"
xdiff-interface.c +1 -0
@@ -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"
Signature · 1 line
gitgitgadget
PATCH v2 9/17 pretty.h: move has_non_ascii() declaration from commit.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
The function is defined in pretty.c, so this moves the declaration to a more logical place.
--- commit.h | 1 - diffcore-pickaxe.c | 4 ++-- pretty.h | 2 ++ 3 files changed, 4 insertions(+), 3 deletions(-)
commit.h +0 -1
@@ -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);
diffcore-pickaxe.c +2 -2
@@ -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,
pretty.h +2 -0
@@ -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.
Signature · 1 line
gitgitgadget
PATCH v2 10/17 ident.h: move ident-related declarations out of cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
These functions were all defined in a separate ident.c already, so create ident.h and move the declarations into that file.
--- builtin/cat-file.c | 1 + builtin/check-mailmap.c | 1 + builtin/config.c | 1 + builtin/var.c | 1 + cache.h | 58 ----------------------------------- config.c | 1 + gpg-interface.c | 1 + ident.c | 5 ++- ident.h | 67 +++++++++++++++++++++++++++++++++++++++++ refs/files-backend.c | 1 + revision.h | 1 + 11 files changed, 79 insertions(+), 59 deletions(-) create mode 100644 ident.h
builtin/cat-file.c +1 -0
@@ -10,6 +10,7 @@#include "builtin.h" #include "diff.h" #include "hex.h" +#include "ident.h" #include "parse-options.h" #include "userdiff.h" #include "streaming.h"
builtin/check-mailmap.c +1 -0
@@ -1,5 +1,6 @@#include "builtin.h" #include "config.h" +#include "ident.h" #include "mailmap.h" #include "parse-options.h" #include "string-list.h"
builtin/config.c +1 -0
@@ -2,6 +2,7 @@#include "alloc.h" #include "config.h" #include "color.h" +#include "ident.h" #include "parse-options.h" #include "urlmatch.h" #include "quote.h"
builtin/var.c +1 -0
@@ -5,6 +5,7 @@*/ #include "builtin.h" #include "config.h" +#include "ident.h" #include "refs.h" static const char var_usage[] ="git var (-l | <variable>)" ;
cache.h +0 -58
74 lines not on this page · raw message
config.c +1 -0
@@ -11,6 +11,7 @@#include "branch.h" #include "config.h" #include "environment.h" +#include "ident.h" #include "repository.h" #include "lockfile.h" #include "exec-cmd.h"
gpg-interface.c +1 -0
@@ -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"
ident.c +4 -1
@@ -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 ;
ident.h new file +67 -0
67 lines not on this page · raw message
refs/files-backend.c +1 -0
@@ -5,6 +5,7 @@#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"
revision.h +1 -0
@@ -8,6 +8,7 @@#include "pretty.h" #include "diff.h" #include "commit-slab-decl.h" +#include "ident.h" #include "list-objects-filter-options.h" /**
Signature · 1 line
gitgitgadget
PATCH v2 11/17 object.h: stop depending on cache.h; make cache.h depend on object.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
Things should be able to depend on object.h without pulling in all of cache.h. Move an enum to allow this.
Note that a couple files previously depended on things brought in through cache.h indirectly (revision.h -> commit.h -> object.h -> cache.h). As such, this change requires making existing dependencies more explicit in half a dozen files. The inclusion of strbuf.h in some headers if of particular note: these headers directly embedded a strbuf in some new structs, meaning they should have been including strbuf.h all along but were indirectly getting the necessary definitions.
--- alloc.c | 2 +- blame.h | 1 - blob.c | 2 +- cache-tree.h | 1 - cache.h | 21 +-------------------- diff-merges.c | 1 + diff.h | 2 +- diffcore-delta.c | 2 +- fsck.h | 1 + help.c | 1 + list-objects-filter-options.h | 3 ++- negotiator/noop.c | 2 +- object.h | 22 +++++++++++++++++++++- shallow.h | 2 ++ t/helper/test-bloom.c | 2 +- t/helper/test-example-decorate.c | 2 +- worktree.h | 1 - 17 files changed, 36 insertions(+), 32 deletions(-)
alloc.c +1 -1
@@ -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"
blame.h +0 -1
@@ -1,7 +1,6 @@#ifndef BLAME_H #define BLAME_H -#include "cache.h" #include "commit.h" #include "xdiff-interface.h" #include "revision.h"
blob.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "blob.h" #include "repository.h" #include "alloc.h"
cache-tree.h +0 -1
@@ -1,7 +1,6 @@#ifndef CACHE_TREE_H #define CACHE_TREE_H -#include "cache.h" #include "tree.h" #include "tree-walk.h"
cache.h +1 -20
@@ -14,6 +14,7 @@#include "pack-revindex.h" #include "hash.h" #include "path.h" +#include "object.h" #include "oid-array.h" #include "repository.h" #include "mem-pool.h"
@@ -453,26 +454,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 :
diff-merges.c +1 -0
@@ -1,6 +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.h +1 -1
@@ -8,6 +8,7 @@#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 +72,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,
diffcore-delta.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "diff.h" #include "diffcore.h"
fsck.h +1 -0
@@ -1,6 +1,7 @@#ifndef GIT_FSCK_H #define GIT_FSCK_H +#include "object.h" #include "oidset.h" enum fsck_msg_type {
help.c +1 -0
@@ -5,6 +5,7 @@#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"
list-objects-filter-options.h +2 -1
@@ -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.
negotiator/noop.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "noop.h" #include "../commit.h" #include "../fetch-negotiator.h"
object.h +21 -1
@@ -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. */
shallow.h +2 -0
@@ -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);
t/helper/test-bloom.c +1 -1
@@ -1,4 +1,4 @@ -#include "git-compat-util.h" +#include "cache.h" #include "bloom.h" #include "hex.h" #include "test-tool.h"
t/helper/test-example-decorate.c +1 -1
@@ -1,5 +1,5 @@#include "test-tool.h" -#include "cache.h" +#include "git-compat-util.h" #include "object.h" #include "decorate.h"
worktree.h +0 -1
@@ -1,7 +1,6 @@#ifndef WORKTREE_H #define WORKTREE_H -#include "cache.h" #include "refs.h" struct strbuf ;
Signature · 1 line
gitgitgadget
PATCH v2 12/17 dir.h: refactor to no longer need to include cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
Moving a few functions around allows us to make dir.h no longer need to include cache.h. This commit is best viewed with:
git log -1 -p --color-moved
--- cache.h | 31 +++++++++++-------------------- dir.h | 16 ++-------------- pathspec.h | 5 +++++ statinfo.h | 24 ++++++++++++++++++++++++ trace2/tr2_sysenv.c | 2 +- 5 files changed, 43 insertions(+), 35 deletions(-) create mode 100644 statinfo.h
cache.h +11 -20
@@ -14,9 +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 {
@@ -119,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;
@@ -294,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 */
dir.h +2 -14
@@ -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" /**
@@ -363,10 +364,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);
@@ -533,15 +530,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,
pathspec.h +5 -0
@@ -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
statinfo.h new file +24 -0
@@ -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
trace2/tr2_sysenv.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "config.h" #include "dir.h" #include "tr2_sysenv.h"
Signature · 1 line
gitgitgadget
PATCH v2 13/17 object-store.h: move struct object_info from cache.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
Move struct object_info, and a few related #define's from cache.h to object-store.h.
A surprising effect of this change is that replace-object.h, which includes object-store.h, now needs to directly include cache.h since that is where read_replace_refs is declared and that variable is used in one of its inline functions. The next commit will move that declaration and fix that unfortunate new direct inclusion of cache.h.
--- merge-blobs.c | 2 +- object-store.h | 128 +++++++++++++++++++++++------------------------ protocol-caps.c | 1 + replace-object.h | 1 + 4 files changed, 67 insertions(+), 65 deletions(-)
merge-blobs.c +1 -1
@@ -1,4 +1,4 @@ -#include "cache.h" +#include "git-compat-util.h" #include "run-command.h" #include "xdiff-interface.h" #include "ll-merge.h"
object-store.h +64 -64
146 lines not on this page · raw message
protocol-caps.c +1 -0
@@ -5,6 +5,7 @@#include "pkt-line.h" #include "strvec.h" #include "hash.h" +#include "hex.h" #include "object.h" #include "object-store.h" #include "string-list.h"
replace-object.h +1 -0
@@ -1,6 +1,7 @@#ifndef REPLACE_OBJECT_H #define REPLACE_OBJECT_H +#include "cache.h" #include "oidmap.h" #include "repository.h" #include "object-store.h"
Signature · 1 line
gitgitgadget
PATCH v2 14/17 replace-object.h: move read_replace_refs declaration from cache.h to here
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
Adjust several files to be more explicit about their dependency on replace-objects to accommodate this change.
--- builtin/cat-file.c | 1 + builtin/commit-graph.c | 1 + builtin/fsck.c | 1 + builtin/index-pack.c | 1 + builtin/pack-objects.c | 1 + builtin/prune.c | 1 + builtin/replace.c | 1 + builtin/unpack-objects.c | 1 + builtin/upload-pack.c | 1 + cache.h | 8 -------- config.c | 1 + environment.c | 1 + git.c | 1 + log-tree.c | 1 + replace-object.h | 9 ++++++++- 15 files changed, 21 insertions(+), 9 deletions(-)
builtin/cat-file.c +1 -0
@@ -18,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"
builtin/commit-graph.c +1 -0
@@ -8,6 +8,7 @@#include "commit-graph.h" #include "object-store.h" #include "progress.h" +#include "replace-object.h" #include "tag.h" #define BUILTIN_COMMIT_GRAPH_VERIFY_USAGE \
builtin/fsck.c +1 -0
@@ -20,6 +20,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"
builtin/index-pack.c +1 -0
@@ -16,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[] =
builtin/pack-objects.c +1 -0
@@ -32,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"
builtin/prune.c +1 -0
@@ -8,6 +8,7 @@#include "parse-options.h" #include "progress.h" #include "prune-packed.h" +#include "replace-object.h" #include "object-store.h" #include "shallow.h"
builtin/replace.c +1 -0
@@ -16,6 +16,7 @@#include "parse-options.h" #include "run-command.h" #include "object-store.h" +#include "replace-object.h" #include "repository.h" #include "tag.h"
builtin/unpack-objects.c +1 -0
@@ -9,6 +9,7 @@#include "pack.h" #include "blob.h" #include "commit.h" +#include "replace-object.h" #include "tag.h" #include "tree.h" #include "tree-walk.h"
builtin/upload-pack.c +1 -0
@@ -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"
cache.h +0 -8
@@ -886,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
config.c +1 -0
@@ -23,6 +23,7 @@#include "utf8.h" #include "dir.h" #include "color.h" +#include "replace-object.h" #include "refs.h" #include "worktree.h"
environment.c +1 -0
@@ -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"
git.c +1 -0
@@ -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)
log-tree.c +1 -0
@@ -13,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"
replace-object.h +8 -1
@@ -1,11 +1,18 @@ #ifndef REPLACE_OBJECT_H #define REPLACE_OBJECT_H -#include "cache.h" #include "oidmap.h" #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;
Signature · 1 line
gitgitgadget
PATCH v2 15/17 treewide: replace cache.h with more direct headers, where possible
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
--- advice.c | 4 +++- decorate.c | 3 ++- diffcore-order.c | 3 ++- diffcore-rename.c | 6 +++++- diffcore-rotate.c | 3 ++- graph.c | 3 ++- hook.c | 5 ++++- quote.c | 1 + sha1dc_git.c | 3 ++- unix-socket.c | 3 ++- url.c | 3 ++- urlmatch.c | 4 +++- 12 files changed, 30 insertions(+), 11 deletions(-)
advice.c +3 -1
@@ -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"
decorate.c +2 -1
@@ -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"
diffcore-order.c +2 -1
@@ -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"
diffcore-rename.c +5 -1
@@ -2,15 +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 */
diffcore-rotate.c +2 -1
@@ -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"
graph.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "gettext.h" #include "config.h" #include "commit.h" #include "color.h"
hook.c +4 -1
@@ -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) {
quote.c +1 -0
@@ -1,6 +1,7 @@#include "cache.h" #include "alloc.h" #include "quote.h" +#include "strbuf.h" #include "strvec.h" int quote_path_fully =1 ;
sha1dc_git.c +2 -1
@@ -1,4 +1,5 @@ -#include "cache.h" +#include "git-compat-util.h" +#include "sha1dc_git.h" #include "hex.h" #ifdef DC_SHA1_EXTERNAL
unix-socket.c +2 -1
@@ -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)
url.c +2 -1
@@ -1,5 +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)
urlmatch.c +3 -1
@@ -1,5 +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"
Signature · 1 line
gitgitgadget
PATCH v2 16/17 Remove unnecessary includes of builtin.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
--- diff-no-index.c | 1 - merge-recursive.c | 1 - send-pack.c | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-)
diff-no-index.c +0 -1
@@ -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"
merge-recursive.c +0 -1
@@ -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"
send-pack.c +1 -1
@@ -1,4 +1,4 @@ -#include "builtin.h" +#include "git-compat-util.h" #include "config.h" #include "commit.h" #include "hex.h"
Signature · 1 line
gitgitgadget
PATCH v2 17/17 diff.h: remove unnecessary include of object.h
In reply to Elijah Newren via GitGitGadgetFrom: Elijah Newren <[email protected]>
--- diff.h | 1 - 1 file changed, 1 deletion(-)
diff.h +0 -1
@@ -6,7 +6,6 @@#include "tree-walk.h" #include "pathspec.h" -#include "object.h" #include "oidset.h" #include "strbuf.h"
Signature · 1 line
gitgitgadget
Hi Elijah,
Quoted 3 lines · Elijah Newren via GitGitGadget
* Big props to Dscho for gitgitgadget; being able to test on a bunch of platforms with a variety of configurations easily is a big win in general but especially for series like this one.
Thank you so much! It is gratifying to see my hard work bring benefit to this project and its contributors.
Ciao,
Johannes
Quoted 4 lines · Elijah Newren via GitGitGadget
This series cleans up headers a bit, trying to remove excessive dependency on "
cache.h". I created this series a while ago, but decided to clean it up and submit it due to Emily's recent thread and suggestion that this might be helpful to their efforts[1].
[snip]
Quoted 2 lines
[1] Search for "Extremely yes" in
https://lore.kernel.org/git/CAJoAoZm+TkCL0Jpg_qFgKottxbtiG2QOiY0qGrz3-uQy+=waPg@mail.gmail.com/
Thanks, the series looks good. I especially appreciated the separating out of alloc.h and moving function declarations to the .h of the same name as the .c file their definition is found in.
Quoted 7 lines · Jonathan Tan
Quoted 4 lines · Elijah Newren via GitGitGadget
This series cleans up headers a bit, trying to remove excessive dependency on "
cache.h". I created this series a while ago, but decided to clean it up and submit it due to Emily's recent thread and suggestion that this might be helpful to their efforts[1].
Quoted 6 lines
[snip]
Quoted 2 lines
[1] Search for "Extremely yes" in
https://lore.kernel.org/git/CAJoAoZm+TkCL0Jpg_qFgKottxbtiG2QOiY0qGrz3-uQy+=waPg@mail.gmail.com/Thanks, the series looks good.
Thanks for the reviews!
Quoted 3 lines
I especially appreciated the separating
out ofalloc.hand moving function declarations to the .h of the same name as the .c file their definition is found in.
There are several more cases where we could do this, but my series was already long enough and I wanted to get it reviewed (and make sure others agreed with the directions) before adding more. I'm glad you like this direction, since I'd really like to move more things this way.
Quoted 9 lines · Elijah Newren via GitGitGadget
Changes since v1:
* Fixed a bad squash; moved the changes to the right commit
* More thorough justification in the commit message for the 2nd commit
* Removed an accidental added include ofgettext.h(the file was used, but it makes it harder to review that patch)
* Add some explanation of surprising changes to commit messages
* Add a new commit which removes the include ofhex.hfromcache.h, and instead makes C files include it directly, as suggested by Stolee
I'm happy with these updates. Thanks for the series!
-Stolee