summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9373373)
raw | patch | inline | side by side (parent: 9373373)
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | |
Wed, 15 Dec 2010 15:02:38 +0000 (22:02 +0700) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 16 Dec 2010 21:14:24 +0000 (13:14 -0800) |
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/diff-files.c | patch | blob | history | |
builtin/diff.c | patch | blob | history | |
builtin/log.c | patch | blob | history | |
diff-lib.c | patch | blob | history | |
diff-no-index.c | patch | blob | history | |
diff.h | patch | blob | history | |
revision.c | patch | blob | history | |
tree-diff.c | patch | blob | history |
diff --git a/builtin/diff-files.c b/builtin/diff-files.c
index 951c7c8994704543fc1784c87a17a1aa47ede257..46085f862f937b005493319cea25b93bcb10c999 100644 (file)
--- a/builtin/diff-files.c
+++ b/builtin/diff-files.c
(rev.diffopt.output_format & DIFF_FORMAT_PATCH))
rev.combine_merges = rev.dense_combined_merges = 1;
- if (read_cache_preload(rev.diffopt.paths) < 0) {
+ if (read_cache_preload(rev.diffopt.pathspec.raw) < 0) {
perror("read_cache_preload");
return -1;
}
diff --git a/builtin/diff.c b/builtin/diff.c
index a43d3263638daf083c52f37f3bd0872327d7459b..76c42d834f6c3982eaae463689c38eebfc091131 100644 (file)
--- a/builtin/diff.c
+++ b/builtin/diff.c
revs->max_count != -1 || revs->min_age != -1 ||
revs->max_age != -1)
usage(builtin_diff_usage);
- if (read_cache_preload(revs->diffopt.paths) < 0) {
+ if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {
perror("read_cache_preload");
return -1;
}
@@ -237,7 +237,7 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
revs->combine_merges = revs->dense_combined_merges = 1;
setup_work_tree();
- if (read_cache_preload(revs->diffopt.paths) < 0) {
+ if (read_cache_preload(revs->diffopt.pathspec.raw) < 0) {
perror("read_cache_preload");
return -1;
}
diff --git a/builtin/log.c b/builtin/log.c
index eaa1ee0fa71a344af747dec038c6a5907c8273a5..92779a522c20d7b8b89aca6718333b506ee0fb37 100644 (file)
--- a/builtin/log.c
+++ b/builtin/log.c
rev->always_show_header = 0;
if (DIFF_OPT_TST(&rev->diffopt, FOLLOW_RENAMES)) {
rev->always_show_header = 0;
- if (rev->diffopt.nr_paths != 1)
+ if (rev->diffopt.pathspec.nr != 1)
usage("git logs can only follow renames on one pathname at a time");
}
for (i = 1; i < argc; i++) {
diff --git a/diff-lib.c b/diff-lib.c
index 392ce2bef05746cea7922d39da67bf25d1d3d192..3b809f2e0d1a937df99d3c3018848930ee13a25b 100644 (file)
--- a/diff-lib.c
+++ b/diff-lib.c
active_nr = dst - active_cache;
init_revisions(&revs, NULL);
- revs.prune_data = opt->paths;
+ revs.prune_data = opt->pathspec.raw;
tree = parse_tree_indirect(tree_sha1);
if (!tree)
die("bad tree object %s", sha1_to_hex(tree_sha1));
diff --git a/diff-no-index.c b/diff-no-index.c
index e48ab92ba1ae9bfe746eaedaa76fe73421a80cb9..3a36144687ae2f5bf7bb3afc914ddbada8d5ff93 100644 (file)
--- a/diff-no-index.c
+++ b/diff-no-index.c
if (diff_setup_done(&revs->diffopt) < 0)
die("diff_setup_done failed");
- if (queue_diff(&revs->diffopt, revs->diffopt.paths[0],
- revs->diffopt.paths[1]))
+ if (queue_diff(&revs->diffopt, revs->diffopt.pathspec.raw[0],
+ revs->diffopt.pathspec.raw[1]))
exit(1);
diff_set_mnemonic_prefix(&revs->diffopt, "1/", "2/");
diffcore_std(&revs->diffopt);
index bf2f44d840735684c89f654ee6f3b3a935af2c55..6497b71aa8dc4122e7f328ff51e292460144bd1a 100644 (file)
--- a/diff.h
+++ b/diff.h
FILE *file;
int close_file;
- int nr_paths;
- const char **paths;
- int *pathlens;
+ struct pathspec pathspec;
change_fn_t change;
add_remove_fn_t add_remove;
diff_format_fn_t format_callback;
diff --git a/revision.c b/revision.c
index b1c18906badc5fc4ce3af48daa7c226365e3c08f..b2a5867dcd15eff3279cdeb2ed1612156cae00b0 100644 (file)
--- a/revision.c
+++ b/revision.c
left_first = left_count < right_count;
init_patch_ids(&ids);
- if (revs->diffopt.nr_paths) {
- ids.diffopts.nr_paths = revs->diffopt.nr_paths;
- ids.diffopts.paths = revs->diffopt.paths;
- ids.diffopts.pathlens = revs->diffopt.pathlens;
- }
+ ids.diffopts.pathspec = revs->diffopt.pathspec;
/* Compute patch-ids for one side */
for (p = list; p; p = p->next) {
diff --git a/tree-diff.c b/tree-diff.c
index cd659c6fe447b6fcdedee2843113feb358f23849..7a4cc4b71d64ff88f0e11a100397cc62b151c279 100644 (file)
--- a/tree-diff.c
+++ b/tree-diff.c
@@ -100,16 +100,17 @@ static int tree_entry_interesting(struct tree_desc *desc, const char *base, int
int pathlen;
int never_interesting = -1;
- if (!opt->nr_paths)
+ if (!opt->pathspec.nr)
return 1;
sha1 = tree_entry_extract(desc, &path, &mode);
pathlen = tree_entry_len(path, sha1);
- for (i = 0; i < opt->nr_paths; i++) {
- const char *match = opt->paths[i];
- int matchlen = opt->pathlens[i];
+ for (i = 0; i < opt->pathspec.nr; i++) {
+ const struct pathspec_item *item = opt->pathspec.items+i;
+ const char *match = item->match;
+ int matchlen = item->len;
int m = -1; /* signals that we haven't called strncmp() */
if (baselen >= matchlen) {
@@ -289,7 +290,7 @@ int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, stru
if (DIFF_OPT_TST(opt, QUICK) &&
DIFF_OPT_TST(opt, HAS_CHANGES))
break;
- if (opt->nr_paths) {
+ if (opt->pathspec.nr) {
skip_uninteresting(t1, base, baselen, opt);
skip_uninteresting(t2, base, baselen, opt);
}
@@ -348,7 +349,7 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
DIFF_OPT_SET(&diff_opts, RECURSIVE);
DIFF_OPT_SET(&diff_opts, FIND_COPIES_HARDER);
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
- diff_opts.single_follow = opt->paths[0];
+ diff_opts.single_follow = opt->pathspec.raw[0];
diff_opts.break_opt = opt->break_opt;
paths[0] = NULL;
diff_tree_setup_paths(paths, &diff_opts);
@@ -368,15 +369,16 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
* diff_queued_diff, we will also use that as the path in
* the future!
*/
- if ((p->status == 'R' || p->status == 'C') && !strcmp(p->two->path, opt->paths[0])) {
+ if ((p->status == 'R' || p->status == 'C') &&
+ !strcmp(p->two->path, opt->pathspec.raw[0])) {
/* Switch the file-pairs around */
q->queue[i] = choice;
choice = p;
/* Update the path we use from now on.. */
diff_tree_release_paths(opt);
- opt->paths[0] = xstrdup(p->one->path);
- diff_tree_setup_paths(opt->paths, opt);
+ opt->pathspec.raw[0] = xstrdup(p->one->path);
+ diff_tree_setup_paths(opt->pathspec.raw, opt);
/*
* The caller expects us to return a set of vanilla
@@ -451,36 +453,12 @@ int diff_root_tree_sha1(const unsigned char *new, const char *base, struct diff_
return retval;
}
-static int count_paths(const char **paths)
-{
- int i = 0;
- while (*paths++)
- i++;
- return i;
-}
-
void diff_tree_release_paths(struct diff_options *opt)
{
- free(opt->pathlens);
+ free_pathspec(&opt->pathspec);
}
void diff_tree_setup_paths(const char **p, struct diff_options *opt)
{
- opt->nr_paths = 0;
- opt->pathlens = NULL;
- opt->paths = NULL;
-
- if (p) {
- int i;
-
- opt->paths = p;
- opt->nr_paths = count_paths(p);
- if (opt->nr_paths == 0) {
- opt->pathlens = NULL;
- return;
- }
- opt->pathlens = xmalloc(opt->nr_paths * sizeof(int));
- for (i=0; i < opt->nr_paths; i++)
- opt->pathlens[i] = strlen(p[i]);
- }
+ init_pathspec(&opt->pathspec, p);
}