Merge branch 'js/rebase-orig-head-fix'
authorJunio C Hamano <gitster@pobox.com>
Wed, 20 Mar 2019 06:16:05 +0000 (15:16 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 20 Mar 2019 06:16:05 +0000 (15:16 +0900)
"git rebase" that was reimplemented in C did not set ORIG_HEAD
correctly, which has been corrected.

* js/rebase-orig-head-fix:
built-in rebase: set ORIG_HEAD just once, before the rebase
built-in rebase: demonstrate that ORIG_HEAD is not set correctly
built-in rebase: use the correct reflog when switching branches
built-in rebase: no need to check out `onto` twice

1  2 
builtin/rebase.c
index 52114cbf0d9f98d52a5b48d8806019d14b1c7029,0f4e1ead4902c38ab534904e3e09428182528109..77deebc65c6bd7fbe6261b91cfb78c7ec3f85c2d
@@@ -367,8 -368,8 +367,9 @@@ static void add_var(struct strbuf *buf
  
  #define RESET_HEAD_DETACH (1<<0)
  #define RESET_HEAD_HARD (1<<1)
 -#define RESET_HEAD_REFS_ONLY (1<<2)
 -#define RESET_ORIG_HEAD (1<<3)
 +#define RESET_HEAD_RUN_POST_CHECKOUT_HOOK (1<<2)
 +#define RESET_HEAD_REFS_ONLY (1<<3)
++#define RESET_ORIG_HEAD (1<<4)
  
  static int reset_head(struct object_id *oid, const char *action,
                      const char *switch_to_branch, unsigned flags,
  {
        unsigned detach_head = flags & RESET_HEAD_DETACH;
        unsigned reset_hard = flags & RESET_HEAD_HARD;
 +      unsigned run_hook = flags & RESET_HEAD_RUN_POST_CHECKOUT_HOOK;
        unsigned refs_only = flags & RESET_HEAD_REFS_ONLY;
+       unsigned update_orig_head = flags & RESET_ORIG_HEAD;
        struct object_id head_oid;
        struct tree_desc desc[2] = { { NULL }, { NULL } };
        struct lock_file lock = LOCK_INIT;
@@@ -1777,8 -1730,7 +1782,9 @@@ int cmd_rebase(int argc, const char **a
        strbuf_addf(&msg, "%s: checkout %s",
                    getenv(GIT_REFLOG_ACTION_ENVIRONMENT), options.onto_name);
        if (reset_head(&options.onto->object.oid, "checkout", NULL,
-                      RESET_HEAD_DETACH | RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
 -                     RESET_HEAD_DETACH | RESET_ORIG_HEAD, NULL, msg.buf))
++                     RESET_HEAD_DETACH | RESET_ORIG_HEAD | 
++                     RESET_HEAD_RUN_POST_CHECKOUT_HOOK,
 +                     NULL, msg.buf))
                die(_("Could not detach HEAD"));
        strbuf_release(&msg);