X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=diff.c;h=2e0797bf3ee651a644be50aee10ee125fe96368f;hb=830273d10cf1cfe646db39b87d3ccb49bf88b73a;hp=0391e8c42336cda9c83eeb1b9ac8f1378e4a43f9;hpb=8fc66df237afce0b4318657f166b3583831949f3;p=git.git diff --git a/diff.c b/diff.c index 0391e8c4..2e0797bf 100644 --- a/diff.c +++ b/diff.c @@ -15,6 +15,16 @@ static int use_size_cache; int diff_rename_limit_default = -1; +int git_diff_config(const char *var, const char *value) +{ + if (!strcmp(var, "diff.renamelimit")) { + diff_rename_limit_default = git_config_int(var, value); + return 0; + } + + return git_default_config(var, value); +} + static char *quote_one(const char *str) { int needlen; @@ -838,16 +848,29 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac) static int parse_num(const char **cp_p) { - int num, scale, ch, cnt; + unsigned long num, scale; + int ch, dot; const char *cp = *cp_p; - cnt = num = 0; + num = 0; scale = 1; - while ('0' <= (ch = *cp) && ch <= '9') { - if (cnt++ < 5) { - /* We simply ignore more than 5 digits precision. */ - scale *= 10; - num = num * 10 + ch - '0'; + dot = 0; + for(;;) { + ch = *cp; + if ( !dot && ch == '.' ) { + scale = 1; + dot = 1; + } else if ( ch == '%' ) { + scale = dot ? scale*100 : 100; + cp++; /* % is always at the end */ + break; + } else if ( ch >= '0' && ch <= '9' ) { + if ( scale < 100000 ) { + scale *= 10; + num = (num*10) + (ch-'0'); + } + } else { + break; } cp++; } @@ -856,7 +879,7 @@ static int parse_num(const char **cp_p) /* user says num divided by scale and we say internally that * is MAX_SCORE * num / scale. */ - return (MAX_SCORE * num / scale); + return (num >= scale) ? MAX_SCORE : (MAX_SCORE * num / scale); } int diff_scoreopt_parse(const char *opt)