From: "René Scharfe" <l.s.r@web.de>
To: Git List <git@vger.kernel.org>
Cc: Junio C Hamano <gitster@pobox.com>, Stefan Beller <sbeller@google.com>
Subject: [PATCH] wt-status: use separate variable for result of shorten_unambiguous_ref
Date: Sat, 8 Jul 2017 12:51:01 +0200 [thread overview]
Message-ID: <d70bf87c-f8b3-9f02-14bd-b3ceb5e9f7e4@web.de> (raw)
Store the pointer to the string allocated by shorten_unambiguous_ref in
a dedicated variable, short_base, and keep base unchanged. A non-const
variable is more appropriate for such an object. It avoids having to
cast const away on free and stops redefining the meaning of base, making
the code slightly clearer.
Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
wt-status.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/wt-status.c b/wt-status.c
index 8d2fb35b08..77c27c5113 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1763,6 +1763,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
const char *branch_color_remote = color(WT_STATUS_REMOTE_BRANCH, s);
const char *base;
+ char *short_base;
const char *branch_name;
int num_ours, num_theirs;
int upstream_is_gone = 0;
@@ -1797,10 +1798,10 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
upstream_is_gone = 1;
}
- base = shorten_unambiguous_ref(base, 0);
+ short_base = shorten_unambiguous_ref(base, 0);
color_fprintf(s->fp, header_color, "...");
- color_fprintf(s->fp, branch_color_remote, "%s", base);
- free((char *)base);
+ color_fprintf(s->fp, branch_color_remote, "%s", short_base);
+ free(short_base);
if (!upstream_is_gone && !num_ours && !num_theirs)
goto conclude;
--
2.13.2
next reply other threads:[~2017-07-08 10:51 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-08 10:51 René Scharfe [this message]
2017-07-10 2:51 ` [PATCH] wt-status: use separate variable for result of shorten_unambiguous_ref Stefan Beller
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=d70bf87c-f8b3-9f02-14bd-b3ceb5e9f7e4@web.de \
--to=l.s.r@web.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sbeller@google.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).