From: Junio C Hamano Date: Tue, 21 Dec 2010 22:30:52 +0000 (-0800) Subject: Merge branch 'ks/blame-worktree-textconv-cached' X-Git-Tag: v1.7.4-rc0~15 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/6ae7a51a2e8efdb10c18d59693e647a73d98d9d3?ds=inline;hp=-c Merge branch 'ks/blame-worktree-textconv-cached' * ks/blame-worktree-textconv-cached: fill_textconv(): Don't get/put cache if sha1 is not valid t/t8006: Demonstrate blame is broken when cachetextconv is on --- 6ae7a51a2e8efdb10c18d59693e647a73d98d9d3 diff --combined diff.c index 0a43869435,fa3b29d92e..5422c43882 --- a/diff.c +++ b/diff.c @@@ -3149,23 -3149,20 +3149,23 @@@ int diff_opt_parse(struct diff_options return stat_opt(options, av); /* renames options */ - else if (!prefixcmp(arg, "-B")) { + else if (!prefixcmp(arg, "-B") || !prefixcmp(arg, "--break-rewrites=") || + !strcmp(arg, "--break-rewrites")) { if ((options->break_opt = diff_scoreopt_parse(arg)) == -1) - return -1; + return error("invalid argument to -B: %s", arg+2); } - else if (!prefixcmp(arg, "-M")) { + else if (!prefixcmp(arg, "-M") || !prefixcmp(arg, "--find-renames=") || + !strcmp(arg, "--find-renames")) { if ((options->rename_score = diff_scoreopt_parse(arg)) == -1) - return -1; + return error("invalid argument to -M: %s", arg+2); options->detect_rename = DIFF_DETECT_RENAME; } - else if (!prefixcmp(arg, "-C")) { + else if (!prefixcmp(arg, "-C") || !prefixcmp(arg, "--find-copies=") || + !strcmp(arg, "--find-copies")) { if (options->detect_rename == DIFF_DETECT_COPY) DIFF_OPT_SET(options, FIND_COPIES_HARDER); if ((options->rename_score = diff_scoreopt_parse(arg)) == -1) - return -1; + return error("invalid argument to -C: %s", arg+2); options->detect_rename = DIFF_DETECT_COPY; } else if (!strcmp(arg, "--no-renames")) @@@ -3283,17 -3280,12 +3283,17 @@@ } else if ((argcount = short_opt('S', av, &optarg))) { options->pickaxe = optarg; + options->pickaxe_opts |= DIFF_PICKAXE_KIND_S; + return argcount; + } else if ((argcount = short_opt('G', av, &optarg))) { + options->pickaxe = optarg; + options->pickaxe_opts |= DIFF_PICKAXE_KIND_G; return argcount; } else if (!strcmp(arg, "--pickaxe-all")) - options->pickaxe_opts = DIFF_PICKAXE_ALL; + options->pickaxe_opts |= DIFF_PICKAXE_ALL; else if (!strcmp(arg, "--pickaxe-regex")) - options->pickaxe_opts = DIFF_PICKAXE_REGEX; + options->pickaxe_opts |= DIFF_PICKAXE_REGEX; else if ((argcount = short_opt('O', av, &optarg))) { options->orderfile = optarg; return argcount; @@@ -3335,7 -3327,7 +3335,7 @@@ return 1; } -static int parse_num(const char **cp_p) +int parse_rename_score(const char **cp_p) { unsigned long num, scale; int ch, dot; @@@ -3378,26 -3370,10 +3378,26 @@@ static int diff_scoreopt_parse(const ch if (*opt++ != '-') return -1; cmd = *opt++; + if (cmd == '-') { + /* convert the long-form arguments into short-form versions */ + if (!prefixcmp(opt, "break-rewrites")) { + opt += strlen("break-rewrites"); + if (*opt == 0 || *opt++ == '=') + cmd = 'B'; + } else if (!prefixcmp(opt, "find-copies")) { + opt += strlen("find-copies"); + if (*opt == 0 || *opt++ == '=') + cmd = 'C'; + } else if (!prefixcmp(opt, "find-renames")) { + opt += strlen("find-renames"); + if (*opt == 0 || *opt++ == '=') + cmd = 'M'; + } + } if (cmd != 'M' && cmd != 'C' && cmd != 'B') return -1; /* that is not a -M, -C nor -B option */ - opt1 = parse_num(&opt); + opt1 = parse_rename_score(&opt); if (cmd != 'B') opt2 = 0; else { @@@ -3407,7 -3383,7 +3407,7 @@@ return -1; /* we expect -B80/99 or -B80 */ else { opt++; - opt2 = parse_num(&opt); + opt2 = parse_rename_score(&opt); } } if (*opt != 0) @@@ -4209,7 -4185,7 +4209,7 @@@ void diffcore_std(struct diff_options * diffcore_merge_broken(); } if (options->pickaxe) - diffcore_pickaxe(options->pickaxe, options->pickaxe_opts); + diffcore_pickaxe(options); if (options->orderfile) diffcore_order(options->orderfile); if (!options->found_follow) @@@ -4412,7 -4388,7 +4412,7 @@@ size_t fill_textconv(struct userdiff_dr return df->size; } - if (driver->textconv_cache) { + if (driver->textconv_cache && df->sha1_valid) { *outbuf = notes_cache_get(driver->textconv_cache, df->sha1, &size); if (*outbuf) @@@ -4423,7 -4399,7 +4423,7 @@@ if (!*outbuf) die("unable to read files to diff"); - if (driver->textconv_cache) { + if (driver->textconv_cache && df->sha1_valid) { /* ignore errors, as we might be in a readonly repository */ notes_cache_put(driver->textconv_cache, df->sha1, *outbuf, size);