{"thread":{"id":"16374","subject":"Grafting mis-aligned trees.","startedAt":"2008-11-17T22:45:12Z","lastAt":"2008-12-02T18:28:06Z","messageCount":7,"participants":["Boyd Stephen Smith Jr.","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"96066","messageId":"200811171645.12869.bss03@volumehost.net","threadId":"16374","inReplyTo":null,"subject":"Grafting mis-aligned trees.","fromName":"Boyd Stephen Smith Jr.","fromEmail":"bss03@volumehost.net","sentAt":"2008-11-17T22:45:12Z","receivedAt":"2008-11-17T22:45:12Z","isPatch":false,"sender":{"key":"bss03@volumehost.net","avatar":"https://gravatar.com/avatar/74fa10b37dfd44462a6a30c4d4e3bda26ab7991ddb0d8ab24b022714a8ecb918?d=mp&s=160"},"body":"I haven't gotten a response from my subscription email, so please CC me on any replies.\n\nSo, I've been managaing the source I had from a client project in git and \nhave a non-linear history.  Currently, two tips (production and testing) \nbut there are many feature branches that were git-merge'd in, not rebased.\n\nNow, I've gotten the full tree.  Turns out all the source code I was \nworking on was in a subdirectory \"project/web\".  I'd like to \"graft\" the \n*changes* I made onto the full tree.\n\nI figured this might be a job for git-filter-branch.  Certainly, that did \nthe job of moving all my changes into the subdirectory.  But, now I want to \ndo something that's a combination or git-rebase and git-filter-branch.  I \nwant to replay the *patches/deltas* (like rebase) on top of the full tree I \nhave, but *maintain the non-liear history* (like filter-branch).\n\nCan anyone think of a recipe for me?\n\nTrees look something like this right now.\n\n<some history> -> FT\n\nTI -> <non-linear history> -> A -> <non-linear history> -> C\n   \\                            \\                           \\\n    -> PI ------------------------> B ------------------------> D\n\nI'd like to have it look something like:\n\n<some history> -> FT -> <non-linear history> -> A' -> <non-linear history> -> C'\n                    \\                            \\                           \\\n                     -> PI' ----------------------> B' -----------------------> D'\n\nA', B', C', and D' are different commits, but the diff (and history) between \nFT and A' is the same as the diff (and history) between TI and A.\n\nAgain, please CC me on any replies.\n-- \nBoyd Stephen Smith Jr.                     ,= ,-_-. =. \nbss03@volumehost.net                      ((_/)o o(\\_))\nICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' \nhttp://iguanasuicide.org/                      \\_/     \n"},{"id":"96077","messageId":"492289B0.4010903@drmicha.warpmail.net","threadId":"16374","inReplyTo":"200811171645.12869.bss03@volumehost.net","subject":"Re: Grafting mis-aligned trees.","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2008-11-18T09:24:00Z","receivedAt":"2008-11-18T09:24:00Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Boyd Stephen Smith Jr. venit, vidit, dixit 17.11.2008 23:45:\n> I haven't gotten a response from my subscription email, so please CC me on any replies.\n> \n> So, I've been managaing the source I had from a client project in git and \n> have a non-linear history.  Currently, two tips (production and testing) \n> but there are many feature branches that were git-merge'd in, not rebased.\n> \n> Now, I've gotten the full tree.  Turns out all the source code I was \n> working on was in a subdirectory \"project/web\".  I'd like to \"graft\" the \n> *changes* I made onto the full tree.\n> \n> I figured this might be a job for git-filter-branch.  Certainly, that did \n> the job of moving all my changes into the subdirectory.  But, now I want to \n> do something that's a combination or git-rebase and git-filter-branch.  I \n> want to replay the *patches/deltas* (like rebase) on top of the full tree I \n> have, but *maintain the non-liear history* (like filter-branch).\n> \n> Can anyone think of a recipe for me?\n> \n> Trees look something like this right now.\n> \n> <some history> -> FT\n> \n> TI -> <non-linear history> -> A -> <non-linear history> -> C\n>    \\                            \\                           \\\n>     -> PI ------------------------> B ------------------------> D\n> \n> I'd like to have it look something like:\n> \n> <some history> -> FT -> <non-linear history> -> A' -> <non-linear history> -> C'\n>                     \\                            \\                           \\\n>                      -> PI' ----------------------> B' -----------------------> D'\n> \n> A', B', C', and D' are different commits, but the diff (and history) between \n> FT and A' is the same as the diff (and history) between TI and A.\n> \n> Again, please CC me on any replies.\n\n[CCing is customary here anyways.]\n\nSo, your base directory for TI and FT is different, right? I.e.: In the\nTI repo, your project sits at the root, whereas in the FT repo it sits\nin project/web? Has FT advanced since you took the initial subdir\nsnapshot for TI?\n\nMichael\n"},{"id":"96701","messageId":"200811281701.46778.bss03@volumehost.net","threadId":"16374","inReplyTo":"492289B0.4010903@drmicha.warpmail.net","subject":"Re: Grafting mis-aligned trees.","fromName":"Boyd Stephen Smith Jr.","fromEmail":"bss03@volumehost.net","sentAt":"2008-11-28T23:01:41Z","receivedAt":"2008-11-28T23:01:41Z","isPatch":false,"sender":{"key":"bss03@volumehost.net","avatar":"https://gravatar.com/avatar/74fa10b37dfd44462a6a30c4d4e3bda26ab7991ddb0d8ab24b022714a8ecb918?d=mp&s=160"},"body":"On Tuesday 2008 November 18 03:24, Michael J Gruber wrote:\n> Boyd Stephen Smith Jr. venit, vidit, dixit 17.11.2008 23:45:\n> > I haven't gotten a response from my subscription email, so please CC me\n> > on any replies.\n> >\n> > So, I've been managaing the source I had from a client project in git and\n> > have a non-linear history.  Currently, two tips (production and testing)\n> > but there are many feature branches that were git-merge'd in, not\n> > rebased.\n> >\n> > Now, I've gotten the full tree.  Turns out all the source code I was\n> > working on was in a subdirectory \"project/web\".  I'd like to \"graft\" the\n> > *changes* I made onto the full tree.\n> >\n> > I figured this might be a job for git-filter-branch.  Certainly, that did\n> > the job of moving all my changes into the subdirectory.  But, now I want\n> > to do something that's a combination or git-rebase and git-filter-branch.\n> >  I want to replay the *patches/deltas* (like rebase) on top of the full\n> > tree I have, but *maintain the non-liear history* (like filter-branch).\n> >\n> > Can anyone think of a recipe for me?\n> >\n> > Trees look something like this right now.\n> >\n> > <some history> -> FT\n> >\n> > TI -> <non-linear history> -> A -> <non-linear history> -> C\n> >    \\                            \\                           \\\n> >     -> PI ------------------------> B ------------------------> D\n> >\n> > I'd like to have it look something like:\n> >\n> > <some history> -> FT -> <non-linear history> -> A' -> <non-linear\n> > history> -> C' \\                            \\                           \\\n> > -> PI' ----------------------> B' -----------------------> D'\n> >\n> > A', B', C', and D' are different commits, but the diff (and history)\n> > between FT and A' is the same as the diff (and history) between TI and A.\n> >\n> > Again, please CC me on any replies.\n>\n> [CCing is customary here anyways.]\n>\n> So, your base directory for TI and FT is different, right? I.e.: In the\n> TI repo, your project sits at the root, whereas in the FT repo it sits\n> in project/web?\n\nYes.\n\n> Has FT advanced since you took the initial subdir \n> snapshot for TI?\n\nNo.  Well, maybe.  I think the subdir diff is fairly trivial if not empty.  TI \nis an import from the code actually present on the testing server.  FT was \nthe a subversion repository obtained later after some hullabaloo with the \nex-development house.\n\nRight now this tree is effectively all mine, so I can always graft in commits \nto synchronize the common subtree of FT and TI, if that makes things easier.\n-- \nBoyd Stephen Smith Jr.                     ,= ,-_-. =. \nbss03@volumehost.net                      ((_/)o o(\\_))\nICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' \nhttp://iguanasuicide.org/                      \\_/     \n"},{"id":"96960","messageId":"4935606A.8050906@drmicha.warpmail.net","threadId":"16374","inReplyTo":"200811281701.46778.bss03@volumehost.net","subject":"Re: Grafting mis-aligned trees.","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2008-12-02T16:20:58Z","receivedAt":"2008-12-02T16:20:58Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Boyd Stephen Smith Jr. venit, vidit, dixit 29.11.2008 00:01:\n> On Tuesday 2008 November 18 03:24, Michael J Gruber wrote:\n>> Boyd Stephen Smith Jr. venit, vidit, dixit 17.11.2008 23:45:\n>>> I haven't gotten a response from my subscription email, so please CC me\n>>> on any replies.\n>>>\n>>> So, I've been managaing the source I had from a client project in git and\n>>> have a non-linear history.  Currently, two tips (production and testing)\n>>> but there are many feature branches that were git-merge'd in, not\n>>> rebased.\n>>>\n>>> Now, I've gotten the full tree.  Turns out all the source code I was\n>>> working on was in a subdirectory \"project/web\".  I'd like to \"graft\" the\n>>> *changes* I made onto the full tree.\n>>>\n>>> I figured this might be a job for git-filter-branch.  Certainly, that did\n>>> the job of moving all my changes into the subdirectory.  But, now I want\n>>> to do something that's a combination or git-rebase and git-filter-branch.\n>>>  I want to replay the *patches/deltas* (like rebase) on top of the full\n>>> tree I have, but *maintain the non-liear history* (like filter-branch).\n>>>\n>>> Can anyone think of a recipe for me?\n>>>\n>>> Trees look something like this right now.\n>>>\n>>> <some history> -> FT\n>>>\n>>> TI -> <non-linear history> -> A -> <non-linear history> -> C\n>>>    \\                            \\                           \\\n>>>     -> PI ------------------------> B ------------------------> D\n>>>\n>>> I'd like to have it look something like:\n>>>\n>>> <some history> -> FT -> <non-linear history> -> A' -> <non-linear\n>>> history> -> C' \\                            \\                           \\\n>>> -> PI' ----------------------> B' -----------------------> D'\n>>>\n>>> A', B', C', and D' are different commits, but the diff (and history)\n>>> between FT and A' is the same as the diff (and history) between TI and A.\n>>>\n>>> Again, please CC me on any replies.\n>> [CCing is customary here anyways.]\n>>\n>> So, your base directory for TI and FT is different, right? I.e.: In the\n>> TI repo, your project sits at the root, whereas in the FT repo it sits\n>> in project/web?\n> \n> Yes.\n> \n>> Has FT advanced since you took the initial subdir \n>> snapshot for TI?\n> \n> No.  Well, maybe.  I think the subdir diff is fairly trivial if not empty.  TI \n> is an import from the code actually present on the testing server.  FT was \n> the a subversion repository obtained later after some hullabaloo with the \n> ex-development house.\n> \n> Right now this tree is effectively all mine, so I can always graft in commits \n> to synchronize the common subtree of FT and TI, if that makes things easier.\n\nOK, here's a possibly primitive solution, but it works with my little\ntoy model of your layout:\n\n- filter-branch your TI branches so that they are in the proper subdir\n(you did that already)\n\n- take a snapshot (say ftstuff.tar) of everything in FT's head (assuming\nthis is where TI branched off, or else take that point) *but exclude\nproject/web*\n\n- using filter-branch again, rewrite your TI branches to contain those\nmissing FT files:\ngit filter-branch --tree-filter 'tar -xf /tmp/ftstuff.tar && git add .'\n-f -- ti/master ti/whatever\n\nNow your TI branches produce the same diffs as before, but are based on\nthe full tree. You can happily graft FT's head onto TI's root as a parent.\nIn fact those two should produce no diff in between them, so you might\nas well get rid of one of them.\n\n[cleaning out refs/original and repack -adf might be in order afterwards]\n\nThe tree-filter part feels hacky but does the job (probably with -f). I\ndon't think a subtree merge can do what you want.\n\nCheers,\nMichael\n"},{"id":"96967","messageId":"200812021119.51857.bss03@volumehost.net","threadId":"16374","inReplyTo":"4935606A.8050906@drmicha.warpmail.net","subject":"Re: Grafting mis-aligned trees.","fromName":"Boyd Stephen Smith Jr.","fromEmail":"bss03@volumehost.net","sentAt":"2008-12-02T17:19:46Z","receivedAt":"2008-12-02T17:19:46Z","isPatch":false,"sender":{"key":"bss03@volumehost.net","avatar":"https://gravatar.com/avatar/74fa10b37dfd44462a6a30c4d4e3bda26ab7991ddb0d8ab24b022714a8ecb918?d=mp&s=160"},"body":"On Tuesday 02 December 2008, Michael J Gruber <git@drmicha.warpmail.net> \nwrote about 'Re: Grafting mis-aligned trees.':\n>Boyd Stephen Smith Jr. venit, vidit, dixit 29.11.2008 00:01:\n>> On Tuesday 2008 November 18 03:24, Michael J Gruber wrote:\n>>> Boyd Stephen Smith Jr. venit, vidit, dixit 17.11.2008 23:45:\n>>>> Trees look something like this right now.\n>>>>\n>>>> <some history> -> FT\n>>>>\n>>>> TI -> <non-linear history> -> A -> <non-linear history> -> C\n>>>>    \\                            \\                           \\\n>>>>     -> PI ------------------------> B ------------------------> D\n>>>>\n>>>> I'd like to have it look something like:\n>>>>\n>>>> <some history> -> FT -> <non-linear history> -> A' -> <non-linear\n>>>> history> -> C' \\                            \\                        \n>>>>   \\ -> PI' ----------------------> B' -----------------------> D'\n>>>>\n>>>> A', B', C', and D' are different commits, but the diff (and history)\n>>>> between FT and A' is the same as the diff (and history) between TI\n>>>> and A.\n>>>\n>>> So, your base directory for TI and FT is different, right? I.e.: In\n>>> the TI repo, your project sits at the root, whereas in the FT repo it\n>>> sits in project/web?\n>>\n>> Yes.\n>>\n>>> Has FT advanced since you took the initial subdir\n>>> snapshot for TI?\n>>\n>> No.\n>\n>OK, here's a possibly primitive solution, but it works with my little\n>toy model of your layout:\n\nThat sounds like it will work fine.  Thank you very much.\n\nIt does feel a bit \"hacky\", I was hoping git would have better support \nthis, through the subtree merge or something else.  It seems like \nsomething that might happen to others, perhaps as a side-effect of a \nfailed attempt at using submodules.\n\nI can't help thinking that rebase -ip might have helped.  I wasn't aware \nof -p when I was initially working on this problem.  (It doesn't help that \nI generally use Debian stable, and git 1.4 did not have -p.)\n\n>- filter-branch your TI branches so that they are in the proper subdir\n>(you did that already)\n\nIf I need to \"undo\" this, it's really easy.\n\n>- take a snapshot (say ftstuff.tar) of everything in FT's head (assuming\n>this is where TI branched off, or else take that point) *but exclude\n>project/web*\n>\n>- using filter-branch again, rewrite your TI branches to contain those\n>missing FT files:\n>git filter-branch --tree-filter 'tar -xf /tmp/ftstuff.tar && git add .'\n>-f -- ti/master ti/whatever\n\nI probably don't need the -f.  If there are files that should be ignored \n(and thus shouldn't be in the repo), I'll filter-branch to cut them out of \nthe history at some point.\n\nNow is as good a time as any.\n\n>Now your TI branches produce the same diffs as before, but are based on\n>the full tree. You can happily graft FT's head onto TI's root as a\n> parent. In fact those two should produce no diff in between them, so you\n> might as well get rid of one of them.\n\nMakes sense.\n\n>[cleaning out refs/original and repack -adf might be in order afterwards]\n\nI generally do these after a successful filter-branch.\n\n>The tree-filter part feels hacky but does the job (probably with -f). I\n>don't think a subtree merge can do what you want.\n\nWhat *exactly* is the subtree merge.  The documentation I've read sounds \nlike this case, sort of, but it's rather unclear to me.\n-- \nBoyd Stephen Smith Jr.                     ,= ,-_-. =. \nbss03@volumehost.net                      ((_/)o o(\\_))\nICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' \nhttp://iguanasuicide.org/                      \\_/     \n"},{"id":"96970","messageId":"493572A3.4070205@drmicha.warpmail.net","threadId":"16374","inReplyTo":"200812021119.51857.bss03@volumehost.net","subject":"Re: Grafting mis-aligned trees.","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2008-12-02T17:38:43Z","receivedAt":"2008-12-02T17:38:43Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Boyd Stephen Smith Jr. venit, vidit, dixit 02.12.2008 18:19:\n...\n> It does feel a bit \"hacky\", I was hoping git would have better support \n> this, through the subtree merge or something else.  It seems like \n> something that might happen to others, perhaps as a side-effect of a \n> failed attempt at using submodules.\n\nWell, except for 'tar' my solution uses only git commands ;)\n\n> I can't help thinking that rebase -ip might have helped.  I wasn't aware \n> of -p when I was initially working on this problem.  (It doesn't help that \n> I generally use Debian stable, and git 1.4 did not have -p.)\n\nrebase rebases one branch at a time, but you need to rebase/rewrite\nseveral, and the merge info between depends on rewritten sha1s.\n\n...\n> I probably don't need the -f.  If there are files that should be ignored \n> (and thus shouldn't be in the repo), I'll filter-branch to cut them out of \n> the history at some point.\n\n'-f' is about not having to clean out refs/original from a previous\nfilter-branch run.\n\n> What *exactly* is the subtree merge.  The documentation I've read sounds \n> like this case, sort of, but it's rather unclear to me.\n\nI think 'subtree' does what you want, but 'merge' doesn't! 'subtree'\nsaves you the rewriting (putting TI into project/web), but you want a\none-time conversion anyway. 'subtree' allows you to repeatedly merge\nbranches with a different root. What it does is it looks for subdir,\n'rewrites' the incoming tree automatically and merges the result.\n\nBut you don't want a merge, do you? Or else your whole TI history would\nbe tacked onto FT's head \"to the left\": a new (subtree) merge commit\nwould have FT's and TI's head as parents. This is one way of storing TI\nhistory in the full repo, but not the one you said you wanted.\n\nMichael\n"},{"id":"96974","messageId":"200812021228.07070.bss03@volumehost.net","threadId":"16374","inReplyTo":"493572A3.4070205@drmicha.warpmail.net","subject":"Re: Grafting mis-aligned trees.","fromName":"Boyd Stephen Smith Jr.","fromEmail":"bss03@volumehost.net","sentAt":"2008-12-02T18:28:06Z","receivedAt":"2008-12-02T18:28:06Z","isPatch":false,"sender":{"key":"bss03@volumehost.net","avatar":"https://gravatar.com/avatar/74fa10b37dfd44462a6a30c4d4e3bda26ab7991ddb0d8ab24b022714a8ecb918?d=mp&s=160"},"body":"On Tuesday 02 December 2008, Michael J Gruber <git@drmicha.warpmail.net> \nwrote about 'Re: Grafting mis-aligned trees.':\n>Boyd Stephen Smith Jr. venit, vidit, dixit 02.12.2008 18:19:\n>> I can't help thinking that rebase -ip might have helped.  I wasn't\n>> aware of -p when I was initially working on this problem.  (It doesn't\n>> help that I generally use Debian stable, and git 1.4 did not have -p.)\n>\n>rebase rebases one branch at a time, but you need to rebase/rewrite\n>several, and the merge info between depends on rewritten sha1s.\n\nYes.  I guess that's why I employed filter-branch to begin with.\n\n>> I probably don't need the -f.  If there are files that should be\n>> ignored (and thus shouldn't be in the repo), I'll filter-branch to cut\n>> them out of the history at some point.\n>\n>'-f' is about not having to clean out refs/original from a previous\n>filter-branch run.\n\nOkay, I misread your command line.  For some reason I thought \"-f\" was an \noption to add.\n\n>> What *exactly* is the subtree merge.  The documentation I've read\n>> sounds like this case, sort of, but it's rather unclear to me.\n>\n>I think 'subtree' does what you want, but 'merge' doesn't!\n\n*giggle*  I'm not quite sure what makes this funny to me, but it made me \nlaugh.\n\n>'subtree' \n>saves you the rewriting (putting TI into project/web), but you want a\n>one-time conversion anyway. 'subtree' allows you to repeatedly merge\n>branches with a different root. What it does is it looks for subdir,\n>'rewrites' the incoming tree automatically and merges the result.\n> \n>But you don't want a merge, do you? Or else your whole TI history would\n>be tacked onto FT's head \"to the left\": a new (subtree) merge commit\n>would have FT's and TI's head as parents. This is one way of storing TI\n>history in the full repo, but not the one you said you wanted.\n\nYou are right; that's not what I want.  But, it is a good second-place \nresult that I'll keep in mind.  Sometimes keeping the history at all is \nmore important that keeping the history orderly.\n\nAgain, thanks for the help.\n-- \nBoyd Stephen Smith Jr.                     ,= ,-_-. =. \nbss03@volumehost.net                      ((_/)o o(\\_))\nICQ: 514984 YM/AIM: DaTwinkDaddy           `-'(. .)`-' \nhttp://iguanasuicide.org/                      \\_/     \n"}]}