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

[PATCH] string_list: use the right kind of STRING_LIST_INIT

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 21, 2022, 01:02 UTC
Message-ID
<xmqq7d471dns.fsf@gitster.g>

Since 4a4b4cda (builtin-remote: Make "remote -v" display push urls, 2009-06-13), the string_list that was initialized with 0 in its strdup_string member is immediately made to strdup its key strings by flipping the strdup_string member to true. When 183113a5 (string_list: Add STRING_LIST_INIT macro and make use of it., 2010-07-04) has introduced STRING_LIST_INIT macros, it mechanically replaced the initialization to STRING_LIST_INIT_NODUP.

Instead, just use the other initialization macro to make it strdup the key from the beginning.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/remote.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git c/builtin/remote.c w/builtin/remote.c
index d9b8746cb3..c713463d89 100644
--- c/builtin/remote.c
+++ w/builtin/remote.c
@@ -1229,10 +1229,9 @@ static int get_one_entry(struct remote *remote, void *priv)
 
 static int show_all(void)
 {
-	struct string_list list = STRING_LIST_INIT_NODUP;
+	struct string_list list = STRING_LIST_INIT_DUP;
 	int result;
 
-	list.strdup_strings = 1;
 	result = for_each_remote(get_one_entry, &list);
 
 	if (!result) {
Next: Elijah Newren
Message 1 of 5 in “string_list: use the right kind of STRING_LIST_INIT”
  1. string_list: use the right kind of STRING_LIST_INITJunio C Hamano, Jul 21, 2022
  2. Elijah NewrenJul 21, 2022
  3. Junio C HamanoJul 21, 2022
  4. Ævar Arnfjörð BjarmasonJul 21, 2022
  5. Junio C HamanoJul 25, 2022

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.