git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Keeping <john@keeping.me.uk>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: git@vger.kernel.org, Junio C Hamano <gitster@pobox.com>
Subject: Re: [PATCH] rebase: use reflog to find common base with upstream
Date: Wed, 16 Oct 2013 20:44:44 +0100	[thread overview]
Message-ID: <20131016194444.GQ27238@serenity.lan> (raw)
In-Reply-To: <20131016192412.GK9464@google.com>

On Wed, Oct 16, 2013 at 12:24:13PM -0700, Jonathan Nieder wrote:
> John Keeping wrote:
> 
> >                                    Since commit d44e712 (pull: support
> > rebased upstream + fetch + pull --rebase, 2009-07-19), pull has actually
> > chosen the most recent reflog entry which is an ancestor of the current
> > branch if it can find one.
> >
> > Change rebase so that it uses the same logic.
> 
> Nice idea.
> 
> Could pull be made to rely on rebase for this as a follow-up?

It's not an obvious change to do that (at least to me) - pull does the
different steps of figuring out the base and then rebasing at different
points in the script.

> [...]
> > --- a/git-rebase.sh
> > +++ b/git-rebase.sh
> > @@ -437,6 +437,14 @@ then
> >  			error_on_missing_default_upstream "rebase" "rebase" \
> >  				"against" "git rebase <branch>"
> >  		fi
> > +		for reflog in $(git rev-list -g "$upstream_name" 2>/dev/null)
> > +		do
> > +			if test "$reflog" = "$(git merge-base "$reflog" HEAD)"
> 
> "git merge-base --is-ancestor" is faster.

We should probably change git-pull to use that as well.

> What should happen if HEAD is not a valid commit?  (Tested with:
> 
> 	$ git checkout --orphan foo
> 	$ cat >>.git/config <<EOF
> 	[branch "foo"]
> 		remote = origin
> 		merge = refs/heads/master
> 	EOF
> 	$ bin-wrappers/git rebase 2>&1 | wc -l
> 	83
> 
> ).

Adding "2>/dev/null" to the merge-base line silences most of that, all
we're left with is "fatal: Needed a single revision" which is the same
as I get from master's git-rebase.  I think silencing stderr is the
right thing to do here - in the worst case we just use the merge-base of
the two branches instead of the appropriate reflog entry.

> diff --git i/git-rebase.sh w/git-rebase.sh
> index fd36cf7..d2e2c2e 100755
> --- i/git-rebase.sh
> +++ w/git-rebase.sh
> @@ -439,7 +439,7 @@ then
>  		fi
>  		for reflog in $(git rev-list -g "$upstream_name" 2>/dev/null)
>  		do
> -			if test "$reflog" = "$(git merge-base "$reflog" HEAD)"
> +			if git merge-base --is-ancestor "$reflog" HEAD
>  			then
>  				upstream_name=$reflog
>  				break

  reply	other threads:[~2013-10-16 19:45 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-16 18:53 [PATCH] rebase: use reflog to find common base with upstream John Keeping
2013-10-16 19:24 ` Jonathan Nieder
2013-10-16 19:44   ` John Keeping [this message]
2013-10-21  5:03 ` Martin von Zweigbergk
2013-10-21 11:24   ` John Keeping
2013-10-22  6:24     ` Martin von Zweigbergk
2013-10-24 19:04   ` Junio C Hamano
2013-10-24 19:11     ` [PATCH 0/2] finding the fork point from reflog entries Junio C Hamano
2013-10-24 19:11       ` [PATCH 1/2] merge-base: use OPT_CMDMODE and clarify the command line parsing Junio C Hamano
2013-10-24 19:11       ` [PATCH 2/2] merge-base: "--reflog" mode finds fork point from reflog entries Junio C Hamano
2013-10-24 21:01         ` Eric Sunshine
2013-10-24 21:26           ` Junio C Hamano
2013-10-24 21:43             ` Eric Sunshine
2013-10-24 22:13               ` Junio C Hamano
2013-10-24 22:21                 ` [PATCH v2 " Junio C Hamano
2013-10-25  7:12                   ` Johannes Sixt
2013-10-25  8:09                     ` John Keeping
2013-10-25  8:17                       ` Johannes Sixt
2013-10-25 16:53                     ` Junio C Hamano
2013-10-25 21:38                       ` [PATCH v3 2/2] merge-base: teach "--fork-point" mode Junio C Hamano
2013-10-25 21:56                         ` Eric Sunshine
2013-10-26  5:15                         ` Martin von Zweigbergk
2013-10-28 14:47                           ` Junio C Hamano
2013-10-26  9:00                         ` John Keeping
2013-10-28 19:13                           ` Junio C Hamano
2013-10-29  8:51                             ` John Keeping
2013-10-29 20:11                               ` Junio C Hamano
2013-10-24 20:54       ` [PATCH 0/2] finding the fork point from reflog entries John Keeping
2013-10-24 21:20         ` Junio C Hamano
2013-10-24 21:31           ` John Keeping
2013-10-24 21:40             ` John Keeping
2013-10-24 21:50               ` John Keeping
2013-10-25  2:46               ` Junio C Hamano
2013-10-22  5:40 ` [PATCH] rebase: use reflog to find common base with upstream Martin von Zweigbergk
2013-10-24 20:26   ` John Keeping

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=20131016194444.GQ27238@serenity.lan \
    --to=john@keeping.me.uk \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jrnieder@gmail.com \
    /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).