@@ -202,8 +202,8 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
202
202
return branch -> merge [0 ]-> src ;
203
203
}
204
204
205
- static void setup_push_upstream (struct remote * remote , struct branch * branch ,
206
- int same_remote )
205
+ static const char * setup_push_upstream (struct remote * remote , struct branch * branch ,
206
+ int same_remote )
207
207
{
208
208
const char * upstream_ref ;
209
209
upstream_ref = get_upstream_ref (branch , remote -> name );
@@ -212,16 +212,15 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,
212
212
"your current branch '%s', without telling me what to push\n"
213
213
"to update which remote branch." ),
214
214
remote -> name , branch -> name );
215
-
216
- refspec_appendf (& rs , "%s:%s" , branch -> refname , upstream_ref );
215
+ return upstream_ref ;
217
216
}
218
217
219
- static void setup_push_current (struct remote * remote , struct branch * branch )
218
+ static const char * setup_push_current (struct remote * remote , struct branch * branch )
220
219
{
221
- refspec_appendf ( & rs , "%s:%s" , branch -> refname , branch -> refname ) ;
220
+ return branch -> refname ;
222
221
}
223
222
224
- static void setup_push_simple (struct remote * remote , struct branch * branch , int same_remote )
223
+ static const char * setup_push_simple (struct remote * remote , struct branch * branch , int same_remote )
225
224
{
226
225
if (same_remote ) {
227
226
const char * upstream_ref ;
@@ -232,7 +231,7 @@ static void setup_push_simple(struct remote *remote, struct branch *branch, int
232
231
if (strcmp (branch -> refname , upstream_ref ))
233
232
die_push_simple (branch , remote );
234
233
}
235
- refspec_appendf ( & rs , "%s:%s" , branch -> refname , branch -> refname ) ;
234
+ return branch -> refname ;
236
235
}
237
236
238
237
static int is_same_remote (struct remote * remote )
@@ -245,6 +244,7 @@ static void setup_default_push_refspecs(struct remote *remote)
245
244
{
246
245
struct branch * branch ;
247
246
int same_remote = is_same_remote (remote );
247
+ const char * dst ;
248
248
249
249
switch (push_default ) {
250
250
case PUSH_DEFAULT_MATCHING :
@@ -267,17 +267,19 @@ static void setup_default_push_refspecs(struct remote *remote)
267
267
default :
268
268
case PUSH_DEFAULT_UNSPECIFIED :
269
269
case PUSH_DEFAULT_SIMPLE :
270
- setup_push_simple (remote , branch , same_remote );
271
- return ;
270
+ dst = setup_push_simple (remote , branch , same_remote );
271
+ break ;
272
272
273
273
case PUSH_DEFAULT_UPSTREAM :
274
- setup_push_upstream (remote , branch , same_remote );
275
- return ;
274
+ dst = setup_push_upstream (remote , branch , same_remote );
275
+ break ;
276
276
277
277
case PUSH_DEFAULT_CURRENT :
278
- setup_push_current (remote , branch );
279
- return ;
278
+ dst = setup_push_current (remote , branch );
279
+ break ;
280
280
}
281
+
282
+ refspec_appendf (& rs , "%s:%s" , branch -> refname , dst );
281
283
}
282
284
283
285
static const char message_advice_pull_before_push [] =
0 commit comments