3 test_description='messages from rebase operation'
7 test_expect_success 'setup' '
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 &&
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 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
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
79 test_expect_success 'GIT_REFLOG_ACTION' '
81 test_commit reflog-onto &&
82 git checkout -b reflog-topic start &&
83 test_commit reflog-to-rebase &&
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
92 test_cmp expect actual &&
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
102 test_cmp expect actual
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