{"thread":{"id":"16474","subject":"suggestion? only pull cleanly applying commits","startedAt":"2008-11-26T11:48:50Z","lastAt":"2008-11-26T13:30:54Z","messageCount":2,"participants":["Maximilian Mehnert","Andreas Ericsson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"96537","messageId":"492D37A2.4010500@googlemail.com","threadId":"16474","inReplyTo":null,"subject":"suggestion? only pull cleanly applying commits","fromName":"Maximilian Mehnert","fromEmail":"maximilian.mehnert@googlemail.com","sentAt":"2008-11-26T11:48:50Z","receivedAt":"2008-11-26T11:48:50Z","isPatch":false,"sender":{"key":"maximilian.mehnert@googlemail.com","avatar":null},"body":"Hi!\n\nI've a scenario where I don't really want to do a full merge but rather\nto pull all commits from another repository that merge without conflicts.\n\nI've put together the script at the bottom which seems to work ok but is\ndamn slow.\n\nIs there a smarter and faster way to do this that I missed reading the\ndocumentation?\n\nAny help would be really appreciated! :-)\n\nRegards,\nMaximilian\n\n\n#!/bin/sh\n\nfor commit in `git rev-list --reverse HEAD..other-repository/master`; do\n        git diff-tree -p $commit|patch --dry-run -p1 -N -f >/dev/null\n        if [ $? -eq 0 ]; then\n                echo \"getting $commit\"\n                parents=`git rev-list --parents -n1  $commit|wc -w`\n                if [ $parents -eq 2 ]; then\n                        git cherry-pick $commit\n                else\n                        git cherry-pick -m1 $commit\n                fi\n        fi\ndone\n"},{"id":"96545","messageId":"492D4F8E.10002@op5.se","threadId":"16474","inReplyTo":"492D37A2.4010500@googlemail.com","subject":"Re: suggestion? only pull cleanly applying commits","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-11-26T13:30:54Z","receivedAt":"2008-11-26T13:30:54Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Maximilian Mehnert wrote:\n> Hi!\n> \n> I've a scenario where I don't really want to do a full merge but rather\n> to pull all commits from another repository that merge without conflicts.\n> \n> I've put together the script at the bottom which seems to work ok but is\n> damn slow.\n> \n> Is there a smarter and faster way to do this that I missed reading the\n> documentation?\n> \n> Any help would be really appreciated! :-)\n> \n> Regards,\n> Maximilian\n> \n> \n> #!/bin/sh\n> \n> for commit in `git rev-list --reverse HEAD..other-repository/master`; do\n>         git diff-tree -p $commit|patch --dry-run -p1 -N -f >/dev/null\n>         if [ $? -eq 0 ]; then\n>                 echo \"getting $commit\"\n>                 parents=`git rev-list --parents -n1  $commit|wc -w`\n>                 if [ $parents -eq 2 ]; then\n>                         git cherry-pick $commit\n>                 else\n>                         git cherry-pick -m1 $commit\n>                 fi\n>         fi\n> done\n> \n\nThe fact that you're cherry-picking the commits means you create new\nones, constantly. It's very, very, very bad practice to do from a\nscript with commits you're getting from somewhere else. Git can (and\nwill) handle it properly come merge-day, but your history will be a\nstinking pile of horse-manure if you keep it up for very long.\n\nThere are more important questions, however.\n\n1. Why do you have to merge so often? Merging is something that should\n   not be undertaken lightly, and you shouldn't do it \"just to stay up\n   to date\".\n2. Why can't you just merge (resolving conflicts as they appear) when\n   you're done with what you're working on?\n\nRemember that \"conflict-free\" means totally different things depending\non which way you're looking at it. Upstream could rename a function\nthat you're using, and it would merge without *textual* conflicts, but\nyour stuff would be totally broken afterwards. Such design-scope\nconflicts can only be protected from with testing. Git will not handle\nthem for you.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"}]}