summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2018-03-31 22:04:17 -0700
committerJunio C Hamano <gitster@pobox.com>2018-03-31 22:04:17 -0700
commit5b3e6b60c60b8ae17bfb94704f08ff71efc1388d (patch)
treeea122332fe8a50b0dee7196cf69ef1ab29721722
parent4ec289f1bfcebde6eae963faaa9a787c6577c2ff (diff)
parentfa49029577c93b507f875d3809ddd56429deef65 (diff)
downloadgit-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.c2
-rw-r--r--config.c9
-rw-r--r--diff-lib.c6
-rw-r--r--diff.h2
-rw-r--r--dir.c4
-rw-r--r--fsmonitor.c18
-rw-r--r--fsmonitor.h17
-rw-r--r--t/helper/test-dump-fsmonitor.c18
-rwxr-xr-xt/t7519-status-fsmonitor.sh2
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;
}
diff --git a/config.c b/config.c
index 5835b77691..40a63d6c8d 100644
--- a/config.c
+++ b/config.c
@@ -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;
diff --git a/diff.h b/diff.h
index d29560f822..58d1d08366 100644
--- a/diff.h
+++ b/diff.h
@@ -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);
diff --git a/dir.c b/dir.c
index be08d3d296..749c50ec1d 100644
--- a/dir.c
+++ b/dir.c
@@ -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
'