X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=builtin-add.c;h=159117106a3db52b430cb1bf82d094e54693f690;hb=240ba7f235c9b946678bd6d34826fb73ea8fd90e;hp=5e6748f3566b17c7729576c0c42c61bcf0f7657d;hpb=4662231e5654924c78fcb4b630fb48c58b945b7f;p=git.git diff --git a/builtin-add.c b/builtin-add.c index 5e6748f35..159117106 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -16,7 +16,7 @@ static const char builtin_add_usage[] = "git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--] ..."; -static int take_all_worktree_changes; +static int take_worktree_changes; static const char *excludes_file; static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) @@ -122,11 +122,12 @@ static void update_callback(struct diff_queue_struct *q, } } -static void update_all(int verbose) +static void update(int verbose, const char **files) { struct rev_info rev; init_revisions(&rev, ""); setup_revisions(0, NULL, &rev, NULL); + rev.prune_data = get_pathspec(rev.prefix, files); rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = update_callback; rev.diffopt.format_callback_data = &verbose; @@ -200,16 +201,14 @@ int cmd_add(int argc, const char **argv, const char *prefix) continue; } if (!strcmp(arg, "-u")) { - take_all_worktree_changes = 1; + take_worktree_changes = 1; continue; } usage(builtin_add_usage); } - if (take_all_worktree_changes) { - if (i < argc) - die("-u and explicit paths are incompatible"); - update_all(verbose); + if (take_worktree_changes) { + update(verbose, argv + i); goto finish; }