Browse Source

Merge branch 'jk/string-list-static-init'

Instead of taking advantage of a struct string_list that is
allocated with all NULs happens to be STRING_LIST_INIT_NODUP kind,
initialize them explicitly as such, to document their behaviour
better.

* jk/string-list-static-init:
  use string_list initializer consistently
  blame,shortlog: don't make local option variables static
  interpret-trailers: don't duplicate option strings
  parse_opt_string_list: stop allocating new strings
maint
Junio C Hamano 9 years ago
parent
commit
b8b6365a8a
  1. 3
      builtin/apply.c
  2. 14
      builtin/blame.c
  3. 4
      builtin/clone.c
  4. 2
      builtin/interpret-trailers.c
  5. 6
      builtin/log.c
  6. 2
      builtin/remote.c
  7. 6
      builtin/shortlog.c
  8. 2
      notes.c
  9. 2
      parse-options-cb.c
  10. 2
      submodule.c
  11. 2
      t/helper/test-parse-options.c

3
builtin/apply.c

@ -4667,6 +4667,9 @@ static void init_apply_state(struct apply_state *state, @@ -4667,6 +4667,9 @@ static void init_apply_state(struct apply_state *state,
state->ws_error_action = warn_on_ws_error;
state->ws_ignore_action = ignore_ws_none;
state->linenr = 1;
string_list_init(&state->fn_table, 0);
string_list_init(&state->limit_by_name, 0);
string_list_init(&state->symlink_changes, 0);
strbuf_init(&state->root, 0);

git_apply_config();

14
builtin/blame.c

@ -56,7 +56,7 @@ static int show_progress; @@ -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
@ -2520,12 +2520,12 @@ int cmd_blame(int argc, const char **argv, const char *prefix) @@ -2520,12 +2520,12 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
enum object_type type;
struct commit *final_commit = NULL;

static struct string_list range_list;
static int output_option = 0, opt = 0;
static int show_stats = 0;
static const char *revs_file = NULL;
static const char *contents_from = NULL;
static const struct option options[] = {
struct string_list range_list = STRING_LIST_INIT_NODUP;
int output_option = 0, opt = 0;
int show_stats = 0;
const char *revs_file = NULL;
const char *contents_from = NULL;
const struct option options[] = {
OPT_BOOL(0, "incremental", &incremental, N_("Show blame entries as we find them, incrementally")),
OPT_BOOL('b', NULL, &blank_boundary, N_("Show blank SHA-1 for boundary commits (Default: off)")),
OPT_BOOL(0, "root", &show_root, N_("Do not treat root commits as boundaries (Default: off)")),

4
builtin/clone.c

@ -49,8 +49,8 @@ static char *option_upload_pack = "git-upload-pack"; @@ -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;


2
builtin/interpret-trailers.c

@ -20,7 +20,7 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix) @@ -20,7 +20,7 @@ int cmd_interpret_trailers(int argc, const char **argv, const char *prefix)
{
int in_place = 0;
int trim_empty = 0;
struct string_list trailers = STRING_LIST_INIT_DUP;
struct string_list trailers = STRING_LIST_INIT_NODUP;

struct option options[] = {
OPT_BOOL(0, "in-place", &in_place, N_("edit files in place")),

6
builtin/log.c

@ -674,9 +674,9 @@ static int auto_number = 1; @@ -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)
{

2
builtin/remote.c

@ -247,7 +247,7 @@ struct branch_info { @@ -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)
{

6
builtin/shortlog.c

@ -233,11 +233,11 @@ void shortlog_init(struct shortlog *log) @@ -233,11 +233,11 @@ void shortlog_init(struct shortlog *log)

int cmd_shortlog(int argc, const char **argv, const char *prefix)
{
static struct shortlog log;
static struct rev_info rev;
struct shortlog log = { STRING_LIST_INIT_NODUP };
struct rev_info rev;
int nongit = !startup_info->have_repository;

static const struct option options[] = {
const struct option options[] = {
OPT_BOOL('n', "numbered", &log.sort_by_number,
N_("sort output according to the number of commits per author")),
OPT_BOOL('s', "summary", &log.summary,

2
notes.c

@ -70,7 +70,7 @@ struct non_note { @@ -70,7 +70,7 @@ struct non_note {

struct notes_tree default_notes_tree;

static struct string_list display_notes_refs;
static struct string_list display_notes_refs = STRING_LIST_INIT_NODUP;
static struct notes_tree **display_notes_trees;

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

2
parse-options-cb.c

@ -144,7 +144,7 @@ int parse_opt_string_list(const struct option *opt, const char *arg, int unset) @@ -144,7 +144,7 @@ int parse_opt_string_list(const struct option *opt, const char *arg, int unset)
if (!arg)
return -1;

string_list_append(v, xstrdup(arg));
string_list_append(v, arg);
return 0;
}


2
submodule.c

@ -17,7 +17,7 @@ @@ -17,7 +17,7 @@

static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
static int parallel_jobs = 1;
static struct string_list changed_submodule_paths;
static struct string_list changed_submodule_paths = STRING_LIST_INIT_NODUP;
static int initialized_fetch_ref_tips;
static struct sha1_array ref_tips_before_fetch;
static struct sha1_array ref_tips_after_fetch;

2
t/helper/test-parse-options.c

@ -12,7 +12,7 @@ static int dry_run = 0, quiet = 0; @@ -12,7 +12,7 @@ static int dry_run = 0, quiet = 0;
static char *string = NULL;
static char *file = NULL;
static int ambiguous;
static struct string_list list;
static struct string_list list = STRING_LIST_INIT_NODUP;

static struct {
int called;

Loading…
Cancel
Save