git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Björn Steinbrink" <B.Steinbrink@gmx.de>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com>,
	Andi Kleen <andi@firstfloor.org>,
	Jakub Narebski <jnareb@gmail.com>,
	Avery Pennarun <apenwarr@gmail.com>,
	git@vger.kernel.org
Subject: Re: nicer frontend to get rebased tree?
Date: Sun, 24 Aug 2008 00:13:24 +0200	[thread overview]
Message-ID: <20080823221324.GA18472@atjola.homenet> (raw)
In-Reply-To: <alpine.LFD.1.10.0808231440530.3363@nehalem.linux-foundation.org>

On 2008.08.23 14:52:37 -0700, Linus Torvalds wrote:
> On Sat, 23 Aug 2008, Paolo Ciarrocchi wrote:
> >
> > you got nice and detailed answers,  for example you can track a
> > rebased tree in your working directory using git pull --rebase.
> > What's wrong with that?
> 
> 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!)

But before the fetch step, you have remote/branch point to your old
upstream. If "pull --rebase" remembers that and uses:

git rebase --onto remote/branch $old_upstream

That should work. And in fact, it actually seems to do that.

	exec git-rebase $strategy_args --onto $merge_head \
	${oldremoteref:-$merge_head}

With $oldremoteref being the remote tracking branch before the rebase.

That said, it seems very fragile. One "git fetch" and your upstream is
lost and the next "pull --rebase" will fail.

So a somewhat less fragile way to do it would be:

git checkout -b foo origin/foo
git branch foo-upstream
....
git fetch origin
git rebase --onto origin/foo foo-upstream
git branch -f foo-upstream origin/foo

So that you always have the current upstream for your branch available
and can thus do a correct rebase. That at least doesn't break on its
own, but still does when you forget to adjust your upstream reference.

I don't actually like the idea, but maybe a refs/upstreams namespace
could be used by some script to keep track of the current upstreams of
local branches and to help with such a workflow, if one really badly
wants to do that... *hides*

Björn

  parent reply	other threads:[~2008-08-23 22:14 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-22 17:46 nicer frontend to get rebased tree? Andi Kleen
2008-08-22 17:55 ` Linus Torvalds
2008-08-22 18:27   ` Andi Kleen
2008-08-22 19:36     ` Linus Torvalds
2008-08-22 20:11       ` Paolo Ciarrocchi
2008-08-22 20:33         ` Linus Torvalds
2008-08-22 20:36         ` Björn Steinbrink
2008-08-22 20:46           ` Paolo Ciarrocchi
2008-08-22 20:29       ` Linus Torvalds
2008-08-22 21:23       ` Junio C Hamano
2008-08-23  7:10       ` Andi Kleen
2008-08-23  9:24         ` Paolo Bonzini
2008-08-23 16:36           ` Andi Kleen
2008-08-23 23:00             ` Paolo Bonzini
2008-08-23 15:55         ` Linus Torvalds
2008-08-23 16:45           ` Andi Kleen
2008-08-23 17:58             ` Linus Torvalds
2008-08-25  9:36               ` Ingo Molnar
2008-08-23 18:18             ` Björn Steinbrink
2008-08-23 18:56               ` Linus Torvalds
2008-08-23 20:08                 ` Björn Steinbrink
2008-08-23 21:38                 ` Documentating branches (was: nicer frontend to get rebased tree?) Marius Vollmer
2008-08-23 22:17                   ` Miklos Vajna
2008-08-23 22:30                     ` Documenting branches Marius Vollmer
2008-08-23 22:18                   ` Documentating branches Marius Vollmer
2008-08-22 17:56 ` nicer frontend to get rebased tree? Avery Pennarun
2008-08-22 18:31   ` Andi Kleen
2008-08-22 19:03     ` Paolo Ciarrocchi
2008-08-22 19:34     ` Jakub Narebski
2008-08-23  7:15       ` Andi Kleen
2008-08-23  8:52         ` Paolo Ciarrocchi
2008-08-23  9:21         ` Jakub Narebski
2008-08-23 16:53           ` Andi Kleen
2008-08-23 21:04             ` Paolo Ciarrocchi
2008-08-23 21:52               ` Linus Torvalds
2008-08-23 22:09                 ` Paolo Ciarrocchi
2008-08-23 22:13                 ` Björn Steinbrink [this message]
2008-08-24  0:30                 ` Junio C Hamano
2008-08-23 22:49             ` Jakub Narebski
2008-08-23 23:01             ` Theodore Tso
2008-08-23 23:01             ` A proposed solution (Was: nicer frontend to get rebased tree?) Theodore Tso
2008-08-22 20:11 ` nicer frontend to get rebased tree? Mikael Magnusson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080823221324.GA18472@atjola.homenet \
    --to=b.steinbrink@gmx.de \
    --cc=andi@firstfloor.org \
    --cc=apenwarr@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jnareb@gmail.com \
    --cc=paolo.ciarrocchi@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).