@matheusbsbs / matheus-bagliano / commits / 3299c6f6a8
Fork 0

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>

Junio C Hamano committed Nov 15, 2005 at 12:48 UTC 3299c6f6a8a384453d025ffa117c5d8b35ba1972
5 files changed +16 -5
Makefile
+2 -2
@@ -105,7 +105,7 @@ SCRIPT_PYTHON = \
105 # The ones that do not have to link with lcrypto nor lz.
106 SIMPLE_PROGRAMS = \
107 git-get-tar-commit-id$X git-mailinfo$X git-mailsplit$X \
108 - git-stripspace$X git-var$X git-daemon$X
108 + git-stripspace$X git-daemon$X
109
110 # ... and all the rest
111 PROGRAMS = \
@@ -125,7 +125,7 @@ PROGRAMS = \
125 git-unpack-objects$X git-update-index$X git-update-server-info$X \
126 git-upload-pack$X git-verify-pack$X git-write-tree$X \
127 git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \
128 - git-name-rev$X git-pack-redundant$X $(SIMPLE_PROGRAMS)
128 + git-name-rev$X git-pack-redundant$X git-var$X $(SIMPLE_PROGRAMS)
129
130 # Backward compatibility -- to be removed after 1.0
131 PROGRAMS += git-ssh-pull$X git-ssh-push$X
cache.h
+1
@@ -180,6 +180,7 @@ extern void rollback_index_file(struct cache_file *);
180
181 extern int trust_executable_bit;
182 extern int only_use_symrefs;
183 +extern int diff_rename_limit_default;
184
185 #define MTIME_CHANGED 0x0001
186 #define CTIME_CHANGED 0x0002
config.c
+5
@@ -229,6 +229,11 @@ int git_default_config(const char *var, const char *value)
229 return 0;
230 }
231
232 + if (!strcmp(var, "diff.renamelimit")) {
233 + diff_rename_limit_default = git_config_int(var, value);
234 + return 0;
235 + }
236 +
237 /* Add other config variables here.. */
238 return 0;
239 }
diff.c
+7 -2
@@ -13,6 +13,8 @@ static const char *diff_opts = "-pu";
13
14 static int use_size_cache;
15
16 +int diff_rename_limit_default = -1;
17 +
18 static char *quote_one(const char *str)
19 {
20 int needlen;
@@ -761,9 +763,12 @@ void diff_setup(struct diff_options *options)
763
764 int diff_setup_done(struct diff_options *options)
765 {
764 - if ((options->find_copies_harder || 0 <= options->rename_limit) &&
765 - options->detect_rename != DIFF_DETECT_COPY)
766 + if ((options->find_copies_harder &&
767 + options->detect_rename != DIFF_DETECT_COPY) ||
768 + (0 <= options->rename_limit && !options->detect_rename))
769 return -1;
770 + if (options->detect_rename && options->rename_limit < 0)
771 + options->rename_limit = diff_rename_limit_default;
772 if (options->setup & DIFF_SETUP_USE_CACHE) {
773 if (!active_cache)
774 /* read-cache does not die even when it fails
diffcore-rename.c
+1 -1
@@ -283,7 +283,7 @@ void diffcore_rename(struct diff_options *options)
283 register_rename_src(p->one, 1);
284 }
285 if (rename_dst_nr == 0 ||
286 - (0 <= rename_limit && rename_limit < rename_dst_nr))
286 + (0 < rename_limit && rename_limit < rename_dst_nr))
287 goto cleanup; /* nothing to do */
288
289 /* We really want to cull the candidates list early