Skip to content

Commit 2721ce2

Browse files
peffgitster
authored andcommitted
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>
1 parent 7013220 commit 2721ce2

File tree

8 files changed

+13
-13
lines changed

8 files changed

+13
-13
lines changed

builtin/apply.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ struct image {
270270
* the case where more than one patches touch the same file.
271271
*/
272272

273-
static struct string_list fn_table;
273+
static struct string_list fn_table = STRING_LIST_INIT_NODUP;
274274

275275
static uint32_t hash_line(const char *cp, size_t len)
276276
{
@@ -1936,7 +1936,7 @@ static void prefix_patch(struct patch *p)
19361936
* include/exclude
19371937
*/
19381938

1939-
static struct string_list limit_by_name;
1939+
static struct string_list limit_by_name = STRING_LIST_INIT_NODUP;
19401940
static int has_include;
19411941
static void add_name_limit(const char *name, int exclude)
19421942
{
@@ -3582,7 +3582,7 @@ static int check_to_create(const char *new_name, int ok_if_exists)
35823582
* it is perfectly fine, as the patch removes a/b to make room
35833583
* to create a directory a/b so that a/b/c can be created.
35843584
*/
3585-
static struct string_list symlink_changes;
3585+
static struct string_list symlink_changes = STRING_LIST_INIT_NODUP;
35863586
#define SYMLINK_GOES_AWAY 01
35873587
#define SYMLINK_IN_RESULT 02
35883588

builtin/blame.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static int show_progress;
5656
static struct date_mode blame_date_mode = { DATE_ISO8601 };
5757
static size_t blame_date_width;
5858

59-
static struct string_list mailmap;
59+
static struct string_list mailmap = STRING_LIST_INIT_NODUP;
6060

6161
#ifndef DEBUG
6262
#define DEBUG 0

builtin/clone.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ static char *option_upload_pack = "git-upload-pack";
4949
static int option_verbosity;
5050
static int option_progress = -1;
5151
static enum transport_family family;
52-
static struct string_list option_config;
53-
static struct string_list option_reference;
52+
static struct string_list option_config = STRING_LIST_INIT_NODUP;
53+
static struct string_list option_reference = STRING_LIST_INIT_NODUP;
5454
static int option_dissociate;
5555
static int max_jobs = -1;
5656

builtin/log.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,9 +674,9 @@ static int auto_number = 1;
674674

675675
static char *default_attach = NULL;
676676

677-
static struct string_list extra_hdr;
678-
static struct string_list extra_to;
679-
static struct string_list extra_cc;
677+
static struct string_list extra_hdr = STRING_LIST_INIT_NODUP;
678+
static struct string_list extra_to = STRING_LIST_INIT_NODUP;
679+
static struct string_list extra_cc = STRING_LIST_INIT_NODUP;
680680

681681
static void add_header(const char *value)
682682
{

builtin/remote.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ struct branch_info {
247247
enum { NO_REBASE, NORMAL_REBASE, INTERACTIVE_REBASE } rebase;
248248
};
249249

250-
static struct string_list branch_list;
250+
static struct string_list branch_list = STRING_LIST_INIT_NODUP;
251251

252252
static const char *abbrev_ref(const char *name, const char *prefix)
253253
{

notes.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct non_note {
7070

7171
struct notes_tree default_notes_tree;
7272

73-
static struct string_list display_notes_refs;
73+
static struct string_list display_notes_refs = STRING_LIST_INIT_NODUP;
7474
static struct notes_tree **display_notes_trees;
7575

7676
static void load_subtree(struct notes_tree *t, struct leaf_node *subtree,

submodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
1919
static int parallel_jobs = 1;
20-
static struct string_list changed_submodule_paths;
20+
static struct string_list changed_submodule_paths = STRING_LIST_INIT_NODUP;
2121
static int initialized_fetch_ref_tips;
2222
static struct sha1_array ref_tips_before_fetch;
2323
static struct sha1_array ref_tips_after_fetch;

t/helper/test-parse-options.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ static int verbose = 0, dry_run = 0, quiet = 0;
1111
static char *string = NULL;
1212
static char *file = NULL;
1313
static int ambiguous;
14-
static struct string_list list;
14+
static struct string_list list = STRING_LIST_INIT_NODUP;
1515

1616
static int length_callback(const struct option *opt, const char *arg, int unset)
1717
{

0 commit comments

Comments
 (0)