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

Function list_paths

builtin/commit.c:255–290  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

253 * and return the paths that match the given pattern in list.
254 */
255static 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
292static void add_remove_files(struct string_list *list)
293{

Callers 1

prepare_indexFunction · 0.85

Calls 7

xcallocFunction · 0.85
common_prefixFunction · 0.85
overlay_tree_on_indexFunction · 0.85
ensure_full_indexFunction · 0.85
ce_path_matchFunction · 0.85
string_list_insertFunction · 0.85
report_path_errorFunction · 0.85

Tested by

no test coverage detected