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