3 # Copyright (c) 2008 Stephen Haberman
6 test_description='git rebase preserve merges
8 This test runs git rebase with preserve merges and ensures commits
9 dropped by the --cherry-pick flag have their childrens parents
14 if ! test_have_prereq REBASE_P; then
15 skip_all='skipping git rebase -p tests, as asked for'
19 # set up two branches like this:
27 # where B, D and G touch the same file.
29 test_expect_success 'setup' '
30 test_commit A file1 &&
31 test_commit B file1 1 &&
32 test_commit C file2 &&
33 test_commit D file1 2 &&
34 test_commit E file3 &&
36 test_commit F file4 &&
37 test_commit G file1 3 &&
38 test_commit H file5 &&
45 # F - G - H -- L \ --> L
47 # I -- G2 -- J -- K I -- K
48 # G2 = same changes as G
49 test_expect_success 'skip same-resolution merges with -p' '
51 test_must_fail git merge E &&
52 test_commit L file1 23 &&
54 test_commit G2 file1 3 &&
55 test_must_fail git merge E &&
56 test_commit J file1 23 &&
57 test_commit K file7 file7 &&
59 test $(git rev-parse HEAD^^) = $(git rev-parse L) &&
60 test "23" = "$(cat file1)" &&
61 test "I" = "$(cat file6)" &&
62 test "file7" = "$(cat file7)"
67 # F - G - H -- L2 \ --> L2
69 # I -- G3 --- J2 -- K2 I -- G3 -- K2
70 # G2 = different changes as G
71 test_expect_success 'keep different-resolution merges with -p' '
73 test_must_fail git merge E &&
74 test_commit L2 file1 23 &&
76 test_commit G3 file1 4 &&
77 test_must_fail git merge E &&
78 test_commit J2 file1 24 &&
79 test_commit K2 file7 file7 &&
80 test_must_fail git rebase -i -p L2 &&
83 git rebase --continue &&
84 test $(git rev-parse HEAD^^^) = $(git rev-parse L2) &&
85 test "234" = "$(cat file1)" &&
86 test "I" = "$(cat file6)" &&
87 test "file7" = "$(cat file7)"