| 121 | } |
| 122 | |
| 123 | static 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 | |
| 161 | int interactive_add(struct repository *repo, |
| 162 | const char **argv, |
no test coverage detected