@matheusbsbs / matheus-bagliano / commits / afe069d166
Fork 0

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>

Nguyễn Thái Ngọc Duy committed Dec 17, 2010 at 19:43 UTC afe069d16618190a6f7e84ef8451970e274aedb4
7 files changed +20 -23
builtin/add.c
+1 -1
@@ -86,7 +86,7 @@ int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
86 struct rev_info rev;
87 init_revisions(&rev, prefix);
88 setup_revisions(0, NULL, &rev, NULL);
89 - rev.prune_data = pathspec;
89 + init_pathspec(&rev.prune_data, pathspec);
90 rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
91 rev.diffopt.format_callback = update_callback;
92 data.flags = flags;
builtin/diff.c
+4 -8
@@ -371,14 +371,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
371 }
372 die("unhandled object '%s' given.", name);
373 }
374 - if (rev.prune_data) {
375 - const char **pathspec = rev.prune_data;
376 - while (*pathspec) {
377 - if (!path)
378 - path = *pathspec;
379 - paths++;
380 - pathspec++;
381 - }
374 + if (rev.prune_data.nr) {
375 + if (!path)
376 + path = rev.prune_data.items[0].match;
377 + paths += rev.prune_data.nr;
378 }
379
380 /*
builtin/fast-export.c
+1 -1
@@ -651,7 +651,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
651 if (import_filename)
652 import_marks(import_filename);
653
654 - if (import_filename && revs.prune_data)
654 + if (import_filename && revs.prune_data.nr)
655 full_tree = 1;
656
657 get_tags_and_duplicates(&revs.pending, &extra_refs);
diff-lib.c
+3 -3
@@ -106,7 +106,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
106 DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
107 break;
108
109 - if (!ce_path_match(ce, revs->prune_data))
109 + if (!ce_path_match(ce, revs->prune_data.raw))
110 continue;
111
112 if (ce_stage(ce)) {
@@ -427,7 +427,7 @@ static int oneway_diff(struct cache_entry **src, struct unpack_trees_options *o)
427 if (tree == o->df_conflict_entry)
428 tree = NULL;
429
430 - if (ce_path_match(idx ? idx : tree, revs->prune_data))
430 + if (ce_path_match(idx ? idx : tree, revs->prune_data.raw))
431 do_oneway_diff(o, idx, tree);
432
433 return 0;
@@ -501,7 +501,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
501 active_nr = dst - active_cache;
502
503 init_revisions(&revs, NULL);
504 - revs.prune_data = opt->pathspec.raw;
504 + init_pathspec(&revs.prune_data, opt->pathspec.raw);
505 tree = parse_tree_indirect(tree_sha1);
506 if (!tree)
507 die("bad tree object %s", sha1_to_hex(tree_sha1));
revision.c
+8 -7
@@ -323,7 +323,7 @@ static int rev_compare_tree(struct rev_info *revs, struct commit *parent, struct
323 * tagged commit by specifying both --simplify-by-decoration
324 * and pathspec.
325 */
326 - if (!revs->prune_data)
326 + if (!revs->prune_data.nr)
327 return REV_TREE_SAME;
328 }
329
@@ -969,7 +969,7 @@ static void prepare_show_merge(struct rev_info *revs)
969 struct cache_entry *ce = active_cache[i];
970 if (!ce_stage(ce))
971 continue;
972 - if (ce_path_match(ce, revs->prune_data)) {
972 + if (ce_path_match(ce, revs->prune_data.raw)) {
973 prune_num++;
974 prune = xrealloc(prune, sizeof(*prune) * prune_num);
975 prune[prune_num-2] = ce->name;
@@ -979,7 +979,8 @@ static void prepare_show_merge(struct rev_info *revs)
979 ce_same_name(ce, active_cache[i+1]))
980 i++;
981 }
982 - revs->prune_data = prune;
982 + free_pathspec(&revs->prune_data);
983 + init_pathspec(&revs->prune_data, prune);
984 revs->limited = 1;
985 }
986
@@ -1616,7 +1617,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
1617 }
1618
1619 if (prune_data)
1619 - revs->prune_data = get_pathspec(revs->prefix, prune_data);
1620 + init_pathspec(&revs->prune_data, get_pathspec(revs->prefix, prune_data));
1621
1622 if (revs->def == NULL)
1623 revs->def = opt ? opt->def : NULL;
@@ -1647,13 +1648,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
1648 if (revs->topo_order)
1649 revs->limited = 1;
1650
1650 - if (revs->prune_data) {
1651 - diff_tree_setup_paths(revs->prune_data, &revs->pruning);
1651 + if (revs->prune_data.nr) {
1652 + diff_tree_setup_paths(revs->prune_data.raw, &revs->pruning);
1653 /* Can't prune commits with rename following: the paths change.. */
1654 if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
1655 revs->prune = 1;
1656 if (!revs->full_diff)
1656 - diff_tree_setup_paths(revs->prune_data, &revs->diffopt);
1657 + diff_tree_setup_paths(revs->prune_data.raw, &revs->diffopt);
1658 }
1659 if (revs->combine_merges)
1660 revs->ignore_merges = 0;
revision.h
+1 -1
@@ -34,7 +34,7 @@ struct rev_info {
34 /* Basic information */
35 const char *prefix;
36 const char *def;
37 - void *prune_data;
37 + struct pathspec prune_data;
38 unsigned int early_output;
39
40 /* Traversal flags */
wt-status.c
+2 -2
@@ -323,7 +323,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
323 }
324 rev.diffopt.format_callback = wt_status_collect_changed_cb;
325 rev.diffopt.format_callback_data = s;
326 - rev.prune_data = s->pathspec;
326 + init_pathspec(&rev.prune_data, s->pathspec);
327 run_diff_files(&rev, 0);
328 }
329
@@ -348,7 +348,7 @@ static void wt_status_collect_changes_index(struct wt_status *s)
348 rev.diffopt.detect_rename = 1;
349 rev.diffopt.rename_limit = 200;
350 rev.diffopt.break_opt = 0;
351 - rev.prune_data = s->pathspec;
351 + init_pathspec(&rev.prune_data, s->pathspec);
352 run_diff_index(&rev, 1);
353 }
354