convert add_files_to_cache to take struct pathspec

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Jul 14, 2013 at 15:35 UTC 3efe8e43813c859b78796b985a4fc06c2c153fb4
3 files changed +9 -6
builtin/add.c
+7 -4
@@ -166,14 +166,16 @@ static void update_callback(struct diff_queue_struct *q,
166 }
167 }
168
169 -static void update_files_in_cache(const char *prefix, const char **pathspec,
169 +static void update_files_in_cache(const char *prefix,
170 + const struct pathspec *pathspec,
171 struct update_callback_data *data)
172 {
173 struct rev_info rev;
174
175 init_revisions(&rev, prefix);
176 setup_revisions(0, NULL, &rev, NULL);
176 - init_pathspec(&rev.prune_data, pathspec);
177 + if (pathspec)
178 + copy_pathspec(&rev.prune_data, pathspec);
179 rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
180 rev.diffopt.format_callback = update_callback;
181 rev.diffopt.format_callback_data = data;
@@ -181,7 +183,8 @@ static void update_files_in_cache(const char *prefix, const char **pathspec,
183 run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
184 }
185
184 -int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
186 +int add_files_to_cache(const char *prefix,
187 + const struct pathspec *pathspec, int flags)
188 {
189 struct update_callback_data data;
190
@@ -571,7 +574,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
574 memset(&pathspec, 0, sizeof(pathspec));
575 }
576 update_data.flags = flags & ~ADD_CACHE_IMPLICIT_DOT;
574 - update_files_in_cache(prefix, pathspec.raw, &update_data);
577 + update_files_in_cache(prefix, &pathspec, &update_data);
578
579 exit_status |= !!update_data.add_errors;
580 if (add_new_files)
builtin/commit.c
+1 -1
@@ -336,7 +336,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
336 */
337 if (all || (also && pathspec.nr)) {
338 fd = hold_locked_index(&index_lock, 1);
339 - add_files_to_cache(also ? prefix : NULL, pathspec.raw, 0);
339 + add_files_to_cache(also ? prefix : NULL, &pathspec, 0);
340 refresh_cache_or_die(refresh_flags);
341 update_main_cache_tree(WRITE_TREE_SILENT);
342 if (write_cache(fd, active_cache, active_nr) ||
cache.h
+1 -1
@@ -1278,7 +1278,7 @@ void packet_trace_identity(const char *prog);
1278 * return 0 if success, 1 - if addition of a file failed and
1279 * ADD_FILES_IGNORE_ERRORS was specified in flags
1280 */
1281 -int add_files_to_cache(const char *prefix, const char **pathspec, int flags);
1281 +int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int flags);
1282
1283 /* diff.c */
1284 extern int diff_auto_refresh_index;