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