git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Santi Béjar" <santi@agolina.net>
To: git@vger.kernel.org
Subject: [PATCH 2/2] pull: support rebased upstream + fetch + pull --rebase
Date: Thu, 16 Jul 2009 02:09:15 +0200	[thread overview]
Message-ID: <1247702955-1559-2-git-send-email-santi@agolina.net> (raw)
In-Reply-To: <1247702955-1559-1-git-send-email-santi@agolina.net>

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.

Signed-off-by: Santi Béjar <santi@agolina.net>
---
 git-pull.sh     |    9 +++++++--
 t/t5520-pull.sh |    5 ++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/git-pull.sh b/git-pull.sh
index 4b78a0c..f5bef53 100755
--- a/git-pull.sh
+++ b/git-pull.sh
@@ -126,8 +126,13 @@ test true = "$rebase" && {
 
 	. git-parse-remote &&
 	reflist="$(get_remote_merge_branch "$@" 2>/dev/null)" &&
-	oldremoteref="$(git rev-parse -q --verify \
-		"$reflist")"
+	num=0 &&
+	while oldremoteref="$(git rev-parse -q --verify "$reflist@{$num}")"
+	do
+		test $oldremoteref = $(git merge-base $oldremoteref $curr_branch) &&
+		break
+		num=$((num+1))
+	done
 }
 orig_head=$(git rev-parse -q --verify HEAD)
 git fetch $verbosity --update-head-ok "$@" || exit 1
diff --git a/t/t5520-pull.sh b/t/t5520-pull.sh
index 1aae494..37a7e33 100755
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
@@ -117,15 +117,14 @@ test_expect_success '--rebase with rebased default upstream' '
 
 '
 
-test_expect_failure 'rebased upstream + fetch + pull --rebase' '
+test_expect_success 'rebased upstream + fetch + pull --rebase' '
 
 	git update-ref refs/remotes/me/copy copy-orig &&
 	git reset --hard to-rebase-orig &&
 	git checkout --track -b to-rebase3 me/copy &&
 	git reset --hard to-rebase-orig &&
 	git fetch &&
-	test_must_fail git pull --rebase &&
-	git rebase --abort &&
+	git pull --rebase &&
 	test "conflicting modification" = "$(cat file)" &&
 	test file = $(cat file2)
 
-- 
1.6.4.rc0.18.g60787.dirty

  reply	other threads:[~2009-07-16  0:09 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 ` Santi Béjar [this message]
2009-07-16  0:26   ` [PATCH 2/2] pull: support " 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
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=1247702955-1559-2-git-send-email-santi@agolina.net \
    --to=santi@agolina.net \
    --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).