Merge branch 'js/test-unc-fetch'
[git/debian.git] / t / t3406-rebase-message.sh
blobb393e1e9fee88bb9b3df6ecc8544dfa370086e41
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 >report &&
22 >expect &&
23 sed -n -e "/^Already applied: /p" \
24 -e "/^Committed: /p" report >actual &&
25 test_cmp expect actual
28 test_expect_success 'rebase against master twice' '
29 git rebase master >out &&
30 test_i18ngrep "Current branch topic is up to date" out
33 test_expect_success 'rebase against master twice with --force' '
34 git rebase --force-rebase master >out &&
35 test_i18ngrep "Current branch topic is up to date, rebase forced" out
38 test_expect_success 'rebase against master twice from another branch' '
39 git checkout topic^ &&
40 git rebase master topic >out &&
41 test_i18ngrep "Current branch topic is up to date" out
44 test_expect_success 'rebase fast-forward to master' '
45 git checkout topic^ &&
46 git rebase topic >out &&
47 test_i18ngrep "Fast-forwarded HEAD to topic" out
50 test_expect_success 'rebase --stat' '
51 git reset --hard start &&
52 git rebase --stat master >diffstat.txt &&
53 grep "^ fileX | *1 +$" diffstat.txt
56 test_expect_success 'rebase w/config rebase.stat' '
57 git reset --hard start &&
58 git config rebase.stat true &&
59 git rebase master >diffstat.txt &&
60 grep "^ fileX | *1 +$" diffstat.txt
63 test_expect_success 'rebase -n overrides config rebase.stat config' '
64 git reset --hard start &&
65 git config rebase.stat true &&
66 git rebase -n master >diffstat.txt &&
67 ! grep "^ fileX | *1 +$" diffstat.txt
70 # Output to stderr:
72 # "Does not point to a valid commit: invalid-ref"
74 # NEEDSWORK: This "grep" is fine in real non-C locales, but
75 # GIT_TEST_GETTEXT_POISON poisons the refname along with the enclosing
76 # error message.
77 test_expect_success 'rebase --onto outputs the invalid ref' '
78 test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err &&
79 test_i18ngrep "invalid-ref" err
82 test_expect_success 'error out early upon -C<n> or --whitespace=<bad>' '
83 test_must_fail git rebase -Cnot-a-number HEAD 2>err &&
84 test_i18ngrep "numerical value" err &&
85 test_must_fail git rebase --whitespace=bad HEAD 2>err &&
86 test_i18ngrep "Invalid whitespace option" err
89 test_expect_success 'GIT_REFLOG_ACTION' '
90 git checkout start &&
91 test_commit reflog-onto &&
92 git checkout -b reflog-topic start &&
93 test_commit reflog-to-rebase &&
95 git rebase reflog-onto &&
96 git log -g --format=%gs -3 >actual &&
97 cat >expect <<-\EOF &&
98 rebase finished: returning to refs/heads/reflog-topic
99 rebase: reflog-to-rebase
100 rebase: checkout reflog-onto
102 test_cmp expect actual &&
104 git checkout -b reflog-prefix reflog-to-rebase &&
105 GIT_REFLOG_ACTION=change-the-reflog git rebase reflog-onto &&
106 git log -g --format=%gs -3 >actual &&
107 cat >expect <<-\EOF &&
108 rebase finished: returning to refs/heads/reflog-prefix
109 change-the-reflog: reflog-to-rebase
110 change-the-reflog: checkout reflog-onto
112 test_cmp expect actual
115 test_expect_success 'rebase -i onto unrelated history' '
116 git init unrelated &&
117 test_commit -C unrelated 1 &&
118 git -C unrelated remote add -f origin "$PWD" &&
119 git -C unrelated branch --set-upstream-to=origin/master &&
120 git -C unrelated -c core.editor=true rebase -i -v --stat >actual &&
121 test_i18ngrep "Changes to " actual &&
122 test_i18ngrep "5 files changed" actual
125 test_done