MCPcopy Create free account
hub / github.com/git/git / refresh

Function refresh

builtin/add.c:123–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

121}
122
123static int refresh(struct repository *repo, int verbose, const struct pathspec *pathspec)
124{
125 char *seen;
126 int i, ret = 0;
127 char *skip_worktree_seen = NULL;
128 struct string_list only_match_skip_worktree = STRING_LIST_INIT_NODUP;
129 unsigned int flags = REFRESH_IGNORE_SKIP_WORKTREE |
130 (verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET);
131
132 seen = xcalloc(pathspec->nr, 1);
133 refresh_index(repo->index, flags, pathspec, seen,
134 _("Unstaged changes after refreshing the index:"));
135 for (i = 0; i < pathspec->nr; i++) {
136 if (!seen[i]) {
137 const char *path = pathspec->items[i].original;
138
139 if (matches_skip_worktree(pathspec, i, &skip_worktree_seen) ||
140 !path_in_sparse_checkout(path, repo->index)) {
141 string_list_append(&only_match_skip_worktree,
142 pathspec->items[i].original);
143 } else {
144 die(_("pathspec '%s' did not match any files"),
145 pathspec->items[i].original);
146 }
147 }
148 }
149
150 if (only_match_skip_worktree.nr) {
151 advise_on_updating_sparse_paths(&only_match_skip_worktree);
152 ret = 1;
153 }
154
155 free(seen);
156 free(skip_worktree_seen);
157 string_list_clear(&only_match_skip_worktree, 0);
158 return ret;
159}
160
161int interactive_add(struct repository *repo,
162 const char **argv,

Callers 1

cmd_addFunction · 0.70

Calls 8

xcallocFunction · 0.85
refresh_indexFunction · 0.85
matches_skip_worktreeFunction · 0.85
path_in_sparse_checkoutFunction · 0.85
string_list_clearFunction · 0.85
string_list_appendFunction · 0.50
dieFunction · 0.50

Tested by

no test coverage detected