@@ -202,30 +202,6 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
202202 return branch -> merge [0 ]-> src ;
203203}
204204
205- static const char * setup_push_upstream (struct remote * remote , struct branch * branch ,
206- int same_remote )
207- {
208- if (!same_remote )
209- die (_ ("You are pushing to remote '%s', which is not the upstream of\n"
210- "your current branch '%s', without telling me what to push\n"
211- "to update which remote branch." ),
212- remote -> name , branch -> name );
213- return get_upstream_ref (branch , remote -> name );
214- }
215-
216- static const char * setup_push_current (struct remote * remote , struct branch * branch )
217- {
218- return branch -> refname ;
219- }
220-
221- static const char * setup_push_simple (struct remote * remote , struct branch * branch , int same_remote )
222- {
223- if (same_remote )
224- if (strcmp (branch -> refname , get_upstream_ref (branch , remote -> name )))
225- die_push_simple (branch , remote );
226- return branch -> refname ;
227- }
228-
229205static int is_same_remote (struct remote * remote )
230206{
231207 struct remote * fetch_remote = remote_get (NULL );
@@ -259,15 +235,23 @@ static void setup_default_push_refspecs(struct remote *remote)
259235 default :
260236 case PUSH_DEFAULT_UNSPECIFIED :
261237 case PUSH_DEFAULT_SIMPLE :
262- dst = setup_push_simple (remote , branch , same_remote );
238+ if (same_remote )
239+ if (strcmp (branch -> refname , get_upstream_ref (branch , remote -> name )))
240+ die_push_simple (branch , remote );
241+ dst = branch -> refname ;
263242 break ;
264243
265244 case PUSH_DEFAULT_UPSTREAM :
266- dst = setup_push_upstream (remote , branch , same_remote );
245+ if (!same_remote )
246+ die (_ ("You are pushing to remote '%s', which is not the upstream of\n"
247+ "your current branch '%s', without telling me what to push\n"
248+ "to update which remote branch." ),
249+ remote -> name , branch -> name );
250+ dst = get_upstream_ref (branch , remote -> name );
267251 break ;
268252
269253 case PUSH_DEFAULT_CURRENT :
270- dst = setup_push_current ( remote , branch ) ;
254+ dst = branch -> refname ;
271255 break ;
272256 }
273257
0 commit comments