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

Am 17.06.2013 22:44, schrieb Junio C Hamano:
> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:
> 
>>> The information is only useful for the unpack_trees callback, and
>>> "info->data" is a more appropriate place to hang such a callback
>>> specific data.
>>>
>>> Perhaps we should use info->data field to point at
>>>
>>> 	struct {
>>>           	struct unpack_trees_options *o;
>>>           	unsigned long df_conflict;
>>> 	};
>>>
>>> and get rid of info->conflicts field?
>>
>> Here's a patch that does so, but it complicates matters quite a bit.
>> Did I miss anything (or rather: add too much)?
> 
> I do not think so.  These bits are needed per recursion level, and
> it cannot be shoved into unpack_trees_options so I suspect that your
> patch is the best we can do.  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".  It would
look something like this:


 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 22: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 [this message]
2013-06-17 23:29         ` Junio C Hamano
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

  List information: http://vger.kernel.org/majordomo-info.html

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

  git send-email \
    --in-reply-to=51BF8DC7.4020008@lsrfire.ath.cx \
    --to=rene.scharfe@lsrfire.ath.cx \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).