git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 17, 2013, 23:42 UTC
Message-ID
<7vsj0g9udh.fsf@alter.siamese.dyndns.org>
In-Reply-To
<51BF9B35.3010801@lsrfire.ath.cx>
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
Show 10 quoted lines
> 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.
Show 6 quoted lines
> @@ -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.
Show 8 quoted lines
> +	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.
Previous: René ScharfeNext: René Scharfe
Message 8 of 9 in “unpack-trees: don't shift conflicts left and right”
  1. unpack-trees: don't shift conflicts left and rightRené Scharfe, Jun 15, 2013
  2. Junio C HamanoJun 16, 2013
  3. René ScharfeJun 17, 2013
  4. Junio C HamanoJun 17, 2013
  5. René ScharfeJun 17, 2013
  6. Junio C HamanoJun 17, 2013
  7. René ScharfeJun 17, 2013
  8. Junio C HamanoJun 17, 2013
  9. René ScharfeJun 18, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.