blame,shortlog: don't make local option variables static
There's no need for these option variables to be static, except that they are referenced by the options array itself, which is static. But having all of this static is simply unnecessary and confusing (and inconsistent with most other commands, which either use a static global option list or a true function-local one). Note that in some cases we may need to actually initialize the variables (since we cannot rely on BSS to do so). This is a net improvement to readability, though, as we can use the more verbose initializers for our string_lists. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff King committed
Jun 13, 2016 at 01:39 UTC
64093fc06a871f71316211a2aea6bb46c49b20ab
2 files changed
+9
-9
builtin/blame.c
+6
-6
@@ -2503,12 +2503,12 @@ int cmd_blame(int argc, const char **argv, const char *prefix)
2503
char *final_commit_name = NULL;
2504
enum object_type type;
2505
2506
- static struct string_list range_list;
2507
- static int output_option = 0, opt = 0;
2508
- static int show_stats = 0;
2509
- static const char *revs_file = NULL;
2510
- static const char *contents_from = NULL;
2511
- static const struct option options[] = {
2506
+ struct string_list range_list = STRING_LIST_INIT_NODUP;
2507
+ int output_option = 0, opt = 0;
2508
+ int show_stats = 0;
2509
+ const char *revs_file = NULL;
2510
+ const char *contents_from = NULL;
2511
+ const struct option options[] = {
2512
OPT_BOOL(0, "incremental", &incremental, N_("Show blame entries as we find them, incrementally")),
2513
OPT_BOOL('b', NULL, &blank_boundary, N_("Show blank SHA-1 for boundary commits (Default: off)")),
2514
OPT_BOOL(0, "root", &show_root, N_("Do not treat root commits as boundaries (Default: off)")),
builtin/shortlog.c
+3
-3
@@ -221,11 +221,11 @@ void shortlog_init(struct shortlog *log)
221
222
int cmd_shortlog(int argc, const char **argv, const char *prefix)
223
{
224
- static struct shortlog log;
225
- static struct rev_info rev;
224
+ struct shortlog log = { STRING_LIST_INIT_NODUP };
225
+ struct rev_info rev;
226
int nongit = !startup_info->have_repository;
227
228
- static const struct option options[] = {
228
+ const struct option options[] = {
229
OPT_BOOL('n', "numbered", &log.sort_by_number,
230
N_("sort output according to the number of commits per author")),
231
OPT_BOOL('s', "summary", &log.summary,