Skip to content

Commit ef803fd

Browse files
Michael J Grubergitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2352570 commit ef803fd

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

builtin/log.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,8 @@ static int parse_decoration_style(const char *var, const char *value)
4949
return -1;
5050
}
5151

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)
5453
{
55-
int i;
56-
int decoration_given = 0;
57-
struct userformat_want w;
58-
5954
rev->abbrev = DEFAULT_ABBREV;
6055
rev->commit_format = CMIT_FMT_DEFAULT;
6156
if (fmt_pretty)
@@ -68,7 +63,14 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
6863

6964
if (default_date_mode)
7065
rev->date_mode = parse_date_format(default_date_mode);
66+
}
7167

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;
7274
/*
7375
* Check for -h before setup_revisions(), or "git log -h" will
7476
* fail when run without a git directory.
@@ -128,6 +130,13 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix,
128130
setup_pager();
129131
}
130132

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+
131140
/*
132141
* This gives a rough estimate for how many commits we
133142
* will print out in the list.

0 commit comments

Comments
 (0)