3 # Copyright (c) 2008 Stephen Haberman
6 test_description='git rebase preserve merges
8 This test runs git rebase with and tries to squash a commit from after a merge
13 # Copy/paste from t3404-rebase-interactive.sh
14 echo "#!$SHELL_PATH" >fake-editor.sh
15 cat >> fake-editor.sh <<\EOF
18 test -z "$FAKE_COMMIT_MESSAGE" || echo "$FAKE_COMMIT_MESSAGE" > "$1"
19 test -z "$FAKE_COMMIT_AMEND" || echo "$FAKE_COMMIT_AMEND" >> "$1"
23 test -z "$EXPECT_COUNT" ||
24 test "$EXPECT_COUNT" = $(sed -e '/^#/d' -e '/^$/d' < "$1" | wc -l) ||
26 test -z "$FAKE_LINES" && exit
27 grep -v '^#' < "$1" > "$1".tmp
31 for line in $FAKE_LINES; do
36 echo sed -n "${line}s/^pick/$action/p"
37 sed -n "${line}p" < "$1".tmp
38 sed -n "${line}s/^pick/$action/p" < "$1".tmp >> "$1"
44 test_set_editor "$(pwd)/fake-editor.sh"
45 chmod a+x fake-editor.sh
47 # set up two branches like this:
49 # A1 - B1 - D1 - E1 - F1
53 test_expect_success 'setup' '
62 git checkout -b branch &&
66 git checkout master &&
83 test_expect_success 'squash F1 into D1' '
84 FAKE_LINES="1 squash 3 2" git rebase -i -p B1 &&
85 test "$(git rev-parse HEAD^2)" = "$(git rev-parse branch)" &&
86 test "$(git rev-parse HEAD~2)" = "$(git rev-parse B1)" &&
100 # And rebase G1..M1 onto E2
102 test_expect_success 'rebase two levels of merge' '
103 git checkout -b branch2 A1 &&
107 git checkout -b branch3 &&
111 git checkout -b branch4 &&
116 git checkout branch3 &&
120 git merge I1 --no-commit &&
123 git checkout branch2 &&
127 git merge K1 --no-commit &&
129 GIT_EDITOR=: git rebase -i -p E2 &&
130 test "$(git rev-parse HEAD~3)" = "$(git rev-parse E2)" &&
131 test "$(git rev-parse HEAD~2)" = "$(git rev-parse HEAD^2^2~2)" &&
132 test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse HEAD^2^2^1)"