@@ -202,8 +202,8 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
202202 return branch -> merge [0 ]-> src ;
203203}
204204
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 )
207207{
208208 const char * upstream_ref ;
209209 upstream_ref = get_upstream_ref (branch , remote -> name );
@@ -212,16 +212,15 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,
212212 "your current branch '%s', without telling me what to push\n"
213213 "to update which remote branch." ),
214214 remote -> name , branch -> name );
215-
216- refspec_appendf (& rs , "%s:%s" , branch -> refname , upstream_ref );
215+ return upstream_ref ;
217216}
218217
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 )
220219{
221- refspec_appendf ( & rs , "%s:%s" , branch -> refname , branch -> refname ) ;
220+ return branch -> refname ;
222221}
223222
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 )
225224{
226225 if (same_remote ) {
227226 const char * upstream_ref ;
@@ -232,7 +231,7 @@ static void setup_push_simple(struct remote *remote, struct branch *branch, int
232231 if (strcmp (branch -> refname , upstream_ref ))
233232 die_push_simple (branch , remote );
234233 }
235- refspec_appendf ( & rs , "%s:%s" , branch -> refname , branch -> refname ) ;
234+ return branch -> refname ;
236235}
237236
238237static int is_same_remote (struct remote * remote )
@@ -245,6 +244,7 @@ static void setup_default_push_refspecs(struct remote *remote)
245244{
246245 struct branch * branch ;
247246 int same_remote = is_same_remote (remote );
247+ const char * dst ;
248248
249249 switch (push_default ) {
250250 case PUSH_DEFAULT_MATCHING :
@@ -267,17 +267,19 @@ static void setup_default_push_refspecs(struct remote *remote)
267267 default :
268268 case PUSH_DEFAULT_UNSPECIFIED :
269269 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 ;
272272
273273 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 ;
276276
277277 case PUSH_DEFAULT_CURRENT :
278- setup_push_current (remote , branch );
279- return ;
278+ dst = setup_push_current (remote , branch );
279+ break ;
280280 }
281+
282+ refspec_appendf (& rs , "%s:%s" , branch -> refname , dst );
281283}
282284
283285static const char message_advice_pull_before_push [] =
0 commit comments