git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Brian Gernhardt <benji@silverinsanity.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH] branch -v: Prevent garbage output on remote refs
Date: Sun, 06 Jul 2008 03:07:34 -0700	[thread overview]
Message-ID: <7vhcb3fhqx.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: <1215336279-99480-1-git-send-email-benji@silverinsanity.com> (Brian Gernhardt's message of "Sun, 6 Jul 2008 05:24:39 -0400")

Thanks, but I have pushed out a slightly different change.

-- >8 --
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>

---
 builtin-branch.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/builtin-branch.c b/builtin-branch.c
index e9423d1..ff71f3d 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -287,10 +287,8 @@ static void fill_tracking_info(char *stat, const char *branch_name)
 	int ours, theirs;
 	struct branch *branch = branch_get(branch_name);
 
-	if (!stat_tracking_info(branch, &ours, &theirs) || (!ours && !theirs)) {
-		stat[0] = '\0';
+	if (!stat_tracking_info(branch, &ours, &theirs) || (!ours && !theirs))
 		return;
-	}
 	if (!ours)
 		sprintf(stat, "[behind %d] ", theirs);
 	else if (!theirs)
@@ -330,6 +328,7 @@ static void print_ref_item(struct ref_item *item, int maxwidth, int verbose,
 		char stat[128];
 
 		strbuf_init(&subject, 0);
+		stat[0] = '\0';
 
 		commit = lookup_commit(item->sha1);
 		if (commit && !parse_commit(commit)) {

  reply	other threads:[~2008-07-06 10:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-06  9:24 [PATCH] branch -v: Prevent garbage output on remote refs Brian Gernhardt
2008-07-06 10:07 ` Junio C Hamano [this message]
2008-07-06 16:13   ` Brian Gernhardt

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=7vhcb3fhqx.fsf@gitster.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=benji@silverinsanity.com \
    --cc=git@vger.kernel.org \
    /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).