diff options
author | Russell Belfer <rb@github.com> | 2013-12-11 10:39:36 -0800 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-12-11 10:39:36 -0800 |
commit | 0eedacb06ae07fd0d784066ad41383276e05d92e (patch) | |
tree | 9db818d0db31172563c24aea6a283576a5b10ba7 /src | |
parent | 65e9dc659a013817d1adb3cdc1ed43e697cfbc54 (diff) | |
parent | 5a52d6be4c3a2635a3121b529e0ab2ab674f6be6 (diff) | |
download | libgit2-0eedacb06ae07fd0d784066ad41383276e05d92e.tar.gz |
Merge pull request #1985 from libgit2/diff-rename-config
Rename detection using diff.renames
Diffstat (limited to 'src')
-rw-r--r-- | src/diff_tform.c | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c index 0a28e58c7..702e43bd3 100644 --- a/src/diff_tform.c +++ b/src/diff_tform.c @@ -275,28 +275,36 @@ static int normalize_find_opts( { git_config *cfg = NULL; + GITERR_CHECK_VERSION(given, GIT_DIFF_FIND_OPTIONS_VERSION, "git_diff_find_options"); + if (diff->repo != NULL && git_repository_config__weakptr(&cfg, diff->repo) < 0) return -1; - if (given != NULL) + if (given) { memcpy(opts, given, sizeof(*opts)); - else { - const char *val = NULL; - + } else { GIT_INIT_STRUCTURE(opts, GIT_DIFF_FIND_OPTIONS_VERSION); + } - opts->flags = GIT_DIFF_FIND_RENAMES; + if (!given || + (given->flags & GIT_DIFF_FIND_ALL) == GIT_DIFF_FIND_BY_CONFIG) + { + const char *val = NULL; if (git_config_get_string(&val, cfg, "diff.renames") < 0) giterr_clear(); - else if (val && - (!strcasecmp(val, "copies") || !strcasecmp(val, "copy"))) - opts->flags = GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES; + else if (val) { + int boolval; + if (!git__parse_bool(&boolval, val) && !boolval) { + /* do nothing */ + } else if (!strcasecmp(val, "copies") || !strcasecmp(val, "copy")) + opts->flags |= (GIT_DIFF_FIND_RENAMES | GIT_DIFF_FIND_COPIES); + else + opts->flags |= GIT_DIFF_FIND_RENAMES; + } } - GITERR_CHECK_VERSION(opts, GIT_DIFF_FIND_OPTIONS_VERSION, "git_diff_find_options"); - /* some flags imply others */ if (opts->flags & GIT_DIFF_FIND_EXACT_MATCH_ONLY) { @@ -830,6 +838,10 @@ int git_diff_find_similar( if ((error = normalize_find_opts(diff, &opts, given_opts)) < 0) return error; + /* No flags set; nothing to do */ + if ((opts.flags & GIT_DIFF_FIND_ALL) == 0) + return 0; + num_deltas = diff->deltas.length; /* TODO: maybe abort if deltas.length > rename_limit ??? */ |