From: Junio C Hamano <junkio@cox.net>
To: Linus Torvalds <torvalds@osdl.org>
Cc: git@vger.kernel.org
Subject: new read-tree questions.
Date: Mon, 06 Jun 2005 01:43:03 -0700 [thread overview]
Message-ID: <7v64wrvpt4.fsf@assigned-by-dhcp.cox.net> (raw)
I am trying to understand the new git-read-tree, by using
git-resolve-script as an example and also reading read-tree.c; I
am somewhat confused.
* two-way merge (git-read-tree -m $H $M)
My understanding is that the current index is allowed to be
empty, but if it is not, they are kept at stage0, and each of
them must match $H and must be up-to-date if the merge involves
them.
To summarize my understanding of what should happen for each
path:
stage0 (index) stage1 ($H) stage2 ($M)
------------------------------------------------------------
no such path no such path no such path
* this does not happen (the code would not see such thing).
----------------------------------------------------------
no such path no such path exists
* take $M without complaining.
----------------------------------------------------------
no such path exists (does not matter) *0*
* although index does not match $H, we do not reject, so
that a merge can happen on an empty cache. We take $M.
----------------------------------------------------------
exists no such path no such path
* reject, because index does not match $H.
----------------------------------------------------------
exists no such path exists (index!=$M)
* reject, because index does not match $H.
----------------------------------------------------------
exists no such path exists (index=$M) *1*
* take $M (same as "keep stage0").
----------------------------------------------------------
exists exists (index!=$H) (does not matter)
* reject, because index does not match $H.
----------------------------------------------------------
exists exists (index=$H) no such path *2*
* path is removed.
----------------------------------------------------------
exists exists (index=$H) exists
* take stage2.
----------------------------------------------------------
Does the above matrix represent the intended behaviour?
I think I understand why we would want *0*, but this asymmetry
feels wrong.
I am having trouble with the case *1*. This would call
twoway_check with !seen_stage1 and it says OK, because the
merged tree has the same contents as what we started with. Is
it to help the case where" the merged tree changes things the
same way we already have as our local change" case?
Also I am not sure if the code does the right thing for case
*2*. If I am reading the code right, for such a path, we will
see stage0 and stage1, and at that point say seen_stage1 = 1 and
keep stage0 entry in "old". Then we continue on to the next
path. When it happens to be:
- stage0: we barf because we still have our "old".
- stage1: we barf because our "old" does not match the new
path; !path_matches(old,ce) triggers.
- stage2: we barf because our "old" does not match the new
path; twoway_check(old, seen_stage1, ce) triggers.
Only when such a "exists-exists-removed" were the last entry,
the control falls out of the loop and "unmatched with a new
entry?" check takes care of it without barfing. The path is
removed which is what I understand you want to happen in the
case *2*.
Maybe my version of intended behaviour for case *2* is wrong,
but then I do not understand why.
I'll do a similar matrix for three-way merge case later and
probably ask more questions.
next reply other threads:[~2005-06-06 8:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-06 8:43 Junio C Hamano [this message]
2005-06-06 15:04 ` new read-tree questions Linus Torvalds
[not found] ` <7vbr6jtiqi.fsf_-_@assigned-by-dhcp.cox.net>
[not found] ` <Pine.LNX.4.58.0506061210490.1876@ppc970.osdl.org>
2005-06-06 19:59 ` clarifying two tree merge semantics Junio C Hamano
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=7v64wrvpt4.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=torvalds@osdl.org \
/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