]>
Commit | Line | Data |
---|---|---|
359ecebc DL |
1 | #!/bin/sh |
2 | # | |
3 | # Copyright (c) 2019 Denton Liu | |
4 | # | |
5 | ||
6 | test_description='git rebase --fork-point test' | |
7 | ||
d1c02d93 | 8 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
9 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
10 | ||
359ecebc DL |
11 | . ./test-lib.sh |
12 | ||
d1c02d93 | 13 | # A---B---D---E (main) |
359ecebc DL |
14 | # \ |
15 | # C*---F---G (side) | |
16 | # | |
d1c02d93 | 17 | # C was formerly part of main but main was rewound to remove C |
359ecebc DL |
18 | # |
19 | test_expect_success setup ' | |
20 | test_commit A && | |
21 | test_commit B && | |
22 | test_commit C && | |
23 | git branch -t side && | |
24 | git reset --hard HEAD^ && | |
25 | test_commit D && | |
26 | test_commit E && | |
27 | git checkout side && | |
28 | test_commit F && | |
29 | test_commit G | |
30 | ' | |
31 | ||
32 | test_rebase () { | |
33 | expected="$1" && | |
34 | shift && | |
35 | test_expect_success "git rebase $*" " | |
d1c02d93 | 36 | git checkout main && |
359ecebc DL |
37 | git reset --hard E && |
38 | git checkout side && | |
39 | git reset --hard G && | |
40 | git rebase $* && | |
41 | test_write_lines $expected >expect && | |
42 | git log --pretty=%s >actual && | |
43 | test_cmp expect actual | |
44 | " | |
45 | } | |
46 | ||
47 | test_rebase 'G F E D B A' | |
48 | test_rebase 'G F D B A' --onto D | |
414d924b | 49 | test_rebase 'G F B A' --keep-base |
359ecebc DL |
50 | test_rebase 'G F C E D B A' --no-fork-point |
51 | test_rebase 'G F C D B A' --no-fork-point --onto D | |
414d924b | 52 | test_rebase 'G F C B A' --no-fork-point --keep-base |
f08132f8 | 53 | |
d1c02d93 JS |
54 | test_rebase 'G F E D B A' --fork-point refs/heads/main |
55 | test_rebase 'G F E D B A' --fork-point main | |
f08132f8 | 56 | |
d1c02d93 JS |
57 | test_rebase 'G F D B A' --fork-point --onto D refs/heads/main |
58 | test_rebase 'G F D B A' --fork-point --onto D main | |
f08132f8 | 59 | |
d1c02d93 JS |
60 | test_rebase 'G F B A' --fork-point --keep-base refs/heads/main |
61 | test_rebase 'G F B A' --fork-point --keep-base main | |
f08132f8 | 62 | |
d1c02d93 JS |
63 | test_rebase 'G F C E D B A' refs/heads/main |
64 | test_rebase 'G F C E D B A' main | |
f08132f8 | 65 | |
d1c02d93 JS |
66 | test_rebase 'G F C D B A' --onto D refs/heads/main |
67 | test_rebase 'G F C D B A' --onto D main | |
f08132f8 | 68 | |
d1c02d93 JS |
69 | test_rebase 'G F C B A' --keep-base refs/heads/main |
70 | test_rebase 'G F C B A' --keep-base main | |
f08132f8 JH |
71 | |
72 | test_expect_success 'git rebase --fork-point with ambigous refname' ' | |
d1c02d93 | 73 | git checkout main && |
f08132f8 JH |
74 | git checkout -b one && |
75 | git checkout side && | |
76 | git tag one && | |
77 | test_must_fail git rebase --fork-point --onto D one | |
78 | ' | |
359ecebc DL |
79 | |
80 | test_done |