All of lore.kernel.org
 help / color / mirror / Atom feed
* Issue when merging a subtree whose a file has been removed
       [not found] <160239201.419722978.1432221938533.JavaMail.root@zimbra41-e7.priv.proxad.net>
@ 2015-05-21 15:40 ` adatoccpptranslator
  0 siblings, 0 replies; 3+ messages in thread
From: adatoccpptranslator @ 2015-05-21 15:40 UTC (permalink / raw)
  To: git

Hi all,

I want to use subtrees in one of my projects and I use method desribed here https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging
I`m facing issues when merging subtree in my subproject in case some files have been removed from the subtree.

I`m running git 1.9.1 on Kubuntu  14.04
sub_project is integrated as subtree in my main project. I modify a file and remove an other file from my sub_project, commit the modification, go in my main_project, checkout the sub_project integration branch, pull the modification.
I see the modification of the modified file and the deletion of the removed file
I checkout the master branch of my main project.
git diff-tree -p sub_project_branch indicate that one file has been modified and one files has been deleted
then I perform a merge of my subtree integration branch into master branch.

Here are the corresponding commands:
#!/bin/sh

# Creating project that will be used as subtree
$ mkdir sub_project
$ cd sub_project
$ git init
$ touch toto
$ echo "-----------------" >> toto
$ echo "- toto file">> toto
$ echo "-----------------" >> toto
$ touch tata
$ echo "-----------------" >> tata
$ echo "- tata file">> tata
$ echo "-----------------" >> tata
$ git add toto tata
$ git commit -m "Initial commit"
$ echo "echo toto" >> toto
$ echo "echo tata" >> tata
$ git commit -am "Add content to file"
$ cd ..

# Creating main project that will use the subtree
$ mkdir main_project
$ cd main_project
$ git init
$ touch tutu
$ echo "-----------------" >> tutu
$ echo "- tutu file">> tutu
$ echo "-----------------" >> tutu
$ git add tutu
$ git commit -m "Add tutu file"
# Creation of subtree
$ mkdir sources
$ git remote add sub_project_remote ../sub_project
$ git fetch sub_project_remote
$ git checkout -b sub_project_branch sub_project_remote/master
$ git checkout master
$ git read-tree --prefix=sources/sub_project/ -u sub_project_branch
$ git commit -am "Integration of subtree"

$ echo "------------------------"
------------------------
$ echo "Subtree well integrated "
Subtree well integrated 
$ ls *
tutu

sources:
sub_project
$ ls sources/sub_project
tata
toto
$ echo "------------------------"
------------------------

# Go in subtree to remove tata file
$ cd ../sub_project
$ echo "#EOF" >> toto
$ git add toto
$ git rm tata
$ git commit -m "Add EOF and remove tata"

# go back in main project to integrate subtree modifications
$ cd ../main_project
$ git checkout sub_project_branch
$ git fetch sub_project_remote
$ git pull

$ echo "------------------------"
------------------------
$ echo "Check that tata has been removed "
Check that tata has been removed 
$ ls *
toto
$ echo "------------------------"
------------------------

$ git checkout master
$ git diff-tree -p sub_project_branch
diff --git a/tata b/tata
deleted file mode 100644
index a4f4cc4..0000000
--- a/tata
+++ /dev/null
@@ -1,4 +0,0 @@
------------------
-- tata file
------------------
-echo tata
diff --git a/toto b/toto
index 8dfbe14..98ae756 100644
--- a/toto
+++ b/toto
@@ -2,3 +2,4 @@
 - toto file
 -----------------
 echo toto
+#EOF

$ git merge -v --squash --no-commit -X subtree=sources/sub_project -X theirs sub_project_branch

$ echo "------------------------"
------------------------
$ echo "Check after merge that tata has been removed "
Check after merge that tata has been removed 
$ ls sources/*
tata
toto
$ echo "------------------------"
------------------------
$ git commit -m "Second integration from subtree"
$ cd ..
#EOF

I was expecting to see the in master the modification of the file and the deletion of the other file but the removed file is still there and tracked. The modification of file has been done but It looks like the deletion has not been "merged".

The behaviour I expect is the same that the one illustrated in command sequence below which perform exactly the same actions excepted they are done in a branch instead of a subtree:
toto should have been modified, tata should no more be there or at least no more be tracked
#!/bin/sh
$ git init
$ touch toto
$ echo "-----------------" >> toto
$ echo "- toto file">> toto
$ echo "-----------------" >> toto
$ touch tata
$ echo "-----------------" >> tata
$ echo "- tata file">> tata
$ echo "-----------------" >> tata
$ git add toto tata
$ git commit -m "Initial commit"
$ echo "echo toto" >> toto
$ echo "echo tata" >> tata
$ git commit -am "Add content to file"
$ git checkout -b headers
$ echo "#EOF" >> toto
$ git add toto
$ git rm tata
$ git commit -m "Add EOF and remove tata"
$ git checkout master
$ touch tutu
$ echo "-----------------" >> tutu
$ echo "- tutu file">> tutu
$ echo "-----------------" >> tutu
$ git add tutu
$ git commit -m "Add tutu file"
$ git merge -m "Merge from headers branch" headers
Merge made by the 'recursive' strategy.
 tata | 4 ----
 toto | 1 +
 2 files changed, 1 insertion(+), 4 deletions(-)
 delete mode 100644 tata
[master a9cad6d] Add EOF
 1 file changed, 1 insertion(+)
$ echo "#EOF" >> tutu
$ git add tutu
$ git commit -m "Add EOF"
$ ls
toto
tutu
#EOF


According to what I see it seems that the subtree merge is doing a kind of copy instead of a real merge meaning that if source file disappear then the corresponding target file is untouched instead of being deleted.
Is this behaviour correct or is it my understanding of what subtree merge should do that is wrong ?


Thanks by advance
Julien

PS : as my subtree prefix has 2 levels I also test with a single level like in subtree tutorial to ensure this was not the cause of my issue but the problem remains the same. the single level test is performed by the following command sequence:

#!/bin/sh

# Creating project that will be used as subtree
$ mkdir sub_project
$ cd sub_project
$ git init
$ touch toto
$ echo "-----------------" >> toto
$ echo "- toto file">> toto
$ echo "-----------------" >> toto
$ touch tata
$ echo "-----------------" >> tata
$ echo "- tata file">> tata
$ echo "-----------------" >> tata
$ git add toto tata
$ git commit -m "Initial commit"
$ echo "echo toto" >> toto
$ echo "echo tata" >> tata
$ git commit -am "Add content to file"
$ cd ..

# Creating main project that will use the subtree
$ mkdir main_project
$ cd main_project
$ git init
$ touch tutu
$ echo "-----------------" >> tutu
$ echo "- tutu file">> tutu
$ echo "-----------------" >> tutu
$ git add tutu
$ git commit -m "Add tutu file"
# Creation of subtree
$ git remote add sub_project_remote ../sub_project
$ git fetch sub_project_remote
$ git checkout -b sub_project_branch sub_project_remote/master
$ git checkout master
$ git read-tree --prefix=sub_project/ -u sub_project_branch
$ git commit -am "Integration of subtree"

$ echo "------------------------"
------------------------
$ echo "Subtree well integrated "
Subtree well integrated
$ ls *
tutu

sub_project:
tata
toto
$ echo "------------------------"
------------------------

# Go in subtree to remove tata file
$ cd ../sub_project
$ echo "#EOF" >> toto
$ git add toto
$ git rm tata
$ git commit -m "Add EOF and remove tata"

# go back in main project to integrate subtree modifications
$ cd ../main_project
$ git checkout sub_project_branch
$ git fetch sub_project_remote
$ git pull

$ echo "------------------------"
------------------------
$ echo "Check that tata has been removed "
Check that tata has been removed 
$ ls *
toto
$ echo "------------------------"
------------------------

$ git checkout master
$ git diff-tree -p sub_project_branch
diff --git a/tata b/tata
deleted file mode 100644
index a4f4cc4..0000000
--- a/tata
+++ /dev/null
@@ -1,4 +0,0 @@
------------------
-- tata file
------------------
-echo tata
diff --git a/toto b/toto
index 8dfbe14..98ae756 100644
--- a/toto
+++ b/toto
@@ -2,3 +2,4 @@
 - toto file
 -----------------
 echo toto
+#EOF
$ git merge -v --squash --no-commit -s subtree -X theirs sub_project_branch

$ echo "------------------------"
------------------------
$ echo "Check after merge that tata has been removed "
Check after merge that tata has been removed 
$ ls *
tutu

sub_project:
tata
toto
$ echo "------------------------"
------------------------
$ git commit -m "Second integration from subtree"
$ cd ..
#EOF

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

* Issue when merging a subtree whose a file has been removed
       [not found] <2074448442.419140473.1432212498797.JavaMail.root@zimbra41-e7.priv.proxad.net>
@ 2015-05-21 12:49 ` adatoccpptranslator
  0 siblings, 0 replies; 3+ messages in thread
From: adatoccpptranslator @ 2015-05-21 12:49 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 2124 bytes --]

Hi all, ( sorry for possible the double mail, the first one seems could have been rejected by server due to sh scripts in attachment),

 

I want to use subtrees in one of my projects and I use method desribed here https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging
I`m facing issues when merging subtree in my subproject in case some files have been removed from the subtree.

I`m running git 1.9.1 on Kubuntu  14.04
sub_project is integrated as subtree in my main project. I modify a file and remove an other file from my sub_project, commit the modification, go in my main_project, checkout the sub_project integration branch, pull the modification.
I see the modification of the modified file and the deletion of the removed file
I checkout the master branch of my main project.
git diff-tree -p sub_project_branch indicate that one file has been modified and one files has been deleted
then I perform a merge of my subtree integration branch into master branch.

I was expecting to see the in master the modification of the file and the deletion of the other file but the removed file is still there and tracked. The modification of file has been done but It looks like the deletion has not been "merged".
The test case can be reproduced using run_subtree.sh attached script

The behaviour I expect is the same that the one illustrated in run.sh which perform exactly the same actions excepted they are done in a branch instead of a subtree:
toto should have been modified, tata should no more be there or at least no more be tracked

According to what I see it seems that the subtree merge is doing a kind of copy instead of a real merge meaning that if source file disappear then the corresponding target file is untouched instead of being deleted.
Is this behaviour correct or is it my understanding of what subtree merge should do that is wrong ?


Thanks by advance
Julien

PS : as my subtree prefix has 2 levels I also test with a single level like in subtree tutorial to ensure this was not the cause of my issue but the problem remains the same. the single level test is performed by run_simple_subtree.sh

[-- Attachment #2: scripts.zip --]
[-- Type: application/zip, Size: 1730 bytes --]

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

* Issue when merging a subtree whose a file has been removed
       [not found] <1663657179.419121722.1432212216042.JavaMail.root@zimbra41-e7.priv.proxad.net>
@ 2015-05-21 12:44 ` adatoccpptranslator
  0 siblings, 0 replies; 3+ messages in thread
From: adatoccpptranslator @ 2015-05-21 12:44 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1999 bytes --]

Hi all,

 

I want to use subtrees in one of my projects and I use method desribed here https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging
I`m facing issues when merging subtree in my subproject in case some files have been removed from the subtree.

I`m running git 1.9.1 on Kubuntu  14.04
sub_project is integrated as subtree in my main project. I modify a file and remove an other file from my sub_project, commit the modification, go in my main_project, checkout the sub_project integration branch, pull the modification.
I see the modification of the modified file and the deletion of the removed file 
I checkout the master branch of my main project.
git diff-tree -p sub_project_branch indicate that one file has been modified and one files has been deleted
then I perform a merge of my subtree integration branch into master branch.

I was expecting to see the in master the modification of the file and the deletion of the other file but the removed file is still there and tracked. The modification of file has been done but It looks like the deletion has not been "merged".
The test case can be reproduced using run_subtree.sh attached script 

The behaviour I expect is the same that the one illustrated in run.sh which perform exactly the same actions excepted they are done in a branch instead of a subtree:
toto should have been modified, tata should no more be there or at least no more be tracked

According to what I see it seems that the subtree merge is doing a kind of copy instead of a real merge meaning that if source file disappear then the corresponding target file is untouched instead of being deleted.
Is this behaviour correct or is it my understanding of what subtree merge should do that is wrong ?


Thanks by advance
Julien

PS : as my subtree prefix has 2 levels I also test with a single level like in subtree tutorial to ensure this was not the cause of my issue but the problem remains the same. the single level test is performed by run_simple_subtree.sh

[-- Attachment #2: run.sh --]
[-- Type: application/x-shellscript, Size: 763 bytes --]

[-- Attachment #3: run_subtree.sh --]
[-- Type: application/x-shellscript, Size: 1858 bytes --]

[-- Attachment #4: run_simple_subtree.sh --]
[-- Type: application/x-shellscript, Size: 1801 bytes --]

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

end of thread, other threads:[~2015-05-21 15:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <160239201.419722978.1432221938533.JavaMail.root@zimbra41-e7.priv.proxad.net>
2015-05-21 15:40 ` Issue when merging a subtree whose a file has been removed adatoccpptranslator
     [not found] <2074448442.419140473.1432212498797.JavaMail.root@zimbra41-e7.priv.proxad.net>
2015-05-21 12:49 ` adatoccpptranslator
     [not found] <1663657179.419121722.1432212216042.JavaMail.root@zimbra41-e7.priv.proxad.net>
2015-05-21 12:44 ` adatoccpptranslator

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.