| 787 | } |
| 788 | |
| 789 | static int get_untracked_files(struct repository *r, |
| 790 | struct prefix_item_list *files, |
| 791 | const struct pathspec *ps) |
| 792 | { |
| 793 | struct dir_struct dir = { 0 }; |
| 794 | size_t i; |
| 795 | struct strbuf buf = STRBUF_INIT; |
| 796 | |
| 797 | if (repo_read_index(r) < 0) |
| 798 | return error(_("could not read index")); |
| 799 | |
| 800 | prefix_item_list_clear(files); |
| 801 | setup_standard_excludes(&dir); |
| 802 | add_pattern_list(&dir, EXC_CMDL, "--exclude option"); |
| 803 | fill_directory(&dir, r->index, ps); |
| 804 | |
| 805 | for (i = 0; i < dir.nr; i++) { |
| 806 | struct dir_entry *ent = dir.entries[i]; |
| 807 | |
| 808 | if (index_name_is_other(r->index, ent->name, ent->len)) { |
| 809 | strbuf_reset(&buf); |
| 810 | strbuf_add(&buf, ent->name, ent->len); |
| 811 | add_file_item(&files->items, buf.buf); |
| 812 | } |
| 813 | } |
| 814 | |
| 815 | strbuf_release(&buf); |
| 816 | dir_clear(&dir); |
| 817 | return 0; |
| 818 | } |
| 819 | |
| 820 | static int run_add_untracked(struct add_i_state *s, const struct pathspec *ps, |
| 821 | struct prefix_item_list *files, |
no test coverage detected