]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3406-rebase-message.sh
The sixth batch
[thirdparty/git.git] / t / t3406-rebase-message.sh
CommitLineData
7afa845e
JS
1#!/bin/sh
2
3test_description='messages from rebase operation'
4
5. ./test-lib.sh
6
9e2248ef
MZ
7test_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
7afa845e 20test_expect_success 'rebase -m' '
7db00f0b
EN
21 git rebase -m master >actual &&
22 test_must_be_empty actual
7afa845e
JS
23'
24
c9581cc8 25test_expect_success 'rebase against master twice' '
10cdb9f3 26 git rebase --apply master >out &&
c9581cc8
MZ
27 test_i18ngrep "Current branch topic is up to date" out
28'
29
30test_expect_success 'rebase against master twice with --force' '
10cdb9f3 31 git rebase --force-rebase --apply master >out &&
c9581cc8
MZ
32 test_i18ngrep "Current branch topic is up to date, rebase forced" out
33'
34
35test_expect_success 'rebase against master twice from another branch' '
36 git checkout topic^ &&
10cdb9f3 37 git rebase --apply master topic >out &&
c9581cc8
MZ
38 test_i18ngrep "Current branch topic is up to date" out
39'
40
41test_expect_success 'rebase fast-forward to master' '
42 git checkout topic^ &&
10cdb9f3 43 git rebase --apply topic >out &&
c9581cc8
MZ
44 test_i18ngrep "Fast-forwarded HEAD to topic" out
45'
46
a9c3821c 47test_expect_success 'rebase --stat' '
a48fcd83 48 git reset --hard start &&
a9c3821c
TAV
49 git rebase --stat master >diffstat.txt &&
50 grep "^ fileX | *1 +$" diffstat.txt
51'
52
53test_expect_success 'rebase w/config rebase.stat' '
a48fcd83 54 git reset --hard start &&
a9c3821c
TAV
55 git config rebase.stat true &&
56 git rebase master >diffstat.txt &&
57 grep "^ fileX | *1 +$" diffstat.txt
58'
59
60test_expect_success 'rebase -n overrides config rebase.stat config' '
a48fcd83 61 git reset --hard start &&
a9c3821c
TAV
62 git config rebase.stat true &&
63 git rebase -n master >diffstat.txt &&
64 ! grep "^ fileX | *1 +$" diffstat.txt
65'
66
c7108bf9
JX
67# Output to stderr:
68#
69# "Does not point to a valid commit: invalid-ref"
70#
71# NEEDSWORK: This "grep" is fine in real non-C locales, but
6cdccfce 72# GIT_TEST_GETTEXT_POISON poisons the refname along with the enclosing
c7108bf9 73# error message.
9180feaf
EFL
74test_expect_success 'rebase --onto outputs the invalid ref' '
75 test_must_fail git rebase --onto invalid-ref HEAD HEAD 2>err &&
c7108bf9 76 test_i18ngrep "invalid-ref" err
9180feaf
EFL
77'
78
04519d72
JS
79test_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
84'
85
13a5a9f0
JS
86test_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 &&
91
1f6965f9 92 git rebase reflog-onto &&
13a5a9f0
JS
93 git log -g --format=%gs -3 >actual &&
94 cat >expect <<-\EOF &&
1f6965f9
EN
95 rebase (finish): returning to refs/heads/reflog-topic
96 rebase (pick): reflog-to-rebase
97 rebase (start): checkout reflog-onto
13a5a9f0
JS
98 EOF
99 test_cmp expect actual &&
100
101 git checkout -b reflog-prefix reflog-to-rebase &&
1f6965f9 102 GIT_REFLOG_ACTION=change-the-reflog git rebase reflog-onto &&
13a5a9f0
JS
103 git log -g --format=%gs -3 >actual &&
104 cat >expect <<-\EOF &&
1f6965f9
EN
105 change-the-reflog (finish): returning to refs/heads/reflog-prefix
106 change-the-reflog (pick): reflog-to-rebase
107 change-the-reflog (start): checkout reflog-onto
13a5a9f0
JS
108 EOF
109 test_cmp expect actual
110'
111
8797f0f0
JS
112test_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
120'
121
7afa845e 122test_done