Skip to content

Commit 926ab84

Browse files
committed
branch -r -v: do not spit out garbage
The codepath to emit relationship between the branch and what it tracks forgot to initialize a string buffer stat[] to empty when showing a tracking branch. This moves the emptying so that the buffer starts as empty and stays so when no information is added to fix this issue. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c0234b2 commit 926ab84

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

builtin-branch.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,10 +287,8 @@ static void fill_tracking_info(char *stat, const char *branch_name)
287287
int ours, theirs;
288288
struct branch *branch = branch_get(branch_name);
289289

290-
if (!stat_tracking_info(branch, &ours, &theirs) || (!ours && !theirs)) {
291-
stat[0] = '\0';
290+
if (!stat_tracking_info(branch, &ours, &theirs) || (!ours && !theirs))
292291
return;
293-
}
294292
if (!ours)
295293
sprintf(stat, "[behind %d] ", theirs);
296294
else if (!theirs)
@@ -330,6 +328,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
330328
char stat[128];
331329

332330
strbuf_init(&subject, 0);
331+
stat[0] = '\0';
333332

334333
commit = lookup_commit(item->sha1);
335334
if (commit && !parse_commit(commit)) {

0 commit comments

Comments
 (0)