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

Re: [PATCH v2 1/2] string-list: Add string_list initializer helper functions

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 16, 2014, 22:59 UTC
Message-ID
<xmqqsin4o406.fsf@gitster.dls.corp.google.com>
In-Reply-To
<1402907232-24629-2-git-send-email-tanayabh@gmail.com>
Tanay Abhra <tanayabh@gmail.com> writes:
Show 7 quoted lines
> When a compound construct like a string_list within another
> struct is used, the default initializer macros are useless.
> For such cases add helper functions for string_list
> initialization for both DUP and NODUP modes.
>
> Signed-off-by: Tanay Abhra <tanayabh@gmail.com>
> ---

Sorry, but I do not understand the above "useless". Do you mean to say that xyzzy below cannot be initialized that way?

 git.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/git.c b/git.c
index d261575..17714d1 100644
--- a/git.c
+++ b/git.c
@@ -595,11 +595,24 @@ static int run_argv(int *argcp, const char ***argv)
 }
 
 
+#include "string-list.h"
+
 int main(int argc, char **av)
 {
 	const char **argv = (const char **) av;
 	const char *cmd;
 
+	struct compound {
+		int frotz;
+		struct string_list nitfol;
+	} xyzzy = {
+		314,
+		STRING_LIST_INIT_DUP,
+	};
+	printf("dup-strings is set to %s\n",
+	       xyzzy.nitfol.strdup_strings ? "true" : "false");
+	return 0;
+
 	startup_info = &git_startup_info;
 
 	cmd = git_extract_argv0_path(argv[0]);
Previous: Tanay AbhraNext: Tanay Abhra
Message 3 of 11 in “Git config cache & special querying api utilizing the cache”
  1. 0/2 Git config cache & special querying api utilizing the cacheTanay Abhra, Jun 16, 2014
  2. 1/2 string-list: Add string_list initializer helper functionsTanay Abhra, Jun 16, 2014
  3. Junio C HamanoJun 16, 2014
  4. Tanay AbhraJun 17, 2014
  5. Junio C HamanoJun 17, 2014
  6. 2/2 config: Add hashtable for config parsing & retrievalTanay Abhra, Jun 16, 2014
  7. Matthieu MoyJun 16, 2014
  8. Tanay AbhraJun 16, 2014
  9. Matthieu MoyJun 16, 2014
  10. Jeff KingJun 17, 2014
  11. Jeff KingJun 17, 2014

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.