{"thread":{"id":"18810","subject":"Allow users to un-configure rename detection","startedAt":"2009-04-09T18:46:15Z","lastAt":"2009-04-09T19:40:39Z","messageCount":2,"participants":["Linus Torvalds"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"110946","messageId":"alpine.LFD.2.00.0904091141420.4583@localhost.localdomain","threadId":"18810","inReplyTo":null,"subject":"Allow users to un-configure rename detection","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-04-09T18:46:15Z","receivedAt":"2009-04-09T18:46:15Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\nI told people on the kernel mailing list to please use \"-M\" when sending \nme rename patches, so that I can see what they do while reading email \nrather than having to apply the patch and then look at the end result.\n\nI also told them that if they want to make it the default, they can just \nadd\n\n\t[diff]\n\t\trenames\n\nto their ~/.gitconfig file. And while I was thinking about that, I wanted \nto also check whether you can then mark individual projects to _not_ have \nthat default in the per-repository .git/config file.\n\nAnd you can't. Currently you cannot have a global \"enable renames by \ndefault\" and then a local \".. but not for _this_ project\". Why? Because if \nsomebody writes\n\n\t[diff]\n\t\trenames = no\n\nwe simply ignore it, rather than resetting \"diff_detect_rename_default\" \nback to zero.\n\nFixed thusly.\n\nSigned-off-by: Linus Torvalds <torvalds@linux-foundation.org>\n---\nOk, so I didn't test it much. But it seems to work now.\n\n diff.c |   17 ++++++++++-------\n 1 files changed, 10 insertions(+), 7 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex e0fa78c..3ac7168 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -62,6 +62,15 @@ static int parse_diff_color_slot(const char *var, int ofs)\n \tdie(\"bad config variable '%s'\", var);\n }\n \n+static int git_config_rename(const char *var, const char *value)\n+{\n+\tif (!value)\n+\t\treturn DIFF_DETECT_RENAME;\n+\tif (!strcasecmp(value, \"copies\") || !strcasecmp(value, \"copy\"))\n+\t\treturn  DIFF_DETECT_COPY;\n+\treturn git_config_bool(var,value) ? DIFF_DETECT_RENAME : 0;\n+}\n+\n /*\n  * These are to give UI layer defaults.\n  * The core-level commands such as git-diff-files should\n@@ -75,13 +84,7 @@ int git_diff_ui_config(const char *var, const char *value, void *cb)\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"diff.renames\")) {\n-\t\tif (!value)\n-\t\t\tdiff_detect_rename_default = DIFF_DETECT_RENAME;\n-\t\telse if (!strcasecmp(value, \"copies\") ||\n-\t\t\t !strcasecmp(value, \"copy\"))\n-\t\t\tdiff_detect_rename_default = DIFF_DETECT_COPY;\n-\t\telse if (git_config_bool(var,value))\n-\t\t\tdiff_detect_rename_default = DIFF_DETECT_RENAME;\n+\t\tdiff_detect_rename_default = git_config_rename(var, value);\n \t\treturn 0;\n \t}\n \tif (!strcmp(var, \"diff.autorefreshindex\")) {\n"},{"id":"110951","messageId":"alpine.LFD.2.00.0904091232420.4583@localhost.localdomain","threadId":"18810","inReplyTo":"alpine.LFD.2.00.0904091141420.4583@localhost.localdomain","subject":"Re: Allow users to un-configure rename detection","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2009-04-09T19:40:39Z","receivedAt":"2009-04-09T19:40:39Z","isPatch":false,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Thu, 9 Apr 2009, Linus Torvalds wrote:\n> \n> \t[diff]\n> \t\trenames = no\n\nBtw, while doing this, I also though that \"renames = on/off\" made more \nsense, but while we allow yes/no and true/false for booleans, we don't \nallow on/off.\n\nShould we? Maybe. Here's a stupid patch. \n\n\t\tLinus\n\n---\n config.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/config.c b/config.c\nindex b76fe4c..e7d91f5 100644\n--- a/config.c\n+++ b/config.c\n@@ -331,9 +331,9 @@ int git_config_bool_or_int(const char *name, const char *value, int *is_bool)\n \t\treturn 1;\n \tif (!*value)\n \t\treturn 0;\n-\tif (!strcasecmp(value, \"true\") || !strcasecmp(value, \"yes\"))\n+\tif (!strcasecmp(value, \"true\") || !strcasecmp(value, \"yes\") || !strcasecmp(value, \"on\"))\n \t\treturn 1;\n-\tif (!strcasecmp(value, \"false\") || !strcasecmp(value, \"no\"))\n+\tif (!strcasecmp(value, \"false\") || !strcasecmp(value, \"no\") || !strcasecmp(value, \"off\"))\n \t\treturn 0;\n \t*is_bool = 0;\n \treturn git_config_int(name, value);\n"}]}