git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Problem with merge when renaming
@ 2007-09-18 20:34 David Euresti
  2007-09-18 22:12 ` [PATCH] Extend t6020 with another test for d/f interactions Alex Riesen
  2007-09-18 22:28 ` Problem with merge when renaming Junio C Hamano
  0 siblings, 2 replies; 7+ messages in thread
From: David Euresti @ 2007-09-18 20:34 UTC (permalink / raw)
  To: git

Hi,

I think I found a problem when you move a file into a directory of the
same name.  Here's what I did.

In a repository I created a directory with a file in it.  Commit it.
Then I move the file into a tmp name, make a directory with that name,
and move it into the directory.
git-mv dir/foo dir/foo.bin
mkdir dir/foo
git-mv dir/foo.bin dir/foo/foo.bin

Then in another branch I make a completely unrelated change.  I create
a file in another directory.

If I try to merge in the changes from the other branch or if the other
branch tries to merge in these changes I get this error:

dir/foo/foo.bin: unmerged (257cc5642cb1a054f08cc83f2d943e56fd3ebe99)
fatal: git-write-tree: error building trees
Merge with strategy recursive failed.

This is the script I've been using
#!/bin/bash
#

# Make sure it's all clean
rm -rf git-repo

mkdir git-repo
pushd git-repo
git-init
mkdir dir
git-add dir
pushd dir
echo foo > foo
git-add foo
popd
git-commit -a -m "one"
popd

# Developer A moves file into dir of same name
pushd git-repo
git-checkout -b branch-a
git-mv dir/foo dir/foo.bin
mkdir dir/foo
git-mv dir/foo.bin dir/foo/foo.bin
git-commit -a -m "File renamed"
git-checkout master
popd

# Developer B makes completely unrelated changes.
pushd git-repo
git-checkout -b branch-b
echo baz > foo.txt
echo bar > bar.txt
git-add bar.txt
git-add foo.txt
git-commit -a -m "unrelated changes"
git-checkout master
popd

# Developer A wants to merge changes from B
pushd git-repo
#git-merge branch-a
echo
#git-merge branch-b
#popd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] Extend t6020 with another test for d/f interactions
  2007-09-18 20:34 Problem with merge when renaming David Euresti
@ 2007-09-18 22:12 ` Alex Riesen
  2007-09-18 22:28 ` Problem with merge when renaming Junio C Hamano
  1 sibling, 0 replies; 7+ messages in thread
From: Alex Riesen @ 2007-09-18 22:12 UTC (permalink / raw)
  To: git; +Cc: Johannes Schindelin, Junio C Hamano, David Euresti

A test for a merge when one of the trees has a file moved into a
directory with the same name (not just file replaced by a directory).

The problem noticed and reported by David Euresti

Signed-off-by: Alex Riesen <raa.lkml@gmail.com>

---
 t/t6020-merge-df.sh |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)

David Euresti, Tue, Sep 18, 2007 22:34:53 +0200:
> If I try to merge in the changes from the other branch or if the other
> branch tries to merge in these changes I get this error:
> 
> dir/foo/foo.bin: unmerged (257cc5642cb1a054f08cc83f2d943e56fd3ebe99)
> fatal: git-write-tree: error building trees
> Merge with strategy recursive failed.

I extended the d/f merge test with the case. Have no idea how to fix
it yet though.

diff --git a/t/t6020-merge-df.sh b/t/t6020-merge-df.sh
index a19d49d..c081d3f 100755
--- a/t/t6020-merge-df.sh
+++ b/t/t6020-merge-df.sh
@@ -10,6 +10,7 @@ test_expect_success 'prepare repository' \
 'echo "Hello" > init &&
 git add init &&
 git commit -m "Initial commit" &&
+git branch init &&
 git branch B &&
 mkdir dir &&
 echo "foo" > dir/foo &&
@@ -22,4 +23,20 @@ git commit -m "File: dir"'
 
 test_expect_code 1 'Merge with d/f conflicts' 'git merge "merge msg" B master'
 
+test_expect_success 'file moved into a dir of same name' '
+    git reset --hard &&
+    git checkout -b d1 init &&
+    mkdir dir &&
+    mv init dir/init &&
+    mv dir init &&
+    git add . &&
+    git commit -a -m"init moved into init/init" &&
+    git checkout -b d2 init &&
+    echo file >file &&
+    git add file &&
+    git commit -m"unrelated change" &&
+    git checkout d1 &&
+    git merge d2
+'
+
 test_done
-- 
1.5.3.1.173.g9a67

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: Problem with merge when renaming
  2007-09-18 20:34 Problem with merge when renaming David Euresti
  2007-09-18 22:12 ` [PATCH] Extend t6020 with another test for d/f interactions Alex Riesen
@ 2007-09-18 22:28 ` Junio C Hamano
  2007-09-18 22:42   ` David Euresti
  2007-09-18 22:44   ` Alex Riesen
  1 sibling, 2 replies; 7+ messages in thread
From: Junio C Hamano @ 2007-09-18 22:28 UTC (permalink / raw)
  To: David Euresti; +Cc: git

"David Euresti" <evelio@gmail.com> writes:

> I think I found a problem when you move a file into a directory of the
> same name.  Here's what I did.

Two questions.

 (1) git --version?

 (2) if you do "git merge -s resolve" instead of just "git
     merge", do you see a difference?

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with merge when renaming
  2007-09-18 22:28 ` Problem with merge when renaming Junio C Hamano
@ 2007-09-18 22:42   ` David Euresti
  2007-09-18 22:44   ` Alex Riesen
  1 sibling, 0 replies; 7+ messages in thread
From: David Euresti @ 2007-09-18 22:42 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git

1) git version 1.5.2.5 and 1.5.3.1.139.g9346b

2)
$ git-merge -s resolve branch-a
$ git-merge -s resolve branch-b
Trying really trivial in-index merge...
fatal: Merge requires file-level merging
Nope.
Trying simple merge.
Simple merge failed, trying Automatic merge.
fatal: merge program failed
Automatic merge failed; fix conflicts and then commit the result.

$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   bar.txt
#       new file:   foo.txt
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       unmerged:   dir/foo
#       unmerged:   dir/foo/foo.bin
#       modified:   dir/foo/foo.bin
#

But if I do it in the other order I get this:
$ git-merge -s resolve branch-b
$ git-merge -s resolve branch-a
Trying really trivial in-index merge...
fatal: Merge requires file-level merging
Nope.
Trying simple merge.
Simple merge failed, trying Automatic merge.
Removing dir/foo
Adding dir/foo/foo.bin
ERROR: untracked dir/foo/foo.bin is overwritten by the merge.
fatal: merge program failed
Automatic merge failed; fix conflicts and then commit the result.

deuresti@deuresti-lnx /tmp/scm-rename-test/git-repo
$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    dir/foo
#
# Changed but not updated:
#   (use "git add <file>..." to update what will be committed)
#
#       unmerged:   dir/foo/foo.bin
#

Thanks,
David
On 9/18/07, Junio C Hamano <gitster@pobox.com> wrote:
> "David Euresti" <evelio@gmail.com> writes:
>
> > I think I found a problem when you move a file into a directory of the
> > same name.  Here's what I did.
>
> Two questions.
>
>  (1) git --version?
>
>  (2) if you do "git merge -s resolve" instead of just "git
>      merge", do you see a difference?
>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with merge when renaming
  2007-09-18 22:28 ` Problem with merge when renaming Junio C Hamano
  2007-09-18 22:42   ` David Euresti
@ 2007-09-18 22:44   ` Alex Riesen
  2007-09-18 23:27     ` Junio C Hamano
  1 sibling, 1 reply; 7+ messages in thread
From: Alex Riesen @ 2007-09-18 22:44 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: David Euresti, git

Junio C Hamano, Wed, Sep 19, 2007 00:28:39 +0200:
> "David Euresti" <evelio@gmail.com> writes:
> 
> > I think I found a problem when you move a file into a directory of the
> > same name.  Here's what I did.
> 
> Two questions.
> 
>  (1) git --version?

it happens with very recent git (as of today)

>  (2) if you do "git merge -s resolve" instead of just "git
>      merge", do you see a difference?

yes: it has more error output.

Trying really trivial in-index merge...
warning: Merge requires file-level merging
Nope, a really trivial in-index merge not possible
Trying simple merge.
Simple merge failed, trying Automatic merge.
error: init: is a directory - add individual files instead
fatal: Unable to process path init
fatal: merge program failed
Automatic merge failed; fix conflicts and then commit the result.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with merge when renaming
  2007-09-18 22:44   ` Alex Riesen
@ 2007-09-18 23:27     ` Junio C Hamano
  2007-09-19 21:11       ` Alex Riesen
  0 siblings, 1 reply; 7+ messages in thread
From: Junio C Hamano @ 2007-09-18 23:27 UTC (permalink / raw)
  To: Alex Riesen; +Cc: David Euresti, git

Alex Riesen <raa.lkml@gmail.com> writes:

> Junio C Hamano, Wed, Sep 19, 2007 00:28:39 +0200:
>> "David Euresti" <evelio@gmail.com> writes:
>> 
>> > I think I found a problem when you move a file into a directory of the
>> > same name.  Here's what I did.
>> 
>> Two questions.
>> 
>>  (1) git --version?
>
> it happens with very recent git (as of today)
>
>>  (2) if you do "git merge -s resolve" instead of just "git
>>      merge", do you see a difference?
>
> yes: it has more error output.
>
> Trying really trivial in-index merge...
> warning: Merge requires file-level merging
> Nope, a really trivial in-index merge not possible
> Trying simple merge.
> Simple merge failed, trying Automatic merge.
> error: init: is a directory - add individual files instead
> fatal: Unable to process path init
> fatal: merge program failed
> Automatic merge failed; fix conflicts and then commit the result.

Isn't this the same as the known issue here?

	<http://permalink.gmane.org/gmane.comp.version-control.git/53402>

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Problem with merge when renaming
  2007-09-18 23:27     ` Junio C Hamano
@ 2007-09-19 21:11       ` Alex Riesen
  0 siblings, 0 replies; 7+ messages in thread
From: Alex Riesen @ 2007-09-19 21:11 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: David Euresti, git

Junio C Hamano, Wed, Sep 19, 2007 01:27:01 +0200:
> > it happens with very recent git (as of today)
> >
> >>  (2) if you do "git merge -s resolve" instead of just "git
> >>      merge", do you see a difference?
> >
> > yes: it has more error output.
> >
> > Trying really trivial in-index merge...
> > warning: Merge requires file-level merging
> > Nope, a really trivial in-index merge not possible
> > Trying simple merge.
> > Simple merge failed, trying Automatic merge.
> > error: init: is a directory - add individual files instead
> > fatal: Unable to process path init
> > fatal: merge program failed
> > Automatic merge failed; fix conflicts and then commit the result.
> 
> Isn't this the same as the known issue here?
> 
> 	<http://permalink.gmane.org/gmane.comp.version-control.git/53402>
> 

Yes, looks similar:

    .../git/t$ ./t3031-df-3way.sh -d -v -i
    ...
    Created commit 992a330: side moves and makes changes
     6 files changed, 155 insertions(+), 153 deletions(-)
     create mode 100644 D
     create mode 100644 D.A
     delete mode 100644 D/A
     delete mode 100644 D/B
     delete mode 100644 D/C
     create mode 100644 D0C
    *   ok 1: setup

    * expecting success: 

	    git read-tree -m initial side master


    fatal: Entry 'D/A' would be overwritten by merge. Cannot merge.
    * FAIL 2: threeway


		    git read-tree -m initial side master

    .../git/t$

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-09-19 21:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-18 20:34 Problem with merge when renaming David Euresti
2007-09-18 22:12 ` [PATCH] Extend t6020 with another test for d/f interactions Alex Riesen
2007-09-18 22:28 ` Problem with merge when renaming Junio C Hamano
2007-09-18 22:42   ` David Euresti
2007-09-18 22:44   ` Alex Riesen
2007-09-18 23:27     ` Junio C Hamano
2007-09-19 21:11       ` Alex Riesen

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).