summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: a418441)
raw | patch | inline | side by side (parent: a418441)
author | Santi Béjar <santi@agolina.net> | |
Sun, 19 Jul 2009 07:45:16 +0000 (09:45 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 19 Jul 2009 17:29:38 +0000 (10:29 -0700) |
You cannot do a "git pull --rebase" with a rebased upstream, if you have
already run "git fetch". Try to behave as if the "git fetch" was not run.
In other words, find the fork point of the current branch, where
the tip of upstream branch used to be, and use it as the upstream
parameter of "git rebase".
This patch computes the fork point by walking the reflog to find the first
commit which is an ancestor of the current branch. Maybe there are
smarter ways to compute it, but this is a straight forward implementation.
Signed-off-by: Santi Béjar <santi@agolina.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
already run "git fetch". Try to behave as if the "git fetch" was not run.
In other words, find the fork point of the current branch, where
the tip of upstream branch used to be, and use it as the upstream
parameter of "git rebase".
This patch computes the fork point by walking the reflog to find the first
commit which is an ancestor of the current branch. Maybe there are
smarter ways to compute it, but this is a straight forward implementation.
Signed-off-by: Santi Béjar <santi@agolina.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-pull.sh | patch | blob | history | |
t/t5520-pull.sh | patch | blob | history |
diff --git a/git-pull.sh b/git-pull.sh
index 4b78a0cd37ba70236a05f78fb5bed3f763348096..0f24182974fe2040c950b846decf360c1c22dbb1 100755 (executable)
--- a/git-pull.sh
+++ b/git-pull.sh
git diff-index --ignore-submodules --cached --quiet HEAD -- ||
die "refusing to pull with rebase: your working tree is not up-to-date"
+ oldremoteref= &&
. 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)" &&
+ oldremoteref="$(git rev-parse -q --verify "$remoteref")" &&
+ for reflog in $(git rev-list -g $remoteref 2>/dev/null)
+ do
+ if test "$reflog" = "$(git merge-base $reflog $curr_branch)"
+ then
+ oldremoteref="$reflog"
+ break
+ fi
+ 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 3ebc886bdcb97f2473ab2e05afdad933401f44b8..e78d40242a80d9b2aa74e74d3a4aecddbb63ab99 100755 (executable)
--- a/t/t5520-pull.sh
+++ b/t/t5520-pull.sh
'
-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)"