Skip to content

Commit 35919bf

Browse files
fhrbatagitster
authored andcommitted
transport: unify return values and exit point from transport_push()
It seems there is no reason to return 1 instead of -1 when push_refs() is not set in transport vtable. Let's unify the error return values and use the done label as a single exit point from transport_push(). Suggested-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Frantisek Hrbata <[email protected]> Reviewed-by: Josh Steadmon <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6448182 commit 35919bf

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

transport.c

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,29 +1276,30 @@ int transport_push(struct repository *r,
12761276
struct refspec *rs, int flags,
12771277
unsigned int *reject_reasons)
12781278
{
1279-
struct ref *remote_refs;
1280-
struct ref *local_refs;
1279+
struct ref *remote_refs = NULL;
1280+
struct ref *local_refs = NULL;
12811281
int match_flags = MATCH_REFS_NONE;
12821282
int verbose = (transport->verbose > 0);
12831283
int quiet = (transport->verbose < 0);
12841284
int porcelain = flags & TRANSPORT_PUSH_PORCELAIN;
12851285
int pretend = flags & TRANSPORT_PUSH_DRY_RUN;
1286-
int push_ret, ret, err;
1286+
int push_ret, err;
1287+
int ret = -1;
12871288
struct transport_ls_refs_options transport_options =
12881289
TRANSPORT_LS_REFS_OPTIONS_INIT;
12891290

12901291
*reject_reasons = 0;
12911292

12921293
if (transport_color_config() < 0)
1293-
return -1;
1294+
goto done;
12941295

12951296
if (!transport->vtable->push_refs)
1296-
return 1;
1297+
goto done;
12971298

12981299
local_refs = get_local_heads();
12991300

13001301
if (check_push_refs(local_refs, rs) < 0)
1301-
return -1;
1302+
goto done;
13021303

13031304
refspec_ref_prefixes(rs, &transport_options.ref_prefixes);
13041305

@@ -1319,7 +1320,7 @@ int transport_push(struct repository *r,
13191320
match_flags |= MATCH_REFS_FOLLOW_TAGS;
13201321

13211322
if (match_push_refs(local_refs, &remote_refs, rs, match_flags))
1322-
return -1;
1323+
goto done;
13231324

13241325
if (transport->smart_options &&
13251326
transport->smart_options->cas &&
@@ -1333,7 +1334,7 @@ int transport_push(struct repository *r,
13331334

13341335
if (!(flags & TRANSPORT_PUSH_NO_HOOK))
13351336
if (run_pre_push_hook(transport, remote_refs))
1336-
return -1;
1337+
goto done;
13371338

13381339
if ((flags & (TRANSPORT_RECURSE_SUBMODULES_ON_DEMAND |
13391340
TRANSPORT_RECURSE_SUBMODULES_ONLY)) &&
@@ -1417,6 +1418,7 @@ int transport_push(struct repository *r,
14171418
else if (!quiet && !ret && !transport_refs_pushed(remote_refs))
14181419
fprintf(stderr, "Everything up-to-date\n");
14191420

1421+
done:
14201422
return ret;
14211423
}
14221424

0 commit comments

Comments
 (0)