{"thread":{"id":"28997","subject":"How to deal with mixed tree?","startedAt":"2011-11-22T11:21:40Z","lastAt":"2011-11-22T18:29:40Z","messageCount":8,"participants":["Pascal Obry","Holger Hellmuth","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"179827","messageId":"CA+9ZNic-9U0nP1NGL0shUijnxdhaoEHwyxWM8rOzR2B6Qjq6zQ@mail.gmail.com","threadId":"28997","inReplyTo":null,"subject":"How to deal with mixed tree?","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2011-11-22T11:21:40Z","receivedAt":"2011-11-22T11:21:40Z","isPatch":false,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"A project P1 is under Git.\n\nA project P2 is under Subversion.\n\nP2 in fact replace a sub-directory (say SD) in P1. The project P2 is a\nreplacement (extension) of the code in P1.\n\nHow to deal with this?\n\nIf you clone P1, remove SD in P1 to replace it by P2:\n\n   $ git diff\n\n   -> will display all the changes in SD, is there a way to avoid that?\n\n   $ git merge (between branches) will try to merge changes in SD\n\nI'd like to really tell Git to ignore SD as if it was not there. Any solution?\n\nThanks,\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|              http://www.obry.net\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595\n"},{"id":"179829","messageId":"4ECB8917.8010305@ira.uka.de","threadId":"28997","inReplyTo":"CA+9ZNic-9U0nP1NGL0shUijnxdhaoEHwyxWM8rOzR2B6Qjq6zQ@mail.gmail.com","subject":"Re: How to deal with mixed tree?","fromName":"Holger Hellmuth","fromEmail":"hellmuth@ira.uka.de","sentAt":"2011-11-22T11:35:51Z","receivedAt":"2011-11-22T11:35:51Z","isPatch":false,"sender":{"key":"hellmuth@ira.uka.de","avatar":null},"body":"On 22.11.2011 12:21, Pascal Obry wrote:\n> A project P1 is under Git.\n>\n> A project P2 is under Subversion.\n>\n> P2 in fact replace a sub-directory (say SD) in P1. The project P2 is a\n> replacement (extension) of the code in P1.\n>\n> How to deal with this?\n\nRemove SD in P1, make a logical link from P2 to SD, add SD to \n.git/info/exclude\n\n(see \"Bug report - local (and git ignored) file silently removed after \ncheckout\" on the mailing list why exclude is better than .gitignore at \nthe moment)\n"},{"id":"179833","messageId":"4ECBAFB7.9040505@obry.net","threadId":"28997","inReplyTo":"4ECB8917.8010305@ira.uka.de","subject":"Re: How to deal with mixed tree?","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2011-11-22T14:20:39Z","receivedAt":"2011-11-22T14:20:39Z","isPatch":false,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"\nHolger,\n\n> Remove SD in P1, make a logical link from P2 to SD, add SD to\n> .git/info/exclude\n\nThanks for your quick reply. That's what I have tested but...\n\n> (see \"Bug report - local (and git ignored) file silently removed after\n> checkout\" on the mailing list why exclude is better than .gitignore at\n> the moment)\n\nSeems like this is working only if file names are different. This is not\nmy case as the replacement is very similar. With the following script\nI'm expecting empty status and no diff:\n\n<<\n#!/bin/sh\n\n# create sd (directory that will replace src2)\nmkdir sd\necho sd1 > sd/file1\necho sd2 > sd/file2\n\n# create Git repo\nmkdir repo\ncd repo\ngit init\nmkdir src1\nmkdir src2\necho file > src1/file\necho 3 > src2/file3\ngit add .\ngit ci -a -m \"first\"\n\n# let's replace src2 by sd\n\nrm -fr src2\n# ln -s ../sd src2\ncp -r ../sd src2\n\n# make sure src2 is excluded\n\necho 'src2/*' >> .git/info/exclude\n\n# the following output should be clean\n\necho '============== Status'\ngit status\n\necho '============== Diff'\ngit diff\n>>\n\nBut the output is actually:\n\nInitialized empty Git repository in /home/obry/tmp/repo/.git/\n[master (root-commit) 527c7a1] first\n 2 files changed, 2 insertions(+), 0 deletions(-)\n create mode 100644 src1/file\n create mode 100644 src2/file3\ncp: cannot stat `../src': No such file or directory\n============== Status\n# On branch master\n# Changes not staged for commit:\n#   (use \"git add/rm <file>...\" to update what will be committed)\n#   (use \"git checkout -- <file>...\" to discard changes in working\ndirectory)\n#\n#\tdeleted:    src2/file3\n#\nno changes added to commit (use \"git add\" and/or \"git commit -a\")\n============== Diff\ndiff --git a/src2/file3 b/src2/file3\ndeleted file mode 100644\nindex 00750ed..0000000\n--- a/src2/file3\n+++ /dev/null\n@@ -1 +0,0 @@\n-3\n\nAny other idea?\n\nThanks.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|    http://www.obry.net  -  http://v2p.fr.eu.org\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B\n"},{"id":"179834","messageId":"4ECBBAD4.6080206@ira.uka.de","threadId":"28997","inReplyTo":"4ECBAFB7.9040505@obry.net","subject":"Re: How to deal with mixed tree?","fromName":"Holger Hellmuth","fromEmail":"hellmuth@ira.uka.de","sentAt":"2011-11-22T15:08:04Z","receivedAt":"2011-11-22T15:08:04Z","isPatch":false,"sender":{"key":"hellmuth@ira.uka.de","avatar":null},"body":"On 22.11.2011 15:20, Pascal Obry wrote:\n>\n> Holger,\n>\n>> Remove SD in P1, make a logical link from P2 to SD, add SD to\n>> .git/info/exclude\n>\n> Thanks for your quick reply. That's what I have tested but...\n>\n>> (see \"Bug report - local (and git ignored) file silently removed after\n>> checkout\" on the mailing list why exclude is better than .gitignore at\n>> the moment)\n>\n> Seems like this is working only if file names are different. This is not\n> my case as the replacement is very similar. With the following script\n> I'm expecting empty status and no diff:\n>\n> <<\n> #!/bin/sh\n>\n> # create sd (directory that will replace src2)\n> mkdir sd\n> echo sd1>  sd/file1\n> echo sd2>  sd/file2\n>\n> # create Git repo\n> mkdir repo\n> cd repo\n> git init\n> mkdir src1\n> mkdir src2\n> echo file>  src1/file\n> echo 3>  src2/file3\n> git add .\n> git ci -a -m \"first\"\n>\n> # let's replace src2 by sd\n>\n> rm -fr src2\n> # ln -s ../sd src2\n> cp -r ../sd src2\n>\n> # make sure src2 is excluded\n>\n> echo 'src2/*'>>  .git/info/exclude\n>\n> # the following output should be clean\n\nYou should also remove src2 and all files in it from the git repository. \nSomething like\n\ngit rm -r src2\ngit ci\necho 'src2' >> .git/info/exclude\n\ninstead of\n\nrm -fr src2\necho 'src2/*' >> .git/info/exclude\n"},{"id":"179836","messageId":"4ECBBDE3.3010904@obry.net","threadId":"28997","inReplyTo":"4ECBBAD4.6080206@ira.uka.de","subject":"Re: How to deal with mixed tree?","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2011-11-22T15:21:07Z","receivedAt":"2011-11-22T15:21:07Z","isPatch":false,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"\nHolger,\n\n> You should also remove src2 and all files in it from the git repository.\n> Something like\n> \n> git rm -r src2\n> git ci\n> echo 'src2' >> .git/info/exclude\n> \n> instead of\n> \n> rm -fr src2\n> echo 'src2/*' >> .git/info/exclude\n\nThanks this is working indeed. But it was not the whole story :)\n\nIn fact I want to do that in a branch (say work) and keep master as-is\nas this branch is used to pull changes from origin. And in this case,\ndoing 'git diff master' still shows the files under src2. See script to\nreproduce:\n\n<<\n#!/bin/sh\n\n# create sd (directory that will replace src2)\nmkdir sd\necho sd1 > sd/file1\necho sd2 > sd/file2\n\n# create Git repo\nmkdir repo\ncd repo\ngit init\nmkdir src1\nmkdir src2\necho file > src1/file\necho 3 > src2/file3\ngit add .\ngit ci -a -m \"first\"\n\n# let's replace src2 by sd in branch work\n\ngit checkout -b work\ngit rm src2/*\ngit ci -m \"no more src2\"\n# ln -s ../sd src2\ncp -r ../sd src2\n\n# make sure src2 is excluded\n\necho 'src2' >> .git/info/exclude\n\n# the following output should be clean\n\necho '============== Status'\ngit status\n\necho '============== Diff'\ngit diff\n\necho '============== Diff master'\ngit diff master\n>>\n\nIs that possible?\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|    http://www.obry.net  -  http://v2p.fr.eu.org\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B\n"},{"id":"179838","messageId":"4ECBCA4F.5090505@ira.uka.de","threadId":"28997","inReplyTo":"4ECBBDE3.3010904@obry.net","subject":"Re: How to deal with mixed tree?","fromName":"Holger Hellmuth","fromEmail":"hellmuth@ira.uka.de","sentAt":"2011-11-22T16:14:07Z","receivedAt":"2011-11-22T16:14:07Z","isPatch":false,"sender":{"key":"hellmuth@ira.uka.de","avatar":null},"body":"On 22.11.2011 16:21, Pascal Obry wrote:\n> In fact I want to do that in a branch (say work) and keep master as-is\n> as this branch is used to pull changes from origin. And in this case,\n> doing 'git diff master' still shows the files under src2. See script to\n> reproduce:\n[...]\n> # let's replace src2 by sd in branch work\n>\n> git checkout -b work\n> git rm src2/*\n> git ci -m \"no more src2\"\n> # ln -s ../sd src2\n> cp -r ../sd src2\n>\n> # make sure src2 is excluded\n>\n> echo 'src2'>>  .git/info/exclude\n>\n> # the following output should be clean\n>\n> echo '============== Status'\n> git status\n>\n> echo '============== Diff'\n> git diff\n>\n> echo '============== Diff master'\n> git diff master\n>>>\n>\n> Is that possible?\n>\n\nIn my not-really-expert opinion no. At least git diff master has to show \nsomething because there obviously is a difference between what is in \nmaster (that you can't gitignore) and your branch (whether you ignore it \nor not).\n\nI would\n\na) use a different directory name for src2 and adapt the Makefile to \ncope with that\n\nor\n\nb) remove the src2 link from .git/info/exclude and commit it into the \nbranch. That way whenever you switch branch and master, the correct dir \nor link will be present and still because of the link none of the files \nin the svn will be handled by git in any way\n"},{"id":"179839","messageId":"4ECBDC12.3050308@obry.net","threadId":"28997","inReplyTo":"4ECBCA4F.5090505@ira.uka.de","subject":"Re: How to deal with mixed tree?","fromName":"Pascal Obry","fromEmail":"pascal@obry.net","sentAt":"2011-11-22T17:29:54Z","receivedAt":"2011-11-22T17:29:54Z","isPatch":false,"sender":{"key":"pascal@obry.net","avatar":"https://avatars.githubusercontent.com/u/467069?v=4"},"body":"\nHolger,\n\n> In my not-really-expert opinion no. At least git diff master has to show\n> something because there obviously is a difference between what is in\n> master (that you can't gitignore) and your branch (whether you ignore it\n> or not).\n\nI had come to the same conclusion. Sad, it would have been nice to have\nan option to fully ignore a path in a repository.\n\nAnyway, thanks a lot for your feedback.\n\nPascal.\n\n-- \n\n--|------------------------------------------------------\n--| Pascal Obry                           Team-Ada Member\n--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE\n--|------------------------------------------------------\n--|    http://www.obry.net  -  http://v2p.fr.eu.org\n--| \"The best way to travel is by means of imagination\"\n--|\n--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B\n"},{"id":"179844","messageId":"7vk46sdn8r.fsf@alter.siamese.dyndns.org","threadId":"28997","inReplyTo":"4ECB8917.8010305@ira.uka.de","subject":"Re: How to deal with mixed tree?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-22T18:29:40Z","receivedAt":"2011-11-22T18:29:40Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Holger Hellmuth <hellmuth@ira.uka.de> writes:\n\n> (see \"Bug report - local (and git ignored) file silently removed after\n> checkout\" on the mailing list why exclude is better than .gitignore at\n> the moment)\n\nDon't look at it or encourage people to rely on that bug to be\nfixed. exclude and .gitignore should behave the same way.\n"}]}