Merge branch 'dl/test-must-fail-fixes-3'
[git.git] / t / t3406-rebase-message.sh
blob61b76f3301982d26b808044bde9ce928f663112e
1 #!/bin/sh
3 test_description='messages from rebase operation'
5 . ./test-lib.sh
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 &&
14 git checkout -b topic O &&
15 git cherry-pick A B &&
16 test_commit Z fileZ &&
17 git tag start
20 test_expect_success 'rebase -m' '
21 git rebase -m master >actual &&
22 test_must_be_empty actual
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
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
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
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
47 test_expect_success 'rebase --stat' '
48 git reset --hard start &&
49 git rebase --stat master >diffstat.txt &&
50 grep "^ fileX | *1 +$" diffstat.txt
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
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
67 # Output to stderr:
69 # "Does not point to a valid commit: invalid-ref"
71 # NEEDSWORK: This "grep" is fine in real non-C locales, but
72 # GIT_TEST_GETTEXT_POISON poisons the refname along with the enclosing
73 # error message.
74 test_expect_success 'rebase --onto outputs the invalid ref' '
75 test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err &&
76 test_i18ngrep "invalid-ref" err
79 test_expect_success 'error out early upon -C<n> or --whitespace=<bad>' '
80 test_must_fail git rebase -Cnot-a-number HEAD 2>err &&
81 test_i18ngrep "numerical value" err &&
82 test_must_fail git rebase --whitespace=bad HEAD 2>err &&
83 test_i18ngrep "Invalid whitespace option" err
86 test_expect_success 'GIT_REFLOG_ACTION' '
87 git checkout start &&
88 test_commit reflog-onto &&
89 git checkout -b reflog-topic start &&
90 test_commit reflog-to-rebase &&
92 git rebase --apply reflog-onto &&
93 git log -g --format=%gs -3 >actual &&
94 cat >expect <<-\EOF &&
95 rebase finished: returning to refs/heads/reflog-topic
96 rebase: reflog-to-rebase
97 rebase: checkout reflog-onto
98 EOF
99 test_cmp expect actual &&
101 git checkout -b reflog-prefix reflog-to-rebase &&
102 GIT_REFLOG_ACTION=change-the-reflog git rebase --apply reflog-onto &&
103 git log -g --format=%gs -3 >actual &&
104 cat >expect <<-\EOF &&
105 rebase finished: returning to refs/heads/reflog-prefix
106 change-the-reflog: reflog-to-rebase
107 change-the-reflog: checkout reflog-onto
109 test_cmp expect actual
112 test_expect_success 'rebase -i onto unrelated history' '
113 git init unrelated &&
114 test_commit -C unrelated 1 &&
115 git -C unrelated remote add -f origin "$PWD" &&
116 git -C unrelated branch --set-upstream-to=origin/master &&
117 git -C unrelated -c core.editor=true rebase -i -v --stat >actual &&
118 test_i18ngrep "Changes to " actual &&
119 test_i18ngrep "5 files changed" actual
122 test_done