Grafting mis-aligned trees.
I haven't gotten a response from my subscription email, so please CC me on any replies.
So, I've been managaing the source I had from a client project in git and have a non-linear history. Currently, two tips (production and testing) but there are many feature branches that were git-merge'd in, not rebased.
Now, I've gotten the full tree. Turns out all the source code I was working on was in a subdirectory "project/web". I'd like to "graft" the *changes* I made onto the full tree.
I figured this might be a job for git-filter-branch. Certainly, that did the job of moving all my changes into the subdirectory. But, now I want to do something that's a combination or git-rebase and git-filter-branch. I want to replay the *patches/deltas* (like rebase) on top of the full tree I have, but *maintain the non-liear history* (like filter-branch).
Can anyone think of a recipe for me?
Trees look something like this right now.
<some history> -> FT
TI -> <non-linear history> -> A -> <non-linear history> -> C
\ \ \
-> PI ------------------------> B ------------------------> DI'd like to have it look something like:
<some history> -> FT -> <non-linear history> -> A' -> <non-linear history> -> C'
\ \ \
-> PI' ----------------------> B' -----------------------> D'A', B', C', and D' are different commits, but the diff (and history) between FT and A' is the same as the diff (and history) between TI and A.
Again, please CC me on any replies.
Signature · 4 lines
Boyd Stephen Smith Jr. ,= ,-_-. =. [email protected] ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.org/ \_/
Boyd Stephen Smith Jr. venit, vidit, dixit 17.11.2008 23:45:
Quoted 28 lines
I haven't gotten a response from my subscription email, so please CC me on any replies.
So, I've been managaing the source I had from a client project in git and have a non-linear history. Currently, two tips (production and testing) but there are many feature branches that were git-merge'd in, not rebased.
Now, I've gotten the full tree. Turns out all the source code I was working on was in a subdirectory "project/web". I'd like to "graft" the *changes* I made onto the full tree.
I figured this might be a job for git-filter-branch. Certainly, that did the job of moving all my changes into the subdirectory. But, now I want to do something that's a combination or git-rebase and git-filter-branch. I want to replay the *patches/deltas* (like rebase) on top of the full tree I have, but *maintain the non-liear history* (like filter-branch).
Can anyone think of a recipe for me?
Trees look something like this right now.
<some history> -> FT
TI -> <non-linear history> -> A -> <non-linear history> -> C
\ \ \ -> PI ------------------------> B ------------------------> DI'd like to have it look something like:
Quoted 8 lines
<some history> -> FT -> <non-linear history> -> A' -> <non-linear history> -> C'
\ \ \ -> PI' ----------------------> B' -----------------------> D'A', B', C', and D' are different commits, but the diff (and history) between FT and A' is the same as the diff (and history) between TI and A.
Again, please CC me on any replies.
[CCing is customary here anyways.]
So, your base directory for TI and FT is different, right? I.e.: In the TI repo, your project sits at the root, whereas in the FT repo it sits in project/web? Has FT advanced since you took the initial subdir snapshot for TI?
Michael
Quoted 38 lines · Michael J Gruber
Boyd Stephen Smith Jr. venit, vidit, dixit 17.11.2008 23:45:
Quoted 37 lines
I haven't gotten a response from my subscription email, so please CC me on any replies.
So, I've been managaing the source I had from a client project in git and have a non-linear history. Currently, two tips (production and testing) but there are many feature branches that were git-merge'd in, not rebased.
Now, I've gotten the full tree. Turns out all the source code I was working on was in a subdirectory "project/web". I'd like to "graft" the *changes* I made onto the full tree.
I figured this might be a job for git-filter-branch. Certainly, that did the job of moving all my changes into the subdirectory. But, now I want to do something that's a combination or git-rebase and git-filter-branch.
I want to replay the *patches/deltas* (like rebase) on top of the full
tree I have, but *maintain the non-liear history* (like filter-branch).Can anyone think of a recipe for me?
Trees look something like this right now.
<some history> -> FT
TI -> <non-linear history> -> A -> <non-linear history> -> C
\ \ \ -> PI ------------------------> B ------------------------> DI'd like to have it look something like:
<some history> -> FT -> <non-linear history> -> A' -> <non-linear
history> -> C' \ \ \
-> PI' ----------------------> B' -----------------------> D'A', B', C', and D' are different commits, but the diff (and history) between FT and A' is the same as the diff (and history) between TI and A.
Quoted 7 lines
Quoted 1 line
Again, please CC me on any replies.
[CCing is customary here anyways.]
So, your base directory for TI and FT is different, right? I.e.: In the TI repo, your project sits at the root, whereas in the FT repo it sits in project/web?
Yes.
Quoted 2 lines
Has FT advanced since you took the initial subdir
snapshot for TI?
No. Well, maybe. I think the subdir diff is fairly trivial if not empty. TI is an import from the code actually present on the testing server. FT was the a subversion repository obtained later after some hullabaloo with the ex-development house.
Right now this tree is effectively all mine, so I can always graft in commits to synchronize the common subtree of FT and TI, if that makes things easier.
Signature · 4 lines
Boyd Stephen Smith Jr. ,= ,-_-. =. [email protected] ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.org/ \_/
Boyd Stephen Smith Jr. venit, vidit, dixit 29.11.2008 00:01:
Quoted 51 lines · Michael J Gruber
Quoted 38 lines
Boyd Stephen Smith Jr. venit, vidit, dixit 17.11.2008 23:45:
Quoted 37 lines
I haven't gotten a response from my subscription email, so please CC me on any replies.
So, I've been managaing the source I had from a client project in git and have a non-linear history. Currently, two tips (production and testing) but there are many feature branches that were git-merge'd in, not rebased.
Now, I've gotten the full tree. Turns out all the source code I was working on was in a subdirectory "project/web". I'd like to "graft" the *changes* I made onto the full tree.
I figured this might be a job for git-filter-branch. Certainly, that did the job of moving all my changes into the subdirectory. But, now I want to do something that's a combination or git-rebase and git-filter-branch.
I want to replay the *patches/deltas* (like rebase) on top of the full
tree I have, but *maintain the non-liear history* (like filter-branch).Can anyone think of a recipe for me?
Trees look something like this right now.
<some history> -> FT
TI -> <non-linear history> -> A -> <non-linear history> -> C
\ \ \ -> PI ------------------------> B ------------------------> DI'd like to have it look something like:
<some history> -> FT -> <non-linear history> -> A' -> <non-linear
history> -> C' \ \ \
-> PI' ----------------------> B' -----------------------> D'A', B', C', and D' are different commits, but the diff (and history) between FT and A' is the same as the diff (and history) between TI and A.
Quoted 6 lines
Quoted 1 line
Again, please CC me on any replies.
[CCing is customary here anyways.]
So, your base directory for TI and FT is different, right? I.e.: In the TI repo, your project sits at the root, whereas in the FT repo it sits in project/web?
Yes.
Quoted 2 lines
Has FT advanced since you took the initial subdir
snapshot for TI?
Quoted 7 lines
No. Well, maybe. I think the subdir diff is fairly trivial if not empty. TI is an import from the code actually present on the testing server. FT was the a subversion repository obtained later after some hullabaloo with the ex-development house.
Right now this tree is effectively all mine, so I can always graft in commits to synchronize the common subtree of FT and TI, if that makes things easier.
OK, here's a possibly primitive solution, but it works with my little toy model of your layout:
- filter-branch your TI branches so that they are in the proper subdir (you did that already)
- take a snapshot (say ftstuff.tar) of everything in FT's head (assuming this is where TI branched off, or else take that point) *but exclude project/web*
- using filter-branch again, rewrite your TI branches to contain those missing FT files:
git filter-branch --tree-filter 'tar -xf /tmp/ftstuff.tar && git add .' -f -- ti/master ti/whatever
Now your TI branches produce the same diffs as before, but are based on the full tree. You can happily graft FT's head onto TI's root as a parent. In fact those two should produce no diff in between them, so you might as well get rid of one of them.
[cleaning out refs/original and repack -adf might be in order afterwards]
The tree-filter part feels hacky but does the job (probably with -f). I don't think a subtree merge can do what you want.
Cheers,
Michael
On Tuesday 02 December 2008, Michael J Gruber <[email protected]> wrote about 'Re: Grafting mis-aligned trees.':
Quoted 27 lines
Boyd Stephen Smith Jr. venit, vidit, dixit 29.11.2008 00:01:
Quoted 26 lines · Michael J Gruber
Quoted 15 lines
Boyd Stephen Smith Jr. venit, vidit, dixit 17.11.2008 23:45:
Quoted 14 lines
Trees look something like this right now.
<some history> -> FT
TI -> <non-linear history> -> A -> <non-linear history> -> C
\ \ \ -> PI ------------------------> B ------------------------> DI'd like to have it look something like:
<some history> -> FT -> <non-linear history> -> A' -> <non-linear
history> -> C' \ \
\ -> PI' ----------------------> B' -----------------------> D'Quoted 7 lines
Quoted 3 lines
A', B', C', and D' are different commits, but the diff (and history) between FT and A' is the same as the diff (and history) between TI and A.
So, your base directory for TI and FT is different, right? I.e.: In the TI repo, your project sits at the root, whereas in the FT repo it sits in project/web?
Yes.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Has FT advanced since you took the initial subdir
snapshot for TI?No.
OK, here's a possibly primitive solution, but it works with my little toy model of your layout:
That sounds like it will work fine. Thank you very much.
It does feel a bit "hacky", I was hoping git would have better support this, through the subtree merge or something else. It seems like something that might happen to others, perhaps as a side-effect of a failed attempt at using submodules.
I can't help thinking that rebase -ip might have helped. I wasn't aware of -p when I was initially working on this problem. (It doesn't help that I generally use Debian stable, and git 1.4 did not have -p.)
Quoted 2 lines
- filter-branch your TI branches so that they are in the proper subdir (you did that already)
If I need to "undo" this, it's really easy.
Quoted 8 lines
- take a snapshot (say ftstuff.tar) of everything in FT's head (assuming this is where TI branched off, or else take that point) *but exclude project/web*
- using filter-branch again, rewrite your TI branches to contain those missing FT files:
git filter-branch --tree-filter 'tar -xf/tmp/ftstuff.tar&& git add .' -f -- ti/master ti/whatever
I probably don't need the -f. If there are files that should be ignored (and thus shouldn't be in the repo), I'll filter-branch to cut them out of the history at some point.
Now is as good a time as any.
Quoted 4 lines
Now your TI branches produce the same diffs as before, but are based on the full tree. You can happily graft FT's head onto TI's root as a parent. In fact those two should produce no diff in between them, so you might as well get rid of one of them.
Makes sense.
Quoted 1 line
[cleaning out refs/original and repack -adf might be in order afterwards]
I generally do these after a successful filter-branch.
Quoted 2 lines
The tree-filter part feels hacky but does the job (probably with -f). I don't think a subtree merge can do what you want.
What *exactly* is the subtree merge. The documentation I've read sounds like this case, sort of, but it's rather unclear to me.
Signature · 4 lines
Boyd Stephen Smith Jr. ,= ,-_-. =. [email protected] ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.org/ \_/
Boyd Stephen Smith Jr. venit, vidit, dixit 02.12.2008 18:19:
...
Quoted 4 lines
It does feel a bit "hacky", I was hoping git would have better support this, through the subtree merge or something else. It seems like something that might happen to others, perhaps as a side-effect of a failed attempt at using submodules.
Well, except for 'tar' my solution uses only git commands ;)
Quoted 3 lines
I can't help thinking that rebase -ip might have helped. I wasn't aware of -p when I was initially working on this problem. (It doesn't help that I generally use Debian stable, and git 1.4 did not have -p.)
rebase rebases one branch at a time, but you need to rebase/rewrite several, and the merge info between depends on rewritten sha1s.
...
Quoted 3 lines
I probably don't need the -f. If there are files that should be ignored (and thus shouldn't be in the repo), I'll filter-branch to cut them out of the history at some point.
'-f' is about not having to clean out refs/original from a previous filter-branch run.
Quoted 2 lines
What *exactly* is the subtree merge. The documentation I've read sounds like this case, sort of, but it's rather unclear to me.
I think 'subtree' does what you want, but 'merge' doesn't! 'subtree' saves you the rewriting (putting TI into project/web), but you want a one-time conversion anyway. 'subtree' allows you to repeatedly merge branches with a different root. What it does is it looks for subdir, 'rewrites' the incoming tree automatically and merges the result.
But you don't want a merge, do you? Or else your whole TI history would be tacked onto FT's head "to the left": a new (subtree) merge commit would have FT's and TI's head as parents. This is one way of storing TI history in the full repo, but not the one you said you wanted.
Michael
On Tuesday 02 December 2008, Michael J Gruber <[email protected]> wrote about 'Re: Grafting mis-aligned trees.':
Quoted 7 lines
Boyd Stephen Smith Jr. venit, vidit, dixit 02.12.2008 18:19:
Quoted 3 lines
I can't help thinking that rebase -ip might have helped. I wasn't aware of -p when I was initially working on this problem. (It doesn't help that I generally use Debian stable, and git 1.4 did not have -p.)
rebase rebases one branch at a time, but you need to rebase/rewrite several, and the merge info between depends on rewritten sha1s.
Yes. I guess that's why I employed filter-branch to begin with.
Quoted 6 lines
Quoted 3 lines
I probably don't need the -f. If there are files that should be ignored (and thus shouldn't be in the repo), I'll filter-branch to cut them out of the history at some point.
'-f' is about not having to clean out refs/original from a previous filter-branch run.
Okay, I misread your command line. For some reason I thought "-f" was an option to add.
Quoted 4 lines
Quoted 2 lines
What *exactly* is the subtree merge. The documentation I've read sounds like this case, sort of, but it's rather unclear to me.
I think 'subtree' does what you want, but 'merge' doesn't!
*giggle* I'm not quite sure what makes this funny to me, but it made me laugh.
Quoted 10 lines
'subtree'
saves you the rewriting (putting TI into project/web), but you want a one-time conversion anyway. 'subtree' allows you to repeatedly merge branches with a different root. What it does is it looks for subdir, 'rewrites' the incoming tree automatically and merges the result.But you don't want a merge, do you? Or else your whole TI history would be tacked onto FT's head "to the left": a new (subtree) merge commit would have FT's and TI's head as parents. This is one way of storing TI history in the full repo, but not the one you said you wanted.
You are right; that's not what I want. But, it is a good second-place result that I'll keep in mind. Sometimes keeping the history at all is more important that keeping the history orderly.
Again, thanks for the help.
Signature · 4 lines
Boyd Stephen Smith Jr. ,= ,-_-. =. [email protected] ((_/)o o(\_)) ICQ: 514984 YM/AIM: DaTwinkDaddy `-'(. .)`-' http://iguanasuicide.org/ \_/