Merge branch 'js/sequencer-and-root-commits'
authorJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 05:04:04 +0000 (14:04 +0900)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 May 2018 05:04:04 +0000 (14:04 +0900)
The implementation of "git rebase -i --root" has been updated to use
the sequencer machinery more.

* js/sequencer-and-root-commits:
rebase --rebase-merges: root commits can be cousins, too
rebase --rebase-merges: a "merge" into a new root is a fast-forward
sequencer: allow introducing new root commits
rebase -i --root: let the sequencer handle even the initial part
sequencer: learn about the special "fake root commit" handling
sequencer: extract helper to update active_cache_tree

1  2 
sequencer.c
sequencer.h
diff --cc sequencer.c
index 1ce63261a32a2398c3916fd41f577db58478fe0f,01e561bc20ec39587c6b4852c3deff9beb20a3f4..abb6c5dc26c04e21607615326c4d101cd85d5c00
@@@ -582,15 -604,10 +603,10 @@@ static int is_index_unchanged(void
        if (parse_commit(head_commit))
                return -1;
  
-       if (!active_cache_tree)
-               active_cache_tree = cache_tree();
-       if (!cache_tree_fully_valid(active_cache_tree))
-               if (cache_tree_update(&the_index, 0))
-                       return error(_("unable to update cache tree"));
+       if (!(cache_tree_oid = get_cache_tree_oid()))
+               return -1;
  
-       return !oidcmp(&active_cache_tree->oid,
-                      get_commit_tree_oid(head_commit));
 -      return !oidcmp(cache_tree_oid, &head_commit->tree->object.oid);
++      return !oidcmp(cache_tree_oid, get_commit_tree_oid(head_commit));
  }
  
  static int write_author_script(const char *message)
@@@ -2132,16 -2248,12 +2253,22 @@@ static int read_populate_opts(struct re
                read_strategy_opts(opts, &buf);
                strbuf_release(&buf);
  
 +              if (read_oneliner(&opts->current_fixups,
 +                                rebase_path_current_fixups(), 1)) {
 +                      const char *p = opts->current_fixups.buf;
 +                      opts->current_fixup_count = 1;
 +                      while ((p = strchr(p, '\n'))) {
 +                              opts->current_fixup_count++;
 +                              p++;
 +                      }
 +              }
 +
+               if (read_oneliner(&buf, rebase_path_squash_onto(), 0)) {
+                       if (get_oid_hex(buf.buf, &opts->squash_onto) < 0)
+                               return error(_("unusable squash-onto"));
+                       opts->have_squash_onto = 1;
+               }
                return 0;
        }
  
diff --cc sequencer.h
index a800cb57558fab14d43cda47c9a69b3c5015e1a8,4b2717881fa1c6f5011cddd6a5f1c28761d8e8ca..c5787c6b566bbc89caad1a099f4281fecba01766
@@@ -44,10 -44,10 +44,14 @@@ struct replay_opts 
        char **xopts;
        size_t xopts_nr, xopts_alloc;
  
 +      /* Used by fixup/squash */
 +      struct strbuf current_fixups;
 +      int current_fixup_count;
 +
+       /* placeholder commit for -i --root */
+       struct object_id squash_onto;
+       int have_squash_onto;
        /* Only used by REPLAY_NONE */
        struct rev_info *revs;
  };