diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-03-31 22:04:17 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-03-31 22:04:17 -0700 |
commit | 5b3e6b60c60b8ae17bfb94704f08ff71efc1388d (patch) | |
tree | ea122332fe8a50b0dee7196cf69ef1ab29721722 | |
parent | 4ec289f1bfcebde6eae963faaa9a787c6577c2ff (diff) | |
parent | fa49029577c93b507f875d3809ddd56429deef65 (diff) | |
download | git-5b3e6b60c60b8ae17bfb94704f08ff71efc1388d.tar.gz |
Merge branch 'av/fsmonitor-updates' into pu
Code clean-up on fsmonitor integration, plus optional utilization
of the fsmonitor data in diff-files.
* av/fsmonitor-updates:
fsmonitor: use fsmonitor data in `git diff`
fsmonitor: remove debugging lines from t/t7519-status-fsmonitor.sh
fsmonitor: make output of test-dump-fsmonitor more concise
fsmonitor: update helper tool, now that flags are filled later
fsmonitor: stop inline'ing mark_fsmonitor_valid / _invalid
dir.c: update comments to match argument name
-rw-r--r-- | builtin/add.c | 2 | ||||
-rw-r--r-- | config.c | 9 | ||||
-rw-r--r-- | diff-lib.c | 6 | ||||
-rw-r--r-- | diff.h | 2 | ||||
-rw-r--r-- | dir.c | 4 | ||||
-rw-r--r-- | fsmonitor.c | 18 | ||||
-rw-r--r-- | fsmonitor.h | 17 | ||||
-rw-r--r-- | t/helper/test-dump-fsmonitor.c | 18 | ||||
-rwxr-xr-x | t/t7519-status-fsmonitor.sh | 2 |
9 files changed, 52 insertions, 26 deletions
diff --git a/builtin/add.c b/builtin/add.c index 9ef7fb02d5..5d4fd8f161 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -119,7 +119,7 @@ int add_files_to_cache(const char *prefix, rev.diffopt.format_callback_data = &data; rev.diffopt.flags.override_submodule_config = 1; rev.max_count = 0; /* do not compare unmerged paths with stage #2 */ - run_diff_files(&rev, DIFF_RACY_IS_MODIFIED); + run_diff_files(&rev, DIFF_RACY_IS_MODIFIED | DIFF_SKIP_FSMONITOR); clear_pathspec(&rev.prune_data); return !!data.add_errors; } @@ -2197,8 +2197,13 @@ int git_config_get_fsmonitor(void) if (core_fsmonitor && !*core_fsmonitor) core_fsmonitor = NULL; - if (core_fsmonitor) - return 1; + + if (core_fsmonitor) { + if (!strcasecmp(core_fsmonitor, "keep")) + return -1; + else + return 1; + } return 0; } diff --git a/diff-lib.c b/diff-lib.c index 104f954a25..93d0502dd5 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -96,6 +96,9 @@ int run_diff_files(struct rev_info *revs, unsigned int option) diff_set_mnemonic_prefix(&revs->diffopt, "i/", "w/"); + if (!(option & DIFF_SKIP_FSMONITOR)) + refresh_fsmonitor(&the_index); + if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; entries = active_nr; @@ -198,6 +201,9 @@ int run_diff_files(struct rev_info *revs, unsigned int option) if (ce_uptodate(ce) || ce_skip_worktree(ce)) continue; + if (ce->ce_flags & CE_FSMONITOR_VALID && !(option & DIFF_SKIP_FSMONITOR)) + continue; + /* If CE_VALID is set, don't look at workdir for file removal */ if (ce->ce_flags & CE_VALID) { changed = 0; @@ -402,6 +402,8 @@ extern const char *diff_aligned_abbrev(const struct object_id *sha1, int); #define DIFF_SILENT_ON_REMOVED 01 /* report racily-clean paths as modified */ #define DIFF_RACY_IS_MODIFIED 02 +/* skip loading the fsmonitor data */ +#define DIFF_SKIP_FSMONITOR 04 extern int run_diff_files(struct rev_info *revs, unsigned int option); extern int run_diff_index(struct rev_info *revs, int cached); @@ -797,9 +797,9 @@ static int add_excludes_from_buffer(char *buf, size_t size, * an index if 'istate' is non-null), parse it and store the * exclude rules in "el". * - * If "ss" is not NULL, compute SHA-1 of the exclude file and fill + * If sha1_stat is not NULL, compute SHA-1 of the exclude file and fill * stat data from disk (only valid if add_excludes returns zero). If - * ss_valid is non-zero, "ss" must contain good value as input. + * sha1_stat.valid is non-zero, sha1_stat must contain good value as input. */ static int add_excludes(const char *fname, const char *base, int baselen, struct exclude_list *el, struct index_state *istate, diff --git a/fsmonitor.c b/fsmonitor.c index 6d7bcd5d0e..ec48446ad1 100644 --- a/fsmonitor.c +++ b/fsmonitor.c @@ -194,6 +194,24 @@ void refresh_fsmonitor(struct index_state *istate) istate->fsmonitor_last_update = last_update; } +void mark_fsmonitor_valid(struct cache_entry *ce) +{ + if (core_fsmonitor) { + ce->ce_flags |= CE_FSMONITOR_VALID; + trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name); + } +} + +void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce) +{ + if (core_fsmonitor) { + ce->ce_flags &= ~CE_FSMONITOR_VALID; + untracked_cache_invalidate_path(istate, ce->name, 1); + trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_invalid '%s'", ce->name); + } +} + + void add_fsmonitor(struct index_state *istate) { int i; diff --git a/fsmonitor.h b/fsmonitor.h index 65f3743636..6328745b23 100644 --- a/fsmonitor.h +++ b/fsmonitor.h @@ -46,13 +46,7 @@ extern void refresh_fsmonitor(struct index_state *istate); * called any time the cache entry has been updated to reflect the * current state of the file on disk. */ -static inline void mark_fsmonitor_valid(struct cache_entry *ce) -{ - if (core_fsmonitor) { - ce->ce_flags |= CE_FSMONITOR_VALID; - trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_clean '%s'", ce->name); - } -} +extern void mark_fsmonitor_valid(struct cache_entry *ce); /* * Clear the given cache entry's CE_FSMONITOR_VALID bit and invalidate @@ -61,13 +55,6 @@ static inline void mark_fsmonitor_valid(struct cache_entry *ce) * trigger an lstat() or invalidate the untracked cache for the * corresponding directory */ -static inline void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce) -{ - if (core_fsmonitor) { - ce->ce_flags &= ~CE_FSMONITOR_VALID; - untracked_cache_invalidate_path(istate, ce->name, 1); - trace_printf_key(&trace_fsmonitor, "mark_fsmonitor_invalid '%s'", ce->name); - } -} +extern void mark_fsmonitor_invalid(struct index_state *istate, struct cache_entry *ce); #endif diff --git a/t/helper/test-dump-fsmonitor.c b/t/helper/test-dump-fsmonitor.c index ad452707e8..348720fc83 100644 --- a/t/helper/test-dump-fsmonitor.c +++ b/t/helper/test-dump-fsmonitor.c @@ -1,21 +1,31 @@ #include "cache.h" +#include "config.h" int cmd_main(int ac, const char **av) { struct index_state *istate = &the_index; - int i; + uint64_t now = getnanotime(); + int i, valid = 0; + git_config_push_parameter("core.fsmonitor=keep"); setup_git_directory(); - if (do_read_index(istate, get_index_file(), 0) < 0) + if (read_index_from(istate, get_index_file(), get_git_dir()) < 0) die("unable to read index file"); if (!istate->fsmonitor_last_update) { printf("no fsmonitor\n"); return 0; } - printf("fsmonitor last update %"PRIuMAX"\n", (uintmax_t)istate->fsmonitor_last_update); + + printf("fsmonitor last update %"PRIuMAX", (%.2f seconds ago)\n", + (uintmax_t)istate->fsmonitor_last_update, + (now - istate->fsmonitor_last_update)/1.0e9); for (i = 0; i < istate->cache_nr; i++) - printf((istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) ? "+" : "-"); + if (istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) + valid++; + + printf(" valid: %d\n", valid); + printf(" invalid: %d\n", istate->cache_nr - valid); return 0; } diff --git a/t/t7519-status-fsmonitor.sh b/t/t7519-status-fsmonitor.sh index 756beb0d8e..a48cf2777b 100755 --- a/t/t7519-status-fsmonitor.sh +++ b/t/t7519-status-fsmonitor.sh @@ -307,9 +307,7 @@ test_expect_success 'splitting the index results in the same state' ' dirty_repo && git update-index --fsmonitor && git ls-files -f >expect && - test-dump-fsmonitor >&2 && echo && git update-index --fsmonitor --split-index && - test-dump-fsmonitor >&2 && echo && git ls-files -f >actual && test_cmp expect actual ' |