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.
12 GIT_AUTHOR_EMAIL
=bogus_email_address
13 export GIT_AUTHOR_EMAIL
16 'prepare repository with topic branches' \
17 'git config core.logAllRefUpdates true &&
19 git update-index --add A &&
20 git commit -m "Add A." &&
21 git checkout -b my-topic-branch &&
23 git update-index --add B &&
24 git commit -m "Add B." &&
25 git checkout -f master &&
28 git commit -m "Modify A." &&
29 git checkout -b side my-topic-branch &&
32 git commit -m "Add C" &&
33 git checkout -b nonlinear my-topic-branch &&
36 git commit -m "Modify B" &&
38 git checkout -b upstream-merged-nonlinear &&
40 git checkout -f my-topic-branch &&
44 test_expect_success
'rebase on dirty worktree' '
46 test_must_fail git rebase master'
48 test_expect_success
'rebase on dirty cache' '
50 test_must_fail git rebase master'
52 test_expect_success
'rebase against master' '
53 git reset --hard HEAD &&
56 test_expect_success
'rebase against master twice' '
57 git rebase master >out &&
58 grep "Current branch my-topic-branch is up to date" out
61 test_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
66 test_expect_success
'rebase against master twice from another branch' '
67 git checkout my-topic-branch^ &&
68 git rebase master my-topic-branch >out &&
69 grep "Current branch my-topic-branch is up to date" out
72 test_expect_success
'rebase fast-forward to master' '
73 git checkout my-topic-branch^ &&
74 git rebase my-topic-branch >out &&
75 grep "Fast-forwarded HEAD to my-topic-branch" out
79 'the rebase operation should not have destroyed author information' \
80 '! (git log | grep "Author:" | grep "<>")'
82 test_expect_success
'HEAD was detached during rebase' '
83 test $(git rev-parse HEAD@{1}) != $(git rev-parse my-topic-branch@{1})
86 test_expect_success
'rebase after merge master' '
87 git reset --hard topic &&
90 ! (git show | grep "^Merge:")
93 test_expect_success
'rebase of history with merges is linearized' '
94 git checkout nonlinear &&
95 test 4 = $(git rev-list master.. | wc -l) &&
97 test 3 = $(git rev-list master.. | wc -l)
100 test_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) &&
105 test 3 = $(git rev-list master.. | wc -l)
108 test_expect_success
'rebase a single mode change' '
109 git checkout master &&
113 git commit -m prepare &&
114 git checkout -b modechange HEAD^ &&
119 git commit -m modechange &&
120 GIT_TRACE=1 git rebase master
123 test_expect_success
'Show verbose error when HEAD could not be detached' '
125 test_must_fail git rebase topic 2> output.err > output.out &&
126 grep "Untracked working tree file .B. would be overwritten" output.err
129 test_expect_success
'rebase -q is quiet' '
131 git checkout -b quiet topic &&
132 git rebase -q master > output.out 2>&1 &&