Skip to content

Commit 73d15b0

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Merge pull request #1468 from atetubou/fscache_checkout_flush
checkout.c: enable fscache for checkout again Signed-off-by: Johannes Schindelin <[email protected]>
2 parents e62117c + 593eb88 commit 73d15b0

File tree

6 files changed

+60
-0
lines changed

6 files changed

+60
-0
lines changed

builtin/checkout.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ static int checkout_worktree(const struct checkout_opts *opts,
374374
NULL);
375375

376376
enable_delayed_checkout(&state);
377+
enable_fscache(1);
377378
if (pc_workers > 1)
378379
init_parallel_checkout();
379380
for (pos = 0; pos < active_nr; pos++) {
@@ -400,6 +401,7 @@ static int checkout_worktree(const struct checkout_opts *opts,
400401
errs |= run_parallel_checkout(&state, pc_workers, pc_threshold,
401402
NULL, NULL);
402403
mem_pool_discard(&ce_mem_pool, should_validate_cache_entries());
404+
enable_fscache(0);
403405
remove_marked_cache_entries(&the_index, 1);
404406
remove_scheduled_dirs();
405407
errs |= finish_delayed_checkout(&state, &nr_checkouts);

compat/win32/fscache.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,18 @@ int fscache_enable(int enable)
420420
return result;
421421
}
422422

423+
/*
424+
* Flush cached stats result when fscache is enabled.
425+
*/
426+
void fscache_flush(void)
427+
{
428+
if (enabled) {
429+
EnterCriticalSection(&mutex);
430+
fscache_clear();
431+
LeaveCriticalSection(&mutex);
432+
}
433+
}
434+
423435
/*
424436
* Lstat replacement, uses the cache if enabled, otherwise redirects to
425437
* mingw_lstat.

compat/win32/fscache.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ int fscache_enable(int enable);
77
int 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+
1013
DIR *fscache_opendir(const char *dir);
1114
int fscache_lstat(const char *file_name, struct stat *buf);
1215

entry.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ static int write_entry(struct cache_entry *ce, char *path, struct conv_attrs *ca
386386
}
387387

388388
finish:
389+
/* Flush cached lstat in fscache after writing to disk. */
390+
flush_fscache();
391+
389392
if (state->refresh_cache) {
390393
if (!fstat_done && lstat(ce->name, &st) < 0)
391394
return error_errno("unable to stat just-written file %s",

git-compat-util.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,10 @@ static inline int is_missing_file_error(int errno_)
13081308
#define is_fscache_enabled(path) (0)
13091309
#endif
13101310

1311+
#ifndef flush_fscache
1312+
#define flush_fscache() /* noop */
1313+
#endif
1314+
13111315
int cmd_main(int, const char **);
13121316

13131317
/*

t/t7201-co.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
3571
test_expect_success setup '
3672
3773
fill x y z > same &&

0 commit comments

Comments
 (0)