@matheusbsbs / matheus-bagliano / commits / ef803fd4b0
Fork 0

builtin/log.c: separate default and setup of cmd_log_init()

cmd_log_init() sets up some default rev options and then calls setup_revisions(), so that a caller cannot set up own defaults: Either they get overriden by cmd_log_init() (if set before) or they override the command line (if set after). We even complain about this in a comment to cmd_log_reflog(). Therefore, separate the two steps so that one can still call cmd_log_init() or, alternatively, cmd_log_init_defaults() followed by cmd_log_init_finish() (and set defaults in between). No functional change so far. Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Michael J Gruber committed Apr 1, 2011 at 11:20 UTC ef803fd4b09bca707c7c27669a2789bb050b488c
1 file changed +15 -6
builtin/log.c
+15 -6
@@ -49,13 +49,8 @@ static int parse_decoration_style(const char *var, const char *value)
49 return -1;
50 }
51
52 -static void cmd_log_init(int argc, const char **argv, const char *prefix,
53 - struct rev_info *rev, struct setup_revision_opt *opt)
52 +static void cmd_log_init_defaults(struct rev_info *rev)
53 {
55 - int i;
56 - int decoration_given = 0;
57 - struct userformat_want w;
58 -
54 rev->abbrev = DEFAULT_ABBREV;
55 rev->commit_format = CMIT_FMT_DEFAULT;
56 if (fmt_pretty)
@@ -68,7 +63,14 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
63
64 if (default_date_mode)
65 rev->date_mode = parse_date_format(default_date_mode);
66 +}
67
68 +static void cmd_log_init_finish(int argc, const char **argv, const char *prefix,
69 + struct rev_info *rev, struct setup_revision_opt *opt)
70 +{
71 + int i;
72 + int decoration_given = 0;
73 + struct userformat_want w;
74 /*
75 * Check for -h before setup_revisions(), or "git log -h" will
76 * fail when run without a git directory.
@@ -128,6 +130,13 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
130 setup_pager();
131 }
132
133 +static void cmd_log_init(int argc, const char **argv, const char *prefix,
134 + struct rev_info *rev, struct setup_revision_opt *opt)
135 +{
136 + cmd_log_init_defaults(rev);
137 + cmd_log_init_finish(argc, argv, prefix, rev, opt);
138 +}
139 +
140 /*
141 * This gives a rough estimate for how many commits we
142 * will print out in the list.