René Scharfe <rene.scha...@lsrfire.ath.cx> writes:

> 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.

>
>
>  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;
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to