From: Junio C Hamano Date: Thu, 29 Jun 2023 23:43:20 +0000 (-0700) Subject: Merge branch 'en/header-split-cache-h-part-3' X-Git-Tag: v2.42.0-rc0~80 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a1264a08a1a6e0cd7e510c899cd0ba42dcf1045d;p=thirdparty%2Fgit.git Merge branch 'en/header-split-cache-h-part-3' Header files cleanup. * en/header-split-cache-h-part-3: (28 commits) fsmonitor-ll.h: split this header out of fsmonitor.h hash-ll, hashmap: move oidhash() to hash-ll object-store-ll.h: split this header out of object-store.h khash: name the structs that khash declares merge-ll: rename from ll-merge git-compat-util.h: remove unneccessary include of wildmatch.h builtin.h: remove unneccessary includes list-objects-filter-options.h: remove unneccessary include diff.h: remove unnecessary include of oidset.h repository: remove unnecessary include of path.h log-tree: replace include of revision.h with simple forward declaration cache.h: remove this no-longer-used header read-cache*.h: move declarations for read-cache.c functions from cache.h repository.h: move declaration of the_index from cache.h merge.h: move declarations for merge.c from cache.h diff.h: move declaration for global in diff.c from cache.h preload-index.h: move declarations for preload-index.c from elsewhere sparse-index.h: move declarations for sparse-index.c from cache.h name-hash.h: move declarations for name-hash.c from cache.h run-command.h: move declarations for run-command.c from cache.h ... --- a1264a08a1a6e0cd7e510c899cd0ba42dcf1045d diff --cc builtin/diff-index.c index b9a19bb7d3,a8b2c0a4b9..9db7139b83 --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@@ -3,9 -3,10 +3,11 @@@ #include "diff.h" #include "diff-merges.h" #include "commit.h" + #include "preload-index.h" + #include "repository.h" #include "revision.h" - #include "builtin.h" #include "setup.h" ++#include "sparse-index.h" #include "submodule.h" static const char diff_cache_usage[] = diff --cc builtin/worktree.c index 5a9cf076ad,1a25980eb5..05dec7e330 --- a/builtin/worktree.c +++ b/builtin/worktree.c @@@ -1,6 -1,5 +1,6 @@@ - #include "cache.h" + #include "builtin.h" #include "abspath.h" +#include "advice.h" #include "checkout.h" #include "config.h" #include "copy.h" @@@ -12,10 -10,11 +11,12 @@@ #include "object-file.h" #include "object-name.h" #include "parse-options.h" + #include "path.h" #include "strvec.h" #include "branch.h" + #include "read-cache-ll.h" #include "refs.h" +#include "remote.h" #include "repository.h" #include "run-command.h" #include "hook.h" diff --cc reachable.c index 60a7336b87,434f09e9eb..0ce8f83e56 --- a/reachable.c +++ b/reachable.c @@@ -13,11 -13,9 +13,11 @@@ #include "list-objects.h" #include "packfile.h" #include "worktree.h" - #include "object-store.h" + #include "object-store-ll.h" #include "pack-bitmap.h" #include "pack-mtimes.h" +#include "config.h" +#include "run-command.h" struct connectivity_progress { struct progress *progress; diff --cc replace-object.h index ba478eb30c,a964db1670..66c41b938b --- a/replace-object.h +++ b/replace-object.h @@@ -3,8 -3,16 +3,8 @@@ #include "oidmap.h" #include "repository.h" - #include "object-store.h" + #include "object-store-ll.h" -/* - * Do replace refs need to be checked this run? This variable is - * initialized to true unless --no-replace-object is used or - * $GIT_NO_REPLACE_OBJECTS is set, but is set to false by some - * commands that do not want replace references to be active. - */ -extern int read_replace_refs; - struct replace_object { struct oidmap_entry original; struct object_id replacement; diff --cc statinfo.h index fe8df633a4,bb9b61bc47..700f502ac0 --- a/statinfo.h +++ b/statinfo.h @@@ -21,18 -23,53 +23,67 @@@ struct stat_data unsigned int sd_size; }; + /* + * A struct to encapsulate the concept of whether a file has changed + * since we last checked it. This uses criteria similar to those used + * for the index. + */ + struct stat_validity { + struct stat_data *sd; + }; + + #define MTIME_CHANGED 0x0001 + #define CTIME_CHANGED 0x0002 + #define OWNER_CHANGED 0x0004 + #define MODE_CHANGED 0x0008 + #define INODE_CHANGED 0x0010 + #define DATA_CHANGED 0x0020 + #define TYPE_CHANGED 0x0040 + + /* + * Record to sd the data from st that we use to check whether a file + * might have changed. + */ + void fill_stat_data(struct stat_data *sd, struct stat *st); + + /* + * Return 0 if st is consistent with a file not having been changed + * since sd was filled. If there are differences, return a + * combination of MTIME_CHANGED, CTIME_CHANGED, OWNER_CHANGED, + * INODE_CHANGED, and DATA_CHANGED. + */ + int match_stat_data(const struct stat_data *sd, struct stat *st); + + void stat_validity_clear(struct stat_validity *sv); + + /* + * Returns 1 if the path is a regular file (or a symlink to a regular + * file) and matches the saved stat_validity, 0 otherwise. A missing + * or inaccessible file is considered a match if the struct was just + * initialized, or if the previous update found an inaccessible file. + */ + int stat_validity_check(struct stat_validity *sv, const char *path); + + /* + * Update the stat_validity from a file opened at descriptor fd. If + * the file is missing, inaccessible, or not a regular file, then + * future calls to stat_validity_check will match iff one of those + * conditions continues to be true. + */ + void stat_validity_update(struct stat_validity *sv, int fd); + +#if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT) +#define DTYPE(de) ((de)->d_type) +#else +#undef DT_UNKNOWN +#undef DT_DIR +#undef DT_REG +#undef DT_LNK +#define DT_UNKNOWN 0 +#define DT_DIR 1 +#define DT_REG 2 +#define DT_LNK 3 +#define DTYPE(de) DT_UNKNOWN +#endif + #endif