]>
Commit | Line | Data |
---|---|---|
7afa845e JS |
1 | #!/bin/sh |
2 | ||
3 | test_description='messages from rebase operation' | |
4 | ||
d1c02d93 | 5 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
6 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
7 | ||
7afa845e JS |
8 | . ./test-lib.sh |
9 | ||
9e2248ef MZ |
10 | test_expect_success 'setup' ' |
11 | test_commit O fileO && | |
12 | test_commit X fileX && | |
13 | test_commit A fileA && | |
14 | test_commit B fileB && | |
15 | test_commit Y fileY && | |
7afa845e | 16 | |
9e2248ef MZ |
17 | git checkout -b topic O && |
18 | git cherry-pick A B && | |
19 | test_commit Z fileZ && | |
a9c3821c | 20 | git tag start |
7afa845e JS |
21 | ' |
22 | ||
7afa845e | 23 | test_expect_success 'rebase -m' ' |
d1c02d93 | 24 | git rebase -m main >actual && |
7db00f0b | 25 | test_must_be_empty actual |
7afa845e JS |
26 | ' |
27 | ||
d1c02d93 JS |
28 | test_expect_success 'rebase against main twice' ' |
29 | git rebase --apply main >out && | |
c9581cc8 MZ |
30 | test_i18ngrep "Current branch topic is up to date" out |
31 | ' | |
32 | ||
d1c02d93 JS |
33 | test_expect_success 'rebase against main twice with --force' ' |
34 | git rebase --force-rebase --apply main >out && | |
c9581cc8 MZ |
35 | test_i18ngrep "Current branch topic is up to date, rebase forced" out |
36 | ' | |
37 | ||
d1c02d93 | 38 | test_expect_success 'rebase against main twice from another branch' ' |
c9581cc8 | 39 | git checkout topic^ && |
d1c02d93 | 40 | git rebase --apply main topic >out && |
c9581cc8 MZ |
41 | test_i18ngrep "Current branch topic is up to date" out |
42 | ' | |
43 | ||
d1c02d93 | 44 | test_expect_success 'rebase fast-forward to main' ' |
c9581cc8 | 45 | git checkout topic^ && |
10cdb9f3 | 46 | git rebase --apply topic >out && |
c9581cc8 MZ |
47 | test_i18ngrep "Fast-forwarded HEAD to topic" out |
48 | ' | |
49 | ||
a9c3821c | 50 | test_expect_success 'rebase --stat' ' |
a48fcd83 | 51 | git reset --hard start && |
d1c02d93 | 52 | git rebase --stat main >diffstat.txt && |
0f321f95 | 53 | grep "^ fileX | *1 +$" diffstat.txt |
a9c3821c TAV |
54 | ' |
55 | ||
56 | test_expect_success 'rebase w/config rebase.stat' ' | |
a48fcd83 | 57 | git reset --hard start && |
0f321f95 | 58 | git config rebase.stat true && |
d1c02d93 | 59 | git rebase main >diffstat.txt && |
0f321f95 | 60 | grep "^ fileX | *1 +$" diffstat.txt |
a9c3821c TAV |
61 | ' |
62 | ||
63 | test_expect_success 'rebase -n overrides config rebase.stat config' ' | |
a48fcd83 | 64 | git reset --hard start && |
0f321f95 | 65 | git config rebase.stat true && |
d1c02d93 | 66 | git rebase -n main >diffstat.txt && |
0f321f95 | 67 | ! grep "^ fileX | *1 +$" diffstat.txt |
a9c3821c TAV |
68 | ' |
69 | ||
9180feaf EFL |
70 | test_expect_success 'rebase --onto outputs the invalid ref' ' |
71 | test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err && | |
c7108bf9 | 72 | test_i18ngrep "invalid-ref" err |
9180feaf EFL |
73 | ' |
74 | ||
04519d72 JS |
75 | test_expect_success 'error out early upon -C<n> or --whitespace=<bad>' ' |
76 | test_must_fail git rebase -Cnot-a-number HEAD 2>err && | |
77 | test_i18ngrep "numerical value" err && | |
78 | test_must_fail git rebase --whitespace=bad HEAD 2>err && | |
79 | test_i18ngrep "Invalid whitespace option" err | |
80 | ' | |
81 | ||
13a5a9f0 JS |
82 | test_expect_success 'GIT_REFLOG_ACTION' ' |
83 | git checkout start && | |
84 | test_commit reflog-onto && | |
85 | git checkout -b reflog-topic start && | |
86 | test_commit reflog-to-rebase && | |
87 | ||
1f6965f9 | 88 | git rebase reflog-onto && |
13a5a9f0 JS |
89 | git log -g --format=%gs -3 >actual && |
90 | cat >expect <<-\EOF && | |
1f6965f9 EN |
91 | rebase (finish): returning to refs/heads/reflog-topic |
92 | rebase (pick): reflog-to-rebase | |
93 | rebase (start): checkout reflog-onto | |
13a5a9f0 JS |
94 | EOF |
95 | test_cmp expect actual && | |
96 | ||
97 | git checkout -b reflog-prefix reflog-to-rebase && | |
1f6965f9 | 98 | GIT_REFLOG_ACTION=change-the-reflog git rebase reflog-onto && |
13a5a9f0 JS |
99 | git log -g --format=%gs -3 >actual && |
100 | cat >expect <<-\EOF && | |
1f6965f9 EN |
101 | change-the-reflog (finish): returning to refs/heads/reflog-prefix |
102 | change-the-reflog (pick): reflog-to-rebase | |
103 | change-the-reflog (start): checkout reflog-onto | |
13a5a9f0 JS |
104 | EOF |
105 | test_cmp expect actual | |
106 | ' | |
107 | ||
8797f0f0 JS |
108 | test_expect_success 'rebase -i onto unrelated history' ' |
109 | git init unrelated && | |
110 | test_commit -C unrelated 1 && | |
111 | git -C unrelated remote add -f origin "$PWD" && | |
d1c02d93 | 112 | git -C unrelated branch --set-upstream-to=origin/main && |
8797f0f0 JS |
113 | git -C unrelated -c core.editor=true rebase -i -v --stat >actual && |
114 | test_i18ngrep "Changes to " actual && | |
115 | test_i18ngrep "5 files changed" actual | |
116 | ' | |
117 | ||
7afa845e | 118 | test_done |