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:29 UTC
Message-ID
<7vy5a89v0e.fsf@alter.siamese.dyndns.org>
In-Reply-To
<51BF8DC7.4020008@lsrfire.ath.cx>
René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
Show 15 quoted lines
> Am 17.06.2013 22:44, schrieb Junio C Hamano:
>> 
>> ...  Or, perhaps we can
>> 
>>   - add df_conflict to struct unpack_trees_options;
>> 
>>   - have traverse_info->data point at struct unpack_trees_options as
>>     before; and
>> 
>>   - save the old value of o->df_conflict on the stack of
>>     traverse_trees_recursive(), update the field in place, and
>>     restore it when the recursion returns???
>
> I'm not sure unpack_trees_options is the right place for that, but it
> already has several members that aren't really "options".
Yup, most notably the "df_conflict_entry" singleton sentinel.
> It would look something like this:
Hmm, that does not look too bad, actually.
Show 72 quoted lines
>
>
>  tree-walk.h    | 1 -
>  unpack-trees.c | 9 +++++++--
>  unpack-trees.h | 1 +
>  3 files changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/tree-walk.h b/tree-walk.h
> index ae04b64..4876695 100644
> --- a/tree-walk.h
> +++ b/tree-walk.h
> @@ -46,7 +46,6 @@ struct traverse_info {
>  	int pathlen;
>  	struct pathspec *pathspec;
>  
> -	unsigned long df_conflicts;
>  	traverse_callback_t fn;
>  	void *data;
>  	int show_all_errors;
> diff --git a/unpack-trees.c b/unpack-trees.c
> index b27f2a6..1c0ead0 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -454,6 +454,10 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
>  	void *buf[MAX_UNPACK_TREES];
>  	struct traverse_info newinfo;
>  	struct name_entry *p;
> +	struct unpack_trees_options *o = info->data;
> +	unsigned long saved_df_conflicts = o->df_conflicts;
> +
> +	o->df_conflicts |= df_conflicts;
>  
>  	p = names;
>  	while (!p->mode)
> @@ -464,7 +468,6 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
>  	newinfo.pathspec = info->pathspec;
>  	newinfo.name = *p;
>  	newinfo.pathlen += tree_entry_len(p) + 1;
> -	newinfo.df_conflicts |= df_conflicts;
>  
>  	for (i = 0; i < n; i++, dirmask >>= 1) {
>  		const unsigned char *sha1 = NULL;
> @@ -480,6 +483,8 @@ static int traverse_trees_recursive(int n, unsigned long dirmask,
>  	for (i = 0; i < n; i++)
>  		free(buf[i]);
>  
> +	o->df_conflicts = saved_df_conflicts;
> +
>  	return ret;
>  }
>  
> @@ -565,7 +570,7 @@ 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 = o->df_conflicts | dirmask;
>  
>  	/* Do we have *only* directories? Nothing to do */
>  	if (mask == dirmask && !src[0])
> diff --git a/unpack-trees.h b/unpack-trees.h
> index 36a73a6..05ee968 100644
> --- a/unpack-trees.h
> +++ b/unpack-trees.h
> @@ -66,6 +66,7 @@ struct unpack_trees_options {
>  
>  	struct cache_entry *df_conflict_entry;
>  	void *unpack_data;
> +	unsigned long df_conflicts;
>  
>  	struct index_state *dst_index;
>  	struct index_state *src_index;
Previous: René ScharfeNext: René Scharfe
Message 6 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.