remove diff_tree_{setup,release}_paths
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
Jul 14, 2013 at 15:35 UTC
bd1928df1d1cc6a10a7b275694d3504d9a041fae
7 files changed
+22
-32
builtin/blame.c
+6
-6
@@ -408,7 +408,7 @@ static struct origin *find_origin(struct scoreboard *sb,
408
paths[0] = origin->path;
409
paths[1] = NULL;
410
411
- diff_tree_setup_paths(paths, &diff_opts);
411
+ init_pathspec(&diff_opts.pathspec, paths);
412
diff_setup_done(&diff_opts);
413
414
if (is_null_sha1(origin->commit->object.sha1))
@@ -458,7 +458,7 @@ static struct origin *find_origin(struct scoreboard *sb,
458
}
459
}
460
diff_flush(&diff_opts);
461
- diff_tree_release_paths(&diff_opts);
461
+ free_pathspec(&diff_opts.pathspec);
462
if (porigin) {
463
/*
464
* Create a freestanding copy that is not part of
@@ -494,7 +494,7 @@ static struct origin *find_rename(struct scoreboard *sb,
494
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
495
diff_opts.single_follow = origin->path;
496
paths[0] = NULL;
497
- diff_tree_setup_paths(paths, &diff_opts);
497
+ init_pathspec(&diff_opts.pathspec, paths);
498
diff_setup_done(&diff_opts);
499
500
if (is_null_sha1(origin->commit->object.sha1))
@@ -516,7 +516,7 @@ static struct origin *find_rename(struct scoreboard *sb,
516
}
517
}
518
diff_flush(&diff_opts);
519
- diff_tree_release_paths(&diff_opts);
519
+ free_pathspec(&diff_opts.pathspec);
520
return porigin;
521
}
522
@@ -1079,7 +1079,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
1079
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
1080
1081
paths[0] = NULL;
1082
- diff_tree_setup_paths(paths, &diff_opts);
1082
+ init_pathspec(&diff_opts.pathspec, paths);
1083
diff_setup_done(&diff_opts);
1084
1085
/* Try "find copies harder" on new path if requested;
@@ -1162,7 +1162,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
1162
}
1163
reset_scanned_flag(sb);
1164
diff_flush(&diff_opts);
1165
- diff_tree_release_paths(&diff_opts);
1165
+ free_pathspec(&diff_opts.pathspec);
1166
return retval;
1167
}
1168
builtin/reset.c
+5
-4
@@ -133,12 +133,13 @@ static void update_index_from_diff(struct diff_queue_struct *q,
133
}
134
}
135
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)
138
{
139
struct diff_options opt;
140
141
memset(&opt, 0, sizeof(opt));
141
- diff_tree_setup_paths(pathspec, &opt);
142
+ copy_pathspec(&opt.pathspec, pathspec);
143
opt.output_format = DIFF_FORMAT_CALLBACK;
144
opt.format_callback = update_index_from_diff;
145
@@ -147,7 +148,7 @@ static int read_from_tree(const char **pathspec, unsigned char *tree_sha1)
148
return 1;
149
diffcore_std(&opt);
150
diff_flush(&opt);
150
- diff_tree_release_paths(&opt);
151
+ free_pathspec(&opt.pathspec);
152
153
return 0;
154
}
@@ -332,7 +333,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
333
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
334
int newfd = hold_locked_index(lock, 1);
335
if (reset_type == MIXED) {
335
- if (read_from_tree(pathspec.raw, sha1))
336
+ if (read_from_tree(&pathspec, sha1))
337
return 1;
338
} else {
339
int err = reset_index(sha1, reset_type, quiet);
combine-diff.c
+2
-2
@@ -1305,7 +1305,7 @@ void diff_tree_combined(const unsigned char *sha1,
1305
int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
1306
1307
diffopts = *opt;
1308
- diff_tree_setup_paths(diffopts.pathspec.raw, &diffopts);
1308
+ copy_pathspec(&diffopts.pathspec, &opt->pathspec);
1309
diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
1310
DIFF_OPT_SET(&diffopts, RECURSIVE);
1311
DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
@@ -1377,7 +1377,7 @@ void diff_tree_combined(const unsigned char *sha1,
1377
free(tmp);
1378
}
1379
1380
- diff_tree_release_paths(&diffopts);
1380
+ free_pathspec(&diffopts.pathspec);
1381
}
1382
1383
void diff_tree_combined_merge(const struct commit *commit, int dense,
diff.h
-2
@@ -180,8 +180,6 @@ const char *diff_line_prefix(struct diff_options *);
180
181
extern const char mime_boundary_leader[];
182
183
-extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
184
-extern void diff_tree_release_paths(struct diff_options *);
183
extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
184
const char *base, struct diff_options *opt);
185
extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
notes-merge.c
+2
-2
@@ -170,7 +170,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
170
sha1_to_hex(mp->remote));
171
}
172
diff_flush(&opt);
173
- diff_tree_release_paths(&opt);
173
+ free_pathspec(&opt.pathspec);
174
175
*num_changes = len;
176
return changes;
@@ -256,7 +256,7 @@ static void diff_tree_local(struct notes_merge_options *o,
256
sha1_to_hex(mp->local));
257
}
258
diff_flush(&opt);
259
- diff_tree_release_paths(&opt);
259
+ free_pathspec(&opt.pathspec);
260
}
261
262
static void check_notes_merge_worktree(struct notes_merge_options *o)
revision.c
+3
-2
@@ -2154,12 +2154,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
2154
revs->limited = 1;
2155
2156
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);
2158
/* Can't prune commits with rename following: the paths change.. */
2159
if (!DIFF_OPT_TST(&revs->diffopt, FOLLOW_RENAMES))
2160
revs->prune = 1;
2161
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);
2164
}
2165
if (revs->combine_merges)
2166
revs->ignore_merges = 0;
tree-diff.c
+4
-14
@@ -229,11 +229,11 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
229
diff_opts.break_opt = opt->break_opt;
230
diff_opts.rename_score = opt->rename_score;
231
paths[0] = NULL;
232
- diff_tree_setup_paths(paths, &diff_opts);
232
+ init_pathspec(&diff_opts.pathspec, paths);
233
diff_setup_done(&diff_opts);
234
diff_tree(t1, t2, base, &diff_opts);
235
diffcore_std(&diff_opts);
236
- diff_tree_release_paths(&diff_opts);
236
+ free_pathspec(&diff_opts.pathspec);
237
238
/* Go through the new set of filepairing, and see if we find a more interesting one */
239
opt->found_follow = 0;
@@ -252,9 +252,9 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
252
choice = p;
253
254
/* Update the path we use from now on.. */
255
- diff_tree_release_paths(opt);
255
+ free_pathspec(&opt->pathspec);
256
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);
258
259
/*
260
* 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_
328
free(tree);
329
return retval;
330
}
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
-}