* "refresh" does not calculate a new sha1 file or bring the * cache up-to-date for mode/content changes. But what it * _does_ do is to "re-match" the stat information of a file * with the cache, so that you can refresh the cache for a * file that hasn't been changed but where the stat entry is * out of date. * * For example, you'd want to do this after doing a "git-read-tree", * to link up
| 1337 | * to link up the stat cache details with the proper files. |
| 1338 | */ |
| 1339 | static struct cache_entry *refresh_cache_ent(struct index_state *istate, |
| 1340 | struct cache_entry *ce, |
| 1341 | unsigned int options, int *err, |
| 1342 | int *changed_ret, |
| 1343 | int *t2_did_lstat, |
| 1344 | int *t2_did_scan) |
| 1345 | { |
| 1346 | struct stat st; |
| 1347 | struct cache_entry *updated; |
| 1348 | int changed; |
| 1349 | int refresh = options & CE_MATCH_REFRESH; |
| 1350 | int ignore_valid = options & CE_MATCH_IGNORE_VALID; |
| 1351 | int ignore_skip_worktree = options & CE_MATCH_IGNORE_SKIP_WORKTREE; |
| 1352 | int ignore_missing = options & CE_MATCH_IGNORE_MISSING; |
| 1353 | int ignore_fsmonitor = options & CE_MATCH_IGNORE_FSMONITOR; |
| 1354 | |
| 1355 | if (!refresh || ce_uptodate(ce)) |
| 1356 | return ce; |
| 1357 | |
| 1358 | if (!ignore_fsmonitor) |
| 1359 | refresh_fsmonitor(istate); |
| 1360 | /* |
| 1361 | * CE_VALID or CE_SKIP_WORKTREE means the user promised us |
| 1362 | * that the change to the work tree does not matter and told |
| 1363 | * us not to worry. |
| 1364 | */ |
| 1365 | if (!ignore_skip_worktree && ce_skip_worktree(ce)) { |
| 1366 | ce_mark_uptodate(ce); |
| 1367 | return ce; |
| 1368 | } |
| 1369 | if (!ignore_valid && (ce->ce_flags & CE_VALID)) { |
| 1370 | ce_mark_uptodate(ce); |
| 1371 | return ce; |
| 1372 | } |
| 1373 | if (!ignore_fsmonitor && (ce->ce_flags & CE_FSMONITOR_VALID)) { |
| 1374 | ce_mark_uptodate(ce); |
| 1375 | return ce; |
| 1376 | } |
| 1377 | |
| 1378 | if (has_symlink_leading_path(ce->name, ce_namelen(ce))) { |
| 1379 | if (ignore_missing) |
| 1380 | return ce; |
| 1381 | if (err) |
| 1382 | *err = ENOENT; |
| 1383 | return NULL; |
| 1384 | } |
| 1385 | |
| 1386 | if (t2_did_lstat) |
| 1387 | *t2_did_lstat = 1; |
| 1388 | if (lstat(ce->name, &st) < 0) { |
| 1389 | if (ignore_missing && errno == ENOENT) |
| 1390 | return ce; |
| 1391 | if (err) |
| 1392 | *err = errno; |
| 1393 | return NULL; |
| 1394 | } |
| 1395 | |
| 1396 | changed = ie_match_stat(istate, ce, &st, options); |
no test coverage detected