struct rev_info: convert prune_data to struct pathspec

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Nguyễn Thái Ngọc Duy 2010-12-17 19:43:06 +07:00 committed by Junio C Hamano
parent 61cf282045
commit afe069d166
7 changed files with 20 additions and 23 deletions

View File

@ -86,7 +86,7 @@ int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
struct rev_info rev; struct rev_info rev;
init_revisions(&rev, prefix); init_revisions(&rev, prefix);
setup_revisions(0, NULL, &rev, NULL); setup_revisions(0, NULL, &rev, NULL);
rev.prune_data = pathspec; init_pathspec(&rev.prune_data, pathspec);
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
rev.diffopt.format_callback = update_callback; rev.diffopt.format_callback = update_callback;
data.flags = flags; data.flags = flags;

View File

@ -371,14 +371,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
} }
die("unhandled object '%s' given.", name); die("unhandled object '%s' given.", name);
} }
if (rev.prune_data) { if (rev.prune_data.nr) {
const char **pathspec = rev.prune_data; if (!path)
while (*pathspec) { path = rev.prune_data.items[0].match;
if (!path) paths += rev.prune_data.nr;
path = *pathspec;
paths++;
pathspec++;
}
} }


/* /*

View File

@ -651,7 +651,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
if (import_filename) if (import_filename)
import_marks(import_filename); import_marks(import_filename);


if (import_filename && revs.prune_data) if (import_filename && revs.prune_data.nr)
full_tree = 1; full_tree = 1;


get_tags_and_duplicates(&revs.pending, &extra_refs); get_tags_and_duplicates(&revs.pending, &extra_refs);

View File

@ -106,7 +106,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES)) DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
break; break;


if (!ce_path_match(ce, revs->prune_data)) if (!ce_path_match(ce, revs->prune_data.raw))
continue; continue;


if (ce_stage(ce)) { if (ce_stage(ce)) {
@ -427,7 +427,7 @@ static int oneway_diff(struct cache_entry **src, struct unpack_trees_options *o)
if (tree == o->df_conflict_entry) if (tree == o->df_conflict_entry)
tree = NULL; tree = NULL;


if (ce_path_match(idx ? idx : tree, revs->prune_data)) if (ce_path_match(idx ? idx : tree, revs->prune_data.raw))
do_oneway_diff(o, idx, tree); do_oneway_diff(o, idx, tree);


return 0; return 0;
@ -501,7 +501,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
active_nr = dst - active_cache; active_nr = dst - active_cache;


init_revisions(&revs, NULL); init_revisions(&revs, NULL);
revs.prune_data = opt->pathspec.raw; init_pathspec(&revs.prune_data, opt->pathspec.raw);
tree = parse_tree_indirect(tree_sha1); tree = parse_tree_indirect(tree_sha1);
if (!tree) if (!tree)
die("bad tree object %s", sha1_to_hex(tree_sha1)); die("bad tree object %s", sha1_to_hex(tree_sha1));

View File

@ -323,7 +323,7 @@ static int rev_compare_tree(struct rev_info *revs, struct commit *parent, struct
* tagged commit by specifying both --simplify-by-decoration * tagged commit by specifying both --simplify-by-decoration
* and pathspec. * and pathspec.
*/ */
if (!revs->prune_data) if (!revs->prune_data.nr)
return REV_TREE_SAME; return REV_TREE_SAME;
} }


@ -969,7 +969,7 @@ static void prepare_show_merge(struct rev_info *revs)
struct cache_entry *ce = active_cache[i]; struct cache_entry *ce = active_cache[i];
if (!ce_stage(ce)) if (!ce_stage(ce))
continue; continue;
if (ce_path_match(ce, revs->prune_data)) { if (ce_path_match(ce, revs->prune_data.raw)) {
prune_num++; prune_num++;
prune = xrealloc(prune, sizeof(*prune) * prune_num); prune = xrealloc(prune, sizeof(*prune) * prune_num);
prune[prune_num-2] = ce->name; prune[prune_num-2] = ce->name;
@ -979,7 +979,8 @@ static void prepare_show_merge(struct rev_info *revs)
ce_same_name(ce, active_cache[i+1])) ce_same_name(ce, active_cache[i+1]))
i++; i++;
} }
revs->prune_data = prune; free_pathspec(&revs->prune_data);
init_pathspec(&revs->prune_data, prune);
revs->limited = 1; revs->limited = 1;
} }


@ -1616,7 +1617,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
} }


if (prune_data) if (prune_data)
revs->prune_data = get_pathspec(revs->prefix, prune_data); init_pathspec(&revs->prune_data, get_pathspec(revs->prefix, prune_data));


if (revs->def == NULL) if (revs->def == NULL)
revs->def = opt ? opt->def : NULL; revs->def = opt ? opt->def : NULL;
@ -1647,13 +1648,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
if (revs->topo_order) if (revs->topo_order)
revs->limited = 1; revs->limited = 1;


if (revs->prune_data) { if (revs->prune_data.nr) {
diff_tree_setup_paths(revs->prune_data, &revs->pruning); diff_tree_setup_paths(revs->prune_data.raw, &revs->pruning);
/* Can't prune commits with rename following: the paths change.. */ /* Can't prune commits with rename following: the paths change.. */
if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES)) if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
revs->prune = 1; revs->prune = 1;
if (!revs->full_diff) if (!revs->full_diff)
diff_tree_setup_paths(revs->prune_data, &revs->diffopt); diff_tree_setup_paths(revs->prune_data.raw, &revs->diffopt);
} }
if (revs->combine_merges) if (revs->combine_merges)
revs->ignore_merges = 0; revs->ignore_merges = 0;

View File

@ -34,7 +34,7 @@ struct rev_info {
/* Basic information */ /* Basic information */
const char *prefix; const char *prefix;
const char *def; const char *def;
void *prune_data; struct pathspec prune_data;
unsigned int early_output; unsigned int early_output;


/* Traversal flags */ /* Traversal flags */

View File

@ -323,7 +323,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
} }
rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback = wt_status_collect_changed_cb;
rev.diffopt.format_callback_data = s; rev.diffopt.format_callback_data = s;
rev.prune_data = s->pathspec; init_pathspec(&rev.prune_data, s->pathspec);
run_diff_files(&rev, 0); run_diff_files(&rev, 0);
} }


@ -348,7 +348,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)
rev.diffopt.detect_rename = 1; rev.diffopt.detect_rename = 1;
rev.diffopt.rename_limit = 200; rev.diffopt.rename_limit = 200;
rev.diffopt.break_opt = 0; rev.diffopt.break_opt = 0;
rev.prune_data = s->pathspec; init_pathspec(&rev.prune_data, s->pathspec);
run_diff_index(&rev, 1); run_diff_index(&rev, 1);
} }