From: Junio C Hamano Date: Wed, 30 May 2018 05:04:04 +0000 (+0900) Subject: Merge branch 'js/sequencer-and-root-commits' X-Git-Tag: v2.18.0-rc0~32 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c5aa4bccb5ffcc01e45915c00d2fce30ce959dab Merge branch 'js/sequencer-and-root-commits' 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 --- c5aa4bccb5ffcc01e45915c00d2fce30ce959dab diff --cc sequencer.c index 1ce63261a3,01e561bc20..abb6c5dc26 --- a/sequencer.c +++ b/sequencer.c @@@ -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 a800cb5755,4b2717881f..c5787c6b56 --- a/sequencer.h +++ b/sequencer.h @@@ -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; };