diff.c: respect diff.renames config option
diff.renames is mentioned several times in the documentation, but to my surprise it didn't do anything before this patch. Also add the --no-renames option to override this from the command-line. Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Eric Wong committed
Jul 7, 2006 at 04:01 UTC
b68ea12e305043a7feef085b6ba098f42357af9b
2 files changed
+19
Documentation/config.txt
+5
@@ -114,6 +114,11 @@ diff.renameLimit::
114
The number of files to consider when performing the copy/rename
115
detection; equivalent to the git diff option '-l'.
116
117
+diff.renames::
118
+ Tells git to detect renames. If set to any boolean value, it
119
+ will enable basic rename detection. If set to "copies" or
120
+ "copy", it will detect copies, as well.
121
+
122
format.headers::
123
Additional email headers to include in a patch to be submitted
124
by mail. See gitlink:git-format-patch[1].
diff.c
+14
@@ -13,6 +13,7 @@
13
14
static int use_size_cache;
15
16
+static int diff_detect_rename_default = 0;
17
static int diff_rename_limit_default = -1;
18
static int diff_use_color_default = 0;
19
@@ -120,6 +121,16 @@ int git_diff_config(const char *var, const char *value)
121
diff_use_color_default = git_config_bool(var, value);
122
return 0;
123
}
124
+ if (!strcmp(var, "diff.renames")) {
125
+ if (!value)
126
+ diff_detect_rename_default = DIFF_DETECT_RENAME;
127
+ else if (!strcasecmp(value, "copies") ||
128
+ !strcasecmp(value, "copy"))
129
+ diff_detect_rename_default = DIFF_DETECT_COPY;
130
+ else if (git_config_bool(var,value))
131
+ diff_detect_rename_default = DIFF_DETECT_RENAME;
132
+ return 0;
133
+ }
134
if (!strncmp(var, "diff.color.", 11)) {
135
int slot = parse_diff_color_slot(var, 11);
136
diff_colors[slot] = parse_diff_color_value(value, var);
@@ -1431,6 +1442,7 @@ void diff_setup(struct diff_options *options)
1442
options->change = diff_change;
1443
options->add_remove = diff_addremove;
1444
options->color_diff = diff_use_color_default;
1445
+ options->detect_rename = diff_detect_rename_default;
1446
}
1447
1448
int diff_setup_done(struct diff_options *options)
@@ -1617,6 +1629,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)
1629
options->xdl_opts |= XDF_IGNORE_WHITESPACE;
1630
else if (!strcmp(arg, "-b") || !strcmp(arg, "--ignore-space-change"))
1631
options->xdl_opts |= XDF_IGNORE_WHITESPACE_CHANGE;
1632
+ else if (!strcmp(arg, "--no-renames"))
1633
+ options->detect_rename = 0;
1634
else
1635
return 0;
1636
return 1;