3 # Copyright (c) 2009 Greg Price
6 test_description
='git rebase -p should respect --onto
8 In a rebase with --onto, we should rewrite all the commits that
9 aren'"'"'t on top of $ONTO, even if they are on top of $UPSTREAM.
13 if ! test_have_prereq REBASE_P
; then
14 skip_all
='skipping git rebase -p tests, as asked for'
18 .
"$TEST_DIRECTORY"/lib-rebase.sh
20 # Set up branches like this:
21 # A1---B1---E1---F1---G1
26 test_expect_success
'setup' '
31 git reset --hard B1 &&
35 git reset --hard A1 &&
39 # Now rebase merge G1 from both branches' base B1, both should move:
40 # A1---B1---E1---F1---G1
48 test_expect_success
'rebase from B1 onto H1' '
50 git rebase -p --onto H1 B1 &&
51 test "$(git rev-parse HEAD^1^1^1)" = "$(git rev-parse H1)" &&
52 test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse H1)"
55 # On the other hand if rebase from E1 which is within one branch,
56 # then the other branch stays:
57 # A1---B1---E1---F1---G1
63 test_expect_success
'rebase from E1 onto H1' '
65 git rebase -p --onto H1 E1 &&
66 test "$(git rev-parse HEAD^1^1)" = "$(git rev-parse H1)" &&
67 test "$(git rev-parse HEAD^2)" = "$(git rev-parse D1)"
70 # And the same if we rebase from a commit in the second-parent branch.
71 # A1---B1---E1---F1----G1
77 test_expect_success
'rebase from C1 onto H1' '
79 git rev-list --first-parent --pretty=oneline C1..G1 &&
80 git rebase -p --onto H1 C1 &&
81 test "$(git rev-parse HEAD^2^1)" = "$(git rev-parse H1)" &&
82 test "$(git rev-parse HEAD^1)" = "$(git rev-parse F1)"