MCPcopy Create free account
hub / github.com/git/git / try_to_follow_renames

Function try_to_follow_renames

tree-diff.c:600–696  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

598}
599
600static void try_to_follow_renames(const struct object_id *old_oid,
601 const struct object_id *new_oid,
602 struct strbuf *base, struct diff_options *opt)
603{
604 struct diff_options diff_opts;
605 struct diff_queue_struct *q = &diff_queued_diff;
606 struct diff_filepair *choice;
607 int i;
608
609 /*
610 * follow-rename code is very specific, we need exactly one
611 * path. Magic that matches more than one path is not
612 * supported.
613 */
614 GUARD_PATHSPEC(&opt->pathspec, PATHSPEC_FROMTOP | PATHSPEC_LITERAL);
615#if 0
616 /*
617 * We should reject wildcards as well. Unfortunately we
618 * haven't got a reliable way to detect that 'foo\*bar' in
619 * fact has no wildcards. nowildcard_len is merely a hint for
620 * optimization. Let it slip for now until wildmatch is taught
621 * about dry-run mode and returns wildcard info.
622 */
623 if (opt->pathspec.has_wildcard)
624 BUG("wildcards are not supported");
625#endif
626
627 /* Remove the file creation entry from the diff queue, and remember it */
628 choice = q->queue[0];
629 q->nr = 0;
630
631 repo_diff_setup(opt->repo, &diff_opts);
632 diff_opts.flags.recursive = 1;
633 diff_opts.flags.find_copies_harder = 1;
634 diff_opts.output_format = DIFF_FORMAT_NO_OUTPUT;
635 diff_opts.single_follow = opt->pathspec.items[0].match;
636 diff_opts.break_opt = opt->break_opt;
637 diff_opts.rename_score = opt->rename_score;
638 diff_setup_done(&diff_opts);
639 ll_diff_tree_oid(old_oid, new_oid, base, &diff_opts);
640 diffcore_std(&diff_opts);
641 clear_pathspec(&diff_opts.pathspec);
642
643 /* Go through the new set of filepairing, and see if we find a more interesting one */
644 opt->found_follow = 0;
645 for (i = 0; i < q->nr; i++) {
646 struct diff_filepair *p = q->queue[i];
647
648 /*
649 * Found a source? Not only do we use that for the new
650 * diff_queued_diff, we will also use that as the path in
651 * the future!
652 */
653 if ((p->status == 'R' || p->status == 'C') &&
654 !strcmp(p->two->path, opt->pathspec.items[0].match)) {
655 const char *path[2];
656
657 /* Switch the file-pairs around */

Callers 1

diff_tree_oidFunction · 0.85

Calls 7

repo_diff_setupFunction · 0.85
diff_setup_doneFunction · 0.85
ll_diff_tree_oidFunction · 0.85
diffcore_stdFunction · 0.85
clear_pathspecFunction · 0.85
parse_pathspecFunction · 0.85
diff_free_filepairFunction · 0.85

Tested by

no test coverage detected