From: Junio C Hamano <gitster@pobox.com>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] pull --rebase: be cleverer with rebased upstream branches
Date: Sat, 26 Jan 2008 11:34:05 -0800 [thread overview]
Message-ID: <7vk5lwz8ia.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <alpine.LSU.1.00.0801261801360.23907@racer.site> (Johannes Schindelin's message of "Sat, 26 Jan 2008 18:04:37 +0000 (GMT)")
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> When the upstream branch is tracked, we can detect if that branch
> was rebased since it was last fetched. Teach git to use that
> information to rebase from the old remote head onto the new remote head.
>
> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is certainly nicer than the original (which is not in
1.5.3, so even this late in the cycle it is "fixing up a new
feature we will be introducing in 1.5.4" category that I will
apply). But I think a bit of caution and perhaps an
illustration or two in the doucmentation would help.
If you do "git fetch" from the origin since the last time you
ran "pull --rebase" for the remote, we will have the same
issue. Suppose you have this history:
.---x---x---x
/
.---A---B
/
---0---o---o---A'--B'--C'--D'
\
o---o---A''-B''-C''-D''-E''
Originally your upstream had 0---A---B; you built your 'x' on
top of it. Then the upstream rebases and publishes history that
leads to D' (i.e. A and B are rewritten). Later, the history is
further rewritten and E'' is the latest upstream tip.
If you haven't done "git fetch" since you started building on
top of B, refs/remotes/ will still say B and using B as base
(and E'' as onto) will give you the right rebase. Earlier, we
did not use B in the rebase in any way, so your patch is
definitely an improvement.
However, if you have run "git fetch" (say, to peek what the
upstream has been up to), your refs/remote/ may say D'. Using
that as the base and rebasing onto E'' is not quite optimal,
isn't it?
So it might make sense to make the logic to figure out B, given
your local history that leads from 0 to x's (and nothing else),
a bit cleverer than looking at the tracking branch. We can look
at reflog for example. "git log -g --pretty=oneline" may have
entries of this form:
* branch: Created from B
* rebase finished <branch> onto B
and the latest (i.e. younguest) entry is where the part of your
current history to be rebased (i.e. base commit) starts. This
is much more reliable than looking at the tracking branch, whose
answer may or may not match B at all.
I do not mean this comment makes your approach invalid, though.
It is a start in the good direction.
next prev parent reply other threads:[~2008-01-26 19:34 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-01-21 15:47 Should "pull --rebase" try to be a little cleverer? Johannes Schindelin
2008-01-21 16:03 ` Nicolas Pitre
2008-01-21 16:21 ` Johannes Schindelin
2008-01-21 16:42 ` Nicolas Pitre
2008-01-21 18:21 ` Junio C Hamano
2008-01-26 18:04 ` [PATCH] pull --rebase: be cleverer with rebased upstream branches Johannes Schindelin
2008-01-26 19:34 ` Junio C Hamano [this message]
2008-01-26 19:49 ` Johannes Schindelin
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=7vk5lwz8ia.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.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).