Discussion:
git merge - "both added" conflict resolution
Eugene Sajine
2010-08-04 20:18:30 UTC
Permalink
hi,

I'm trying to merge two projects into one. Both are having different
and simple set of files inside, but both have build.xml file.
Let's say i have source repo with master branch and dest repo.

When i'm trying to merge source into dest it all goes well with an
exception of the build.xml file - it has conflict. The conflict is one
liner and is easy to resolve, eventually i want it to be as it was
before the merge.
First of all, after the merge git status gives me message "both added;
build.xml" not both modified, which is understandable, but i have no
clue yet how to work with it;)

Secondly, when i resolve the conflict the build.xml returns to its
last committed state of dest repo, so git cannot determine any
changes.
Therefore, i cannot execute git add for this file and i cannot commit
my merge results, because git sees it as a partial commit.

Any ideas?

Thanks,
Eugene
Jonathan Nieder
2010-08-04 20:59:16 UTC
Permalink
Hi Eugene,

Eugene Sajine wrote:

[in an add/add conflict]
Post by Eugene Sajine
when i resolve the conflict the build.xml returns to its
last committed state of dest repo, so git cannot determine any
changes.
Therefore, i cannot execute git add for this file and i cannot commit
my merge results
Could you explain further (preferrably with a simple example
transcript)? I would think that after an add/add conflict,
a simple "git add" would mark the file resolved and allow
committing.
Eugene Sajine
2010-08-04 23:29:21 UTC
Permalink
Post by Jonathan Nieder
Hi Eugene,
[in an add/add conflict]
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 when i resolve the conflict the b=
uild.xml returns to its
Post by Jonathan Nieder
last committed state of dest repo, so git cannot determine any
changes.
Therefore, i cannot execute git add for this file and i cannot commi=
t
Post by Jonathan Nieder
my merge results
Could you explain further (preferrably with a simple example
transcript)? =C2=A0I would think that after an add/add conflict,
a simple "git add" would mark the file resolved and allow
committing.
Let's say in a source repository i have a master branch with few
coomits and only two files file1.java and build.xml
build.xml is as simple as few lines one of which is
=2E..
<property name=3DprojectName value=3DprojectOne/>
=2E..
In the second *unrelated* repository which is the destination for
merge I have a master branch with two files: file2.java and build.xml
this build.xml is absolutely identical with an exception of the
projectName property
=2E..
<property name=3DprojectName value=3DprojectTwo/>
=2E..

I'm doing
$ cd projecttwo (I'm in master branch)
$ git add remote temp ../projectone
$ git fetch temp
$ git merge temp/master

here i'm getting a conflict in build.xml.
file1.java is succesfully staged for commit

=46or build.xml git status gives me
=2E..
both added: build.xml
=2E..

Now i have to resolve the conflict on build.xml and as I'm merging two
projects into one it is obvious that the resolution of the conflict is
to leave the original version of build.xml

So, I'm removing all conflict markers and removing the incoming line
with the property value=3DprojectOne leaving it as projectTwo.
This effectively means that there is no changes in build.xml for git.
And I'm stuck because i cannot add file, that is not changed and
cannot commit merge results as it is a partial commit.

Is that better;)?

Interesting enough this worked OK on git version 1.6.4.msysgit.0
But giving me headache in git 1.7.0.5 on Linux

Below is command sequence which is supposed to reflect everything above

mkdir test3
mkdir test4
cd test3/
git init
echo file content> file1.java
git add .
git commit -am "initial commit"
echo "<property name=3Dprojectname value=3Dtest3/>" > build.xml
git add .
git commit -am "add build.xml"
echo "more content" >> file1.java
git commit -am "some change"
cd ../test4
git init
echo file content> file2.java
git add .
git commit -am "initial commit"
echo "<property name=3Dprojectname value=3Dtest4/>" > build.xml
git add .
git commit -am "add build.xml"
echo "more content" >> file2.java
git commit -am "another change"
git remote add temp ../test3
git fetch temp
git merge temp/master
git status
vi build.xml
git status
git add build.xml
git st
git commit -am "merging"


Thanks,
Eugene
Jonathan Nieder
2010-08-04 23:36:52 UTC
Permalink
Post by Eugene Sajine
So, I'm removing all conflict markers and removing the incoming line
with the property value=3DprojectOne leaving it as projectTwo.
This effectively means that there is no changes in build.xml for git.
And I'm stuck because i cannot add file, that is not changed
Sorry I wasn=E2=80=99t clear before. Could you give output from attemp=
ting
to add the file? It is supposed to work.
Eugene Sajine
2010-08-05 14:41:03 UTC
Permalink
Post by Eugene Sajine
So, I'm removing all conflict markers and removing the incoming line
with the property value=3DprojectOne leaving it as projectTwo.
This effectively means that there is no changes in build.xml for git=
=2E
Post by Eugene Sajine
And I'm stuck because i cannot add file, that is not changed
Sorry I wasn=E2=80=99t clear before. =C2=A0Could you give output from=
attempting
to add the file? =C2=A0It is supposed to work.
There is no output after I add build.xml with resolved conflicts. When
i do git status build.xml doesn't show up there.

I tried another way:
After i have a conflict i add the build.xml withtout resolving
conflicts. Then I unstage it - it's status changes from "both added: "
to "modified"
Then i can resolve the conflict, which means build.xml returns to it's
last committed state. But then i'm back to square one as build.xml is
not showing in changes, so i cannot add it and i still cannot commit
because of partial commit.

Thanks,
Eugene
Eugene Sajine
2010-08-06 14:57:07 UTC
Permalink
So, I'm removing all conflict markers and removing the incoming lin=
e
with the property value=3DprojectOne leaving it as projectTwo.
This effectively means that there is no changes in build.xml for gi=
t.
And I'm stuck because i cannot add file, that is not changed
Sorry I wasn=E2=80=99t clear before. =C2=A0Could you give output fro=
m attempting
to add the file? =C2=A0It is supposed to work.
There is no output after I add build.xml with resolved conflicts. Whe=
n
i do git status build.xml doesn't show up there.
After i have a conflict i add the build.xml withtout resolving
conflicts. Then I unstage it - it's status changes from "both added: =
"
to "modified"
Then i can resolve the conflict, which means build.xml returns to it'=
s
last committed state. But then i'm back to square one as build.xml is
not showing in changes, so i cannot add it and i still cannot commit
because of partial commit.
Thanks,
Eugene
When i experimenting with it with test repos - it is working OK.
So, i believe it will be very difficult to reproduce.

I'm still having this problem with two repos of mine, but as it is not
common, i gotta dig deeper there.

Thanks,
Eugene

Loading...