summaryrefslogtreecommitdiff
path: root/t/t3404-rebase-interactive.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t3404-rebase-interactive.sh')
-rwxr-xr-xt/t3404-rebase-interactive.sh96
1 files changed, 45 insertions, 51 deletions
diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
index 7d20a74..8538813 100755
--- a/t/t3404-rebase-interactive.sh
+++ b/t/t3404-rebase-interactive.sh
@@ -7,34 +7,39 @@ 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
+test_cmp_rev () {
+ git rev-parse --verify "$1" >expect.rev &&
+ git rev-parse --verify "$2" >actual.rev &&
+ test_cmp expect.rev actual.rev
+}
+
set_fake_editor
-# Set up the repository like this:
-#
-# 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".
-#
# 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 &&
@@ -46,29 +51,29 @@ test_expect_success 'setup' '
test_commit G file1 &&
test_commit H file5 &&
git checkout -b branch2 F &&
- test_commit I file6
+ test_commit I file6 &&
git checkout -b conflict-branch A &&
- for n in one two three four
- do
- test_commit $n conflict
- done &&
+ test_commit one conflict &&
+ test_commit two conflict &&
+ test_commit three conflict &&
+ test_commit four conflict &&
git checkout -b no-conflict-branch A &&
- for n in J K L M
- do
- test_commit $n file$n
- done &&
+ test_commit J fileJ &&
+ test_commit K fileK &&
+ test_commit L fileL &&
+ test_commit M fileM &&
git checkout -b no-ff-branch A &&
- for n in N O P
- do
- test_commit $n file$n
- done
+ test_commit N fileN &&
+ test_commit O fileO &&
+ test_commit P fileP
'
# "exec" commands are ran 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. Unseting SHELL avoids such non-portable behavior
-# in tests.
+# in tests. It must be exported for it to take effect where needed.
SHELL=
+export SHELL
test_expect_success 'rebase -i with the exec command' '
git checkout master &&
@@ -82,20 +87,12 @@ test_expect_success 'rebase -i with the exec command' '
test_path_is_file touch-one &&
test_path_is_file touch-two &&
test_path_is_missing touch-three " (should have stopped before)" &&
- test $(git rev-parse C) = $(git rev-parse HEAD) || {
- echo "Stopped at wrong revision:"
- echo "($(git describe --tags HEAD) instead of C)"
- false
- } &&
+ test_cmp_rev C HEAD &&
git rebase --continue &&
test_path_is_file touch-three &&
test_path_is_file "touch-file name with spaces" &&
test_path_is_file touch-after-semicolon &&
- test $(git rev-parse master) = $(git rev-parse HEAD) || {
- echo "Stopped at wrong revision:"
- echo "($(git describe --tags HEAD) instead of master)"
- false
- } &&
+ test_cmp_rev master HEAD &&
rm -f touch-*
'
@@ -116,11 +113,7 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
export FAKE_LINES &&
test_must_fail git rebase -i HEAD^
) &&
- test $(git rev-parse master^) = $(git rev-parse HEAD) || {
- echo "Stopped at wrong revision:"
- echo "($(git describe --tags HEAD) instead of master^)"
- false
- } &&
+ test_cmp_rev master^ HEAD &&
git reset --hard &&
git rebase --continue
'
@@ -302,7 +295,7 @@ test_expect_success 'preserve merges with -p' '
'
test_expect_success 'edit ancestor with -p' '
- FAKE_LINES="1 edit 2 3 4" git rebase -i -p HEAD~3 &&
+ FAKE_LINES="1 2 edit 3 4" git rebase -i -p HEAD~3 &&
echo 2 > unrelated-file &&
test_tick &&
git commit -m L2-modified --amend unrelated-file &&
@@ -324,7 +317,7 @@ test_expect_success '--continue tries to commit' '
'
test_expect_success 'verbose flag is heeded, even after --continue' '
- git reset --hard HEAD@{1} &&
+ git reset --hard master@{1} &&
test_tick &&
test_must_fail git rebase -v -i --onto new-branch1 HEAD^ &&
echo resolved > file1 &&
@@ -584,7 +577,7 @@ test_expect_success 'do "noop" when there is nothing to cherry-pick' '
git checkout -b branch4 HEAD &&
GIT_EDITOR=: git commit --amend \
- --author="Somebody else <somebody@else.com>"
+ --author="Somebody else <somebody@else.com>" &&
test $(git rev-parse branch3) != $(git rev-parse branch4) &&
git rebase -i branch3 &&
test $(git rev-parse branch3) = $(git rev-parse branch4)
@@ -599,7 +592,7 @@ test_expect_success 'submodule rebase setup' '
git add elif && git commit -m "submodule initial"
) &&
echo 1 >file1 &&
- git add file1 sub
+ git add file1 sub &&
test_tick &&
git commit -m "One" &&
echo 2 >file1 &&
@@ -655,6 +648,7 @@ test_expect_success 'rebase -i can copy notes' '
cat >expect <<EOF
an earlier note
+
a note
EOF