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 <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Oct 31, 2015 at 18:36 UTC
bcf8cc25acb3378bf62f2cfc27c28302585841c0
1 file changed
+5
-8
wt-status.c
+5
-8
@@ -1535,10 +1535,8 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
1535
color_fprintf(s->fp, branch_color_local, "%s", branch_name);
1536
1537
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;
1540
1541
upstream_is_gone = 1;
1542
}
@@ -1548,10 +1546,8 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
1546
color_fprintf(s->fp, branch_color_remote, "%s", base);
1547
free((char *)base);
1548
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;
1551
1552
#define LABEL(string) (s->no_gettext ? (string) : _(string))
1553
@@ -1572,6 +1568,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
1568
}
1569
1570
color_fprintf(s->fp, header_color, "]");
1571
+ conclude:
1572
fputc(s->null_termination ? '\0' : '\n', s->fp);
1573
}
1574