]> git.ipfire.org Git - thirdparty/git.git/commit - builtin/pull.c
pull: teach git pull about --rebase
authorPaul Tan <pyokagan@gmail.com>
Thu, 18 Jun 2015 10:54:08 +0000 (18:54 +0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Jun 2015 20:17:46 +0000 (13:17 -0700)
commit1678b81ecce8bcde1356dbe969fdfea96fc91639
tree6cc38dd4ba900b8a5c0ec453406976c2c7446769
parent41fca0989e7ebf3e809e08840c89f44021aa1f2c
pull: teach git pull about --rebase

Since cd67e4d (Teach 'git pull' about --rebase, 2007-11-28), if the
--rebase option is set, git-rebase is run instead of git-merge.

Re-implement this by introducing run_rebase(), which is called instead
of run_merge() if opt_rebase is a true value.

Since c85c792 (pull --rebase: be cleverer with rebased upstream
branches, 2008-01-26), git-pull handles the case where the upstream
branch was rebased since it was last fetched. The fork point (old remote
ref) of the branch from the upstream branch is calculated before fetch,
and then rebased from onto the new remote head (merge_head) after fetch.

Re-implement this by introducing get_merge_branch_2() and
get_merge_branch_1() to find the upstream branch for the
specified/current branch, and get_rebase_fork_point() which will find
the fork point between the upstream branch and current branch.

However, the above change created a problem where git-rebase cannot
detect commits that are already upstream, and thus may result in
unnecessary conflicts. cf65426 (pull --rebase: Avoid spurious conflicts
and reapplying unnecessary patches, 2010-08-12) fixes this by ignoring
the above old remote ref if it is contained within the merge base of the
merge head and the current branch.

This is re-implemented in run_rebase() where fork_point is not used if
it is the merge base returned by get_octopus_merge_base().

Helped-by: Stefan Beller <sbeller@google.com>
Helped-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Paul Tan <pyokagan@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/pull.c