rebase -i --root: let the sequencer handle even the initial part

In this developer's earlier attempt to accelerate interactive rebases by converting large parts from Unix shell script into portable, performant C, the --root handling was specifically excluded (to simplify the task a little bit; it still took over a year to get that reduced set of patches into Git proper). This patch ties up that loose end: now only --preserve-merges uses the slow Unix shell script implementation to perform the interactive rebase. As the rebase--helper reports progress to stderr (unlike the scripted interactive rebase, which reports it to stdout, of all places), we have to adjust a couple of tests that did not expect that for `git rebase -i --root`. This patch fixes -- at long last! -- the really old bug reported in 6a6bc5bdc4d (add tests for rebasing root, 2013-06-06) that rebasing with --root *always* rewrote the root commit, even if there were no changes. The bug still persists in --preserve-merges mode, of course, but that mode will be deprecated as soon as the new --rebase-merges mode stabilizes, anyway. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed May 4, 2018 at 01:01 UTC 21d0764c823bdca78b99dae562ca9e5c2a121738
3 files changed +19 -10
git-rebase--interactive.sh
+3 -1
@@ -894,6 +894,8 @@ init_revisions_and_shortrevisions () {
894 else
895 revisions=$onto...$orig_head
896 shortrevisions=$shorthead
897 + test -z "$squash_onto" ||
898 + echo "$squash_onto" >"$state_dir"/squash-onto
899 fi
900 }
901
@@ -948,7 +950,7 @@ EOF
950 die "Could not skip unnecessary pick commands"
951
952 checkout_onto
951 - if test -z "$rebase_root" && test ! -d "$rewritten"
953 + if test ! -d "$rewritten"
954 then
955 require_clean_work_tree "rebase"
956 exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \
t/t3404-rebase-interactive.sh
+13 -6
@@ -1204,10 +1204,6 @@ test_expect_success 'drop' '
1204 test A = $(git cat-file commit HEAD^^ | sed -ne \$p)
1205 '
1206
1207 -cat >expect <<EOF
1208 -Successfully rebased and updated refs/heads/missing-commit.
1209 -EOF
1210 -
1207 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
1208 test_config rebase.missingCommitsCheck ignore &&
1209 rebase_setup_and_clean missing-commit &&
@@ -1215,7 +1211,9 @@ test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
1211 FAKE_LINES="1 2 3 4" \
1212 git rebase -i --root 2>actual &&
1213 test D = $(git cat-file commit HEAD | sed -ne \$p) &&
1218 - test_i18ncmp expect actual
1214 + test_i18ngrep \
1215 + "Successfully rebased and updated refs/heads/missing-commit" \
1216 + actual
1217 '
1218
1219 cat >expect <<EOF
@@ -1227,15 +1225,24 @@ To avoid this message, use "drop" to explicitly remove a commit.
1225 Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
1226 The possible behaviours are: ignore, warn, error.
1227
1228 +Rebasing (1/4)
1229 +Rebasing (2/4)
1230 +Rebasing (3/4)
1231 +Rebasing (4/4)
1232 Successfully rebased and updated refs/heads/missing-commit.
1233 EOF
1234
1235 +cr_to_nl () {
1236 + tr '\015' '\012'
1237 +}
1238 +
1239 test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
1240 test_config rebase.missingCommitsCheck warn &&
1241 rebase_setup_and_clean missing-commit &&
1242 set_fake_editor &&
1243 FAKE_LINES="1 2 3 4" \
1238 - git rebase -i --root 2>actual &&
1244 + git rebase -i --root 2>actual.2 &&
1245 + cr_to_nl <actual.2 >actual &&
1246 test_i18ncmp expect actual &&
1247 test D = $(git cat-file commit HEAD | sed -ne \$p)
1248 '
t/t3421-rebase-topology-linear.sh
+3 -3
@@ -328,9 +328,9 @@ test_run_rebase () {
328 test_cmp_rev c HEAD
329 "
330 }
331 -test_run_rebase failure ''
332 -test_run_rebase failure -m
333 -test_run_rebase failure -i
331 +test_run_rebase success ''
332 +test_run_rebase success -m
333 +test_run_rebase success -i
334 test_run_rebase failure -p
335
336 test_run_rebase () {