git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 2/3] for-each-ref: introduce %(upstream:track[short])

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 13, 2013, 19:42 UTC
Message-ID
<xmqqk3gcdr6z.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1384335406-16332-3-git-send-email-artagnon@gmail.com>

You need to squash 78465bb, which has been queued on the previous round, in to this step. There also is a similar issue introduced by the updated 3/3:

builtin/for-each-ref.c: In function 'populate_value': builtin/for-each-ref.c:701:13: error: 'refname' may be used uninitialized in this function [-Werror=uninitialized]

    700                         if (!strcmp(formatp, "short"))
    701                                 refname = shorten_unambiguous_ref(refname,
    702                                                       warn_ambiguous_refs);
Thanks.
-- >8 --
Date: Thu, 31 Oct 2013 14:17:36 -0700
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 ed81407..67168a1 100644
--- a/builtin/for-each-ref.c
+++ b/builtin/for-each-ref.c
@@ -641,7 +641,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;
@@ -719,6 +719,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-rc1-322-g9c05f5a
Previous: Ramkumar RamachandraNext: Junio C Hamano
Message 4 of 12 in “Minor f-e-r enhacements”
  1. 0/3 Minor f-e-r enhacementsRamkumar Ramachandra, Nov 13, 2013
  2. 1/3 for-each-ref: introduce %(HEAD) asterisk markerRamkumar Ramachandra, Nov 13, 2013
  3. 2/3 for-each-ref: introduce %(upstream:track[short])Ramkumar Ramachandra, Nov 13, 2013
  4. Junio C HamanoNov 13, 2013
  5. Junio C HamanoNov 13, 2013
  6. Ramkumar RamachandraNov 14, 2013
  7. 3/3 for-each-ref: introduce %(color:...) for colorRamkumar Ramachandra, Nov 13, 2013
  8. Junio C HamanoNov 13, 2013
  9. Junio C HamanoNov 13, 2013
  10. Ramkumar RamachandraNov 14, 2013
  11. Junio C HamanoNov 18, 2013
  12. Ramkumar RamachandraNov 18, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.