diff options
author | Jeff King <peff@peff.net> | 2007-05-12 02:42:00 -0400 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2007-05-12 01:01:28 -0700 |
commit | 93c44d493b8c98b9bb74e4f78aa90ee20a01f078 (patch) | |
tree | 82750c971ef1c4e9d2448ec9d2773f29ae01919f /builtin-add.c | |
parent | 16a4c6176ad096881d0021f1a922fbcc2835f799 (diff) | |
download | git-93c44d493b8c98b9bb74e4f78aa90ee20a01f078.tar.gz |
git-add: allow path limiting with -u
Rather than updating all working tree paths, we limit
ourselves to paths listed on the command line.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-add.c')
-rw-r--r-- | builtin-add.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/builtin-add.c b/builtin-add.c index 5e6748f356..159117106a 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] [--] <filepattern>..."; -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; } |