Merge branch 'tb/pull-ff-rebase-autostash'
authorJunio C Hamano <gitster@pobox.com>
Mon, 5 Jun 2017 00:18:13 +0000 (09:18 +0900)
committerJunio C Hamano <gitster@pobox.com>
Mon, 5 Jun 2017 00:18:13 +0000 (09:18 +0900)
"git pull --rebase --autostash" didn't auto-stash when the local history
fast-forwards to the upstream.

* tb/pull-ff-rebase-autostash:
pull: ff --rebase --autostash works in dirty repo

1  2 
builtin/pull.c
diff --cc builtin/pull.c
index 318c273eb3ed0895c5e1679b833b551b983851fe,42f0560252e000310aa8cc8e674890a09a90b471..da8b60fc85e93da880fb955992b8b753715fafda
@@@ -862,16 -863,18 +863,18 @@@ int cmd_pull(int argc, const char **arg
                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.oid[0]);
-               if (is_descendant_of(merge_head, list)) {
-                       /* we can fast-forward this without invoking rebase */
-                       opt_ff = "--ff-only";
-                       return run_merge();
+               if (!autostash) {
+                       struct commit_list *list = NULL;
+                       struct commit *merge_head, *head;
 -                      head = lookup_commit_reference(orig_head.hash);
++                      head = lookup_commit_reference(&orig_head);
+                       commit_list_insert(head, &list);
 -                      merge_head = lookup_commit_reference(merge_heads.oid[0].hash);
++                      merge_head = lookup_commit_reference(&merge_heads.oid[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.oid, &rebase_fork_point);
        } else {