pull --rebase: be cleverer with rebased upstream branches
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> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
e509db990b
commit
c85c79279d
12
git-pull.sh
12
git-pull.sh
@ -106,6 +106,15 @@ error_on_no_merge_candidates () {
|
||||
exit 1
|
||||
}
|
||||
|
||||
test true = "$rebase" && {
|
||||
. git-parse-remote &&
|
||||
origin="$1"
|
||||
test -z "$origin" && origin=$(get_default_remote)
|
||||
reflist="$(get_remote_refs_for_fetch "$@" 2>/dev/null |
|
||||
sed "s|refs/heads/\(.*\):|\1|")" &&
|
||||
oldremoteref="$(git rev-parse --verify \
|
||||
"refs/remotes/$origin/$reflist" 2>/dev/null)"
|
||||
}
|
||||
orig_head=$(git rev-parse --verify HEAD 2>/dev/null)
|
||||
git-fetch --update-head-ok "$@" || exit 1
|
||||
|
||||
@ -164,6 +173,7 @@ then
|
||||
fi
|
||||
|
||||
merge_name=$(git fmt-merge-msg <"$GIT_DIR/FETCH_HEAD") || exit
|
||||
test true = "$rebase" && exec git-rebase $merge_head
|
||||
test true = "$rebase" &&
|
||||
exec git-rebase --onto $merge_head ${oldremoteref:-$merge_head}
|
||||
exec git-merge $no_summary $no_commit $squash $no_ff $strategy_args \
|
||||
"$merge_name" HEAD $merge_head
|
||||
|
Reference in New Issue
Block a user