{"thread":{"id":"9457","subject":"Bug in git-svn: dcommit commits in the wrong branch after a rebase","startedAt":"2007-08-08T21:35:47Z","lastAt":"2007-08-09T15:46:03Z","messageCount":3,"participants":["Benoit SIGOURE","Steven Grimm"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"50326","messageId":"21FC6D7F-5459-406D-AA06-D16E525B3C17@lrde.epita.fr","threadId":"9457","inReplyTo":null,"subject":"Bug in git-svn: dcommit commits in the wrong branch after a rebase","fromName":"Benoit SIGOURE","fromEmail":"tsuna@lrde.epita.fr","sentAt":"2007-08-08T21:35:47Z","receivedAt":"2007-08-08T21:35:47Z","isPatch":false,"sender":{"key":"tsunanet@gmail.com","avatar":"https://avatars.githubusercontent.com/u/128281?v=4"},"body":"Hi,\nI was working with Git on a SVN branch `a' (say my Git branch is  \n`mya') and I wanted to create a new SVN branch `b' and dcommit my  \nchanges there for others (poor SVN users) to see.  So I did a svn cp  \nurl://a url://b to create the branch `b' in SVN, git-svn fetch to  \nimport this branch, git checkout -b myb b and then rebased mya and  \nthen did a dcommit.  Although the last commit at this point (in  \nbranch myb) had a svn-id \"pointing to\" the SVN branch b, dcommit sent  \nthe commits to the branch `a'.\n\nTest case:\n\nsvnadmin create repos\nsvn co file://`pwd`/repos wc\ncd wc\nsvn mkdir branches\nsvn mkdir branches/a\necho foo >branches/a/foo\nsvn add branches/a/foo\nsvn ci -m 'branch a'\ncd ..\ngit-svn clone --branches=branches file://`pwd`/repos wc.git\ncd wc.git\necho git is cool >>foo\ngit-commit -a -m 'commit in git in branch a'\ncd ../wc\nsvn cp branches/a branches/b\nsvn ci -m 'branch b'\ncd ../wc.git\ngit-svn fetch\ngit-checkout -b myb b\ngit-rebase master\ngit-svn dcommit # sends the commit to SVN branch `a' instead of SVN  \nbranch `b'!\n\nTemporary workaround (in case someone finds this post after stumbling  \non this problem):\nsvn mv branches/a branches/tmp\n<commit>\nsvn mv branches/b branches/a\n<commit>\nsvn mv branches/tmp branches/b\n<commit>\n\nAfter this, git-svn fetch will slightly complain but it will work  \nnevertheless.\n\nFound possible branch point: url://repo/branches/a => url://repo/ \nbranches/tmp, <N>\nFound branch parent: (b) <sha1>\nFollowing parent with do_switch\nSuccessfully followed parent\nr<N> = <sha1> (b)\nFound possible branch point: url://repo/branches/b => url://repo/ \nbranches/a, <N+1>\nFound branch parent: (a) <sha1-X>\nIndex mismatch: <sha1> != <sha1>\nrereading <sha1-X>\nFollowing parent with do_switch\nSuccessfully followed parent\nr<N+1> = <sha1> (a)\n[...]\n\nDespite the `Index mismatch' sort of warning, the Git repo seems to  \nbe correct.\n\nCheers,\n\nPS: I use git version 1.5.3.rc3.25.gf9208-dirty\n\n-- \nBenoit Sigoure aka Tsuna\nEPITA Research and Development Laboratory\n\n\n"},{"id":"50327","messageId":"6E86FCDA-F2A9-4516-8CE7-E1CC385FA9E2@lrde.epita.fr","threadId":"9457","inReplyTo":"21FC6D7F-5459-406D-AA06-D16E525B3C17@lrde.epita.fr","subject":"Re: Bug in git-svn: dcommit commits in the wrong branch after a rebase","fromName":"Benoit SIGOURE","fromEmail":"tsuna@lrde.epita.fr","sentAt":"2007-08-09T15:45:38Z","receivedAt":"2007-08-09T15:45:38Z","isPatch":false,"sender":{"key":"tsunanet@gmail.com","avatar":"https://avatars.githubusercontent.com/u/128281?v=4"},"body":"On Aug 8, 2007, at 11:35 PM, Benoit SIGOURE wrote:\n\n> Test case:\n>\n> svnadmin create repos\n> svn co file://`pwd`/repos wc\n> cd wc\n> svn mkdir branches\n> svn mkdir branches/a\n> echo foo >branches/a/foo\n> svn add branches/a/foo\n> svn ci -m 'branch a'\n> cd ..\n> git-svn clone --branches=branches file://`pwd`/repos wc.git\n> cd wc.git\n> echo git is cool >>foo\n> git-commit -a -m 'commit in git in branch a'\n> cd ../wc\n> svn cp branches/a branches/b\n> svn ci -m 'branch b'\n> cd ../wc.git\n> git-svn fetch\n\n\n> git-checkout -b myb b\n> git-rebase master\n> git-svn dcommit # sends the commit to SVN branch `a' instead of SVN  \n> branch `b'!\n>\n\nActually the test case is wrong, it should end in:\ngit-rebase b # while being on `master' branch\ngit-svn dcommit # this works as expected\n\nThanks to siprbaum for spotting this on IRC.  Sorry for the noise.\n\n-- \nBenoit Sigoure aka Tsuna\nEPITA Research and Development Laboratory\n\n\n"},{"id":"50328","messageId":"46BB36BB.4030708@midwinter.com","threadId":"9457","inReplyTo":"21FC6D7F-5459-406D-AA06-D16E525B3C17@lrde.epita.fr","subject":"Re: Bug in git-svn: dcommit commits in the wrong branch after a rebase","fromName":"Steven Grimm","fromEmail":"koreth@midwinter.com","sentAt":"2007-08-09T15:46:03Z","receivedAt":"2007-08-09T15:46:03Z","isPatch":false,"sender":{"key":"koreth@midwinter.com","avatar":"https://gravatar.com/avatar/71b4d2e8b62f168bdc9e9205341159e3567003b4f9e2127c617c5fa0a1f5bad2?d=mp&s=160"},"body":"Benoit SIGOURE wrote:\n> git-svn fetch\n> git-checkout -b myb b\n> git-rebase master\n> git-svn dcommit # sends the commit to SVN branch `a' instead of SVN \n> branch `b'!\n\nThat's exactly what I would expect to happen. The \"git-rebase\" is the \nkey here; it is effectively telling git to switch back to your master \nbranch. Try running \"git log\" before and after the rebase command and \nyou should get a slightly better idea of what's happening. Rebase is \nkind of a tricky beast; a basic rule of thumb is that you should only \nuse it to go forward in time on a single upstream branch, not to hop \nbetween upstream branches. Its behavior in non-forward-in-time cases is \npredictable once you know how it works, but not necessarily intuitive.\n\nWhat are you expecting rebase to do here? We can probably suggest some \nother commands that will do what you're hoping to do. My hunch is that \nyou're trying to use it to effectively do a merge of your \"a\" and \"b\" \nbranches, but maybe I'm wrong about that.\n\n-Steve\n"}]}