From: Junio C Hamano <junkio@cox.net>
To: Jon Loeliger <jdl@freescale.com>
Cc: git@vger.kernel.org
Subject: Re: Expected Behavior?
Date: Mon, 07 Nov 2005 22:00:11 -0800 [thread overview]
Message-ID: <7vwtjjllw4.fsf@assigned-by-dhcp.cox.net> (raw)
In-Reply-To: E1EZKOB-0002j5-VY@jdl.com
Jon Loeliger <jdl@freescale.com> writes:
> That is, after the merge, file3 appears to have simply kept
> the contents of the current, master branch. Why wasn't the
> dev branch represented here?
>
> I _almost_ think I get it, and then *poof*...
Automerge completely punted for this path, and at this point, it
is still unmerged:
------------
$ git ls-files --unmerged
100644 c4da0eb.... 2 file3
100644 fbc2aa4.... 3 file3
------------
Three-way "git-read-tree -m -u O A B" (O is for old, A is ours
and B is hers) puts O in stage1, A in stage2 and B in stage3.
This path did not exist in O so we only have them in stage2 and
stage3. You could compare the stages like this:
------------
$ git diff-stages -p 2 3 file3
diff --git a/file3 b/file3
index c4da0eb..fbc2aa4 100644
--- a/file3
+++ b/file3
@@ -1 +1 @@
-Stuff for a conflict.
+Another file!
------------
When we do a file-level merge (and possibly leave conflicts), we
register _our_ version in the index and leave the merge result
in the working tree. However, when O is empty like this case,
we leave the conflicting path simply unmerged and do not touch
the working tree. We say "ERROR: not handling case" when this
happens.
Nobody complained so far about this, probably because two side
adding different versions is rare enough. And the reasoning
behind the current behaviour is probably because the tool cannot
automerge them sensibly anyway. Leaving the SHA1 in index file
might probably be easier to clean up by hand (e.g. see ls-files
--unmerged, and cut&paste the desired SHA1 to 'git-cat-file
blob' command line, or something silly like that). But if we
were to go that route, adding --stage=[123] flag so that the
user can say 'git-checkout-index --stage=3 file3'might have
helped a bit more.
We could instead use the attached patch to get the behaviour you
are expecting. I have a feeling that the result from this might
be a little more intuitive and easier to resolve by hand than
the current one. Although we may end up unresolvable mess in
file3 if either side is binary, in that case the user can still
sift through 'diff-tree A B file3' output to find out the
relevant SHA1 to recover the blobs from both sides by hand
anyway. Does anybody have strong opinion on this?
--
[PATCH] merge with /dev/null as base, instead of not handling O=='' case
Instead of leaving the path unmerged in a case where each side
adds different version of the same path, attempt to merge it
with empty base and leave "our" version in the index file, just
like we do for the case in conflicting merge.
Signed-off-by: Junio C Hamano <junkio@cox.net>
---
diff --git a/git-merge-one-file.sh b/git-merge-one-file.sh
index 5419e59..32e17cb 100755
--- a/git-merge-one-file.sh
+++ b/git-merge-one-file.sh
@@ -56,9 +56,18 @@ case "${1:-.}${2:-.}${3:-.}" in
#
# Modified in both, but differently.
#
-"$1$2$3")
- echo "Auto-merging $4."
- orig=`git-unpack-file $1`
+"$1$2$3" | ".$2$3")
+ case "$1" in
+ '')
+ echo "Added $4 in both, but differently."
+ orig=`git-unpack-file $2`
+ : >$orig
+ ;;
+ *)
+ echo "Auto-merging $4."
+ orig=`git-unpack-file $1`
+ ;;
+ esac
src2=`git-unpack-file $3`
# We reset the index to the first branch, making
@@ -73,6 +82,9 @@ case "${1:-.}${2:-.}${3:-.}" in
echo "ERROR: Permissions conflict: $5->$6,$7."
ret=1
fi
+ if [ "$1" = '' ]; then
+ ret=1
+ fi
if [ $ret -ne 0 ]; then
echo "ERROR: Merge conflict in $4."
next prev parent reply other threads:[~2005-11-08 6:00 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-11-08 3:43 Expected Behavior? Jon Loeliger
2005-11-08 6:00 ` Junio C Hamano [this message]
2005-11-08 9:56 ` Petr Baudis
2005-11-10 4:41 ` merge-one-file: use common as base, instead of emptiness Junio C Hamano
2005-11-10 19:43 ` Petr Baudis
2005-11-10 20:30 ` Junio C Hamano
2005-11-10 20:35 ` Petr Baudis
2005-11-08 21:03 ` Expected Behavior? Fredrik Kuivinen
2005-11-08 21:41 ` Junio C Hamano
2005-11-08 22:53 ` Fredrik Kuivinen
2005-11-09 5:50 ` Junio C Hamano
2005-11-09 8:19 ` Fredrik Kuivinen
2005-11-09 10:42 ` [PATCH] merge-recursive: Fix support for branch names containing slashes Fredrik Kuivinen
2005-11-10 20:34 ` Expected Behavior? Petr Baudis
2005-11-10 22:52 ` Junio C Hamano
2005-11-10 23:22 ` Petr Baudis
2005-11-09 11:24 ` Petr Baudis
2005-11-09 23:04 ` Martin Langhoff
2005-11-09 23:12 ` Petr Baudis
2005-11-09 23:43 ` Martin Langhoff
2005-11-09 23:49 ` Petr Baudis
2005-11-10 2:47 ` Martin Langhoff
2005-11-10 19:34 ` Petr Baudis
2005-11-10 19:54 ` Martin Langhoff
2005-11-10 20:10 ` Petr Baudis
2005-11-09 23:36 ` Junio C Hamano
2005-11-09 23:42 ` Petr Baudis
2005-11-10 0:03 ` Junio C Hamano
-- strict thread matches above, loose matches on Subject: below --
2005-11-09 13:38 Jon Loeliger
2005-11-09 20:38 ` Junio C Hamano
2005-11-09 2:58 Jon Loeliger
2005-11-09 6:28 ` Junio C Hamano
2005-11-08 3:07 Jon Loeliger
2005-11-06 22:16 Jon Loeliger
2005-11-07 1:38 ` Junio C Hamano
2005-11-07 2:01 ` 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=7vwtjjllw4.fsf@assigned-by-dhcp.cox.net \
--to=junkio@cox.net \
--cc=git@vger.kernel.org \
--cc=jdl@freescale.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.
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).