René Scharfe <> writes:

> How about going into the opposite direction and moving df_conflicts
> handling more into traverse_tree?  If the function saved the mask
> and dirmask in traverse_info then callbacks could calculate the
> cumulated d/f conflicts by walking the info chain, similar to how
> make_traverse_path works.  That would match the spirit of that
> struct.  Below is a patch for that, for illustration.
> We could then remove the mask and dirmask parameters from
> traverse_callback_t functions, as the callbacks can then get them
> through traverse_info.


> @@ -565,12 +563,16 @@ static int unpack_nondirectories(int n, unsigned long 
> mask,
>  {
>       int i;
>       struct unpack_trees_options *o = info->data;
> -     unsigned long conflicts = info->df_conflicts | dirmask;
> +     unsigned long conflicts = dirmask;

We grab the dirmask for the current level.

> +     const struct traverse_info *previnfo;
>       /* Do we have *only* directories? Nothing to do */
>       if (mask == dirmask && !src[0])
>               return 0;
> +     for (previnfo = info->prev; previnfo; previnfo = previnfo->prev)
> +             conflicts |= previnfo->mask & ~previnfo->dirmask;

And OR-in the bits for non-directories in levels that are closer to
the root (i.e. if a path that corresponds to our parent directory is
a non-directory in one of the trees, our path cannot be a file in
that tree).

So the bit-math looks correct here.  conflicts ends up having bits
set for trees that cannot have a non-directory at the path we are
looking at.

But the need to go all the way up in the recursive callframes to get
the union of bitmask to get conflicts looks somewhat ugly.

I dunno.
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to
More majordomo info at

Reply via email to