Thread (2 messages) flat view 2 messages, 2 authors, 2016-06-15

Re: [PATCH] unpack-trees: don't shift conflicts left and right

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:57:47

René Scharfe [off-list ref] 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.
Hmph.
quoted hunk
@@ -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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help