Skip to content

Commit

Permalink
wt-status: exit early using goto in wt_shortstatus_print_tracking()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Nov 1, 2015
1 parent 7ca8c18 commit bcf8cc2
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions wt-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -1535,10 +1535,8 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
color_fprintf(s->fp, branch_color_local, "%s", branch_name);

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

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

if (!upstream_is_gone && !num_ours && !num_theirs) {
fputc(s->null_termination ? '\0' : '\n', s->fp);
return;
}
if (!upstream_is_gone && !num_ours && !num_theirs)
goto conclude;

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

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

color_fprintf(s->fp, header_color, "]");
conclude:
fputc(s->null_termination ? '\0' : '\n', s->fp);
}

Expand Down

0 comments on commit bcf8cc2

Please sign in to comment.