MCPcopy Index your code
hub / github.com/git/git / refresh_cache_ent

Function refresh_cache_ent

read-cache.c:1339–1448  ·  view source on GitHub ↗

* "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

Source from the content-addressed store, hash-verified

1337 * to link up the stat cache details with the proper files.
1338 */
1339static 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);

Callers 2

refresh_indexFunction · 0.85
refresh_cache_entryFunction · 0.85

Calls 8

refresh_fsmonitorFunction · 0.85
has_symlink_leading_pathFunction · 0.85
ie_match_statFunction · 0.85
mark_fsmonitor_validFunction · 0.85
ie_modifiedFunction · 0.85
make_empty_cache_entryFunction · 0.85
copy_cache_entryFunction · 0.85
fill_stat_cache_infoFunction · 0.85

Tested by

no test coverage detected