Skip to content

Commit 21d0764

Browse files
dschogitster
authored andcommitted
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 6a6bc5b (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent d87d48b commit 21d0764

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

git-rebase--interactive.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -894,6 +894,8 @@ init_revisions_and_shortrevisions () {
894894
else
895895
revisions=$onto...$orig_head
896896
shortrevisions=$shorthead
897+
test -z "$squash_onto" ||
898+
echo "$squash_onto" >"$state_dir"/squash-onto
897899
fi
898900
}
899901

@@ -948,7 +950,7 @@ EOF
948950
die "Could not skip unnecessary pick commands"
949951

950952
checkout_onto
951-
if test -z "$rebase_root" && test ! -d "$rewritten"
953+
if test ! -d "$rewritten"
952954
then
953955
require_clean_work_tree "rebase"
954956
exec git rebase--helper ${force_rebase:+--no-ff} $allow_empty_message \

t/t3404-rebase-interactive.sh

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,18 +1204,16 @@ test_expect_success 'drop' '
12041204
test A = $(git cat-file commit HEAD^^ | sed -ne \$p)
12051205
'
12061206

1207-
cat >expect <<EOF
1208-
Successfully rebased and updated refs/heads/missing-commit.
1209-
EOF
1210-
12111207
test_expect_success 'rebase -i respects rebase.missingCommitsCheck = ignore' '
12121208
test_config rebase.missingCommitsCheck ignore &&
12131209
rebase_setup_and_clean missing-commit &&
12141210
set_fake_editor &&
12151211
FAKE_LINES="1 2 3 4" \
12161212
git rebase -i --root 2>actual &&
12171213
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
12191217
'
12201218

12211219
cat >expect <<EOF
@@ -1227,15 +1225,24 @@ To avoid this message, use "drop" to explicitly remove a commit.
12271225
Use 'git config rebase.missingCommitsCheck' to change the level of warnings.
12281226
The possible behaviours are: ignore, warn, error.
12291227
1228+
Rebasing (1/4)
1229+
Rebasing (2/4)
1230+
Rebasing (3/4)
1231+
Rebasing (4/4)
12301232
Successfully rebased and updated refs/heads/missing-commit.
12311233
EOF
12321234

1235+
cr_to_nl () {
1236+
tr '\015' '\012'
1237+
}
1238+
12331239
test_expect_success 'rebase -i respects rebase.missingCommitsCheck = warn' '
12341240
test_config rebase.missingCommitsCheck warn &&
12351241
rebase_setup_and_clean missing-commit &&
12361242
set_fake_editor &&
12371243
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 &&
12391246
test_i18ncmp expect actual &&
12401247
test D = $(git cat-file commit HEAD | sed -ne \$p)
12411248
'

t/t3421-rebase-topology-linear.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ test_run_rebase () {
328328
test_cmp_rev c HEAD
329329
"
330330
}
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
334334
test_run_rebase failure -p
335335

336336
test_run_rebase () {

0 commit comments

Comments
 (0)