From: Junio C Hamano Date: Mon, 3 Aug 2015 18:01:20 +0000 (-0700) Subject: Merge branch 'dt/log-follow-config' X-Git-Tag: v2.6.0-rc0~101 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/2dded96052114c7b902d90f80f75a30eb64d860a?ds=inline;hp=-c Merge branch 'dt/log-follow-config' Add a new configuration variable to enable "--follow" automatically when "git log" is run with one pathspec argument. * dt/log-follow-config: log: add "log.follow" configuration variable --- 2dded96052114c7b902d90f80f75a30eb64d860a diff --combined builtin/log.c index 93025d08cd,d06248a30f..c851c7cc23 --- a/builtin/log.c +++ b/builtin/log.c @@@ -5,7 -5,6 +5,7 @@@ * 2006 Junio Hamano */ #include "cache.h" +#include "refs.h" #include "color.h" #include "commit.h" #include "diff.h" @@@ -32,6 -31,7 +32,7 @@@ static const char *default_date_mode = 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; @@@ -103,6 -103,8 +104,8 @@@ static void cmd_log_init_defaults(struc { 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 */ @@@ -391,6 -393,10 +394,10 @@@ static int git_log_config(const char *v 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")) { @@@ -619,6 -625,14 +626,14 @@@ int cmd_log_reflog(int argc, const cha 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; @@@ -632,6 -646,7 +647,7 @@@ 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); } diff --combined diff.c index 0f17ec5506,135b22231c..7deac90532 --- a/diff.c +++ b/diff.c @@@ -3653,12 -3653,7 +3653,12 @@@ static void enable_patch_output(int *fm static int parse_one_token(const char **arg, const char *token) { - return skip_prefix(*arg, token, arg) && (!**arg || **arg == ','); + const char *rest; + if (skip_prefix(*arg, token, &rest) && (!*rest || *rest == ',')) { + *arg = rest; + return 1; + } + return 0; } static int parse_ws_error_highlight(struct diff_options *opt, const char *arg) @@@ -3820,9 -3815,10 +3820,10 @@@ int diff_opt_parse(struct diff_options DIFF_OPT_SET(options, FIND_COPIES_HARDER); else if (!strcmp(arg, "--follow")) DIFF_OPT_SET(options, FOLLOW_RENAMES); - else if (!strcmp(arg, "--no-follow")) + else if (!strcmp(arg, "--no-follow")) { DIFF_OPT_CLR(options, FOLLOW_RENAMES); - else if (!strcmp(arg, "--color")) + DIFF_OPT_CLR(options, DEFAULT_FOLLOW_RENAMES); + } else if (!strcmp(arg, "--color")) options->use_color = 1; else if (skip_prefix(arg, "--color=", &arg)) { int value = git_config_colorbool(NULL, arg);