* Take a union of paths in the index and the named tree (typically, "HEAD"), * and return the paths that match the given pattern in list. */
| 253 | * and return the paths that match the given pattern in list. |
| 254 | */ |
| 255 | static int list_paths(struct string_list *list, const char *with_tree, |
| 256 | const struct pathspec *pattern) |
| 257 | { |
| 258 | int i, ret; |
| 259 | char *m; |
| 260 | |
| 261 | if (!pattern->nr) |
| 262 | return 0; |
| 263 | |
| 264 | m = xcalloc(1, pattern->nr); |
| 265 | |
| 266 | if (with_tree) { |
| 267 | char *max_prefix = common_prefix(pattern); |
| 268 | overlay_tree_on_index(the_repository->index, with_tree, max_prefix); |
| 269 | free(max_prefix); |
| 270 | } |
| 271 | |
| 272 | /* TODO: audit for interaction with sparse-index. */ |
| 273 | ensure_full_index(the_repository->index); |
| 274 | for (i = 0; i < the_repository->index->cache_nr; i++) { |
| 275 | const struct cache_entry *ce = the_repository->index->cache[i]; |
| 276 | struct string_list_item *item; |
| 277 | |
| 278 | if (ce->ce_flags & CE_UPDATE) |
| 279 | continue; |
| 280 | if (!ce_path_match(the_repository->index, ce, pattern, m)) |
| 281 | continue; |
| 282 | item = string_list_insert(list, ce->name); |
| 283 | if (ce_skip_worktree(ce)) |
| 284 | item->util = item; /* better a valid pointer than a fake one */ |
| 285 | } |
| 286 | |
| 287 | ret = report_path_error(m, pattern); |
| 288 | free(m); |
| 289 | return ret; |
| 290 | } |
| 291 | |
| 292 | static void add_remove_files(struct string_list *list) |
| 293 | { |
no test coverage detected