Skip to content

Commit 3b9fd83

Browse files
felipecgitster
authored andcommitted
push: hedge code of default=simple
`simple` is the most important mode so move the relevant code to its own function to make it easier to see what it's doing. Reviewed-by: Elijah Newren <[email protected]> Signed-off-by: Felipe Contreras <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 050f76b commit 3b9fd83

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

builtin/push.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,14 @@ static void setup_push_current(struct remote *remote, struct branch *branch)
223223
refspec_appendf(&rs, "%s:%s", branch->refname, branch->refname);
224224
}
225225

226+
static void setup_push_simple(struct remote *remote, struct branch *branch, int same_remote)
227+
{
228+
if (!same_remote)
229+
setup_push_current(remote, branch);
230+
else
231+
setup_push_upstream(remote, branch, same_remote, 1);
232+
}
233+
226234
static int is_same_remote(struct remote *remote)
227235
{
228236
struct remote *fetch_remote = remote_get(NULL);
@@ -242,10 +250,7 @@ static void setup_default_push_refspecs(struct remote *remote)
242250

243251
case PUSH_DEFAULT_UNSPECIFIED:
244252
case PUSH_DEFAULT_SIMPLE:
245-
if (!same_remote)
246-
setup_push_current(remote, branch);
247-
else
248-
setup_push_upstream(remote, branch, same_remote, 1);
253+
setup_push_simple(remote, branch, same_remote);
249254
break;
250255

251256
case PUSH_DEFAULT_UPSTREAM:

0 commit comments

Comments
 (0)