aboutsummaryrefslogtreecommitdiff
path: root/builtin-add.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-11-18 01:12:04 -0800
committerJunio C Hamano <gitster@pobox.com>2007-11-22 17:05:05 -0800
commitb6ec1d619fb54642388063a88e2255556cf5de06 (patch)
tree47f2fb8aecb3cb86b6d46961ed51ded21c71a220 /builtin-add.c
parentee425e4643aa2d7be72cb4586d7554cecce44d6e (diff)
downloadgit-b6ec1d619fb54642388063a88e2255556cf5de06.tar.gz
git-b6ec1d619fb54642388063a88e2255556cf5de06.tar.xz
Fix add_files_to_cache() to take pathspec, not user specified list of files
This separates the logic to limit the extent of change to the index by where you are (controlled by "prefix") and what you specify from the command line (controlled by "pathspec"). Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin-add.c')
-rw-r--r--builtin-add.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/builtin-add.c b/builtin-add.c
index cf815a0b8..03508d3dc 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -105,12 +105,12 @@ static void update_callback(struct diff_queue_struct *q,
}
}
-void add_files_to_cache(int verbose, const char *prefix, const char **files)
+void add_files_to_cache(int verbose, const char *prefix, const char **pathspec)
{
struct rev_info rev;
init_revisions(&rev, prefix);
setup_revisions(0, NULL, &rev, NULL);
- rev.prune_data = get_pathspec(prefix, files);
+ rev.prune_data = pathspec;
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = update_callback;
rev.diffopt.format_callback_data = &verbose;
@@ -180,9 +180,11 @@ int cmd_add(int argc, const char **argv, const char *prefix)
newfd = hold_locked_index(&lock_file, 1);
if (take_worktree_changes) {
+ const char **pathspec;
if (read_cache() < 0)
die("index file corrupt");
- add_files_to_cache(verbose, prefix, argv);
+ pathspec = get_pathspec(prefix, argv);
+ add_files_to_cache(verbose, prefix, pathspec);
goto finish;
}