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 .
"$TEST_DIRECTORY"/lib-rebase.sh
15 # Set up branches like this:
16 # A1---B1---E1---F1---G1
21 test_expect_success
'setup' '
26 git reset --hard B1 &&
30 git reset --hard A1 &&
34 # Now rebase merge G1 from both branches' base B1, both should move:
35 # A1---B1---E1---F1---G1
43 test_expect_success
'rebase from B1 onto H1' '
45 git rebase -p --onto H1 B1 &&
46 test "$(git rev-parse HEAD^1^1^1)" = "$(git rev-parse H1)" &&
47 test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse H1)"
50 # On the other hand if rebase from E1 which is within one branch,
51 # then the other branch stays:
52 # A1---B1---E1---F1---G1
58 test_expect_success
'rebase from E1 onto H1' '
60 git rebase -p --onto H1 E1 &&
61 test "$(git rev-parse HEAD^1^1)" = "$(git rev-parse H1)" &&
62 test "$(git rev-parse HEAD^2)" = "$(git rev-parse D1)"
65 # And the same if we rebase from a commit in the second-parent branch.
66 # A1---B1---E1---F1----G1
72 test_expect_success
'rebase from C1 onto H1' '
74 git rev-list --first-parent --pretty=oneline C1..G1 &&
75 git rebase -p --onto H1 C1 &&
76 test "$(git rev-parse HEAD^2^1)" = "$(git rev-parse H1)" &&
77 test "$(git rev-parse HEAD^1)" = "$(git rev-parse F1)"