submodule, repack: migrate to git-sh-setup's say()
[git/git.git] / t / t3400-rebase.sh
CommitLineData
294c695d
AW
1#!/bin/sh
2#
3# Copyright (c) 2005 Amos Waterland
4#
5
6test_description='git rebase should not destroy author information
7
8This test runs git rebase and checks that the author information is not lost.
9'
10. ./test-lib.sh
11
0e46e704
BD
12GIT_AUTHOR_EMAIL=bogus_email_address
13export GIT_AUTHOR_EMAIL
294c695d
AW
14
15test_expect_success \
1308c17b 16 'prepare repository with topic branches' \
3ec7371f
JS
17 'git config core.logAllRefUpdates true &&
18 echo First > A &&
5be60078 19 git update-index --add A &&
0cb0e143 20 git commit -m "Add A." &&
294c695d
AW
21 git checkout -b my-topic-branch &&
22 echo Second > B &&
5be60078 23 git update-index --add B &&
0cb0e143 24 git commit -m "Add B." &&
294c695d
AW
25 git checkout -f master &&
26 echo Third >> A &&
5be60078 27 git update-index A &&
0cb0e143 28 git commit -m "Modify A." &&
1308c17b
JS
29 git checkout -b side my-topic-branch &&
30 echo Side >> C &&
31 git add C &&
32 git commit -m "Add C" &&
33 git checkout -b nonlinear my-topic-branch &&
34 echo Edit >> B &&
35 git add B &&
36 git commit -m "Modify B" &&
37 git merge side &&
38 git checkout -b upstream-merged-nonlinear &&
39 git merge master &&
294c695d 40 git checkout -f my-topic-branch &&
1308c17b
JS
41 git tag topic
42'
43
7a7eb517
NTND
44test_expect_success 'rebase on dirty worktree' '
45 echo dirty >> A &&
46 test_must_fail git rebase master'
47
48test_expect_success 'rebase on dirty cache' '
49 git add A &&
50 test_must_fail git rebase master'
51
1308c17b 52test_expect_success 'rebase against master' '
7a7eb517 53 git reset --hard HEAD &&
294c695d
AW
54 git rebase master'
55
7a7eb517
NTND
56test_expect_success 'rebase against master twice' '
57 git rebase master 2>err &&
58 grep "Current branch my-topic-branch is up to date" err
59'
60
61test_expect_success 'rebase against master twice with --force' '
62 git rebase --force-rebase master >out &&
63 grep "Current branch my-topic-branch is up to date, rebase forced" out
64'
65
66test_expect_success 'rebase against master twice from another branch' '
67 git checkout my-topic-branch^ &&
68 git rebase master my-topic-branch 2>err &&
69 grep "Current branch my-topic-branch is up to date" err
70'
71
72test_expect_success 'rebase fast-forward to master' '
73 git checkout my-topic-branch^ &&
74 git rebase my-topic-branch 2>err &&
75 grep "Fast-forwarded HEAD to my-topic-branch" err
76'
77
41ac414e 78test_expect_success \
294c695d 79 'the rebase operation should not have destroyed author information' \
bbf08124 80 '! (git log | grep "Author:" | grep "<>")'
294c695d 81
2559bff3
JS
82test_expect_success 'HEAD was detached during rebase' '
83 test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})
84'
85
1308c17b
JS
86test_expect_success 'rebase after merge master' '
87 git reset --hard topic &&
88 git merge master &&
89 git rebase master &&
bbf08124 90 ! (git show | grep "^Merge:")
1308c17b
JS
91'
92
93test_expect_success 'rebase of history with merges is linearized' '
94 git checkout nonlinear &&
95 test 4 = $(git rev-list master.. | wc -l) &&
96 git rebase master &&
97 test 3 = $(git rev-list master.. | wc -l)
98'
99
100test_expect_success \
101 'rebase of history with merges after upstream merge is linearized' '
102 git checkout upstream-merged-nonlinear &&
103 test 5 = $(git rev-list master.. | wc -l) &&
104 git rebase master &&
105 test 3 = $(git rev-list master.. | wc -l)
106'
107
ece7b749
JS
108test_expect_success 'rebase a single mode change' '
109 git checkout master &&
110 echo 1 > X &&
111 git add X &&
112 test_tick &&
113 git commit -m prepare &&
114 git checkout -b modechange HEAD^ &&
115 echo 1 > X &&
116 git add X &&
1f553918 117 test_chmod +x A &&
ece7b749 118 test_tick &&
1f553918 119 git commit -m modechange &&
ece7b749
JS
120 GIT_TRACE=1 git rebase master
121'
122
3ec7371f
JS
123test_expect_success 'Show verbose error when HEAD could not be detached' '
124 : > B &&
125 test_must_fail git rebase topic 2> output.err > output.out &&
126 grep "Untracked working tree file .B. would be overwritten" output.err
127'
128
294c695d 129test_done