Merge branch 'jk/parseopt-string-list' into jk/string-list-static-init
authorJunio C Hamano <gitster@pobox.com>
Mon, 13 Jun 2016 17:37:48 +0000 (10:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 13 Jun 2016 17:37:48 +0000 (10:37 -0700)
* jk/parseopt-string-list:
blame,shortlog: don't make local option variables static
interpret-trailers: don't duplicate option strings
parse_opt_string_list: stop allocating new strings

builtin/blame.c
builtin/interpret-trailers.c
builtin/shortlog.c
parse-options-cb.c
index 21f42b0b62b81b637f1cc9589cd6c0306a93d05e..80d24315b3ae3b7bbf3674356673b1af37fc4084 100644 (file)
@@ -2522,12 +2522,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)")),
index b99ae4be8875ad8fb41fd8be2a84b6191681a4e4..175f14797b101d22ead9d1008744440da66a7c1c 100644 (file)
@@ -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")),
index bfc082e58467953c1e4c96fd27a884abea4f5127..f83984e8a1264054b5bd32b3d559c75708a4f428 100644 (file)
@@ -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,
index 239898d946f06d102030569fd45780f523fdcd5a..ba5acf3111d809a3c77314fb2c0852854620cfae 100644 (file)
@@ -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;
 }