From: Junio C Hamano Date: Fri, 01 Nov 2013 17:17:15 GMT Subject: Re: [PATCH 3/3] for-each-ref: introduce %(upstream:track[short]) Message-ID: In-Reply-To: <1383212774-5232-4-git-send-email-artagnon@gmail.com> This patch needed on top of 3/3 for me to pass gcc cleanly. -- >8 -- Subject: [PATCH] fixup! for-each-ref: introduce %(upstream:track[short]) The condition !prefixcmp(name, "upstream") must be true for the variable "branch" to be reused, so the variable should be always set when it gets used, but GCC does not seem to realize this fact. --- builtin/for-each-ref.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 7d5c174..871d86c 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -648,7 +648,7 @@ static void populate_value(struct refinfo *ref) int deref = 0; const char *refname; const char *formatp; - struct branch *branch; + struct branch *branch = NULL; if (*name == '*') { deref = 1; @@ -727,6 +727,7 @@ static void populate_value(struct refinfo *ref) } else if (!strcmp(formatp, "trackshort") && !prefixcmp(name, "upstream")) { + assert(branch != NULL); stat_tracking_info(branch, &num_ours, &num_theirs); if (!num_ours && !num_theirs) v->s = "="; -- 1.8.5-rc0-205-g5b7460b