Start a library for cvsimport-related tests
[git.git] / t / t3400-rebase.sh
blob8c0c5f59827544b47cc7a75f0c3f39cfcecf0a7e
1 #!/bin/sh
3 # Copyright (c) 2005 Amos Waterland
6 test_description='git rebase should not destroy author information
8 This test runs git rebase and checks that the author information is not lost.
10 . ./test-lib.sh
12 GIT_AUTHOR_EMAIL=bogus_email_address
13 export GIT_AUTHOR_EMAIL
15 test_expect_success \
16 'prepare repository with topic branches' \
17 'git config core.logAllRefUpdates true &&
18 echo First > A &&
19 git update-index --add A &&
20 git commit -m "Add A." &&
21 git checkout -b my-topic-branch &&
22 echo Second > B &&
23 git update-index --add B &&
24 git commit -m "Add B." &&
25 git checkout -f master &&
26 echo Third >> A &&
27 git update-index A &&
28 git commit -m "Modify A." &&
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 &&
40 git checkout -f my-topic-branch &&
41 git tag topic
44 test_expect_success 'rebase against master' '
45 git rebase master'
47 test_expect_success \
48 'the rebase operation should not have destroyed author information' \
49 '! (git log | grep "Author:" | grep "<>")'
51 test_expect_success 'rebase after merge master' '
52 git reset --hard topic &&
53 git merge master &&
54 git rebase master &&
55 ! (git show | grep "^Merge:")
58 test_expect_success 'rebase of history with merges is linearized' '
59 git checkout nonlinear &&
60 test 4 = $(git rev-list master.. | wc -l) &&
61 git rebase master &&
62 test 3 = $(git rev-list master.. | wc -l)
65 test_expect_success \
66 'rebase of history with merges after upstream merge is linearized' '
67 git checkout upstream-merged-nonlinear &&
68 test 5 = $(git rev-list master.. | wc -l) &&
69 git rebase master &&
70 test 3 = $(git rev-list master.. | wc -l)
73 test_expect_success 'rebase a single mode change' '
74 git checkout master &&
75 echo 1 > X &&
76 git add X &&
77 test_tick &&
78 git commit -m prepare &&
79 git checkout -b modechange HEAD^ &&
80 echo 1 > X &&
81 git add X &&
82 chmod a+x A &&
83 test_tick &&
84 git commit -m modechange A X &&
85 GIT_TRACE=1 git rebase master
88 test_expect_success 'HEAD was detached during rebase' '
89 test $(git rev-parse HEAD@{1}) != $(git rev-parse modechange@{1})
92 test_expect_success 'Show verbose error when HEAD could not be detached' '
93 : > B &&
94 test_must_fail git rebase topic 2> output.err > output.out &&
95 grep "Untracked working tree file .B. would be overwritten" output.err
98 test_done