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>maint
parent
827f4d6c21
commit
bd1928df1d
|
@ -408,7 +408,7 @@ static struct origin *find_origin(struct scoreboard *sb,
|
||||||
paths[0] = origin->path;
|
paths[0] = origin->path;
|
||||||
paths[1] = NULL;
|
paths[1] = NULL;
|
||||||
|
|
||||||
diff_tree_setup_paths(paths, &diff_opts);
|
init_pathspec(&diff_opts.pathspec, paths);
|
||||||
diff_setup_done(&diff_opts);
|
diff_setup_done(&diff_opts);
|
||||||
|
|
||||||
if (is_null_sha1(origin->commit->object.sha1))
|
if (is_null_sha1(origin->commit->object.sha1))
|
||||||
|
@ -458,7 +458,7 @@ static struct origin *find_origin(struct scoreboard *sb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff_flush(&diff_opts);
|
diff_flush(&diff_opts);
|
||||||
diff_tree_release_paths(&diff_opts);
|
free_pathspec(&diff_opts.pathspec);
|
||||||
if (porigin) {
|
if (porigin) {
|
||||||
/*
|
/*
|
||||||
* Create a freestanding copy that is not part of
|
* Create a freestanding copy that is not part of
|
||||||
|
@ -494,7 +494,7 @@ static struct origin *find_rename(struct scoreboard *sb,
|
||||||
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
||||||
diff_opts.single_follow = origin->path;
|
diff_opts.single_follow = origin->path;
|
||||||
paths[0] = NULL;
|
paths[0] = NULL;
|
||||||
diff_tree_setup_paths(paths, &diff_opts);
|
init_pathspec(&diff_opts.pathspec, paths);
|
||||||
diff_setup_done(&diff_opts);
|
diff_setup_done(&diff_opts);
|
||||||
|
|
||||||
if (is_null_sha1(origin->commit->object.sha1))
|
if (is_null_sha1(origin->commit->object.sha1))
|
||||||
|
@ -516,7 +516,7 @@ static struct origin *find_rename(struct scoreboard *sb,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
diff_flush(&diff_opts);
|
diff_flush(&diff_opts);
|
||||||
diff_tree_release_paths(&diff_opts);
|
free_pathspec(&diff_opts.pathspec);
|
||||||
return porigin;
|
return porigin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1079,7 +1079,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
|
||||||
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
||||||
|
|
||||||
paths[0] = NULL;
|
paths[0] = NULL;
|
||||||
diff_tree_setup_paths(paths, &diff_opts);
|
init_pathspec(&diff_opts.pathspec, paths);
|
||||||
diff_setup_done(&diff_opts);
|
diff_setup_done(&diff_opts);
|
||||||
|
|
||||||
/* Try "find copies harder" on new path if requested;
|
/* Try "find copies harder" on new path if requested;
|
||||||
|
@ -1162,7 +1162,7 @@ static int find_copy_in_parent(struct scoreboard *sb,
|
||||||
}
|
}
|
||||||
reset_scanned_flag(sb);
|
reset_scanned_flag(sb);
|
||||||
diff_flush(&diff_opts);
|
diff_flush(&diff_opts);
|
||||||
diff_tree_release_paths(&diff_opts);
|
free_pathspec(&diff_opts.pathspec);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,12 +133,13 @@ static void update_index_from_diff(struct diff_queue_struct *q,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_from_tree(const char **pathspec, unsigned char *tree_sha1)
|
static int read_from_tree(const struct pathspec *pathspec,
|
||||||
|
unsigned char *tree_sha1)
|
||||||
{
|
{
|
||||||
struct diff_options opt;
|
struct diff_options opt;
|
||||||
|
|
||||||
memset(&opt, 0, sizeof(opt));
|
memset(&opt, 0, sizeof(opt));
|
||||||
diff_tree_setup_paths(pathspec, &opt);
|
copy_pathspec(&opt.pathspec, pathspec);
|
||||||
opt.output_format = DIFF_FORMAT_CALLBACK;
|
opt.output_format = DIFF_FORMAT_CALLBACK;
|
||||||
opt.format_callback = update_index_from_diff;
|
opt.format_callback = update_index_from_diff;
|
||||||
|
|
||||||
|
@ -147,7 +148,7 @@ static int read_from_tree(const char **pathspec, unsigned char *tree_sha1)
|
||||||
return 1;
|
return 1;
|
||||||
diffcore_std(&opt);
|
diffcore_std(&opt);
|
||||||
diff_flush(&opt);
|
diff_flush(&opt);
|
||||||
diff_tree_release_paths(&opt);
|
free_pathspec(&opt.pathspec);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +333,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
||||||
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
|
struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
|
||||||
int newfd = hold_locked_index(lock, 1);
|
int newfd = hold_locked_index(lock, 1);
|
||||||
if (reset_type == MIXED) {
|
if (reset_type == MIXED) {
|
||||||
if (read_from_tree(pathspec.raw, sha1))
|
if (read_from_tree(&pathspec, sha1))
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
int err = reset_index(sha1, reset_type, quiet);
|
int err = reset_index(sha1, reset_type, quiet);
|
||||||
|
|
|
@ -1305,7 +1305,7 @@ void diff_tree_combined(const unsigned char *sha1,
|
||||||
int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
|
int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
|
||||||
|
|
||||||
diffopts = *opt;
|
diffopts = *opt;
|
||||||
diff_tree_setup_paths(diffopts.pathspec.raw, &diffopts);
|
copy_pathspec(&diffopts.pathspec, &opt->pathspec);
|
||||||
diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
|
||||||
DIFF_OPT_SET(&diffopts, RECURSIVE);
|
DIFF_OPT_SET(&diffopts, RECURSIVE);
|
||||||
DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
|
DIFF_OPT_CLR(&diffopts, ALLOW_EXTERNAL);
|
||||||
|
@ -1377,7 +1377,7 @@ void diff_tree_combined(const unsigned char *sha1,
|
||||||
free(tmp);
|
free(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
diff_tree_release_paths(&diffopts);
|
free_pathspec(&diffopts.pathspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
void diff_tree_combined_merge(const struct commit *commit, int dense,
|
void diff_tree_combined_merge(const struct commit *commit, int dense,
|
||||||
|
|
2
diff.h
2
diff.h
|
@ -180,8 +180,6 @@ const char *diff_line_prefix(struct diff_options *);
|
||||||
|
|
||||||
extern const char mime_boundary_leader[];
|
extern const char mime_boundary_leader[];
|
||||||
|
|
||||||
extern void diff_tree_setup_paths(const char **paths, struct diff_options *);
|
|
||||||
extern void diff_tree_release_paths(struct diff_options *);
|
|
||||||
extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
|
extern int diff_tree(struct tree_desc *t1, struct tree_desc *t2,
|
||||||
const char *base, struct diff_options *opt);
|
const char *base, struct diff_options *opt);
|
||||||
extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
|
extern int diff_tree_sha1(const unsigned char *old, const unsigned char *new,
|
||||||
|
|
|
@ -170,7 +170,7 @@ static struct notes_merge_pair *diff_tree_remote(struct notes_merge_options *o,
|
||||||
sha1_to_hex(mp->remote));
|
sha1_to_hex(mp->remote));
|
||||||
}
|
}
|
||||||
diff_flush(&opt);
|
diff_flush(&opt);
|
||||||
diff_tree_release_paths(&opt);
|
free_pathspec(&opt.pathspec);
|
||||||
|
|
||||||
*num_changes = len;
|
*num_changes = len;
|
||||||
return changes;
|
return changes;
|
||||||
|
@ -256,7 +256,7 @@ static void diff_tree_local(struct notes_merge_options *o,
|
||||||
sha1_to_hex(mp->local));
|
sha1_to_hex(mp->local));
|
||||||
}
|
}
|
||||||
diff_flush(&opt);
|
diff_flush(&opt);
|
||||||
diff_tree_release_paths(&opt);
|
free_pathspec(&opt.pathspec);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_notes_merge_worktree(struct notes_merge_options *o)
|
static void check_notes_merge_worktree(struct notes_merge_options *o)
|
||||||
|
|
|
@ -2154,12 +2154,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
|
||||||
revs->limited = 1;
|
revs->limited = 1;
|
||||||
|
|
||||||
if (revs->prune_data.nr) {
|
if (revs->prune_data.nr) {
|
||||||
diff_tree_setup_paths(revs->prune_data.raw, &revs->pruning);
|
copy_pathspec(&revs->pruning.pathspec, &revs->prune_data);
|
||||||
/* 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.raw, &revs->diffopt);
|
copy_pathspec(&revs->diffopt.pathspec,
|
||||||
|
&revs->prune_data);
|
||||||
}
|
}
|
||||||
if (revs->combine_merges)
|
if (revs->combine_merges)
|
||||||
revs->ignore_merges = 0;
|
revs->ignore_merges = 0;
|
||||||
|
|
18
tree-diff.c
18
tree-diff.c
|
@ -229,11 +229,11 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
|
||||||
diff_opts.break_opt = opt->break_opt;
|
diff_opts.break_opt = opt->break_opt;
|
||||||
diff_opts.rename_score = opt->rename_score;
|
diff_opts.rename_score = opt->rename_score;
|
||||||
paths[0] = NULL;
|
paths[0] = NULL;
|
||||||
diff_tree_setup_paths(paths, &diff_opts);
|
init_pathspec(&diff_opts.pathspec, paths);
|
||||||
diff_setup_done(&diff_opts);
|
diff_setup_done(&diff_opts);
|
||||||
diff_tree(t1, t2, base, &diff_opts);
|
diff_tree(t1, t2, base, &diff_opts);
|
||||||
diffcore_std(&diff_opts);
|
diffcore_std(&diff_opts);
|
||||||
diff_tree_release_paths(&diff_opts);
|
free_pathspec(&diff_opts.pathspec);
|
||||||
|
|
||||||
/* Go through the new set of filepairing, and see if we find a more interesting one */
|
/* Go through the new set of filepairing, and see if we find a more interesting one */
|
||||||
opt->found_follow = 0;
|
opt->found_follow = 0;
|
||||||
|
@ -252,9 +252,9 @@ static void try_to_follow_renames(struct tree_desc *t1, struct tree_desc *t2, co
|
||||||
choice = p;
|
choice = p;
|
||||||
|
|
||||||
/* Update the path we use from now on.. */
|
/* Update the path we use from now on.. */
|
||||||
diff_tree_release_paths(opt);
|
free_pathspec(&opt->pathspec);
|
||||||
opt->pathspec.raw[0] = xstrdup(p->one->path);
|
opt->pathspec.raw[0] = xstrdup(p->one->path);
|
||||||
diff_tree_setup_paths(opt->pathspec.raw, opt);
|
init_pathspec(&opt->pathspec, opt->pathspec.raw);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The caller expects us to return a set of vanilla
|
* 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_
|
||||||
free(tree);
|
free(tree);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void diff_tree_release_paths(struct diff_options *opt)
|
|
||||||
{
|
|
||||||
free_pathspec(&opt->pathspec);
|
|
||||||
}
|
|
||||||
|
|
||||||
void diff_tree_setup_paths(const char **p, struct diff_options *opt)
|
|
||||||
{
|
|
||||||
init_pathspec(&opt->pathspec, p);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue