Skip to content

Commit

Permalink
Allow users to un-configure rename detection
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Linus Torvalds authored and Junio C Hamano committed Apr 12, 2009
1 parent 519d05b commit cced5fb
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,15 @@ static int parse_diff_color_slot(const char *var, int ofs)
die("bad config variable '%s'", var);
}

static int git_config_rename(const char *var, const char *value)
{
if (!value)
return DIFF_DETECT_RENAME;
if (!strcasecmp(value, "copies") || !strcasecmp(value, "copy"))
return DIFF_DETECT_COPY;
return git_config_bool(var,value) ? DIFF_DETECT_RENAME : 0;
}

/*
* These are to give UI layer defaults.
* The core-level commands such as git-diff-files should
Expand All @@ -75,13 +84,7 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)
return 0;
}
if (!strcmp(var, "diff.renames")) {
if (!value)
diff_detect_rename_default = DIFF_DETECT_RENAME;
else if (!strcasecmp(value, "copies") ||
!strcasecmp(value, "copy"))
diff_detect_rename_default = DIFF_DETECT_COPY;
else if (git_config_bool(var,value))
diff_detect_rename_default = DIFF_DETECT_RENAME;
diff_detect_rename_default = git_config_rename(var, value);
return 0;
}
if (!strcmp(var, "diff.autorefreshindex")) {
Expand Down

0 comments on commit cced5fb

Please sign in to comment.