git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "René Scharfe" <rene.scharfe@lsrfire.ath.cx>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] unpack-trees: don't shift conflicts left and right
Date: Mon, 17 Jun 2013 16:29:05 -0700	[thread overview]
Message-ID: <7vy5a89v0e.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <51BF8DC7.4020008@lsrfire.ath.cx> ("René Scharfe"'s message of "Tue, 18 Jun 2013 00:29:27 +0200")

René Scharfe <rene.scharfe@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;

  reply	other threads:[~2013-06-17 23:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-15 23:44 [PATCH] unpack-trees: don't shift conflicts left and right René Scharfe
2013-06-16  0:56 ` Junio C Hamano
2013-06-17 20:30   ` René Scharfe
2013-06-17 20:44     ` Junio C Hamano
2013-06-17 22:29       ` René Scharfe
2013-06-17 23:29         ` Junio C Hamano [this message]
2013-06-17 23:26       ` René Scharfe
2013-06-17 23:42         ` Junio C Hamano
2013-06-18 19:33           ` René Scharfe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7vy5a89v0e.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=rene.scharfe@lsrfire.ath.cx \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).