diff options
author | Elijah Newren <newren@gmail.com> | 2021-09-27 19:33:42 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-09-27 23:38:37 +0300 |
commit | c42e0b64093306d59372df288f9b4086290623f5 (patch) | |
tree | e6901d355da3ac756b74d7ccfe3e6edd1e1cd902 /unpack-trees.c | |
parent | 04988c8d182da945cd9420274f33487157c5636f (diff) |
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>
Diffstat (limited to 'unpack-trees.c')
-rw-r--r-- | unpack-trees.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/unpack-trees.c b/unpack-trees.c index 0f0d8ab718..9ccb991084 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1692,9 +1692,12 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options static struct cache_entry *dfc; struct pattern_list pl; int free_pattern_list = 0; + struct dir_struct dir = DIR_INIT; if (len > 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(); 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) { - CALLOC_ARRAY(o->dir, 1); + o->dir = &dir; o->dir->flags |= DIR_SHOW_IGNORED; setup_standard_excludes(o->dir); } @@ -1874,7 +1877,7 @@ done: clear_pattern_list(&pl); if (o->dir) { dir_clear(o->dir); - FREE_AND_NULL(o->dir); + o->dir = NULL; } trace2_region_leave("unpack_trees", "unpack_trees", the_repository); trace_performance_leave("unpack_trees"); |