summaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2016-06-13 06:04:20 -0400
committerLibravatar Junio C Hamano <gitster@pobox.com>2016-06-13 10:37:51 -0700
commit2721ce21e439ee0726dc69073acd7e0d2b2407b3 (patch)
tree204966369741352a8abc9651805ed0c88677598f /builtin
parentMerge branch 'jk/parseopt-string-list' into jk/string-list-static-init (diff)
downloadtgif-2721ce21e439ee0726dc69073acd7e0d2b2407b3.tar.xz
use string_list initializer consistently
There are two types of string_lists: those that own the string memory, and those that don't. You can tell the difference by the strdup_strings flag, and one should use either STRING_LIST_INIT_DUP, or STRING_LIST_INIT_NODUP as an initializer. Historically, the normal all-zeros initialization has corresponded to the NODUP case. Many sites use no initializer at all, and that works as a shorthand for that case. But for a reader of the code, it can be hard to remember which is which. Let's be more explicit and actually have each site declare which type it means to use. This is a fairly mechanical conversion; I assumed each site was correct as-is, and just switched them all to NODUP. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/apply.c6
-rw-r--r--builtin/blame.c2
-rw-r--r--builtin/clone.c4
-rw-r--r--builtin/log.c6
-rw-r--r--builtin/remote.c2
5 files changed, 10 insertions, 10 deletions
diff --git a/builtin/apply.c b/builtin/apply.c
index 8e4da2e1bd..955af4db6c 100644
--- a/builtin/apply.c
+++ b/builtin/apply.c
@@ -270,7 +270,7 @@ struct image {
* the case where more than one patches touch the same file.
*/
-static struct string_list fn_table;
+static struct string_list fn_table = STRING_LIST_INIT_NODUP;
static uint32_t hash_line(const char *cp, size_t len)
{
@@ -1936,7 +1936,7 @@ static void prefix_patch(struct patch *p)
* include/exclude
*/
-static struct string_list limit_by_name;
+static struct string_list limit_by_name = STRING_LIST_INIT_NODUP;
static int has_include;
static void add_name_limit(const char *name, int exclude)
{
@@ -3582,7 +3582,7 @@ static int check_to_create(const char *new_name, int ok_if_exists)
* it is perfectly fine, as the patch removes a/b to make room
* to create a directory a/b so that a/b/c can be created.
*/
-static struct string_list symlink_changes;
+static struct string_list symlink_changes = STRING_LIST_INIT_NODUP;
#define SYMLINK_GOES_AWAY 01
#define SYMLINK_IN_RESULT 02
diff --git a/builtin/blame.c b/builtin/blame.c
index 80d24315b3..de70153685 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -56,7 +56,7 @@ static int show_progress;
static struct date_mode blame_date_mode = { DATE_ISO8601 };
static size_t blame_date_width;
-static struct string_list mailmap;
+static struct string_list mailmap = STRING_LIST_INIT_NODUP;
#ifndef DEBUG
#define DEBUG 0
diff --git a/builtin/clone.c b/builtin/clone.c
index 5f867e67d8..70d8213472 100644
--- a/builtin/clone.c
+++ b/builtin/clone.c
@@ -49,8 +49,8 @@ static char *option_upload_pack = "git-upload-pack";
static int option_verbosity;
static int option_progress = -1;
static enum transport_family family;
-static struct string_list option_config;
-static struct string_list option_reference;
+static struct string_list option_config = STRING_LIST_INIT_NODUP;
+static struct string_list option_reference = STRING_LIST_INIT_NODUP;
static int option_dissociate;
static int max_jobs = -1;
diff --git a/builtin/log.c b/builtin/log.c
index dff3fbbb43..c11bd66f39 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -674,9 +674,9 @@ static int auto_number = 1;
static char *default_attach = NULL;
-static struct string_list extra_hdr;
-static struct string_list extra_to;
-static struct string_list extra_cc;
+static struct string_list extra_hdr = STRING_LIST_INIT_NODUP;
+static struct string_list extra_to = STRING_LIST_INIT_NODUP;
+static struct string_list extra_cc = STRING_LIST_INIT_NODUP;
static void add_header(const char *value)
{
diff --git a/builtin/remote.c b/builtin/remote.c
index fda5c2e53d..e1cc55e13c 100644
--- a/builtin/remote.c
+++ b/builtin/remote.c
@@ -247,7 +247,7 @@ struct branch_info {
enum { NO_REBASE, NORMAL_REBASE, INTERACTIVE_REBASE } rebase;
};
-static struct string_list branch_list;
+static struct string_list branch_list = STRING_LIST_INIT_NODUP;
static const char *abbrev_ref(const char *name, const char *prefix)
{