Skip to content

Commit 5e8d272

Browse files
rscharfegitster
authored andcommitted
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 <[email protected]> Reviewed-by: Stefan Beller <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c8e978 commit 5e8d272

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

wt-status.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1735,6 +1735,7 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
17351735
const char *branch_color_remote = color(WT_STATUS_REMOTE_BRANCH, s);
17361736

17371737
const char *base;
1738+
char *short_base;
17381739
const char *branch_name;
17391740
int num_ours, num_theirs;
17401741
int upstream_is_gone = 0;
@@ -1769,10 +1770,10 @@ static void wt_shortstatus_print_tracking(struct wt_status *s)
17691770
upstream_is_gone = 1;
17701771
}
17711772

1772-
base = shorten_unambiguous_ref(base, 0);
1773+
short_base = shorten_unambiguous_ref(base, 0);
17731774
color_fprintf(s->fp, header_color, "...");
1774-
color_fprintf(s->fp, branch_color_remote, "%s", base);
1775-
free((char *)base);
1775+
color_fprintf(s->fp, branch_color_remote, "%s", short_base);
1776+
free(short_base);
17761777

17771778
if (!upstream_is_gone && !num_ours && !num_theirs)
17781779
goto conclude;

0 commit comments

Comments
 (0)