37
static const char *pathspec_from_file;
38
39
struct update_callback_data {
40
+ struct index_state *index;
41
+ int include_sparse;
42
int flags;
43
int add_errors;
44
};
102
struct diff_filepair *p = q->queue[i];
103
const char *path = p->one->path;
104
103
- if (!include_sparse && !path_in_sparse_checkout(path, &the_index))
105
+ if (!data->include_sparse &&
106
+ !path_in_sparse_checkout(path, data->index))
107
continue;
108
109
switch (fix_unmerged_status(p, data)) {
111
die(_("unexpected diff status %c"), p->status);
112
case DIFF_STATUS_MODIFIED:
113
case DIFF_STATUS_TYPE_CHANGED:
111
- if (add_file_to_index(&the_index, path, data->flags)) {
114
+ if (add_file_to_index(data->index, path, data->flags)) {
115
if (!(data->flags & ADD_CACHE_IGNORE_ERRORS))
116
die(_("updating files failed"));
117
data->add_errors++;
121
if (data->flags & ADD_CACHE_IGNORE_REMOVAL)
122
break;
123
if (!(data->flags & ADD_CACHE_PRETEND))
121
- remove_file_from_index(&the_index, path);
124
+ remove_file_from_index(data->index, path);
125
if (data->flags & (ADD_CACHE_PRETEND|ADD_CACHE_VERBOSE))
126
printf(_("remove '%s'\n"), path);
127
break;
129
}
130
}
131
129
-int add_files_to_cache(const char *prefix,
130
- const struct pathspec *pathspec, int flags)
132
+int add_files_to_cache(struct repository *repo, const char *prefix,
133
+ const struct pathspec *pathspec, int include_sparse,
134
+ int flags)
135
{
136
struct update_callback_data data;
137
struct rev_info rev;
138
139
memset(&data, 0, sizeof(data));
140
+ data.index = repo->index;
141
+ data.include_sparse = include_sparse;
142
data.flags = flags;
143
138
- repo_init_revisions(the_repository, &rev, prefix);
144
+ repo_init_revisions(repo, &rev, prefix);
145
setup_revisions(0, NULL, &rev, NULL);
146
if (pathspec)
147
copy_pathspec(&rev.prune_data, pathspec);
646
if (add_renormalize)
647
exit_status |= renormalize_tracked_files(&pathspec, flags);
648
else
643
- exit_status |= add_files_to_cache(prefix, &pathspec, flags);
649
+ exit_status |= add_files_to_cache(the_repository, prefix,
650
+ &pathspec, include_sparse,
651
+ flags);
652
653
if (add_new_files)
654
exit_status |= add_files(&dir, flags);