diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-12-19 14:45:38 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-12-19 14:45:38 -0800 |
commit | 2fb11ec6c175e8a380d91daccc3bbf9fc5bbea8b (patch) | |
tree | 1f6c6ed0942f20d97705b9e3e4dd603d122fafa8 /builtin/pull.c | |
parent | 101f3dc92a4cedb1f359f6ddce913b631ffa75b6 (diff) | |
parent | 33b842a1e9bf28bcffe953ad9dcdbb0561336314 (diff) | |
download | git-2fb11ec6c175e8a380d91daccc3bbf9fc5bbea8b.tar.gz |
Merge branch 'jc/pull-rebase-ff'
"git pull --rebase", when there is no new commits on our side since
we forked from the upstream, should be able to fast-forward without
invoking "git rebase", but it didn't.
* jc/pull-rebase-ff:
pull: fast-forward "pull --rebase=true"
Diffstat (limited to 'builtin/pull.c')
-rw-r--r-- | builtin/pull.c | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/builtin/pull.c b/builtin/pull.c index d6e46ee6d0..3ecb881b0b 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -857,10 +857,24 @@ int cmd_pull(int argc, const char **argv, const char *prefix) if (merge_heads.nr > 1) die(_("Cannot merge multiple branches into empty head.")); return pull_into_void(*merge_heads.sha1, curr_head); - } else if (opt_rebase) { - if (merge_heads.nr > 1) - die(_("Cannot rebase onto multiple branches.")); + } + if (opt_rebase && merge_heads.nr > 1) + die(_("Cannot rebase onto multiple branches.")); + + if (opt_rebase) { + struct commit_list *list = NULL; + struct commit *merge_head, *head; + + head = lookup_commit_reference(orig_head); + commit_list_insert(head, &list); + merge_head = lookup_commit_reference(merge_heads.sha1[0]); + if (is_descendant_of(merge_head, list)) { + /* we can fast-forward this without invoking rebase */ + opt_ff = "--ff-only"; + return run_merge(); + } return run_rebase(curr_head, *merge_heads.sha1, rebase_fork_point); - } else + } else { return run_merge(); + } } |