Skip to content

Commit afe069d

Browse files
pcloudsgitster
authored andcommitted
struct rev_info: convert prune_data to struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 61cf282 commit afe069d

File tree

7 files changed

+20
-23
lines changed

7 files changed

+20
-23
lines changed

builtin/add.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
8686
struct rev_info rev;
8787
init_revisions(&rev, prefix);
8888
setup_revisions(0, NULL, &rev, NULL);
89-
rev.prune_data = pathspec;
89+
init_pathspec(&rev.prune_data, pathspec);
9090
rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
9191
rev.diffopt.format_callback = update_callback;
9292
data.flags = flags;

builtin/diff.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,10 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
371371
}
372372
die("unhandled object '%s' given.", name);
373373
}
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;
382378
}
383379

384380
/*

builtin/fast-export.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
651651
if (import_filename)
652652
import_marks(import_filename);
653653

654-
if (import_filename && revs.prune_data)
654+
if (import_filename && revs.prune_data.nr)
655655
full_tree = 1;
656656

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

diff-lib.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
106106
DIFF_OPT_TST(&revs->diffopt, HAS_CHANGES))
107107
break;
108108

109-
if (!ce_path_match(ce, revs->prune_data))
109+
if (!ce_path_match(ce, revs->prune_data.raw))
110110
continue;
111111

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

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

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

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

revision.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static int rev_compare_tree(struct rev_info *revs, struct commit *parent, struct
323323
* tagged commit by specifying both --simplify-by-decoration
324324
* and pathspec.
325325
*/
326-
if (!revs->prune_data)
326+
if (!revs->prune_data.nr)
327327
return REV_TREE_SAME;
328328
}
329329

@@ -969,7 +969,7 @@ static void prepare_show_merge(struct rev_info *revs)
969969
struct cache_entry *ce = active_cache[i];
970970
if (!ce_stage(ce))
971971
continue;
972-
if (ce_path_match(ce, revs->prune_data)) {
972+
if (ce_path_match(ce, revs->prune_data.raw)) {
973973
prune_num++;
974974
prune = xrealloc(prune, sizeof(*prune) * prune_num);
975975
prune[prune_num-2] = ce->name;
@@ -979,7 +979,8 @@ static void prepare_show_merge(struct rev_info *revs)
979979
ce_same_name(ce, active_cache[i+1]))
980980
i++;
981981
}
982-
revs->prune_data = prune;
982+
free_pathspec(&revs->prune_data);
983+
init_pathspec(&revs->prune_data, prune);
983984
revs->limited = 1;
984985
}
985986

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

16181619
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));
16201621

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

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);
16521653
/* Can't prune commits with rename following: the paths change.. */
16531654
if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
16541655
revs->prune = 1;
16551656
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);
16571658
}
16581659
if (revs->combine_merges)
16591660
revs->ignore_merges = 0;

revision.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ struct rev_info {
3434
/* Basic information */
3535
const char *prefix;
3636
const char *def;
37-
void *prune_data;
37+
struct pathspec prune_data;
3838
unsigned int early_output;
3939

4040
/* Traversal flags */

wt-status.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s)
323323
}
324324
rev.diffopt.format_callback = wt_status_collect_changed_cb;
325325
rev.diffopt.format_callback_data = s;
326-
rev.prune_data = s->pathspec;
326+
init_pathspec(&rev.prune_data, s->pathspec);
327327
run_diff_files(&rev, 0);
328328
}
329329

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

0 commit comments

Comments
 (0)