Skip to content

Commit bcf8cc2

Browse files
rscharfegitster
authored andcommitted
wt-status: exit early using goto in wt_shortstatus_print_tracking()
Deduplicate printing the line terminator by jumping to the end of the function. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7ca8c18 commit bcf8cc2

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

wt-status.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,10 +1535,8 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
15351535
color_fprintf(s->fp, branch_color_local, "%s", branch_name);
15361536

15371537
if (stat_tracking_info(branch, &num_ours, &num_theirs, &base) < 0) {
1538-
if (!base) {
1539-
fputc(s->null_termination ? '\0' : '\n', s->fp);
1540-
return;
1541-
}
1538+
if (!base)
1539+
goto conclude;
15421540

15431541
upstream_is_gone = 1;
15441542
}
@@ -1548,10 +1546,8 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
15481546
color_fprintf(s->fp, branch_color_remote, "%s", base);
15491547
free((char *)base);
15501548

1551-
if (!upstream_is_gone && !num_ours && !num_theirs) {
1552-
fputc(s->null_termination ? '\0' : '\n', s->fp);
1553-
return;
1554-
}
1549+
if (!upstream_is_gone && !num_ours && !num_theirs)
1550+
goto conclude;
15551551

15561552
#define LABEL(string) (s->no_gettext ? (string) : _(string))
15571553

@@ -1572,6 +1568,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
15721568
}
15731569

15741570
color_fprintf(s->fp, header_color, "]");
1571+
conclude:
15751572
fputc(s->null_termination ? '\0' : '\n', s->fp);
15761573
}
15771574

0 commit comments

Comments
 (0)