Re: [PATCH v3 07/12] unpack-trees: stop recursing into sparse directories
- From
Elijah Newren <newren@gmail.com>
- Date
- May 18, 2021, 02:06 UTC
- Message-ID
- <CABPp-BEdWMnzUay9R_GnbiWzuddrFMu87DLmCz4_s8HaBsrYQQ@mail.gmail.com>
- In-Reply-To
- <CABPp-BGc_Cduk3aFJqk4MjJ2k6KMDWSnwZfJM+E-1oK8txsf7Q@mail.gmail.com>
Sorry, I spoke too soon...
On Mon, May 17, 2021 at 7:03 PM Elijah Newren <newren@gmail.com> wrote:
Show 10 quoted lines
>
> > diff --git a/unpack-trees.c b/unpack-trees.c
> > index ef6a2b1c951c..703b0bdc9dfd 100644
> > --- a/unpack-trees.c
> > +++ b/unpack-trees.c
> > @@ -1261,6 +1261,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
> > struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
> > struct unpack_trees_options *o = info->data;
> > const struct name_entry *p = names;
> > + unsigned unpack_tree = 1;Here, you set unpack_tree to 1.
Show 9 quoted lines
> > > > /* Find first entry with a real name (we could use "mask" too) */ > > while (!p->mode) > > @@ -1307,7 +1308,8 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str > > } > > } > > > > - if (unpack_nondirectories(n, mask, dirmask, src, names, info) < 0) > > + if (unpack_tree &&
You check it's value here...
Show 10 quoted lines
> > + unpack_nondirectories(n, mask, dirmask, src, names, info) < 0)
> > return -1;
> >
> > if (o->merge && src[0]) {
> > @@ -1337,7 +1339,8 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
> > }
> > }
> >
> > - if (traverse_trees_recursive(n, dirmask, mask & ~dirmask,
> > + if (unpack_tree &&...and here....
> > + traverse_trees_recursive(n, dirmask, mask & ~dirmask, > > names, info) < 0) > > return -1; > > return mask;
but you never set unpack_tree to 0, so this is wasted effort and you always recurse. The previous iteration had a case where it'd set unpack_tree to 0 in a certain case, but you deleted that code in this version. Why?