* Allow users to un-configure rename detection
@ 2009-04-09 18:46 Linus Torvalds
2009-04-09 19:40 ` Linus Torvalds
0 siblings, 1 reply; 2+ messages in thread
From: Linus Torvalds @ 2009-04-09 18:46 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
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>
---
Ok, so I didn't test it much. But it seems to work now.
diff.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/diff.c b/diff.c
index e0fa78c..3ac7168 100644
--- a/diff.c
+++ b/diff.c
@@ -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
@@ -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")) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: Allow users to un-configure rename detection
2009-04-09 18:46 Allow users to un-configure rename detection Linus Torvalds
@ 2009-04-09 19:40 ` Linus Torvalds
0 siblings, 0 replies; 2+ messages in thread
From: Linus Torvalds @ 2009-04-09 19:40 UTC (permalink / raw)
To: Junio C Hamano, Git Mailing List
On Thu, 9 Apr 2009, Linus Torvalds wrote:
>
> [diff]
> renames = no
Btw, while doing this, I also though that "renames = on/off" made more
sense, but while we allow yes/no and true/false for booleans, we don't
allow on/off.
Should we? Maybe. Here's a stupid patch.
Linus
---
config.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/config.c b/config.c
index b76fe4c..e7d91f5 100644
--- a/config.c
+++ b/config.c
@@ -331,9 +331,9 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)
return 1;
if (!*value)
return 0;
- if (!strcasecmp(value, "true") || !strcasecmp(value, "yes"))
+ if (!strcasecmp(value, "true") || !strcasecmp(value, "yes") || !strcasecmp(value, "on"))
return 1;
- if (!strcasecmp(value, "false") || !strcasecmp(value, "no"))
+ if (!strcasecmp(value, "false") || !strcasecmp(value, "no") || !strcasecmp(value, "off"))
return 0;
*is_bool = 0;
return git_config_int(name, value);
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-04-09 19:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-09 18:46 Allow users to un-configure rename detection Linus Torvalds
2009-04-09 19:40 ` Linus Torvalds
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox