Re: nicer frontend to get rebased tree?

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Paolo Ciarrocchi <paolo.ciarrocchi@...>
Cc: Andi Kleen <andi@...>, Jakub Narebski <jnareb@...>, Avery Pennarun <apenwarr@...>, <git@...>
Date: Saturday, August 23, 2008 - 5:52 pm

On Sat, 23 Aug 2008, Paolo Ciarrocchi wrote:

No, you really really cannot do that.

If the _tree_ you are tracking is itself rebasing (not just your own 
tree), then you cannot and absolutely SHOULD NOT use rebase (not directly, 
and not with "git pull --rebase".

Why?

Let's look at what happens. Let's say that your history looks like

	... -> A -> B -> C -> a -> b -> c

where the upper-case letters are from the tree you track, and the 
lower-case letters are the commits you added yourself.

Now, let's say that the tree you track gets rebased, and in the process 
'B' is removed (because it turns out it was buggy), and A and C get 
modified. What happens?

You now have

	... -> A -> B -> C -> a -> b -> c     <- your branch
	  \
	    other stuff -> A' -> C'     <- newly rebased branch

(where "other stuff" is whatever the remote branch was rebased on top 
of) and when you now try to rebase your stuff on top of the newly rebased 
branch, you are going to end up trying to rebase all the _old_ commits 
that weren't even yours (ie it's going to try to rebase A, B and C too!)

And that's not what you want! It will potentially not only generate lots 
of conflicts (because A' and A aren't the same, and C' and C aren't the 
same), and it will actually re-insert B - which was buggy - before it 
finally gets to the commits _you_ actually did (a, b and c).

So no, you canno even sanely rebase on top of another persons rebased 
tree, because the _other_ person threw away his history, and since you 
remember their _old_ history, it's basically now you who are in charge of 
it.

What you can do is to basically do

	git fetch nasty-tree
	git rebase C.. --onto nasty-tree

ie you can explicitly _tell_ rebase which commits you want to rebase. 
Obviously, "git rebase --interactive" can help you do this (ie you can get 
the whole list and edit out all the crud that you know isn't yours).

But this is why working on top of somebody elses tree that gets rebased is 
so hard. You lose all the history, because the other person basically 
threw it away and started over.

Don't get me wrong - it's _possible_ to do. See above about how you can 
pick-and-choose the parts you decide you want to keep (your "own" stuff). 

In fact, we could even do a form of "rebase" that only picks commits that 
you committed yourself, and call it "git rebase --my-commits nasty-tree", 
and that would often do the right thing (assuming the source tree only 
ever rebases its own commits, of course! If it rebases other peoples 
commits, it's so terminally broken that you should just refuse to work 
with that tree, and shoot the maintainer)

So we could do more helper functions for this, but the fact is, it's a 
really broken model. The real fix is to teach people not to rebase.

			Linus
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
nicer frontend to get rebased tree?, Andi Kleen, (Fri Aug 22, 1:46 pm)
Re: nicer frontend to get rebased tree?, Mikael Magnusson, (Fri Aug 22, 4:11 pm)
Re: nicer frontend to get rebased tree?, Avery Pennarun, (Fri Aug 22, 1:56 pm)
Re: nicer frontend to get rebased tree?, Andi Kleen, (Fri Aug 22, 2:31 pm)
Re: nicer frontend to get rebased tree?, Jakub Narebski, (Fri Aug 22, 3:34 pm)
Re: nicer frontend to get rebased tree?, Andi Kleen, (Sat Aug 23, 3:15 am)
Re: nicer frontend to get rebased tree?, Jakub Narebski, (Sat Aug 23, 5:21 am)
Re: nicer frontend to get rebased tree?, Andi Kleen, (Sat Aug 23, 12:53 pm)
Re: nicer frontend to get rebased tree?, Theodore Tso, (Sat Aug 23, 7:01 pm)
Re: nicer frontend to get rebased tree?, Jakub Narebski, (Sat Aug 23, 6:49 pm)
Re: nicer frontend to get rebased tree?, Paolo Ciarrocchi, (Sat Aug 23, 5:04 pm)
Re: nicer frontend to get rebased tree?, Linus Torvalds, (Sat Aug 23, 5:52 pm)
Re: nicer frontend to get rebased tree?, Junio C Hamano, (Sat Aug 23, 8:30 pm)
Re: nicer frontend to get rebased tree?, Björn, (Sat Aug 23, 6:13 pm)
Re: nicer frontend to get rebased tree?, Paolo Ciarrocchi, (Sat Aug 23, 6:09 pm)
Re: nicer frontend to get rebased tree?, Paolo Ciarrocchi, (Fri Aug 22, 3:03 pm)
Re: nicer frontend to get rebased tree?, Linus Torvalds, (Fri Aug 22, 1:55 pm)
Re: nicer frontend to get rebased tree?, Andi Kleen, (Fri Aug 22, 2:27 pm)
Re: nicer frontend to get rebased tree?, Linus Torvalds, (Fri Aug 22, 3:36 pm)
Re: nicer frontend to get rebased tree?, Andi Kleen, (Sat Aug 23, 3:10 am)
Re: nicer frontend to get rebased tree?, Linus Torvalds, (Sat Aug 23, 11:55 am)
Re: nicer frontend to get rebased tree?, Andi Kleen, (Sat Aug 23, 12:45 pm)
Re: nicer frontend to get rebased tree?, Björn, (Sat Aug 23, 2:18 pm)
Re: nicer frontend to get rebased tree?, Linus Torvalds, (Sat Aug 23, 2:56 pm)
Re: Documentating branches, Marius Vollmer, (Sat Aug 23, 6:18 pm)
Re: Documenting branches, Marius Vollmer, (Sat Aug 23, 6:30 pm)
Re: nicer frontend to get rebased tree?, Björn, (Sat Aug 23, 4:08 pm)
Re: nicer frontend to get rebased tree?, Linus Torvalds, (Sat Aug 23, 1:58 pm)
Re: nicer frontend to get rebased tree?, Ingo Molnar, (Mon Aug 25, 5:36 am)
Re: nicer frontend to get rebased tree?, Paolo Bonzini, (Sat Aug 23, 5:24 am)
Re: nicer frontend to get rebased tree?, Andi Kleen, (Sat Aug 23, 12:36 pm)
Re: nicer frontend to get rebased tree?, Paolo Bonzini, (Sat Aug 23, 7:00 pm)
Re: nicer frontend to get rebased tree?, Junio C Hamano, (Fri Aug 22, 5:23 pm)
Re: nicer frontend to get rebased tree?, Linus Torvalds, (Fri Aug 22, 4:29 pm)
Re: nicer frontend to get rebased tree?, Paolo Ciarrocchi, (Fri Aug 22, 4:11 pm)
Re: nicer frontend to get rebased tree?, Björn, (Fri Aug 22, 4:36 pm)
Re: nicer frontend to get rebased tree?, Paolo Ciarrocchi, (Fri Aug 22, 4:46 pm)
Re: nicer frontend to get rebased tree?, Linus Torvalds, (Fri Aug 22, 4:33 pm)