summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorJunio C Hamano <junkio@cox.net>2005-11-15 20:48:08 (GMT)
committerJunio C Hamano <junkio@cox.net>2005-11-15 23:08:27 (GMT)
commit3299c6f6a8a384453d025ffa117c5d8b35ba1972 (patch)
treea9067de664756254895eb8d532097d31534b35bc /diff.c
parentf8348be3be8493a62110a09ab0343213990b416b (diff)
downloadgit-3299c6f6a8a384453d025ffa117c5d8b35ba1972.zip
git-3299c6f6a8a384453d025ffa117c5d8b35ba1972.tar.gz
git-3299c6f6a8a384453d025ffa117c5d8b35ba1972.tar.bz2
diff: make default rename detection limit configurable.
A while ago, a rename-detection limit logic was implemented as a response to this thread: http://marc.theaimsgroup.com/?l=git&m=112413080630175 where gitweb was found to be using a lot of time and memory to detect renames on huge commits. git-diff family takes -l<num> flag, and if the number of paths that are rename destination candidates (i.e. new paths with -M, or modified paths with -C) are larger than that number, skips rename/copy detection even when -M or -C is specified on the command line. This commit makes the rename detection limit easier to use. You can have: [diff] renamelimit = 30 in your .git/config file to specify the default rename detection limit. You can override this from the command line; giving 0 means 'unlimited': git diff -M -l0 We might want to change the default behaviour, when you do not have the configuration, to limit it to say 20 paths or so. This would also help the diffstat generation after a big 'git pull'. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/diff.c b/diff.c
index ec94a96..fca61f3 100644
--- a/diff.c
+++ b/diff.c
@@ -13,6 +13,8 @@ static const char *diff_opts = "-pu";
static int use_size_cache;
+int diff_rename_limit_default = -1;
+
static char *quote_one(const char *str)
{
int needlen;
@@ -761,9 +763,12 @@ void diff_setup(struct diff_options *options)
int diff_setup_done(struct diff_options *options)
{
- if ((options->find_copies_harder || 0 <= options->rename_limit) &&
- options->detect_rename != DIFF_DETECT_COPY)
+ if ((options->find_copies_harder &&
+ options->detect_rename != DIFF_DETECT_COPY) ||
+ (0 <= options->rename_limit && !options->detect_rename))
return -1;
+ if (options->detect_rename && options->rename_limit < 0)
+ options->rename_limit = diff_rename_limit_default;
if (options->setup & DIFF_SETUP_USE_CACHE) {
if (!active_cache)
/* read-cache does not die even when it fails