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

[PATCH] get_local_heads(): do not return random pointer if there is no head

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Apr 16, 2009, 22:16 UTC
Message-ID
<1239920183-29512-1-git-send-email-pclouds@gmail.com>
it's silly to do this:
mkdir foo && cd foo && git init && git push somewhere.git
but segfault should not happen even in that case.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 remote.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/remote.c b/remote.c
index d12140e..63f749c 100644
--- a/remote.c
+++ b/remote.c
@@ -1493,7 +1493,7 @@ static int one_local_ref(const char *refname, const unsigned char *sha1, int fla
 
 struct ref *get_local_heads(void)
 {
-	struct ref *local_refs, **local_tail = &local_refs;
+	struct ref *local_refs = NULL, **local_tail = &local_refs;
 	for_each_ref(one_local_ref, &local_tail);
 	return local_refs;
 }
-- 
1.6.2.2.693.g5a1be
Next: Junio C Hamano
Message 1 of 2 in “get_local_heads(): do not return random pointer if there is no head”
  1. get_local_heads(): do not return random pointer if there is no headNguyễn Thái Ngọc Duy, Apr 16, 2009
  2. Junio C HamanoApr 18, 2009

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.