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