Skip to content

Commit bd1928d

Browse files
pcloudsgitster
authored andcommitted
remove diff_tree_{setup,release}_paths
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 827f4d6 commit bd1928d

File tree

7 files changed

+22
-32
lines changed

7 files changed

+22
-32
lines changed

builtin/blame.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static struct origin *find_origin(struct scoreboard *sb,
408408
paths[0] = origin->path;
409409
paths[1] = NULL;
410410

411-
diff_tree_setup_paths(paths, &diff_opts);
411+
init_pathspec(&diff_opts.pathspec, paths);
412412
diff_setup_done(&diff_opts);
413413

414414
if (is_null_sha1(origin->commit->object.sha1))
@@ -458,7 +458,7 @@ static struct origin *find_origin(struct scoreboard *sb,
458458
}
459459
}
460460
diff_flush(&diff_opts);
461-
diff_tree_release_paths(&diff_opts);
461+
free_pathspec(&diff_opts.pathspec);
462462
if (porigin) {
463463
/*
464464
* Create a freestanding copy that is not part of
@@ -494,7 +494,7 @@ static struct origin *find_rename(struct scoreboard *sb,
494494
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
495495
diff_opts.single_follow = origin->path;
496496
paths[0] = NULL;
497-
diff_tree_setup_paths(paths, &diff_opts);
497+
init_pathspec(&diff_opts.pathspec, paths);
498498
diff_setup_done(&diff_opts);
499499

500500
if (is_null_sha1(origin->commit->object.sha1))
@@ -516,7 +516,7 @@ static struct origin *find_rename(struct scoreboard *sb,
516516
}
517517
}
518518
diff_flush(&diff_opts);
519-
diff_tree_release_paths(&diff_opts);
519+
free_pathspec(&diff_opts.pathspec);
520520
return porigin;
521521
}
522522

@@ -1079,7 +1079,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
10791079
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
10801080

10811081
paths[0] = NULL;
1082-
diff_tree_setup_paths(paths, &diff_opts);
1082+
init_pathspec(&diff_opts.pathspec, paths);
10831083
diff_setup_done(&diff_opts);
10841084

10851085
/* Try "find copies harder" on new path if requested;
@@ -1162,7 +1162,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
11621162
}
11631163
reset_scanned_flag(sb);
11641164
diff_flush(&diff_opts);
1165-
diff_tree_release_paths(&diff_opts);
1165+
free_pathspec(&diff_opts.pathspec);
11661166
return retval;
11671167
}
11681168

builtin/reset.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,13 @@ static void update_index_from_diff(struct diff_queue_struct *q,
133133
}
134134
}
135135

136-
static int read_from_tree(const char **pathspec, unsigned char *tree_sha1)
136+
static int read_from_tree(const struct pathspec *pathspec,
137+
unsigned char *tree_sha1)
137138
{
138139
struct diff_options opt;
139140

140141
memset(&opt, 0, sizeof(opt));
141-
diff_tree_setup_paths(pathspec, &opt);
142+
copy_pathspec(&opt.pathspec, pathspec);
142143
opt.output_format = DIFF_FORMAT_CALLBACK;
143144
opt.format_callback = update_index_from_diff;
144145

@@ -147,7 +148,7 @@ static int read_from_tree(const char **pathspec, unsigned char *tree_sha1)
147148
return 1;
148149
diffcore_std(&opt);
149150
diff_flush(&opt);
150-
diff_tree_release_paths(&opt);
151+
free_pathspec(&opt.pathspec);
151152

152153
return 0;
153154
}
@@ -332,7 +333,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
332333
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
333334
int newfd = hold_locked_index(lock, 1);
334335
if (reset_type == MIXED) {
335-
if (read_from_tree(pathspec.raw, sha1))
336+
if (read_from_tree(&pathspec, sha1))
336337
return 1;
337338
} else {
338339
int err = reset_index(sha1, reset_type, quiet);

combine-diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1305,7 +1305,7 @@ void diff_tree_combined(const unsigned char *sha1,
13051305
int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
13061306

13071307
diffopts = *opt;
1308-
diff_tree_setup_paths(diffopts.pathspec.raw, &diffopts);
1308+
copy_pathspec(&diffopts.pathspec, &opt->pathspec);
13091309
diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
13101310
DIFF_OPT_SET(&diffopts, RECURSIVE);
13111311
DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
@@ -1377,7 +1377,7 @@ void diff_tree_combined(const unsigned char *sha1,
13771377
free(tmp);
13781378
}
13791379

1380-
diff_tree_release_paths(&diffopts);
1380+
free_pathspec(&diffopts.pathspec);
13811381
}
13821382

13831383
void diff_tree_combined_merge(const struct commit *commit, int dense,

diff.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,6 @@ const char *diff_line_prefix(struct diff_options *);
180180

181181
extern const char mime_boundary_leader[];
182182

183-
extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
184-
extern void diff_tree_release_paths(struct diff_options *);
185183
extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
186184
const char *base, struct diff_options *opt);
187185
extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,

notes-merge.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
170170
sha1_to_hex(mp->remote));
171171
}
172172
diff_flush(&opt);
173-
diff_tree_release_paths(&opt);
173+
free_pathspec(&opt.pathspec);
174174

175175
*num_changes = len;
176176
return changes;
@@ -256,7 +256,7 @@ static void diff_tree_local(struct notes_merge_options *o,
256256
sha1_to_hex(mp->local));
257257
}
258258
diff_flush(&opt);
259-
diff_tree_release_paths(&opt);
259+
free_pathspec(&opt.pathspec);
260260
}
261261

262262
static void check_notes_merge_worktree(struct notes_merge_options *o)

revision.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,12 +2154,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
21542154
revs->limited = 1;
21552155

21562156
if (revs->prune_data.nr) {
2157-
diff_tree_setup_paths(revs->prune_data.raw, &revs->pruning);
2157+
copy_pathspec(&revs->pruning.pathspec, &revs->prune_data);
21582158
/* Can't prune commits with rename following: the paths change.. */
21592159
if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
21602160
revs->prune = 1;
21612161
if (!revs->full_diff)
2162-
diff_tree_setup_paths(revs->prune_data.raw, &revs->diffopt);
2162+
copy_pathspec(&revs->diffopt.pathspec,
2163+
&revs->prune_data);
21632164
}
21642165
if (revs->combine_merges)
21652166
revs->ignore_merges = 0;

tree-diff.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -229,11 +229,11 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
229229
diff_opts.break_opt = opt->break_opt;
230230
diff_opts.rename_score = opt->rename_score;
231231
paths[0] = NULL;
232-
diff_tree_setup_paths(paths, &diff_opts);
232+
init_pathspec(&diff_opts.pathspec, paths);
233233
diff_setup_done(&diff_opts);
234234
diff_tree(t1, t2, base, &diff_opts);
235235
diffcore_std(&diff_opts);
236-
diff_tree_release_paths(&diff_opts);
236+
free_pathspec(&diff_opts.pathspec);
237237

238238
/* Go through the new set of filepairing, and see if we find a more interesting one */
239239
opt->found_follow = 0;
@@ -252,9 +252,9 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
252252
choice = p;
253253

254254
/* Update the path we use from now on.. */
255-
diff_tree_release_paths(opt);
255+
free_pathspec(&opt->pathspec);
256256
opt->pathspec.raw[0] = xstrdup(p->one->path);
257-
diff_tree_setup_paths(opt->pathspec.raw, opt);
257+
init_pathspec(&opt->pathspec, opt->pathspec.raw);
258258

259259
/*
260260
* The caller expects us to return a set of vanilla
@@ -328,13 +328,3 @@ int diff_root_tree_sha1(const unsigned char *new, const char *base, struct diff_
328328
free(tree);
329329
return retval;
330330
}
331-
332-
void diff_tree_release_paths(struct diff_options *opt)
333-
{
334-
free_pathspec(&opt->pathspec);
335-
}
336-
337-
void diff_tree_setup_paths(const char **p, struct diff_options *opt)
338-
{
339-
init_pathspec(&opt->pathspec, p);
340-
}

0 commit comments

Comments
 (0)