| 3967 | } |
| 3968 | |
| 3969 | static void update_callback(struct diff_queue_struct *q, |
| 3970 | struct diff_options *opt UNUSED, void *cbdata) |
| 3971 | { |
| 3972 | int i; |
| 3973 | struct update_callback_data *data = cbdata; |
| 3974 | |
| 3975 | for (i = 0; i < q->nr; i++) { |
| 3976 | struct diff_filepair *p = q->queue[i]; |
| 3977 | const char *path = p->one->path; |
| 3978 | |
| 3979 | if (!data->include_sparse && |
| 3980 | !path_in_sparse_checkout(path, data->index)) |
| 3981 | continue; |
| 3982 | |
| 3983 | switch (fix_unmerged_status(p, data)) { |
| 3984 | default: |
| 3985 | die(_("unexpected diff status %c"), p->status); |
| 3986 | case DIFF_STATUS_MODIFIED: |
| 3987 | case DIFF_STATUS_TYPE_CHANGED: |
| 3988 | if (skip_submodule(path, data->repo, |
| 3989 | data->pathspec, |
| 3990 | data->ignored_too)) |
| 3991 | continue; |
| 3992 | |
| 3993 | if (add_file_to_index(data->index, path, data->flags)) { |
| 3994 | if (!(data->flags & ADD_CACHE_IGNORE_ERRORS)) |
| 3995 | die(_("updating files failed")); |
| 3996 | data->add_errors++; |
| 3997 | } |
| 3998 | break; |
| 3999 | case DIFF_STATUS_DELETED: |
| 4000 | if (data->flags & ADD_CACHE_IGNORE_REMOVAL) |
| 4001 | break; |
| 4002 | if (!(data->flags & ADD_CACHE_PRETEND)) |
| 4003 | remove_file_from_index(data->index, path); |
| 4004 | if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE)) |
| 4005 | printf(_("remove '%s'\n"), path); |
| 4006 | break; |
| 4007 | } |
| 4008 | } |
| 4009 | } |
| 4010 | |
| 4011 | int add_files_to_cache(struct repository *repo, const char *prefix, |
| 4012 | const struct pathspec *pathspec, char *ps_matched, |
nothing calls this directly
no test coverage detected