Skip to content

Commit 3efe8e4

Browse files
pcloudsgitster
authored andcommitted
convert add_files_to_cache to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7327d3d commit 3efe8e4

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

builtin/add.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,22 +166,25 @@ static void update_callback(struct diff_queue_struct *q,
166166
}
167167
}
168168

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,
170171
struct update_callback_data *data)
171172
{
172173
struct rev_info rev;
173174

174175
init_revisions(&rev, prefix);
175176
setup_revisions(0, NULL, &rev, NULL);
176-
init_pathspec(&rev.prune_data, pathspec);
177+
if (pathspec)
178+
copy_pathspec(&rev.prune_data, pathspec);
177179
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
178180
rev.diffopt.format_callback = update_callback;
179181
rev.diffopt.format_callback_data = data;
180182
rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
181183
run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
182184
}
183185

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)
185188
{
186189
struct update_callback_data data;
187190

@@ -571,7 +574,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
571574
memset(&pathspec, 0, sizeof(pathspec));
572575
}
573576
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);
575578

576579
exit_status |= !!update_data.add_errors;
577580
if (add_new_files)

builtin/commit.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
336336
*/
337337
if (all || (also && pathspec.nr)) {
338338
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);
340340
refresh_cache_or_die(refresh_flags);
341341
update_main_cache_tree(WRITE_TREE_SILENT);
342342
if (write_cache(fd, active_cache, active_nr) ||

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,7 @@ void packet_trace_identity(const char *prog);
12781278
* return 0 if success, 1 - if addition of a file failed and
12791279
* ADD_FILES_IGNORE_ERRORS was specified in flags
12801280
*/
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);
12821282

12831283
/* diff.c */
12841284
extern int diff_auto_refresh_index;

0 commit comments

Comments
 (0)