#!/bin/sh
#
# Copyright (c) 2007 Johannes E. Schindelin
#
test_description='git rebase interactive
This test runs git rebase "interactively", by faking an edit, and verifies
that the result still makes sense.
Initial setup:
one - two - three - four (conflict-branch)
/
A - B - C - D - E (master)
| \
| F - G - H (branch1)
| \
|\ I (branch2)
| \
| J - K - L - M (no-conflict-branch)
\
N - O - P (no-ff-branch)
where A, B, D and G all touch file1, and one, two, three, four all
touch file "conflict".
'
. ./test-lib.sh
. "$TEST_DIRECTORY"/lib-rebase.sh
# WARNING: Modifications to the initial repository can change the SHA ID used
# in the expect2 file for the 'stop on conflicting pick' test.
test_expect_success 'setup' '
test_commit A file1 &&
test_commit B file1 &&
test_commit C file2 &&
test_commit D file1 &&
test_commit E file3 &&
git checkout -b branch1 A &&
test_commit F file4 &&
test_commit G file1 &&
test_commit H file5 &&
git checkout -b branch2 F &&
test_commit I file6 &&
git checkout -b conflict-branch A &&
test_commit one conflict &&
test_commit two conflict &&
test_commit three conflict &&
test_commit four conflict &&
git checkout -b no-conflict-branch A &&
test_commit J fileJ &&
test_commit K fileK &&
test_commit L fileL &&
test_commit M fileM &&
git checkout -b no-ff-branch A &&
test_commit N fileN &&
test_commit O fileO &&
test_commit P fileP
'
# "exec" commands are run with the user shell by default, but this may
# be non-POSIX. For example, if SHELL=zsh then ">file" doesn't work
# to create a file. Unsetting SHELL avoids such non-portable behavior
# in tests. It must be exported for it to take effect where needed.
SHELL=
export SHELL
test_expect_success 'rebase --keep-empty' '
git checkout -b emptybranch master &&
git commit --allow-empty -m "empty" &&
git rebase --keep-empty -i HEAD~2 &&
git log --oneline >actual &&
test_line_count = 6 actual
'
cat > expect <<EOF
error: nothing to do
EOF
test_expect_success 'rebase -i with empty HEAD' '
set_fake_editor &&
test_must_fail env FAKE_LINES="1 exec_true" git rebase -i HEAD^ >actual 2>&1 &&
test_i18ncmp expect actual
'
test_expect_success 'rebase -i with the exec command' '
git checkout m
|