aboutsummaryrefslogtreecommitdiffstats
path: root/wt-status.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2017-07-08 12:51:01 +0200
committerJunio C Hamano <gitster@pobox.com>2017-07-10 09:16:37 -0700
commit5e8d2729ae64483efd5e8663cbc9d476364fb472 (patch)
treee29606f21e89c0edc91f5d01394e44c82e5b7b98 /wt-status.c
parent8c8e978f5719c6a58fb998742207bf907f963143 (diff)
downloadgit-5e8d2729ae64483efd5e8663cbc9d476364fb472.tar.gz
wt-status: use separate variable for result of shorten_unambiguous_ref
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> Reviewed-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'wt-status.c')
-rw-r--r--wt-status.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/wt-status.c b/wt-status.c
index 068de38b51..fd863c81fc 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -1735,6 +1735,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;
@@ -1769,10 +1770,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;