unpack-trees: make dir an internal-only struct
Avoid accidental misuse or confusion over ownership by clearly making unpack_trees_options.dir an internal-only variable. Signed-off-by: Elijah Newren <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
04988c8d18
commit
c42e0b6409
|
@ -1692,9 +1692,12 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
||||||
static struct cache_entry *dfc;
|
static struct cache_entry *dfc;
|
||||||
struct pattern_list pl;
|
struct pattern_list pl;
|
||||||
int free_pattern_list = 0;
|
int free_pattern_list = 0;
|
||||||
|
struct dir_struct dir = DIR_INIT;
|
||||||
|
|
||||||
if (len > MAX_UNPACK_TREES)
|
if (len > MAX_UNPACK_TREES)
|
||||||
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
|
die("unpack_trees takes at most %d trees", MAX_UNPACK_TREES);
|
||||||
|
if (o->dir)
|
||||||
|
BUG("o->dir is for internal use only");
|
||||||
|
|
||||||
trace_performance_enter();
|
trace_performance_enter();
|
||||||
trace2_region_enter("unpack_trees", "unpack_trees", the_repository);
|
trace2_region_enter("unpack_trees", "unpack_trees", the_repository);
|
||||||
|
@ -1706,7 +1709,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!o->preserve_ignored) {
|
if (!o->preserve_ignored) {
|
||||||
CALLOC_ARRAY(o->dir, 1);
|
o->dir = &dir;
|
||||||
o->dir->flags |= DIR_SHOW_IGNORED;
|
o->dir->flags |= DIR_SHOW_IGNORED;
|
||||||
setup_standard_excludes(o->dir);
|
setup_standard_excludes(o->dir);
|
||||||
}
|
}
|
||||||
|
@ -1874,7 +1877,7 @@ done:
|
||||||
clear_pattern_list(&pl);
|
clear_pattern_list(&pl);
|
||||||
if (o->dir) {
|
if (o->dir) {
|
||||||
dir_clear(o->dir);
|
dir_clear(o->dir);
|
||||||
FREE_AND_NULL(o->dir);
|
o->dir = NULL;
|
||||||
}
|
}
|
||||||
trace2_region_leave("unpack_trees", "unpack_trees", the_repository);
|
trace2_region_leave("unpack_trees", "unpack_trees", the_repository);
|
||||||
trace_performance_leave("unpack_trees");
|
trace_performance_leave("unpack_trees");
|
||||||
|
|
|
@ -67,7 +67,6 @@ struct unpack_trees_options {
|
||||||
dry_run;
|
dry_run;
|
||||||
const char *prefix;
|
const char *prefix;
|
||||||
int cache_bottom;
|
int cache_bottom;
|
||||||
struct dir_struct *dir;
|
|
||||||
struct pathspec *pathspec;
|
struct pathspec *pathspec;
|
||||||
merge_fn_t fn;
|
merge_fn_t fn;
|
||||||
const char *msgs[NB_UNPACK_TREES_WARNING_TYPES];
|
const char *msgs[NB_UNPACK_TREES_WARNING_TYPES];
|
||||||
|
@ -89,6 +88,7 @@ struct unpack_trees_options {
|
||||||
struct index_state result;
|
struct index_state result;
|
||||||
|
|
||||||
struct pattern_list *pl; /* for internal use */
|
struct pattern_list *pl; /* for internal use */
|
||||||
|
struct dir_struct *dir; /* for internal use only */
|
||||||
struct checkout_metadata meta;
|
struct checkout_metadata meta;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue