]> git.ipfire.org Git - thirdparty/git.git/commit - unpack-trees.c
unpack-trees: simplify pattern_list freeing
authorElijah Newren <newren@gmail.com>
Fri, 27 Mar 2020 00:48:47 +0000 (00:48 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 27 Mar 2020 18:33:29 +0000 (11:33 -0700)
commitfa0bde45cdebee8bac95e66e4bf5ba16c77fbdba
treefb8a740cf962f7dbc24bfef01300753d467ee5ba
parentd61633ae186d26ab2c216108c917ec0ae7dd2782
unpack-trees: simplify pattern_list freeing

commit e091228e17 ("sparse-checkout: update working directory
in-process", 2019-11-21) allowed passing a pre-defined set of patterns
to unpack_trees().  However, if o->pl was NULL, it would still read the
existing patterns and use those.  If those patterns were read into a
data structure that was allocated, naturally they needed to be free'd.
However, despite the same function being responsible for knowing about
both the allocation and the free'ing, the logic for tracking whether to
free the pattern_list was hoisted to an outer function with an
additional flag in unpack_trees_options.  Put the logic back in the
relevant function and discard the now unnecessary flag.

Reviewed-by: Derrick Stolee <dstolee@microsoft.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/sparse-checkout.c
unpack-trees.c
unpack-trees.h