| 1480 | |
| 1481 | |
| 1482 | int refresh_index(struct index_state *istate, unsigned int flags, |
| 1483 | const struct pathspec *pathspec, |
| 1484 | char *seen, const char *header_msg) |
| 1485 | { |
| 1486 | int i; |
| 1487 | int has_errors = 0; |
| 1488 | int really = (flags & REFRESH_REALLY) != 0; |
| 1489 | int allow_unmerged = (flags & REFRESH_UNMERGED) != 0; |
| 1490 | int quiet = (flags & REFRESH_QUIET) != 0; |
| 1491 | int not_new = (flags & REFRESH_IGNORE_MISSING) != 0; |
| 1492 | int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0; |
| 1493 | int ignore_skip_worktree = (flags & REFRESH_IGNORE_SKIP_WORKTREE) != 0; |
| 1494 | int first = 1; |
| 1495 | int in_porcelain = (flags & REFRESH_IN_PORCELAIN); |
| 1496 | unsigned int options = (CE_MATCH_REFRESH | |
| 1497 | (really ? CE_MATCH_IGNORE_VALID : 0) | |
| 1498 | (not_new ? CE_MATCH_IGNORE_MISSING : 0)); |
| 1499 | const char *modified_fmt; |
| 1500 | const char *deleted_fmt; |
| 1501 | const char *typechange_fmt; |
| 1502 | const char *added_fmt; |
| 1503 | const char *unmerged_fmt; |
| 1504 | struct progress *progress = NULL; |
| 1505 | int t2_sum_lstat = 0; |
| 1506 | int t2_sum_scan = 0; |
| 1507 | |
| 1508 | if (flags & REFRESH_PROGRESS && isatty(2)) |
| 1509 | progress = start_delayed_progress(the_repository, |
| 1510 | _("Refresh index"), |
| 1511 | istate->cache_nr); |
| 1512 | |
| 1513 | trace_performance_enter(); |
| 1514 | modified_fmt = in_porcelain ? "M\t%s\n" : "%s: needs update\n"; |
| 1515 | deleted_fmt = in_porcelain ? "D\t%s\n" : "%s: needs update\n"; |
| 1516 | typechange_fmt = in_porcelain ? "T\t%s\n" : "%s: needs update\n"; |
| 1517 | added_fmt = in_porcelain ? "A\t%s\n" : "%s: needs update\n"; |
| 1518 | unmerged_fmt = in_porcelain ? "U\t%s\n" : "%s: needs merge\n"; |
| 1519 | /* |
| 1520 | * Use the multi-threaded preload_index() to refresh most of the |
| 1521 | * cache entries quickly then in the single threaded loop below, |
| 1522 | * we only have to do the special cases that are left. |
| 1523 | */ |
| 1524 | preload_index(istate, pathspec, 0); |
| 1525 | trace2_region_enter("index", "refresh", NULL); |
| 1526 | |
| 1527 | for (i = 0; i < istate->cache_nr; i++) { |
| 1528 | struct cache_entry *ce, *new_entry; |
| 1529 | int cache_errno = 0; |
| 1530 | int changed = 0; |
| 1531 | int filtered = 0; |
| 1532 | int t2_did_lstat = 0; |
| 1533 | int t2_did_scan = 0; |
| 1534 | |
| 1535 | ce = istate->cache[i]; |
| 1536 | if (ignore_submodules && S_ISGITLINK(ce->ce_mode)) |
| 1537 | continue; |
| 1538 | if (ignore_skip_worktree && ce_skip_worktree(ce)) |
| 1539 | continue; |