push: rename !triangular to same_remote

The typical case is what git was designed for: distributed remotes. It's only the atypical case--fetching and pushing to the same remote--that we need to keep an eye on. No functional changes. Liked-by: Junio C Hamano <gitster@pobox.com> 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:32 UTC 050f76b9af75bf69110d542e0cee569d0112f320
1 file changed +8 -8
builtin/push.c
+8 -8
@@ -186,7 +186,7 @@ static const char message_detached_head_die[] =
186 " git push %s HEAD:<name-of-remote-branch>\n");
187
188 static void setup_push_upstream(struct remote *remote, struct branch *branch,
189 - int triangular, int simple)
189 + int same_remote, int simple)
190 {
191 if (!branch)
192 die(_(message_detached_head_die), remote->name);
@@ -201,7 +201,7 @@ static void setup_push_upstream(struct remote *remote, struct branch *branch,
201 if (branch->merge_nr != 1)
202 die(_("The current branch %s has multiple upstream branches, "
203 "refusing to push."), branch->name);
204 - if (triangular)
204 + if (!same_remote)
205 die(_("You are pushing to remote '%s', which is not the upstream of\n"
206 "your current branch '%s', without telling me what to push\n"
207 "to update which remote branch."),
@@ -223,16 +223,16 @@ static void setup_push_current(struct remote *remote, struct branch *branch)
223 refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
224 }
225
226 -static int is_workflow_triangular(struct remote *remote)
226 +static int is_same_remote(struct remote *remote)
227 {
228 struct remote *fetch_remote = remote_get(NULL);
229 - return (fetch_remote && fetch_remote != remote);
229 + return (!fetch_remote || fetch_remote == remote);
230 }
231
232 static void setup_default_push_refspecs(struct remote *remote)
233 {
234 struct branch *branch = branch_get(NULL);
235 - int triangular = is_workflow_triangular(remote);
235 + int same_remote = is_same_remote(remote);
236
237 switch (push_default) {
238 default:
@@ -242,14 +242,14 @@ static void setup_default_push_refspecs(struct remote *remote)
242
243 case PUSH_DEFAULT_UNSPECIFIED:
244 case PUSH_DEFAULT_SIMPLE:
245 - if (triangular)
245 + if (!same_remote)
246 setup_push_current(remote, branch);
247 else
248 - setup_push_upstream(remote, branch, triangular, 1);
248 + setup_push_upstream(remote, branch, same_remote, 1);
249 break;
250
251 case PUSH_DEFAULT_UPSTREAM:
252 - setup_push_upstream(remote, branch, triangular, 0);
252 + setup_push_upstream(remote, branch, same_remote, 0);
253 break;
254
255 case PUSH_DEFAULT_CURRENT: