log: add "log.follow" configuration variable
People who work on projects with mostly linear history with frequent whole file renames may want to always use "git log --follow" when inspecting the life of the content that live in a single path. Teach the command to behave as if "--follow" was given from the command line when log.follow configuration variable is set *and* there is one (and only one) path on the command line. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
5bdb7a78ad
commit
076c98372e
@ -31,6 +31,7 @@ static const char *default_date_mode = NULL;
|
||||
|
||||
static int default_abbrev_commit;
|
||||
static int default_show_root = 1;
|
||||
static int default_follow;
|
||||
static int decoration_style;
|
||||
static int decoration_given;
|
||||
static int use_mailmap_config;
|
||||
@ -102,6 +103,8 @@ static void cmd_log_init_defaults(struct rev_info *rev)
|
||||
{
|
||||
if (fmt_pretty)
|
||||
get_commit_format(fmt_pretty, rev);
|
||||
if (default_follow)
|
||||
DIFF_OPT_SET(&rev->diffopt, DEFAULT_FOLLOW_RENAMES);
|
||||
rev->verbose_header = 1;
|
||||
DIFF_OPT_SET(&rev->diffopt, RECURSIVE);
|
||||
rev->diffopt.stat_width = -1; /* use full terminal width */
|
||||
@ -390,6 +393,10 @@ static int git_log_config(const char *var, const char *value, void *cb)
|
||||
default_show_root = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "log.follow")) {
|
||||
default_follow = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
if (skip_prefix(var, "color.decorate.", &slot_name))
|
||||
return parse_decorate_color_config(var, slot_name, value);
|
||||
if (!strcmp(var, "log.mailmap")) {
|
||||
@ -618,6 +625,14 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix)
|
||||
return cmd_log_walk(&rev);
|
||||
}
|
||||
|
||||
static void default_follow_tweak(struct rev_info *rev,
|
||||
struct setup_revision_opt *opt)
|
||||
{
|
||||
if (DIFF_OPT_TST(&rev->diffopt, DEFAULT_FOLLOW_RENAMES) &&
|
||||
rev->prune_data.nr == 1)
|
||||
DIFF_OPT_SET(&rev->diffopt, FOLLOW_RENAMES);
|
||||
}
|
||||
|
||||
int cmd_log(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
struct rev_info rev;
|
||||
@ -631,6 +646,7 @@ int cmd_log(int argc, const char **argv, const char *prefix)
|
||||
memset(&opt, 0, sizeof(opt));
|
||||
opt.def = "HEAD";
|
||||
opt.revarg_opt = REVARG_COMMITTISH;
|
||||
opt.tweak = default_follow_tweak;
|
||||
cmd_log_init(argc, argv, prefix, &rev, &opt);
|
||||
return cmd_log_walk(&rev);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user