diff options
author | Johannes Schindelin <Johannes.Schindelin@gmx.de> | 2008-01-26 18:04:37 +0000 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2008-01-26 18:24:24 -0800 |
commit | c85c79279df2c8a583d95449d1029baba41f8660 (patch) | |
tree | 41a2936893206ec54c80bb6e9004f760fdaf303f /git-pull.sh | |
parent | e509db990b2ecae642efe3cdef4014d57d525f24 (diff) | |
download | git-c85c79279df2c8a583d95449d1029baba41f8660.tar.gz |
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>
Diffstat (limited to 'git-pull.sh')
-rwxr-xr-x | git-pull.sh | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/git-pull.sh b/git-pull.sh index fa97b0f356..46da0f4ca2 100755 --- a/git-pull.sh +++ b/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 |