Re: [PATCH] string-list.h: Add STRING_LIST_INIT macro and make use of it.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I think you need the attached on top to be more complete.

But I wonder if this is worth it (not this "more complete", but your
patch).  We convert 16 or so instances of initialization for "no strdup"
list, but there are about the same number of "strdup" instances still
spelled out:

    $ git grep -e 'struct string_list [^ ]* = {.*'
    $ git grep -e 'struct string_list [^ ]* = {.*1'

Wouldn't it be more sensible to use this instead?

    #define STRING_LIST_INIT(pleasedup) { NULL, 0, 0, (pleasedup) }

---
 builtin/mv.c       |    2 +-
 builtin/remote.c   |    4 ++--
 transport-helper.c |    2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin/mv.c b/builtin/mv.c
index c07f53b..e2f0279 100644
--- a/builtin/mv.c
+++ b/builtin/mv.c
@@ -63,7 +63,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
 	const char **source, **destination, **dest_path;
 	enum update_mode { BOTH = 0, WORKING_DIRECTORY, INDEX } *modes;
 	struct stat st;
-	struct string_list src_for_dst = {NULL, 0, 0, 0};
+	struct string_list src_for_dst = STRING_LIST_INIT;
 
 	git_config(git_default_config, NULL);
 
diff --git a/builtin/remote.c b/builtin/remote.c
index 9d41792..5ff2b5b 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -134,7 +134,7 @@ static int add_branch(const char *key, const char *branchname,
 static int add(int argc, const char **argv)
 {
 	int fetch = 0, mirror = 0, fetch_tags = TAGS_DEFAULT;
-	struct string_list track = { NULL, 0, 0 };
+	struct string_list track = STRING_LIST_INIT;
 	const char *master = NULL;
 	struct remote *remote;
 	struct strbuf buf = STRBUF_INIT, buf2 = STRBUF_INIT;
@@ -1483,7 +1483,7 @@ static int get_one_entry(struct remote *remote, void *priv)
 
 static int show_all(void)
 {
-	struct string_list list = { NULL, 0, 0 };
+	struct string_list list = STRING_LIST_INIT;
 	int result;
 
 	list.strdup_strings = 1;
diff --git a/transport-helper.c b/transport-helper.c
index 0381de5..86a79b9 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -689,7 +689,7 @@ static int push_refs_with_export(struct transport *transport,
 	struct child_process *helper, exporter;
 	struct helper_data *data = transport->data;
 	char *export_marks = NULL, *import_marks = NULL;
-	struct string_list revlist_args = { NULL, 0, 0 };
+	struct string_list revlist_args = STRING_LIST_INIT;
 	struct strbuf buf = STRBUF_INIT;
 
 	helper = get_helper(transport);


--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]