git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / 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: Sat, 15 Jun 2013 17:56:13 -0700	[thread overview]
Message-ID: <7va9mqlvpu.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <1371339883-22775-1-git-send-email-rene.scharfe@lsrfire.ath.cx> ("René Scharfe"'s message of "Sun, 16 Jun 2013 01:44:43 +0200")

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

> If o->merge is set, the struct traverse_info member conflicts is shifted
> left in unpack_callback, then passed through traverse_trees_recursive
> to unpack_nondirectories, where it is shifted right before use.  

> @@ -807,13 +802,6 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
>  
>  	/* Now handle any directories.. */
>  	if (dirmask) {
> -		unsigned long conflicts = mask & ~dirmask;
> -		if (o->merge) {
> -			conflicts <<= 1;
> -			if (src[0])
> -				conflicts |= 1;
> -		}
> -
>  		/* special case: "diff-index --cached" looking at a tree */
>  		if (o->diff_index_cached &&
>  		    n == 1 && dirmask == 1 && S_ISDIR(names->mode)) {
> @@ -832,7 +820,7 @@ static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, str
>  			}
>  		}
>  
> -		if (traverse_trees_recursive(n, dirmask, conflicts,
> +		if (traverse_trees_recursive(n, dirmask, mask & ~dirmask,
>  					     names, info) < 0)
>  			return -1;
>  		return mask;

This loses the bottom bit (i.e. are we merging and do have an index
entry?) passed to traverse_trees_recursive(), but when that bitmask
comes back to our callback, we immediately discard the bottom bit by
shifting before using it in unpack_nondirectories(), so this seems a
valid clean-up.

One thing renaming df_conficts to conflicts really proves is that
this field is not used by the traverse_trees machinery at all.

Before this patch, the bits in conflicts (now df_conflicts) mask had
the semantics that is not consistent with the dirmask/mask the
tree-walk machinery uses to communicate with its callers and
callbacks.  Everything in tree-walk.[ch] is about "walk N trees",
and bit 0 of dirmask and mask always means the first tree, not
"first tree, or in index if the callback is doing a merge", which
is used in the conflicts field before this patch.

I think the true source of the confusion is that the "conflicts"
field does not logically belong there.  It is not needed in the
general "walk N trees" machinery.

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?

  reply	other threads:[~2013-06-16  0:56 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 [this message]
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
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=7va9mqlvpu.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.
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).