@@ -15,10 +15,18 @@ test_expect_success 'setup' '
15
15
test_commit 3 &&
16
16
(cd clone &&
17
17
test_commit 4 &&
18
- git branch --track my-side origin/side)
19
-
18
+ git branch --track my-side origin/side &&
19
+ git branch --track local-master master &&
20
+ git remote add -t master master-only .. &&
21
+ git fetch master-only &&
22
+ git branch bad-upstream &&
23
+ git config branch.bad-upstream.remote master-only &&
24
+ git config branch.bad-upstream.merge refs/heads/side
25
+ )
20
26
'
21
27
28
+ sq=" '"
29
+
22
30
full_name () {
23
31
(cd clone &&
24
32
git rev-parse --symbolic-full-name " $@ " )
@@ -29,6 +37,11 @@ commit_subject () {
29
37
git show -s --pretty=format:%s " $@ " )
30
38
}
31
39
40
+ error_message () {
41
+ (cd clone &&
42
+ test_must_fail git rev-parse --verify " $@ " )
43
+ }
44
+
32
45
test_expect_success ' @{upstream} resolves to correct full name' '
33
46
test refs/remotes/origin/master = "$(full_name @{upstream})"
34
47
'
@@ -78,7 +91,6 @@ test_expect_success 'checkout -b new my-side@{u} forks from the same' '
78
91
79
92
test_expect_success ' merge my-side@{u} records the correct name' '
80
93
(
81
- sq="' \' ' " &&
82
94
cd clone || exit
83
95
git checkout master || exit
84
96
git branch -D new ;# can fail but is ok
@@ -107,6 +119,69 @@ test_expect_success 'checkout other@{u}' '
107
119
test_cmp expect actual
108
120
'
109
121
122
+ test_expect_success ' branch@{u} works when tracking a local branch' '
123
+ test refs/heads/master = "$(full_name local-master@{u})"
124
+ '
125
+
126
+ test_expect_success ' branch@{u} error message when no upstream' '
127
+ cat >expect <<-EOF &&
128
+ error: No upstream configured for branch ${sq}non-tracking${sq}
129
+ fatal: Needed a single revision
130
+ EOF
131
+ error_message non-tracking@{u} 2>actual &&
132
+ test_i18ncmp expect actual
133
+ '
134
+
135
+ test_expect_success ' @{u} error message when no upstream' '
136
+ cat >expect <<-EOF &&
137
+ error: No upstream configured for branch ${sq}master${sq}
138
+ fatal: Needed a single revision
139
+ EOF
140
+ test_must_fail git rev-parse --verify @{u} 2>actual &&
141
+ test_i18ncmp expect actual
142
+ '
143
+
144
+ test_expect_success ' branch@{u} error message with misspelt branch' '
145
+ cat >expect <<-EOF &&
146
+ error: No such branch: ${sq}no-such-branch${sq}
147
+ fatal: Needed a single revision
148
+ EOF
149
+ error_message no-such-branch@{u} 2>actual &&
150
+ test_i18ncmp expect actual
151
+ '
152
+
153
+ test_expect_success ' @{u} error message when not on a branch' '
154
+ cat >expect <<-EOF &&
155
+ error: HEAD does not point to a branch
156
+ fatal: Needed a single revision
157
+ EOF
158
+ git checkout HEAD^0 &&
159
+ test_must_fail git rev-parse --verify @{u} 2>actual &&
160
+ test_i18ncmp expect actual
161
+ '
162
+
163
+ test_expect_success ' branch@{u} error message if upstream branch not fetched' '
164
+ cat >expect <<-EOF &&
165
+ error: Upstream branch ${sq}refs/heads/side${sq} not stored as a remote-tracking branch
166
+ fatal: Needed a single revision
167
+ EOF
168
+ error_message bad-upstream@{u} 2>actual &&
169
+ test_i18ncmp expect actual
170
+ '
171
+
172
+ test_expect_success ' pull works when tracking a local branch' '
173
+ (
174
+ cd clone &&
175
+ git checkout local-master &&
176
+ git pull
177
+ )
178
+ '
179
+
180
+ # makes sense if the previous one succeeded
181
+ test_expect_success ' @{u} works when tracking a local branch' '
182
+ test refs/heads/master = "$(full_name @{u})"
183
+ '
184
+
110
185
cat > expect << EOF
111
186
commit 8f489d01d0cc65c3b0f09504ec50b5ed02a70bd5
112
187
Reflog: master@{0} (C O Mitter <[email protected] >)
0 commit comments