File tree Expand file tree Collapse file tree 6 files changed +60
-0
lines changed Expand file tree Collapse file tree 6 files changed +60
-0
lines changed Original file line number Diff line number Diff line change @@ -346,6 +346,7 @@ static int checkout_worktree(const struct checkout_opts *opts)
346346 state .istate = & the_index ;
347347
348348 enable_delayed_checkout (& state );
349+ enable_fscache (1 );
349350 for (pos = 0 ; pos < active_nr ; pos ++ ) {
350351 struct cache_entry * ce = active_cache [pos ];
351352 if (ce -> ce_flags & CE_MATCHED ) {
@@ -365,6 +366,7 @@ static int checkout_worktree(const struct checkout_opts *opts)
365366 pos = skip_same_name (ce , pos ) - 1 ;
366367 }
367368 }
369+ enable_fscache (0 );
368370 remove_marked_cache_entries (& the_index , 1 );
369371 remove_scheduled_dirs ();
370372 errs |= finish_delayed_checkout (& state , & nr_checkouts );
Original file line number Diff line number Diff line change @@ -411,6 +411,18 @@ int fscache_enable(int enable)
411411 return result ;
412412}
413413
414+ /*
415+ * Flush cached stats result when fscache is enabled.
416+ */
417+ void fscache_flush (void )
418+ {
419+ if (enabled ) {
420+ EnterCriticalSection (& mutex );
421+ fscache_clear ();
422+ LeaveCriticalSection (& mutex );
423+ }
424+ }
425+
414426/*
415427 * Lstat replacement, uses the cache if enabled, otherwise redirects to
416428 * mingw_lstat.
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ int fscache_enable(int enable);
77int fscache_enabled (const char * path );
88#define is_fscache_enabled (path ) fscache_enabled(path)
99
10+ void fscache_flush (void );
11+ #define flush_fscache () fscache_flush()
12+
1013DIR * fscache_opendir (const char * dir );
1114int fscache_lstat (const char * file_name , struct stat * buf );
1215
Original file line number Diff line number Diff line change @@ -367,6 +367,9 @@ static int write_entry(struct cache_entry *ce,
367367 }
368368
369369finish :
370+ /* Flush cached lstat in fscache after writing to disk. */
371+ flush_fscache ();
372+
370373 if (state -> refresh_cache ) {
371374 assert (state -> istate );
372375 if (!fstat_done )
Original file line number Diff line number Diff line change @@ -1311,6 +1311,10 @@ static inline int is_missing_file_error(int errno_)
13111311#define is_fscache_enabled (path ) (0 )
13121312#endif
13131313
1314+ #ifndef flush_fscache
1315+ #define flush_fscache () /* noop */
1316+ #endif
1317+
13141318int cmd_main (int , const char **);
13151319
13161320/*
Original file line number Diff line number Diff line change @@ -32,6 +32,42 @@ fill () {
3232}
3333
3434
35+ test_expect_success MINGW ' fscache flush cache' '
36+
37+ git init fscache-test &&
38+ cd fscache-test &&
39+ git config core.fscache 1 &&
40+ echo A > test.txt &&
41+ git add test.txt &&
42+ git commit -m A &&
43+ echo B >> test.txt &&
44+ git checkout . &&
45+ test -z "$(git status -s)" &&
46+ echo A > expect.txt &&
47+ test_cmp expect.txt test.txt &&
48+ cd .. &&
49+ rm -rf fscache-test
50+ '
51+
52+ test_expect_success MINGW ' fscache flush cache dir' '
53+
54+ git init fscache-test &&
55+ cd fscache-test &&
56+ git config core.fscache 1 &&
57+ echo A > test.txt &&
58+ git add test.txt &&
59+ git commit -m A &&
60+ rm test.txt &&
61+ mkdir test.txt &&
62+ touch test.txt/test.txt &&
63+ git checkout . &&
64+ test -z "$(git status -s)" &&
65+ echo A > expect.txt &&
66+ test_cmp expect.txt test.txt &&
67+ cd .. &&
68+ rm -rf fscache-test
69+ '
70+
3571test_expect_success setup '
3672
3773 fill x y z > same &&
You can’t perform that action at this time.
0 commit comments