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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 1, 2013, 17:17 UTC
Message-ID
<xmqq61sc2g9w.fsf@gitster.dls.corp.google.com>
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
Previous: Ramkumar Ramachandra
Message 15 of 15 in “Minor f-e-r enhacements”
  1. 0/3 Minor f-e-r enhacementsRamkumar Ramachandra, Oct 31, 2013
  2. 1/3 for-each-ref: introduce %C(...) for colorRamkumar Ramachandra, Oct 31, 2013
  3. Junio C HamanoOct 31, 2013
  4. Ramkumar RamachandraNov 1, 2013
  5. Junio C HamanoNov 1, 2013
  6. Ramkumar RamachandraNov 2, 2013
  7. Junio C HamanoNov 4, 2013
  8. Ramkumar RamachandraNov 7, 2013
  9. Junio C HamanoNov 7, 2013
  10. Ramkumar RamachandraNov 8, 2013
  11. Junio C HamanoNov 8, 2013
  12. Ramkumar RamachandraNov 12, 2013
  13. 2/3 for-each-ref: introduce %(HEAD) asterisk markerRamkumar Ramachandra, Oct 31, 2013
  14. 3/3 for-each-ref: introduce %(upstream:track[short])Ramkumar Ramachandra, Oct 31, 2013
  15. Junio C HamanoNov 1, 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.