From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>
Subject: [PATCH 2/5] wt-status: exit early using goto in wt_shortstatus_print_tracking()
Date: Sat, 31 Oct 2015 18:36:01 +0100 [thread overview]
Message-ID: <5634FC01.8050601@web.de> (raw)
In-Reply-To: <5634FB59.1000506@web.de>
Deduplicate printing the line terminator by jumping to the end of the
function.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
wt-status.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 3e3b8c0..083328f 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1658,10 +1658,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;
}
@@ -1671,10 +1669,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))
@@ -1695,6 +1691,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);
}
--
2.6.2
next prev parent reply other threads:[~2015-10-31 17:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-31 17:33 [PATCH 0/5] wt-status: fix an invalid memory read, clean up René Scharfe
2015-10-31 17:35 ` [PATCH 1/5] t7060: add test for status --branch on a detached HEAD René Scharfe
2015-10-31 17:36 ` René Scharfe [this message]
2015-10-31 17:36 ` [PATCH 3/5] wt-status: avoid building bogus branch name with " René Scharfe
2015-11-01 17:50 ` Junio C Hamano
2015-11-01 18:11 ` René Scharfe
2015-10-31 17:37 ` [PATCH 4/5] wt-status: don't skip a magical number of characters blindly René Scharfe
2015-11-01 17:51 ` Junio C Hamano
2015-11-01 17:55 ` Junio C Hamano
2015-10-31 17:37 ` [PATCH 5/5] wt-status: use skip_prefix() to get rid of magic string length constants René Scharfe
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5634FC01.8050601@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).