fsck: do not give up too early in fsck_dir()
[git/jnareb-git.git] / t / t3402-rebase-merge.sh
blobbe8c1d5ef9fd650c128a9fe7126cbcd8db6c5a95
1 #!/bin/sh
3 # Copyright (c) 2006 Junio C Hamano
6 test_description='git rebase --merge test'
8 . ./test-lib.sh
10 T="A quick brown fox
11 jumps over the lazy dog."
12 for i in 1 2 3 4 5 6 7 8 9 10
14 echo "$i $T"
15 done >original
17 test_expect_success setup '
18 git add original &&
19 git commit -m"initial" &&
20 git branch side &&
21 echo "11 $T" >>original &&
22 git commit -a -m"master updates a bit." &&
24 echo "12 $T" >>original &&
25 git commit -a -m"master updates a bit more." &&
27 git checkout side &&
28 (echo "0 $T" ; cat original) >renamed &&
29 git add renamed &&
30 git update-index --force-remove original &&
31 git commit -a -m"side renames and edits." &&
33 tr "[a-z]" "[A-Z]" <original >newfile &&
34 git add newfile &&
35 git commit -a -m"side edits further." &&
37 tr "[a-m]" "[A-M]" <original >newfile &&
38 rm -f original &&
39 git commit -a -m"side edits once again." &&
41 git branch test-rebase side &&
42 git branch test-rebase-pick side &&
43 git branch test-reference-pick side &&
44 git checkout -b test-merge side
47 test_expect_success 'reference merge' '
48 git merge -s recursive "reference merge" HEAD master
51 PRE_REBASE=$(git rev-parse test-rebase)
52 test_expect_success rebase '
53 git checkout test-rebase &&
54 GIT_TRACE=1 git rebase --merge master
57 test_expect_success 'test-rebase@{1} is pre rebase' '
58 test $PRE_REBASE = $(git rev-parse test-rebase@{1})
61 test_expect_success 'merge and rebase should match' '
62 git diff-tree -r test-rebase test-merge >difference &&
63 if test -s difference
64 then
65 cat difference
66 (exit 1)
67 else
68 echo happy
72 test_expect_success 'rebase the other way' '
73 git reset --hard master &&
74 git rebase --merge side
77 test_expect_success 'rebase -Xtheirs' '
78 git checkout -b conflicting master~2 &&
79 echo "AB $T" >> original &&
80 git commit -mconflicting original &&
81 git rebase -Xtheirs master &&
82 grep AB original &&
83 ! grep 11 original
86 test_expect_success 'merge and rebase should match' '
87 git diff-tree -r test-rebase test-merge >difference &&
88 if test -s difference
89 then
90 cat difference
91 (exit 1)
92 else
93 echo happy
97 test_expect_success 'picking rebase' '
98 git reset --hard side &&
99 git rebase --merge --onto master side^^ &&
100 mb=$(git merge-base master HEAD) &&
101 if test "$mb" = "$(git rev-parse master)"
102 then
103 echo happy
104 else
105 git show-branch
106 (exit 1)
107 fi &&
108 f=$(git diff-tree --name-only HEAD^ HEAD) &&
109 g=$(git diff-tree --name-only HEAD^^ HEAD^) &&
110 case "$f,$g" in
111 newfile,newfile)
112 echo happy ;;
114 echo "$f"
115 echo "$g"
116 (exit 1)
117 esac
120 test_expect_success 'rebase -s funny -Xopt' '
121 test_when_finished "rm -fr test-bin funny.was.run" &&
122 mkdir test-bin &&
123 cat >test-bin/git-merge-funny <<-EOF &&
124 #!$SHELL_PATH
125 case "\$1" in --opt) ;; *) exit 2 ;; esac
126 shift &&
127 >funny.was.run &&
128 exec git merge-recursive "\$@"
130 chmod +x test-bin/git-merge-funny &&
131 git reset --hard &&
132 git checkout -b test-funny master^ &&
133 test_commit funny &&
135 PATH=./test-bin:$PATH
136 git rebase -s funny -Xopt master
137 ) &&
138 test -f funny.was.run
141 test_done