MCPcopy Index your code
hub / github.com/git/git / get_modified_files

Function get_modified_files

add-interactive.c:472–536  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

470};
471
472static int get_modified_files(struct repository *r,
473 enum modified_files_filter filter,
474 struct prefix_item_list *files,
475 const struct pathspec *ps,
476 size_t *unmerged_count,
477 size_t *binary_count)
478{
479 struct object_id head_oid;
480 int is_initial = !refs_resolve_ref_unsafe(get_main_ref_store(r),
481 "HEAD", RESOLVE_REF_READING,
482 &head_oid, NULL);
483 struct collection_status s = { 0 };
484 int i;
485
486 discard_index(r->index);
487 if (repo_read_index_preload(r, ps, 0) < 0)
488 return error(_("could not read index"));
489
490 prefix_item_list_clear(files);
491 s.files = &files->items;
492 hashmap_init(&s.file_map, pathname_entry_cmp, NULL, 0);
493
494 for (i = 0; i < 2; i++) {
495 struct rev_info rev;
496 struct setup_revision_opt opt = { 0 };
497
498 if (filter == INDEX_ONLY)
499 s.mode = (i == 0) ? FROM_INDEX : FROM_WORKTREE;
500 else
501 s.mode = (i == 0) ? FROM_WORKTREE : FROM_INDEX;
502 s.skip_unseen = filter && i;
503
504 opt.def = is_initial ?
505 empty_tree_oid_hex(r->hash_algo) : oid_to_hex(&head_oid);
506
507 repo_init_revisions(r, &rev, NULL);
508 setup_revisions(0, NULL, &rev, &opt);
509
510 rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
511 rev.diffopt.format_callback = collect_changes_cb;
512 rev.diffopt.format_callback_data = &s;
513
514 if (ps)
515 copy_pathspec(&rev.prune_data, ps);
516
517 if (s.mode == FROM_INDEX)
518 run_diff_index(&rev, DIFF_INDEX_CACHED);
519 else {
520 rev.diffopt.flags.ignore_dirty_submodules = 1;
521 run_diff_files(&rev, 0);
522 }
523
524 release_revisions(&rev);
525 }
526 hashmap_clear_and_free(&s.file_map, struct pathname_entry, ent);
527 if (unmerged_count)
528 *unmerged_count = s.unmerged_count;
529 if (binary_count)

Callers 5

run_statusFunction · 0.85
run_updateFunction · 0.85
run_revertFunction · 0.85
run_patchFunction · 0.85
run_diffFunction · 0.85

Calls 15

refs_resolve_ref_unsafeFunction · 0.85
get_main_ref_storeFunction · 0.85
discard_indexFunction · 0.85
repo_read_index_preloadFunction · 0.85
errorFunction · 0.85
prefix_item_list_clearFunction · 0.85
hashmap_initFunction · 0.85
empty_tree_oid_hexFunction · 0.85
oid_to_hexFunction · 0.85
repo_init_revisionsFunction · 0.85
setup_revisionsFunction · 0.85
copy_pathspecFunction · 0.85

Tested by

no test coverage detected