git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Santi Béjar" <santi@agolina.net>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>,
	Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCHv2 2/2] pull: support rebased upstream + fetch + pull  --rebase
Date: Thu, 16 Jul 2009 18:32:39 +0200	[thread overview]
Message-ID: <adf1fd3d0907160932r313de6e8lec23e4f3409b8c05@mail.gmail.com> (raw)
In-Reply-To: <alpine.DEB.1.00.0907161035060.3155@pacific.mpi-cbg.de>

2009/7/16 Johannes Schindelin <Johannes.Schindelin@gmx.de>:
> Hi,
>
> On Thu, 16 Jul 2009, Santi Béjar wrote:
>
>> Use the fork commit of the current branch (where
>> the tip of upstream branch used to be) as the upstream parameter of
>> "git rebase". Compute it walking the reflog to find the first commit
>> which is an ancestor of the current branch.
>
> I finally understand what this patch is about.  Thanks.

Thanks, it was hard (at least for me) to provide a short and good
commit message.

>
>> diff --git a/git-pull.sh b/git-pull.sh
>> index 4b78a0c..31d3945 100755
>> --- a/git-pull.sh
>> +++ b/git-pull.sh
>> @@ -125,9 +125,14 @@ test true = "$rebase" && {
>>       die "refusing to pull with rebase: your working tree is not up-to-date"
>>
>>       . git-parse-remote &&
>> -     reflist="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
>> -     oldremoteref="$(git rev-parse -q --verify \
>> -             "$reflist")"
>> +     remoteref="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
>> +     num=0 &&
>> +     while oldremoteref="$(git rev-parse -q --verify "$remoteref@{$num}")"
>> +     do
>
> How about
>
>        oldremoteref="$(git rev-list --boundary HEAD --not \
>                        $(git rev-list -g $remoteref | sed 's/$/^@/') |
>                sed -e '/^[^-]/d' -e q)"
>
> Explanation: the "git rev-list -g $remoteref" lists the previous commits
> the remote ref pointed to, and the ^@ appended to them means all their
> parents.  Now, the outer rev-list says to take everything in HEAD but
> _not_ in those parents, showing the boundary commits.  The "sed" call
> lists the first such boundary commit (which must, by construction, be one
> of the commits shown by the first rev-list).

It almost works, thanks. In fact this is how I represent it in my
head, but I couldn't find a working command (hint, hint, the
--boundaries trick). Based on yours here it is the one I am using
right now:

	oldremoteref="$(git rev-list --boundary HEAD --not \
		$(git rev-list -g $remoteref 2>/dev/null) |
		sed -e '/^[^-]/d' -e 's/^-//;q' )"

i.e. without the ^@ as you want the commits in the reflog as boundary
commits, and also remove the - in front of the commit.

Your version performs equally than mine for the normal case but much
better if it has to walk many reflog entries. Also mine has the
problem, at least currently, that it does not give up as "git
rev-parse -q --verify $branch@{n}" does not return an error when n is
too large:

  $ git rev-parse -q --verify origin/next@{18} ; echo $?
warning: Log for 'origin/next' only has 17 entries.
37eb784cfce07ba0048d64e352c5137454396d87
0

even with "-q --verify"!

So, I'll take yours and will send an updated patch (saying that is is
based on a command by you). With your Signed-off-by?

Thanks,
Santi

  reply	other threads:[~2009-07-16 16:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-16  0:09 [PATCH 1/2] t5520-pull: Test for rebased upstream + fetch + pull --rebase Santi Béjar
2009-07-16  0:09 ` [PATCH 2/2] pull: support " Santi Béjar
2009-07-16  0:26   ` Junio C Hamano
2009-07-16  6:29     ` Santi Béjar
2009-07-16  8:12       ` [PATCHv2 " Santi Béjar
2009-07-16  8:12         ` Santi Béjar
2009-07-16  8:15         ` Santi Béjar
2009-07-16  8:51         ` Johannes Schindelin
2009-07-16 16:32           ` Santi Béjar [this message]
2009-07-17 10:13             ` Johannes Schindelin
2009-07-16 20:41           ` Junio C Hamano
2009-07-16 23:18             ` Santi Béjar
2009-07-17  7:51               ` Santi Béjar
2009-07-17  8:25                 ` Junio C Hamano
2009-07-17 13:24                   ` Santi Béjar
2009-07-18 13:46                     ` [PATCHv3 " Santi Béjar
2009-07-18 17:55                       ` Junio C Hamano
2009-07-19  7:27                         ` Santi Béjar
2009-07-19  7:45                           ` [PATCHv4 " Santi Béjar

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=adf1fd3d0907160932r313de6e8lec23e4f3409b8c05@mail.gmail.com \
    --to=santi@agolina.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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).