push: get rid of all the setup_push_* functions

Their code is much simpler now and can move into the parent function. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Felipe Contreras committed May 31, 2021 at 14:51 UTC 0add899baf5a9ee478659821327db719ce74454a
1 file changed +11 -27
builtin/push.c
+11 -27
@@ -202,30 +202,6 @@ static const char *get_upstream_ref(struct branch *branch, const char *remote_na
202 return branch->merge[0]->src;
203 }
204
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 -
205 static int is_same_remote(struct remote *remote)
206 {
207 struct remote *fetch_remote = remote_get(NULL);
@@ -259,15 +235,23 @@ static void setup_default_push_refspecs(struct remote *remote)
235 default:
236 case PUSH_DEFAULT_UNSPECIFIED:
237 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;
242 break;
243
244 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);
251 break;
252
253 case PUSH_DEFAULT_CURRENT:
270 - dst = setup_push_current(remote, branch);
254 + dst = branch->refname;
255 break;
256 }
257