]>
Commit | Line | Data |
---|---|---|
d09e79cb LT |
1 | #!/bin/sh |
2 | ||
3 | test_description='pulling into void' | |
4 | ||
5 | . ./test-lib.sh | |
6 | ||
7 | D=`pwd` | |
8 | ||
9 | test_expect_success setup ' | |
10 | ||
11 | echo file >file && | |
12 | git add file && | |
13 | git commit -a -m original | |
14 | ||
15 | ' | |
16 | ||
17 | test_expect_success 'pulling into void' ' | |
18 | mkdir cloned && | |
19 | cd cloned && | |
5c94f87e | 20 | git init && |
d09e79cb LT |
21 | git pull .. |
22 | ' | |
23 | ||
24 | cd "$D" | |
25 | ||
26 | test_expect_success 'checking the results' ' | |
27 | test -f file && | |
28 | test -f cloned/file && | |
4fdf71be | 29 | test_cmp file cloned/file |
d09e79cb LT |
30 | ' |
31 | ||
b0ad11ea JH |
32 | test_expect_success 'pulling into void using master:master' ' |
33 | mkdir cloned-uho && | |
34 | ( | |
35 | cd cloned-uho && | |
36 | git init && | |
37 | git pull .. master:master | |
38 | ) && | |
39 | test -f file && | |
40 | test -f cloned-uho/file && | |
41 | test_cmp file cloned-uho/file | |
42 | ' | |
43 | ||
9debc324 PB |
44 | test_expect_success 'test . as a remote' ' |
45 | ||
46 | git branch copy master && | |
47 | git config branch.copy.remote . && | |
48 | git config branch.copy.merge refs/heads/master && | |
49 | echo updated >file && | |
50 | git commit -a -m updated && | |
51 | git checkout copy && | |
52 | test `cat file` = file && | |
53 | git pull && | |
54 | test `cat file` = updated | |
55 | ' | |
56 | ||
57 | test_expect_success 'the default remote . should not break explicit pull' ' | |
58 | git checkout -b second master^ && | |
59 | echo modified >file && | |
60 | git commit -a -m modified && | |
61 | git checkout copy && | |
62 | git reset --hard HEAD^ && | |
63 | test `cat file` = file && | |
64 | git pull . second && | |
65 | test `cat file` = modified | |
66 | ' | |
67 | ||
cd67e4d4 JS |
68 | test_expect_success '--rebase' ' |
69 | git branch to-rebase && | |
70 | echo modified again > file && | |
71 | git commit -m file file && | |
72 | git checkout to-rebase && | |
73 | echo new > file2 && | |
74 | git add file2 && | |
75 | git commit -m "new file" && | |
76 | git tag before-rebase && | |
77 | git pull --rebase . copy && | |
78 | test $(git rev-parse HEAD^) = $(git rev-parse copy) && | |
79 | test new = $(git show HEAD:file2) | |
80 | ' | |
81 | ||
82 | test_expect_success 'branch.to-rebase.rebase' ' | |
83 | git reset --hard before-rebase && | |
84 | git config branch.to-rebase.rebase 1 && | |
85 | git pull . copy && | |
c85c7927 | 86 | git config branch.to-rebase.rebase 0 && |
cd67e4d4 JS |
87 | test $(git rev-parse HEAD^) = $(git rev-parse copy) && |
88 | test new = $(git show HEAD:file2) | |
89 | ' | |
90 | ||
c85c7927 JS |
91 | test_expect_success '--rebase with rebased upstream' ' |
92 | ||
93 | git remote add -f me . && | |
94 | git checkout copy && | |
e9460a66 | 95 | git tag copy-orig && |
c85c7927 JS |
96 | git reset --hard HEAD^ && |
97 | echo conflicting modification > file && | |
98 | git commit -m conflict file && | |
99 | git checkout to-rebase && | |
100 | echo file > file2 && | |
101 | git commit -m to-rebase file2 && | |
e9460a66 | 102 | git tag to-rebase-orig && |
c85c7927 JS |
103 | git pull --rebase me copy && |
104 | test "conflicting modification" = "$(cat file)" && | |
105 | test file = $(cat file2) | |
106 | ||
107 | ' | |
108 | ||
e9460a66 SB |
109 | test_expect_success '--rebase with rebased default upstream' ' |
110 | ||
111 | git update-ref refs/remotes/me/copy copy-orig && | |
112 | git checkout --track -b to-rebase2 me/copy && | |
113 | git reset --hard to-rebase-orig && | |
114 | git pull --rebase && | |
115 | test "conflicting modification" = "$(cat file)" && | |
116 | test file = $(cat file2) | |
117 | ||
118 | ' | |
119 | ||
d44e7126 | 120 | test_expect_success 'rebased upstream + fetch + pull --rebase' ' |
a418441b SB |
121 | |
122 | git update-ref refs/remotes/me/copy copy-orig && | |
123 | git reset --hard to-rebase-orig && | |
124 | git checkout --track -b to-rebase3 me/copy && | |
125 | git reset --hard to-rebase-orig && | |
126 | git fetch && | |
d44e7126 | 127 | git pull --rebase && |
a418441b SB |
128 | test "conflicting modification" = "$(cat file)" && |
129 | test file = "$(cat file2)" | |
130 | ||
131 | ' | |
132 | ||
f9189cf8 JS |
133 | test_expect_success 'pull --rebase dies early with dirty working directory' ' |
134 | ||
e9460a66 | 135 | git checkout to-rebase && |
f9189cf8 JS |
136 | git update-ref refs/remotes/me/copy copy^ && |
137 | COPY=$(git rev-parse --verify me/copy) && | |
138 | git rebase --onto $COPY copy && | |
139 | git config branch.to-rebase.remote me && | |
140 | git config branch.to-rebase.merge refs/heads/copy && | |
141 | git config branch.to-rebase.rebase true && | |
142 | echo dirty >> file && | |
143 | git add file && | |
144 | test_must_fail git pull && | |
145 | test $COPY = $(git rev-parse --verify me/copy) && | |
146 | git checkout HEAD -- file && | |
147 | git pull && | |
148 | test $COPY != $(git rev-parse --verify me/copy) | |
149 | ||
150 | ' | |
151 | ||
19a7fcbf JK |
152 | test_expect_success 'pull --rebase works on branch yet to be born' ' |
153 | git rev-parse master >expect && | |
154 | mkdir empty_repo && | |
155 | (cd empty_repo && | |
156 | git init && | |
157 | git pull --rebase .. master && | |
158 | git rev-parse HEAD >../actual | |
159 | ) && | |
160 | test_cmp expect actual | |
161 | ' | |
162 | ||
d09e79cb | 163 | test_done |