Skip to content

Commit cced5fb

Browse files
torvaldsgitster
authored andcommitted
Allow users to un-configure rename detection
I told people on the kernel mailing list to please use "-M" when sending me rename patches, so that I can see what they do while reading email rather than having to apply the patch and then look at the end result. I also told them that if they want to make it the default, they can just add [diff] renames to their ~/.gitconfig file. And while I was thinking about that, I wanted to also check whether you can then mark individual projects to _not_ have that default in the per-repository .git/config file. And you can't. Currently you cannot have a global "enable renames by default" and then a local ".. but not for _this_ project". Why? Because if somebody writes [diff] renames = no we simply ignore it, rather than resetting "diff_detect_rename_default" back to zero. Fixed thusly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 519d05b commit cced5fb

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

diff.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ static int parse_diff_color_slot(const char *var, int ofs)
6262
die("bad config variable '%s'", var);
6363
}
6464

65+
static int git_config_rename(const char *var, const char *value)
66+
{
67+
if (!value)
68+
return DIFF_DETECT_RENAME;
69+
if (!strcasecmp(value, "copies") || !strcasecmp(value, "copy"))
70+
return DIFF_DETECT_COPY;
71+
return git_config_bool(var,value) ? DIFF_DETECT_RENAME : 0;
72+
}
73+
6574
/*
6675
* These are to give UI layer defaults.
6776
* The core-level commands such as git-diff-files should
@@ -75,13 +84,7 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
7584
return 0;
7685
}
7786
if (!strcmp(var, "diff.renames")) {
78-
if (!value)
79-
diff_detect_rename_default = DIFF_DETECT_RENAME;
80-
else if (!strcasecmp(value, "copies") ||
81-
!strcasecmp(value, "copy"))
82-
diff_detect_rename_default = DIFF_DETECT_COPY;
83-
else if (git_config_bool(var,value))
84-
diff_detect_rename_default = DIFF_DETECT_RENAME;
87+
diff_detect_rename_default = git_config_rename(var, value);
8588
return 0;
8689
}
8790
if (!strcmp(var, "diff.autorefreshindex")) {

0 commit comments

Comments
 (0)